duheng
2024-09-22 9ffb31c233f3b4891550293294c2ee716f77b42a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
 
using Yw.WinFrmUI.HydroL3d;
 
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 
    /// </summary>
    public static class HydroL3dTransferHelper
    {
        /// <summary>
        /// 
        /// </summary>
        public static Network ToL3dNetworkViewModel(this Yw.Model.HydroModelInfo rhs)
        {
            if (rhs == null)
            {
                return default;
            }
            var vm = new Network();
            if (rhs.Junctions != null && rhs.Junctions.Count > 0)
            {
                foreach (var junction in rhs.Junctions)
                {
 
                }
            }
            if (rhs.Nozzles != null && rhs.Nozzles.Count > 0)
            {
                foreach (var nozzle in rhs.Nozzles)
                {
 
                }
            }
            if (rhs.Hydrants != null && rhs.Hydrants.Count > 0)
            {
                foreach (var hydrant in rhs.Hydrants)
                {
 
                }
            }
            if (rhs.Elbows != null && rhs.Elbows.Count > 0)
            {
                foreach (var elbow in rhs.Elbows)
                {
 
                }
            }
            if (rhs.Threelinks != null && rhs.Threelinks.Count > 0)
            {
                foreach (var threelink in rhs.Threelinks)
                {
 
                }
            }
            if (rhs.Fourlinks != null && rhs.Fourlinks.Count > 0)
            {
                foreach (var fourlink in rhs.Fourlinks)
                {
 
                }
            }
            if (rhs.Meters != null && rhs.Meters.Count > 0)
            {
                foreach (var meter in rhs.Meters)
                {
 
                }
            }
            if (rhs.Flowmeters != null && rhs.Flowmeters.Count > 0)
            {
                foreach (var flowmeter in rhs.Flowmeters)
                {
 
                }
            }
            if (rhs.Pressmeters != null && rhs.Pressmeters.Count > 0)
            {
                foreach (var pressmeter in rhs.Pressmeters)
                {
 
                }
            }
            if (rhs.Bluntheads != null && rhs.Bluntheads.Count > 0)
            {
                foreach (var blunthead in rhs.Bluntheads)
                {
 
                }
            }
 
            if (rhs.Reservoirs != null && rhs.Reservoirs.Count > 0)
            {
                foreach (var reservoir in rhs.Reservoirs)
                {
 
                }
            }
            if (rhs.Tanks != null && rhs.Tanks.Count > 0)
            {
                foreach (var tank in rhs.Tanks)
                {
 
                }
            }
            if (rhs.Waterboxs != null && rhs.Waterboxs.Count > 0)
            {
                foreach (var waterbox in rhs.Waterboxs)
                {
 
                }
            }
 
            if (rhs.Pipes != null && rhs.Pipes.Count > 0)
            {
                foreach (var pipe in rhs.Pipes)
                {
                    var startNode = rhs.GetAllNodes().Find(x => x.Code == pipe.StartCode);
                    var endNode = rhs.GetAllNodes().Find(x => x.Code == pipe.EndCode);
                    var pipeViewModel = new Pipe();
                    pipeViewModel.Id = pipe.Code;
                    pipeViewModel.Name = pipe.Name;
                    pipeViewModel.StartPosition = new Point3d(startNode.Position3d.X, startNode.Position3d.Y, startNode.Position3d.Z);
                    pipeViewModel.EndPosition = new Point3d(endNode.Position3d.X, endNode.Position3d.Y, endNode.Position3d.Z);
                    vm.Append(pipeViewModel, out _);
                }
            }
            if (rhs.Translations != null && rhs.Translations.Count > 0)
            {
                foreach (var translation in rhs.Translations)
                {
 
                }
            }
            if (rhs.Exchangers != null && rhs.Exchangers.Count > 0)
            {
                foreach (var exchanger in rhs.Exchangers)
                {
 
                }
            }
 
            if (rhs.Pumps != null && rhs.Pumps.Count > 0)
            {
                foreach (var pump in rhs.Pumps)
                {
 
                }
            }
            if (rhs.Valves != null && rhs.Valves.Count > 0)
            {
                foreach (var valve in rhs.Valves)
                {
 
                }
            }
 
            return vm;
        }
    }
}