From 5fa6947054206e2e781eadd4effdcdf52eda28c4 Mon Sep 17 00:00:00 2001
From: cloudflight <cloudflight@126.com>
Date: 星期二, 26 十二月 2023 11:02:28 +0800
Subject: [PATCH] 2023年12月26日

---
 Hydro.Inp/NetWork.cs |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/Hydro.Inp/NetWork.cs b/Hydro.Inp/NetWork.cs
index fae93e4..18fe610 100644
--- a/Hydro.Inp/NetWork.cs
+++ b/Hydro.Inp/NetWork.cs
@@ -17,6 +17,7 @@
 
 namespace Hydro.Inp
 {
+    [Serializable]
     public class NetWork //: INetWork
     {
         public NetWork()
@@ -175,20 +176,20 @@
             nozzles.ForEach(nozzle => { AddNozzle(nozzle); });
         }
 
-        private void CheckNodesExist(NodeModel node)
+        private void CheckNodesExist(NodeCalcModel node)
         {
             if (Nodes.Any(d => d.ID == node.ID))
                 throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄");
         }
 
-        private void CheckLinksExist(LinkModel link)
+        private void CheckLinksExist(LinkCalcModel link)
         {
             if (Links.Any(d => d.ID == link.ID))
                 throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄");
         }
 
-        public List<NodeModel> Nodes { get; set; } = new List<NodeModel>();
-        public List<LinkModel> Links { get; set; } = new List<LinkModel>();
+        public List<NodeCalcModel> Nodes { get; set; } = new List<NodeCalcModel>();
+        public List<LinkCalcModel> Links { get; set; } = new List<LinkCalcModel>();
 
         /// <summary>
         /// 鏍规嵁INP鏂囦欢鐢熸垚
@@ -567,8 +568,15 @@
             {
                 throw new Exception("妯℃澘鏂囦欢涓嶅瓨鍦�," + tempPath);
             }
+            
             if (!File.Exists(InpPath))
+            {
+                FileInfo fi=new FileInfo(InpPath);
+                if (!Directory.Exists(fi.DirectoryName))
+                Directory.CreateDirectory(fi.DirectoryName);
                 File.Create(InpPath).Close();
+
+            }
             tempString = File.ReadAllText(tempPath);
             StringBuilder statusStringBuilder = new StringBuilder();
             statusStringBuilder.AppendLine(";ID              \tStatus/Setting\r\n");
@@ -952,9 +960,9 @@
         /// <returns></returns>
         public virtual List<TimePoint> Calc(string InpPath)
         {
-            HydraulicModel.Epanet epanet = new HydraulicModel.Epanet();
+            HydraulicModel.HydraulicCore epanet = new HydraulicModel.HydraulicCore();
             var result = new List<TimePoint>();
-            var err = epanet.open(InpPath, "d:\\5.log", "");
+            var err = epanet.open(InpPath, "", "");
 
             if (err != 0)
             {
@@ -1014,7 +1022,8 @@
         /// <returns></returns>
         public virtual List<TimePoint> Calc()
         {
-            var inpPath = Path.Combine(Directory.GetCurrentDirectory(), @"data\inp\calc.inp");
+
+            var inpPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"data\inp\calc.inp");
             BuildToInp(inpPath);
             return Calc(inpPath);
         }
@@ -1064,4 +1073,8 @@
         }
 
     }
+
+ 
+
+
 }

--
Gitblit v1.9.3