| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using Yw.EPAnet; |
| | | using Yw.Hydro; |
| | | using Yw.Model; |
| | | |
| | | namespace Yw.WinFrmUI |
| | |
| | | return allVisualList?.ToDictionary(x => x.Code); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修复 |
| | | /// </summary> |
| | | public static bool Repair(this Yw.Model.HydroModelInfo hydroInfo, out string msg) |
| | | { |
| | | msg = string.Empty; |
| | | if (hydroInfo == null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | var checkResult = hydroInfo.Check(); |
| | | if (!checkResult.Succeed) |
| | | { |
| | | msg = "检查失败导致无法进行试算,停止管网修复!"; |
| | | return false; |
| | | } |
| | | |
| | | var calcuResult = hydroInfo.Calcu(Yw.EPAnet.CalcuMode.Simple); |
| | | if (!calcuResult.Succeed) |
| | | { |
| | | msg = "试算失败,停止管网修复!"; |
| | | return false; |
| | | } |
| | | |
| | | var allLinkList = hydroInfo.GetAllLinks(); |
| | | if (allLinkList != null && allLinkList.Count < 1) |
| | | { |
| | | msg = "模型中未包含管段信息,停止管网修复!"; |
| | | return false; |
| | | } |
| | | |
| | | int count = 0; |
| | | foreach (var link in allLinkList) |
| | | { |
| | | var calcuLink = calcuResult.LinkList?.Find(x => x.Code == link.Code); |
| | | if (calcuLink == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (!calcuLink.CalcuFlow.HasValue) |
| | | { |
| | | continue; |
| | | } |
| | | if (calcuLink.CalcuFlow.Value < 0) |
| | | { |
| | | var tempCode = link.StartCode; |
| | | link.StartCode = link.EndCode; |
| | | link.EndCode = tempCode; |
| | | count++; |
| | | } |
| | | } |
| | | |
| | | msg = $"修复完成,共修复管段({count})个!"; |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |
| | | } |