From ac3e88e5dc69c74c80045a86abe38caae81d0101 Mon Sep 17 00:00:00 2001
From: cloudflight <cloudflight@126.com>
Date: 星期三, 20 十二月 2023 13:06:46 +0800
Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/Yw/Hydro.V1.0

---
 Hydro.Revit/RevitNetWork.cs |  116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 115 insertions(+), 1 deletions(-)

diff --git a/Hydro.Revit/RevitNetWork.cs b/Hydro.Revit/RevitNetWork.cs
index b1bdf7d..334c72d 100644
--- a/Hydro.Revit/RevitNetWork.cs
+++ b/Hydro.Revit/RevitNetWork.cs
@@ -1,4 +1,6 @@
-锘縰sing Hydro.Inp;
+锘縰sing Hydro.Core.Model;
+using Hydro.Inp;
+using Hydro.Revit.Model;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -9,5 +11,117 @@
 {
     public class RevitNetWork : NetWork
     {
+        public void AddJunction(JunctionViewModel junction)
+        {
+            if (!CheckNodesExist(junction))
+                Nodes.Add(junction);
+        }
+
+        public new List<PipeViewModel> Pipes
+        {
+            get
+            {
+                var js = Links.Where(d => d is PipeViewModel);
+                return js?.Select(d => d as PipeViewModel).ToList();
+            }
+        }
+
+        public new List<NozzleViewModel> Nozzles
+        {
+            get
+            {
+                var js = Nodes.Where(d => d is NozzleViewModel);
+                return js?.Select(d => d as NozzleViewModel).ToList();
+            }
+        }
+
+        public void AddJunctions(List<JunctionViewModel> junctions)
+        {
+            junctions.ForEach(junction => { AddJunction(junction); });
+        }
+
+        public void AddTank(WaterTankViewModel tank)
+        {
+            if (!CheckNodesExist(tank))
+                Nodes.Add(tank);
+        }
+
+        public List<HydrantBoxViewModel> HydrantBoxes => Nodes.Where((NodeCalcModel d) => d is HydrantBoxViewModel)?.Select((NodeCalcModel d) => d as HydrantBoxViewModel).ToList();
+
+        public void AddTanks(List<WaterTankViewModel> tanks)
+        {
+            tanks.ForEach(tank => { AddTank(tank); });
+
+
+            // WaterTankViewModel kk=null;
+            // Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson);
+            // WaterTankViewModels 
+
+            //((WaterTankViewModel) Nodes[0]).PositionJson
+        }
+
+        public void AddPipe(PipeViewModel pipe)
+        {
+            if (!CheckLinksExist(pipe))
+                Links.Add(pipe);
+        }
+
+        public void AddPipes(List<PipeViewModel> pipes)
+        {
+            pipes.ForEach(pipe => { AddPipe(pipe); });
+        }
+        public void AddPump(WaterPumpViewModel pump)
+        {
+            if (!CheckLinksExist(pump))
+                Links.Add(pump);
+        }
+
+        public void AddPumps(List<WaterPumpViewModel> pumps)
+        {
+            pumps.ForEach(pump => { AddPump(pump); });
+        }
+        public void AddValve(ValveViewModel valve)
+        {
+            if (!CheckLinksExist(valve))
+                Links.Add(valve);
+        }
+
+        public void AddValves(List<ValveViewModel> valves)
+        {
+            valves.ForEach(valve => { AddValve(valve); });
+        }
+
+        public void AddHydrantBox(HydrantBoxViewModel hydrantBox)
+        {
+            if (!CheckNodesExist(hydrantBox))
+                Nodes.Add(hydrantBox);
+        }
+
+        public void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs)
+        {
+            hydrantBoxs.ForEach(hydrantBox => { AddHydrantBox(hydrantBox); });
+        }
+
+        public void AddNozzle(NozzleViewModel nozzle)
+        {
+            if (!CheckNodesExist(nozzle))
+                Nodes.Add(nozzle);
+        }
+        public void AddNozzles(List<NozzleViewModel> nozzles)
+        {
+            nozzles.ForEach(nozzle => { AddNozzle(nozzle); });
+        }
+
+        private bool CheckNodesExist(NodeCalcModel node)
+        {
+            return Nodes.Any(d => d.ID == node.ID);
+            //   throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄");
+        }
+
+        private bool CheckLinksExist(LinkCalcModel link)
+        {
+            return Links.Any(d => d.ID == link.ID);
+            //throw new Exception("宸插瓨鍦ㄩ噸澶嶇殑瀵硅薄");
+        }
     }
 }

--
Gitblit v1.9.3