| | |
| | | using Hydro.Inp; |
| | | using Hydro.Core.Model; |
| | | using Hydro.Inp; |
| | | using Hydro.Revit.Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | |
| | | { |
| | | 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("已存在重复的对象"); |
| | | } |
| | | } |
| | | } |