qinjie
2023-12-19 15d15d24fbccb9b70a305b46b71453b2ab1a720e
提交代码
已修改15个文件
已添加1个文件
179 ■■■■ 文件已修改
Hydro.Core/Common/CheckModel.cs 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Core/Enum/ObjectEnum.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Core/Node/NozzleModel.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Base/IBaseInterface.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Hydro.Revit2022.csproj 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/HydrantBoxViewModel.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/JunctionViewModel.cs 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/NetWorkOutViewModel.cs 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/NozzleViewModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/PipeViewModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/PumpAdapterViewModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/ValveViewModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/WaterPumpViewModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/Model/WaterTankViewModel.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Revit/RevitNetWork.cs 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Test/Program.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Hydro.Core/Common/CheckModel.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Hydro.Core.ObjectEnum;
namespace Hydro.Core.Model
{
@@ -20,5 +21,10 @@
    public class FailModel : BaseModel
    {
        public string FailReason { get; set; }
        public FailType Type { get; set; }
        public string ModelName { get; set; }
    }
}
Hydro.Core/Enum/ObjectEnum.cs
@@ -28,5 +28,13 @@
            æµé‡åŠŸçŽ‡æ›²çº¿ = 2,
            æµé‡æ•ˆçŽ‡æ›²çº¿ = 3
        }
        public enum FailType
        {
            ç¼ºå°‘Node1或Node2连接属性 = 1,
            å–·å¤´åªèƒ½è¿žæŽ¥ç®¡é“ = 2,
            ç¼ºå°‘水箱或水池对象 = 3,
            ç®¡ä»¶å¯¹è±¡è¿žç®¡ä»¶å¯¹è±¡ = 4
        }
    }
}
Hydro.Core/Node/NozzleModel.cs
@@ -22,6 +22,9 @@
        /// </summary>
        public string PatternID { get; set; }
        public string Node1 { get; set; }
        public string Node2 { get; set; }
        public override string ToString()
        {
            if (string.IsNullOrEmpty(PatternID)) PatternID = "";
Hydro.Revit/Base/IBaseInterface.cs
@@ -18,5 +18,10 @@
        /// </summary>
        string SystemType { get; set; }
        /// <summary>
        /// æ¥¼å±‚
        /// </summary>
        string Floor { get; set; }
    }
}
Hydro.Revit/Hydro.Revit2022.csproj
@@ -44,6 +44,7 @@
    <Compile Include="Base\IBaseInterface.cs" />
    <Compile Include="Model\HydrantBoxViewModel.cs" />
    <Compile Include="Model\JunctionViewModel.cs" />
    <Compile Include="Model\NetWorkOutViewModel.cs" />
    <Compile Include="Model\NozzleViewModel.cs" />
    <Compile Include="Model\PipeViewModel.cs" />
    <Compile Include="Model\PositionModel.cs" />
Hydro.Revit/Model/HydrantBoxViewModel.cs
@@ -17,5 +17,6 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/Model/JunctionViewModel.cs
@@ -9,11 +9,15 @@
namespace Hydro.Revit.Model
{
    public class JunctionViewModel:JunctionModel,IBaseInterface
    public class JunctionViewModel : JunctionModel, IBaseInterface
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
        public string Node1 { get; set; }
        public string Node2 { get; set; }
        public void Draw()
        {
            throw new NotImplementedException();
Hydro.Revit/Model/NetWorkOutViewModel.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,39 @@
using Hydro.Core.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Hydro.Revit.Model
{
    public class NetWorkOutViewModel
    {
        public long BimFaceID { get; set; }
        public List<HydrantBoxViewModel> HydrantBoxes { get; set; } = new List<HydrantBoxViewModel>();
        public List<JunctionViewModel> Junctions { get; set; } = new List<JunctionViewModel>();
        public List<NozzleViewModel> Nozzles { get; set; } = new List<NozzleViewModel>();
        public List<PipeViewModel> Pipes { get; set; } = new List<PipeViewModel>();
        public List<PumpAdapterViewModel> PumpAdapters { get; set; } = new List<PumpAdapterViewModel>();
        public List<ValveViewModel> Valves { get; set; } = new List<ValveViewModel>();
        public List<WaterPumpViewModel> Pumps { get; set; } = new List<WaterPumpViewModel>();
        public List<WaterTankViewModel> Tanks { get; set; } = new List<WaterTankViewModel>();
        public List<ReservoisModel> Reservos { get; set; } = new List<ReservoisModel>();
        public List<MeterModel> Meters { get; set; }= new List<MeterModel>();
        public List<NodeCalcModel> Nodes { get; set; } = new List<NodeCalcModel>();
        public List<LinkCalcModel> Links { get; set; } = new List<LinkCalcModel>();
    }
}
Hydro.Revit/Model/NozzleViewModel.cs
@@ -14,5 +14,7 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/Model/PipeViewModel.cs
@@ -13,5 +13,7 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/Model/PumpAdapterViewModel.cs
@@ -14,5 +14,7 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/Model/ValveViewModel.cs
@@ -12,5 +12,7 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/Model/WaterPumpViewModel.cs
@@ -12,5 +12,7 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/Model/WaterTankViewModel.cs
@@ -12,5 +12,7 @@
    {
        public string PositionJson { get; set; }
        public string SystemType { get; set; }
        public string Floor { get; set; }
    }
}
Hydro.Revit/RevitNetWork.cs
@@ -11,59 +11,79 @@
{
    public class RevitNetWork : NetWork
    {
        public  void AddJunction(JunctionViewModel junction)
        public void AddJunction(JunctionViewModel junction)
        {
            CheckNodesExist(junction);
            Nodes.Add(junction);
            if (!CheckNodesExist(junction))
                Nodes.Add(junction);
        }
        public  void AddJunctions(List<JunctionViewModel> junctions)
        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)
        public void AddTank(WaterTankViewModel tank)
        {
            CheckNodesExist(tank);
            Nodes.Add(tank);
            if (!CheckNodesExist(tank))
                Nodes.Add(tank);
        }
        public  void AddTanks(List<WaterTankViewModel> tanks)
        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 kk=null;
            // Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson);
            // WaterTankViewModels
           ((WaterTankViewModel) Nodes[0]).PositionJson
            //((WaterTankViewModel) Nodes[0]).PositionJson
        }
        public  void AddPipe(PipeViewModel pipe)
        public void AddPipe(PipeViewModel pipe)
        {
            CheckLinksExist(pipe);
            Links.Add(pipe);
            if (!CheckLinksExist(pipe))
                Links.Add(pipe);
        }
        public  void AddPipes(List<PipeViewModel> pipes)
        public void AddPipes(List<PipeViewModel> pipes)
        {
            pipes.ForEach(pipe => { AddPipe(pipe); });
        }
        public  void AddPump(WaterPumpViewModel pump)
        public void AddPump(WaterPumpViewModel pump)
        {
            CheckLinksExist(pump);
            Links.Add(pump);
            if (!CheckLinksExist(pump))
                Links.Add(pump);
        }
        public  void AddPumps(List<WaterPumpViewModel> pumps)
        public void AddPumps(List<WaterPumpViewModel> pumps)
        {
            pumps.ForEach(pump => { AddPump(pump); });
        }
        public  void AddValve(ValveViewModel valve)
        public void AddValve(ValveViewModel valve)
        {
            CheckLinksExist(valve);
            Links.Add(valve);
            if (!CheckLinksExist(valve))
                Links.Add(valve);
        }
        public void AddValves(List<ValveViewModel> valves)
@@ -73,35 +93,35 @@
        public void AddHydrantBox(HydrantBoxViewModel hydrantBox)
        {
            CheckNodesExist(hydrantBox);
            Nodes.Add(hydrantBox);
            if (!CheckNodesExist(hydrantBox))
                Nodes.Add(hydrantBox);
        }
        public  void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs)
        public void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs)
        {
            hydrantBoxs.ForEach(hydrantBox => { AddHydrantBox(hydrantBox); });
        }
        public  void AddNozzle(NozzleViewModel nozzle)
        public void AddNozzle(NozzleViewModel nozzle)
        {
            CheckNodesExist(nozzle);
            Nodes.Add(nozzle);
            if (!CheckNodesExist(nozzle))
                Nodes.Add(nozzle);
        }
        public  void AddNozzles(List<NozzleViewModel> nozzles)
        public void AddNozzles(List<NozzleViewModel> nozzles)
        {
            nozzles.ForEach(nozzle => { AddNozzle(nozzle); });
        }
        private void CheckNodesExist(NodeCalcModel node)
        private bool CheckNodesExist(NodeCalcModel node)
        {
            if (Nodes.Any(d => d.ID == node.ID))
                throw new Exception("已存在重复的对象");
            return Nodes.Any(d => d.ID == node.ID);
            //   throw new Exception("已存在重复的对象");
        }
        private void CheckLinksExist(LinkCalcModel link)
        private bool CheckLinksExist(LinkCalcModel link)
        {
            if (Links.Any(d => d.ID == link.ID))
                throw new Exception("已存在重复的对象");
            return Links.Any(d => d.ID == link.ID);
            //throw new Exception("已存在重复的对象");
        }
    }
}
Test/Program.cs
@@ -17,7 +17,7 @@
        const string revitInpPath = "d:\\t2.inp";
        static void Main(string[] args)
        {
            Test4();
            Test3();
        }
        static void Test1()
@@ -138,7 +138,7 @@
        static void Test3()
        {
            var nw = new NetWorkMapModel();
            var result = nw.Calc("d:\\revitinp.inp");
            var result = nw.Calc("d:\\xiaofang.inp");
            Console.WriteLine(result);
            Console.ReadLine();
        }