hytos / DTI_PID / ID2PSN / PSN.cs @ d446786e
이력 | 보기 | 이력해설 | 다운로드 (225 KB)
1 | 6b9e7a56 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Data; |
||
4 | using System.IO; |
||
5 | using System.Linq; |
||
6 | using System.Text; |
||
7 | using System.Threading.Tasks; |
||
8 | 7881ec8f | gaqhf | using ID2PSN.Properties; |
9 | using System.Text.RegularExpressions; |
||
10 | 5dfc785c | LJIYEON | using System.Windows.Forms; |
11 | 4607ff67 | 이지연 | using DevExpress.XtraSplashScreen; |
12 | 6b9e7a56 | gaqhf | |
13 | namespace ID2PSN |
||
14 | { |
||
15 | public enum PSNType |
||
16 | { |
||
17 | None, |
||
18 | Branch, |
||
19 | Equipment, |
||
20 | Header, |
||
21 | Symbol, |
||
22 | OPC, |
||
23 | } |
||
24 | |||
25 | 45529c16 | LJIYEON | public enum ErrorType |
26 | { |
||
27 | Error = -1, |
||
28 | OK, |
||
29 | InValid //이값은 들어가는데가 없음.. |
||
30 | } |
||
31 | |||
32 | 6b9e7a56 | gaqhf | public class PSN |
33 | { |
||
34 | 8f24b438 | gaqhf | private double[] DrawingSize = null; |
35 | private double DrawingWidth = double.NaN; |
||
36 | private double DrawingHeight = double.NaN; |
||
37 | public int Revision; |
||
38 | c6503eaa | gaqhf | public string EquipTagNoAttributeName = string.Empty; |
39 | bd86dd48 | 이지연 | public string TieInPointAttributeName = string.Empty; |
40 | 6b9e7a56 | gaqhf | public DataTable PathItems { get; set; } |
41 | public DataTable SequenceData { get; set; } |
||
42 | public DataTable PipeSystemNetwork { get; set; } |
||
43 | 36a45f13 | gaqhf | public DataTable TopologySet { get; set; } |
44 | 6b9e7a56 | gaqhf | public DataTable Equipment { get; set; } |
45 | public DataTable Nozzle { get; set; } |
||
46 | a36541fb | LJIYEON | public DataTable PipeLine { get; set; } |
47 | 531fb158 | LJIYEON | public DataTable PipeSystem { get; set; } |
48 | 6b9e7a56 | gaqhf | |
49 | 51974d2b | LJIYEON | public string Rule1 = "Missing LineNumber_1"; //Line Disconnected에서 변경 |
50 | public string Rule2 = "Missing LineNumber_2"; //Missing LineNumber에서 변경 |
||
51 | public string Rule3 = "OPC Disconnected"; |
||
52 | 5e4c2ad1 | LJIYEON | public string Rule4 = "Missing ItemTag or Description"; |
53 | 51974d2b | LJIYEON | public string Rule5 = "Line Disconnected"; |
54 | 2ada3be8 | LJIYEON | |
55 | 710a49f1 | gaqhf | int tieInPointIndex = 1; |
56 | bd86dd48 | 이지연 | int tieInPointSymbolIndex = 1; |
57 | 6b9e7a56 | gaqhf | List<Document> Documents; |
58 | List<Group> groups = new List<Group>(); |
||
59 | List<PSNItem> PSNItems = new List<PSNItem>(); |
||
60 | List<Topology> Topologies = new List<Topology>(); |
||
61 | |||
62 | DataTable opcDT = null; |
||
63 | DataTable topologyRuleDT = null; |
||
64 | |||
65 | 5dfc785c | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
66 | |||
67 | d6ef5842 | 이지연 | private Dictionary<string, int> dicMultiwaySymbolUID = new Dictionary<string, int>(); |
68 | private Dictionary<string, int> dicMultiwaySymbolNameTag = new Dictionary<string, int>(); |
||
69 | eb44d82c | LJIYEON | |
70 | a36541fb | LJIYEON | //const string FluidPriorityType = "FLUIDCODE"; |
71 | //const string PipingMaterialsPriorityType = "PIPINGMATERIALSCLASS"; |
||
72 | 6b9e7a56 | gaqhf | |
73 | 5c248ee3 | gaqhf | public PSN() |
74 | { |
||
75 | 7106e181 | LJIYEON | |
76 | 5c248ee3 | gaqhf | } |
77 | |||
78 | 8f24b438 | gaqhf | public PSN(List<Document> documents, int Revision) |
79 | 6b9e7a56 | gaqhf | { |
80 | 5dfc785c | LJIYEON | try |
81 | { |
||
82 | Documents = documents; |
||
83 | foreach (Document document in Documents) |
||
84 | groups.AddRange(document.Groups); |
||
85 | opcDT = GetOPCInfo(); |
||
86 | topologyRuleDT = GetTopologyRule(); |
||
87 | this.Revision = Revision; |
||
88 | DrawingSize = DB.GetDrawingSize(); |
||
89 | if (DrawingSize == null) |
||
90 | { |
||
91 | MessageBox.Show("There is no data whose Section is Area and Key is Drawing in the drawing table.", "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
92 | return; |
||
93 | } |
||
94 | DrawingWidth = DrawingSize[2] - DrawingSize[0]; |
||
95 | DrawingHeight = DrawingSize[3] - DrawingSize[1]; |
||
96 | } |
||
97 | catch (Exception ex) |
||
98 | { |
||
99 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
100 | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
101 | } |
||
102 | 6b9e7a56 | gaqhf | } |
103 | |||
104 | 36a45f13 | gaqhf | private string GetItemTag(Item item) |
105 | { |
||
106 | string result = string.Empty; |
||
107 | if (item.ItemType == ItemType.Line) |
||
108 | result = item.LineNumber != null ? item.LineNumber.Name : string.Empty; |
||
109 | else if (item.ItemType == ItemType.Symbol && item.SubItemType == SubItemType.Nozzle) |
||
110 | result = Nozzle.Select(string.Format("OID = '{0}'", item.UID)).First()["ITEMTAG"].ToString(); |
||
111 | |||
112 | return result; |
||
113 | } |
||
114 | 7881ec8f | gaqhf | private string GetItemName(Item item, string itemOID) |
115 | { |
||
116 | string result = string.Empty; |
||
117 | if (item.ItemType == ItemType.Line && (item.Name == "Secondary" || item.Name == "Primary")) |
||
118 | { |
||
119 | if (itemOID.Contains("_")) |
||
120 | { |
||
121 | string split = itemOID.Split(new char[] { '_' })[1]; |
||
122 | if (split.StartsWith("B")) |
||
123 | result = "Branch"; |
||
124 | else |
||
125 | result = "PipeRun"; |
||
126 | } |
||
127 | else |
||
128 | result = "PipeRun"; |
||
129 | } |
||
130 | else if (item.ItemType == ItemType.Symbol) |
||
131 | { |
||
132 | if (item.ID2DBCategory == "Instrumentation") |
||
133 | result = "Instrument"; |
||
134 | else if (item.ID2DBType == "Nozzles") |
||
135 | result = "Nozzle"; |
||
136 | else if (item.ID2DBType == "Fittings" || |
||
137 | item.ID2DBType == "Piping OPC's" || |
||
138 | item.ID2DBType == "Specialty Components" || |
||
139 | item.ID2DBType == "Valves" || |
||
140 | item.ID2DBType == "Reducers") |
||
141 | result = "PipingComp"; |
||
142 | } |
||
143 | return result; |
||
144 | } |
||
145 | |||
146 | private string GetClass(Item item, string itemOID) |
||
147 | { |
||
148 | string result = string.Empty; |
||
149 | if (item.ItemType == ItemType.Line && (item.Name == "Secondary" || item.Name == "Primary")) |
||
150 | { |
||
151 | if (itemOID.Contains("_")) |
||
152 | { |
||
153 | string split = itemOID.Split(new char[] { '_' })[1]; |
||
154 | if (split.StartsWith("B")) |
||
155 | result = "Branch"; |
||
156 | else |
||
157 | result = "Piping"; |
||
158 | } |
||
159 | else |
||
160 | result = "Piping"; |
||
161 | } |
||
162 | else if (item.ItemType == ItemType.Symbol) |
||
163 | { |
||
164 | if (item.ID2DBCategory == "Instrumentation") |
||
165 | result = item.ID2DBType; |
||
166 | else if (item.ID2DBType == "Nozzles") |
||
167 | result = string.Empty; |
||
168 | else if (item.ID2DBType == "Fittings" || |
||
169 | item.ID2DBType == "Piping OPC's" || |
||
170 | item.ID2DBType == "Specialty Components" || |
||
171 | item.ID2DBType == "Valves" || |
||
172 | item.ID2DBType == "Reducers") |
||
173 | result = item.ID2DBType; |
||
174 | } |
||
175 | return result; |
||
176 | } |
||
177 | |||
178 | private string GetSubClass(Item item, string itemOID) |
||
179 | { |
||
180 | string result = string.Empty; |
||
181 | if (item.ItemType == ItemType.Line && (item.Name == "Secondary" || item.Name == "Primary")) |
||
182 | { |
||
183 | if (itemOID.Contains("_")) |
||
184 | { |
||
185 | string split = itemOID.Split(new char[] { '_' })[1]; |
||
186 | if (split.StartsWith("B")) |
||
187 | result = "Tee"; |
||
188 | else |
||
189 | result = ""; |
||
190 | } |
||
191 | else |
||
192 | result = ""; |
||
193 | } |
||
194 | else if (item.ItemType == ItemType.Symbol) |
||
195 | { |
||
196 | if (item.ID2DBCategory == "Instrumentation") |
||
197 | result = string.Empty; |
||
198 | else if (item.ID2DBType == "Nozzles") |
||
199 | result = string.Empty; |
||
200 | else if (item.ID2DBType == "Fittings" || |
||
201 | item.ID2DBType == "Piping OPC's" || |
||
202 | item.ID2DBType == "Specialty Components" || |
||
203 | item.ID2DBType == "Valves" || |
||
204 | item.ID2DBType == "Reducers") |
||
205 | result = "In-line component"; |
||
206 | } |
||
207 | return result; |
||
208 | } |
||
209 | 36a45f13 | gaqhf | |
210 | 4607ff67 | 이지연 | public void SetPSNData(SplashScreenManager splashScreenManager1) |
211 | 7106e181 | LJIYEON | { |
212 | 7881ec8f | gaqhf | // Item들의 속성으로 Topology Data를 생성한다. |
213 | 4607ff67 | 이지연 | // Topology Data는 Topology Rule Setting을 기준으로 생성한다. |
214 | int i = 1; |
||
215 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetTopologyData ( 3 % )"); |
||
216 | 327a7a9c | LJIYEON | SetTopologyData(); |
217 | 7881ec8f | gaqhf | // ID2의 OPC연결 Data 기반으로 Group(도면단위 PSN)을 연결한다. |
218 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 ConnectByOPC ( 5 % )"); |
219 | 6b9e7a56 | gaqhf | ConnectByOPC(); |
220 | 7881ec8f | gaqhf | // 실제 PSN 생성 로직 |
221 | // 연결된 Group을 하나의 PSN으로 만든다. |
||
222 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetPSNItem ( 10 % )"); |
223 | 6b9e7a56 | gaqhf | SetPSNItem(); |
224 | 7881ec8f | gaqhf | // 생성된 PSN의 Type을 설정한다. |
225 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetPSNType ( 15 % )"); |
226 | 6b9e7a56 | gaqhf | SetPSNType(); |
227 | 7881ec8f | gaqhf | // ID2에는 Branch 정보가 없어서 Branch 정보를 생성한다. |
228 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetBranchInfo ( 20 % )"); |
229 | 6b9e7a56 | gaqhf | SetBranchInfo(); |
230 | 7881ec8f | gaqhf | // 생성된 Topology Data들을 정리하며 Main, Branch를 판단한다. |
231 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetTopology ( 25 % )"); |
232 | 6b9e7a56 | gaqhf | SetTopology(); |
233 | 7881ec8f | gaqhf | // PSN이 Bypass인지 검사 |
234 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetPSNBypass ( 30 % )"); |
235 | 7881ec8f | gaqhf | SetPSNBypass(); |
236 | // Topology들에게 Index를 부여한다 |
||
237 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetTopologyIndex ( 35 % )"); |
238 | 7106e181 | LJIYEON | SetTopologyIndex(); |
239 | 7881ec8f | gaqhf | // Nozzle, Equipment의 정보를 저장 |
240 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SaveNozzleAndEquipment ( 40 % )"); |
241 | 6b9e7a56 | gaqhf | SaveNozzleAndEquipment(); |
242 | 7881ec8f | gaqhf | // PSN의 정보를 저장 |
243 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 SetPSNData ( 45 % )"); |
244 | 6b9e7a56 | gaqhf | SavePSNData(); |
245 | 7d6d1693 | 이지연 | // Update PSN From/To Keyword & EndofHeader |
246 | 4607ff67 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 UpdateKeywordForPSN ( 55 % )"); |
247 | 7d6d1693 | 이지연 | UpdateKeywordForPSN(); |
248 | dd27861e | 이지연 | |
249 | 7881ec8f | gaqhf | // Topology의 subtype을 update(bypass, Header, 등등) |
250 | dd27861e | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 UpdateSubType ( 60 % )"); |
251 | 7881ec8f | gaqhf | UpdateSubType(); |
252 | 2f7c4151 | 이지연 | |
253 | // Vent/Drain PSN 데이터 제거 |
||
254 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 DeleteVentDrain ( 65 % )"); |
||
255 | DeleteVentDrain(); |
||
256 | |||
257 | 7881ec8f | gaqhf | // Update Error |
258 | 2f7c4151 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 UpdateErrorForPSN ( 70 % )"); |
259 | dd27861e | 이지연 | PathItemSorting(); |
260 | 4e2e0aa1 | LJIYEON | UpdateErrorForPSN(); |
261 | // Insert Tee |
||
262 | 2f7c4151 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 InsertTeePSN ( 75 % )"); |
263 | 7d6d1693 | 이지연 | PathItemSorting(); |
264 | 4e2e0aa1 | LJIYEON | InsertTeePSN(); |
265 | 2f7c4151 | 이지연 | |
266 | 7d6d1693 | 이지연 | // ValveGrouping |
267 | 2f7c4151 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 UpdateValveGrouping ( 80 % )"); |
268 | 6805be6e | 이지연 | PathItemSorting(); |
269 | 811d7949 | LJIYEON | UpdateValveGrouping(); |
270 | 63ff8e26 | 이지연 | |
271 | 2f7c4151 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 PathItemSorting ( 85 % )"); |
272 | d21b35b1 | 이지연 | PathItemSorting(); |
273 | 63ff8e26 | 이지연 | |
274 | d21b35b1 | 이지연 | // AirFinCooler |
275 | 2f7c4151 | 이지연 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 UpdateAirFinCooler ( 90 % )"); |
276 | d21b35b1 | 이지연 | UpdateAirFinCooler(); |
277 | 63ff8e26 | 이지연 | |
278 | 2327f39c | 이지연 | UpdateNoPocket(); |
279 | |||
280 | dd27861e | 이지연 | // 확도 계산 |
281 | splashScreenManager1.SetWaitFormDescription(i++ + " / 19 UpdateAccuracy ( 95 % )"); |
||
282 | UpdateAccuracy(); |
||
283 | |||
284 | //UpdatePSNType(); |
||
285 | |||
286 | } |
||
287 | |||
288 | 2327f39c | 이지연 | private void UpdateNoPocket() |
289 | { |
||
290 | try |
||
291 | { |
||
292 | DataRow[] nopocketRows = PipeSystemNetwork.Select("Pocket = 'Yes'"); |
||
293 | foreach (DataRow row in nopocketRows) |
||
294 | { |
||
295 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", row["OID"].ToString())); |
||
296 | foreach (DataRow dr in pathItemRows) |
||
297 | { |
||
298 | if (!string.IsNullOrEmpty(dr["BranchTopologySet_OID"].ToString())) |
||
299 | { |
||
300 | DataRow[] rows = TopologySet.Select(string.Format("OID = '{0}'", dr["BranchTopologySet_OID"].ToString())); |
||
301 | |||
302 | if (rows.First()["SubType"].ToString() == "Bypass") |
||
303 | { |
||
304 | DataRow[] bypassRows = PipeSystemNetwork.Select(string.Format("OID = '{0}'", dr.Field<string>("ViewPipeSystemNetwork_OID"))); |
||
305 | |||
306 | foreach (DataRow drby in bypassRows) |
||
307 | { |
||
308 | drby["Pocket"] = "Yes"; |
||
309 | } |
||
310 | } |
||
311 | } |
||
312 | } |
||
313 | } |
||
314 | } |
||
315 | catch (Exception ex) |
||
316 | { |
||
317 | MessageBox.Show(ex.Message, "ID2 ", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
318 | } |
||
319 | } |
||
320 | |||
321 | dd27861e | 이지연 | private void UpdatePSNType() |
322 | { |
||
323 | try |
||
324 | { |
||
325 | foreach (PSNItem PSNItem in PSNItems) |
||
326 | { |
||
327 | foreach (Group group in PSNItem.Groups) |
||
328 | { |
||
329 | foreach (Item item in group.Items) |
||
330 | { |
||
331 | DataRow[] pipeSystems = PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID())); |
||
332 | // PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
||
333 | |||
334 | foreach(DataRow dr in pipeSystems) |
||
335 | { |
||
336 | dr["Type"] = PSNItem.GetPSNType(); |
||
337 | } |
||
338 | } |
||
339 | } |
||
340 | } |
||
341 | } |
||
342 | catch (Exception ex) |
||
343 | { |
||
344 | MessageBox.Show(ex.Message, "ID2 ", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
345 | } |
||
346 | d21b35b1 | 이지연 | } |
347 | 63ff8e26 | 이지연 | |
348 | d21b35b1 | 이지연 | private void PathItemSorting() |
349 | { |
||
350 | try |
||
351 | { |
||
352 | DataTable dtPathItems = PathItems.Clone(); |
||
353 | DataTable dtPipeSystemNetwork = PipeSystemNetwork.DefaultView.ToTable(true, new string[] { "OID" }); |
||
354 | 63ff8e26 | 이지연 | |
355 | d21b35b1 | 이지연 | foreach (DataRow drpipe in dtPipeSystemNetwork.Rows) |
356 | { |
||
357 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", drpipe["OID"].ToString())); |
||
358 | DataTable dtSequenceItems = SequenceData.Clone(); |
||
359 | foreach (DataRow drpath in pathItemRows) |
||
360 | { |
||
361 | DataRow sequenceRows = SequenceData.Select(string.Format("PathItem_OID = '{0}'", drpath.Field<string>("OID"))).First(); |
||
362 | |||
363 | DataRow newRow = dtSequenceItems.NewRow(); |
||
364 | foreach (DataColumn column in SequenceData.Columns) |
||
365 | if (dtSequenceItems.Columns[column.ColumnName] != null) |
||
366 | newRow[column.ColumnName] = sequenceRows[column.ColumnName]; |
||
367 | |||
368 | dtSequenceItems.Rows.Add(newRow); |
||
369 | } |
||
370 | |||
371 | foreach (DataRow sqrow in dtSequenceItems.Select().OrderBy(x => Convert.ToInt32(x.Field<string>("SERIALNUMBER")))) |
||
372 | { |
||
373 | DataRow newRow = dtPathItems.NewRow(); |
||
374 | DataRow row = PathItems.Select(string.Format("OID = '{0}'", sqrow["PathItem_OID"])).First(); |
||
375 | |||
376 | foreach (DataColumn column in PathItems.Columns) |
||
377 | if (dtPathItems.Columns[column.ColumnName] != null) |
||
378 | newRow[column.ColumnName] = row[column.ColumnName]; |
||
379 | |||
380 | dtPathItems.Rows.Add(newRow); |
||
381 | } |
||
382 | 63ff8e26 | 이지연 | } |
383 | |||
384 | d21b35b1 | 이지연 | PathItems.Clear(); |
385 | PathItems = dtPathItems.Copy(); |
||
386 | } |
||
387 | catch (Exception ex) |
||
388 | { |
||
389 | MessageBox.Show(ex.Message, "ID2 ", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
390 | 63ff8e26 | 이지연 | } |
391 | 811d7949 | LJIYEON | } |
392 | d21b35b1 | 이지연 | |
393 | bf9e8432 | 이지연 | private void UpdateAirFinCooler() |
394 | { |
||
395 | try |
||
396 | { |
||
397 | dd27861e | 이지연 | |
398 | d1afd412 | 이지연 | int pumpTagNum = 0; |
399 | bf9e8432 | 이지연 | #region EquipmentAirFinCooler Info |
400 | EquipmentAirFinCoolerInfo EquipmentAirFinCooler = new EquipmentAirFinCoolerInfo(); |
||
401 | DataTable dtEquipmentAirFinCooler = DB.SelectAirFinCoolerSetting(); |
||
402 | foreach (DataRow row in dtEquipmentAirFinCooler.Rows) |
||
403 | { |
||
404 | EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Add(new EquipmentAirFinCoolerItem() |
||
405 | { |
||
406 | Type = row["Type"].ToString(), |
||
407 | bfbc9f6c | 이지연 | TagIdentifier = row["TagIdentifier"].ToString(), |
408 | AttributeName = row["AttributeName"].ToString(), |
||
409 | bf9e8432 | 이지연 | Name = row["Name"].ToString() |
410 | }); |
||
411 | } |
||
412 | #endregion |
||
413 | |||
414 | dd27861e | 이지연 | |
415 | d1afd412 | 이지연 | DataRow[] pumpRows = PipeSystemNetwork.Select("PUMP = 'PUMP'"); |
416 | a89e25a0 | 이지연 | Dictionary<string, string> eqkeyValuePairs = new Dictionary<string, string>(); |
417 | d1afd412 | 이지연 | // 1, 2번 |
418 | foreach (DataRow dataRow in pumpRows) |
||
419 | bfbc9f6c | 이지연 | { |
420 | d1afd412 | 이지연 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"].ToString())); |
421 | |||
422 | bfbc9f6c | 이지연 | string EGTAG = "EGTAG"; |
423 | 7d6d1693 | 이지연 | // string ItemTag = "ItemTag"; |
424 | d1afd412 | 이지연 | string EGFlowDirection = string.Empty; |
425 | bfbc9f6c | 이지연 | string Prefix = string.Empty; |
426 | 7d6d1693 | 이지연 | string SymbolName = string.Empty; |
427 | bfbc9f6c | 이지연 | |
428 | 63ff8e26 | 이지연 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
429 | if (PSNItem.Groups.First().Items.First().Equipment != null) |
||
430 | { |
||
431 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
432 | { |
||
433 | bfbc9f6c | 이지연 | EquipmentAirFinCoolerItem equipmentAirFinCoolerItem = EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).First(); |
434 | if (!string.IsNullOrEmpty(equipmentAirFinCoolerItem.AttributeName)) |
||
435 | EGTAG = PSNItem.Groups.First().Items.First().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName) == null |
||
436 | ? string.Empty : PSNItem.Groups.First().Items.First().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName).Value; |
||
437 | |||
438 | 7d6d1693 | 이지연 | SymbolName = PSNItem.Groups.First().Items.First().Equipment.Name; |
439 | 85eeb2be | 이지연 | Prefix = equipmentAirFinCoolerItem.TagIdentifier; |
440 | 63ff8e26 | 이지연 | EGFlowDirection = "O"; |
441 | } |
||
442 | } |
||
443 | 7d6d1693 | 이지연 | |
444 | if(string.IsNullOrEmpty(EGFlowDirection) && PSNItem.Groups.Last().Items.Last().Equipment != null) |
||
445 | 63ff8e26 | 이지연 | { |
446 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
447 | { |
||
448 | bfbc9f6c | 이지연 | EquipmentAirFinCoolerItem equipmentAirFinCoolerItem = EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).First(); |
449 | if (!string.IsNullOrEmpty(equipmentAirFinCoolerItem.AttributeName)) |
||
450 | 85eeb2be | 이지연 | EGTAG = PSNItem.Groups.Last().Items.Last().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName) == null |
451 | bfbc9f6c | 이지연 | ? string.Empty : PSNItem.Groups.Last().Items.Last().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName).Value; |
452 | |||
453 | 7d6d1693 | 이지연 | SymbolName = PSNItem.Groups.Last().Items.Last().Equipment.Name; |
454 | 85eeb2be | 이지연 | Prefix = equipmentAirFinCoolerItem.TagIdentifier; |
455 | 63ff8e26 | 이지연 | EGFlowDirection = "I"; |
456 | } |
||
457 | } |
||
458 | d1afd412 | 이지연 | |
459 | bfbc9f6c | 이지연 | //Attribute가 세팅되어있지 않다면 |
460 | if (EGTAG.Equals("EGTAG")) |
||
461 | d1afd412 | 이지연 | { |
462 | 7d6d1693 | 이지연 | if (!eqkeyValuePairs.ContainsKey(SymbolName)) |
463 | 63ff8e26 | 이지연 | { |
464 | 7d6d1693 | 이지연 | if (!string.IsNullOrEmpty(Prefix)) |
465 | { |
||
466 | pumpTagNum++; |
||
467 | EGTAG = Prefix + string.Format("-{0}", string.Format("{0:D5}", pumpTagNum)); |
||
468 | eqkeyValuePairs.Add(SymbolName, EGTAG); |
||
469 | } |
||
470 | else |
||
471 | { |
||
472 | eqkeyValuePairs.Add(SymbolName, SymbolName); |
||
473 | } |
||
474 | 63ff8e26 | 이지연 | } |
475 | bfbc9f6c | 이지연 | else |
476 | { |
||
477 | 7d6d1693 | 이지연 | EGTAG = eqkeyValuePairs[SymbolName]; |
478 | bfbc9f6c | 이지연 | } |
479 | } |
||
480 | 85eeb2be | 이지연 | else |
481 | { |
||
482 | 7d6d1693 | 이지연 | if (!string.IsNullOrEmpty(Prefix)) |
483 | EGTAG = Prefix + "-" + EGTAG; |
||
484 | 85eeb2be | 이지연 | } |
485 | bfbc9f6c | 이지연 | |
486 | 7d6d1693 | 이지연 | |
487 | bfbc9f6c | 이지연 | foreach (DataRow dr in pathItemRows) |
488 | { |
||
489 | dr["EqpGroupTag"] = EGTAG; |
||
490 | dr["EGFlowDirection"] = EGFlowDirection; |
||
491 | d1afd412 | 이지연 | } |
492 | } |
||
493 | |||
494 | // 3, 4번 |
||
495 | foreach (DataRow dataRow in pumpRows) |
||
496 | { |
||
497 | |||
498 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"].ToString())); |
||
499 | 63ff8e26 | 이지연 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
500 | d1afd412 | 이지연 | string EGFlowDirection = string.Empty; |
501 | 63ff8e26 | 이지연 | |
502 | if (PSNItem.Groups.First().Items.First().Equipment != null) |
||
503 | { |
||
504 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
505 | { |
||
506 | EGFlowDirection = "O"; |
||
507 | } |
||
508 | } |
||
509 | 7d6d1693 | 이지연 | |
510 | if (string.IsNullOrEmpty(EGFlowDirection) && PSNItem.Groups.Last().Items.Last().Equipment != null) |
||
511 | 63ff8e26 | 이지연 | { |
512 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
513 | { |
||
514 | EGFlowDirection = "I"; |
||
515 | } |
||
516 | } |
||
517 | |||
518 | d1afd412 | 이지연 | |
519 | List<string> lstViewPipeSystemNetwork_OID = new List<string>(); |
||
520 | |||
521 | foreach (DataRow dr in pathItemRows) |
||
522 | { |
||
523 | if(dr.Field<string>("ViewPipeSystemNetwork_OID") != dataRow["OID"].ToString()) |
||
524 | { |
||
525 | string viewEGFlowDirection = string.Empty; |
||
526 | if (PipeSystemNetwork.Select(string.Format("OID = '{0}'", dr.Field<string>("ViewPipeSystemNetwork_OID"))).Count() > 0) |
||
527 | { |
||
528 | 63ff8e26 | 이지연 | PSNItem viewPSNItem = PSNItems.Find(x => x.PSN_OID() == dr.Field<string>("ViewPipeSystemNetwork_OID")); |
529 | |||
530 | if (viewPSNItem.Groups.First().Items.First().Equipment != null) |
||
531 | { |
||
532 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && viewPSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
533 | { |
||
534 | viewEGFlowDirection = "O"; |
||
535 | } |
||
536 | } |
||
537 | 7d6d1693 | 이지연 | |
538 | |||
539 | if (string.IsNullOrEmpty(viewEGFlowDirection) && viewPSNItem.Groups.Last().Items.Last().Equipment != null) |
||
540 | 63ff8e26 | 이지연 | { |
541 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && viewPSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
542 | { |
||
543 | viewEGFlowDirection = "I"; |
||
544 | } |
||
545 | } |
||
546 | d1afd412 | 이지연 | |
547 | if (EGFlowDirection.Equals(viewEGFlowDirection) && !lstViewPipeSystemNetwork_OID.Contains(dr.Field<string>("ViewPipeSystemNetwork_OID"))) |
||
548 | lstViewPipeSystemNetwork_OID.Add(dr.Field<string>("ViewPipeSystemNetwork_OID")); |
||
549 | } |
||
550 | else |
||
551 | { |
||
552 | } |
||
553 | } |
||
554 | } |
||
555 | |||
556 | string selectViewOID = string.Empty; |
||
557 | |||
558 | if (EGFlowDirection == "O") //From 이면 시작점에서 제일 먼 값 |
||
559 | { |
||
560 | foreach (string viewOID in lstViewPipeSystemNetwork_OID) |
||
561 | { |
||
562 | if (PipeSystemNetwork.Select(string.Format("PUMP = 'PUMP' AND OID = '{0}'", viewOID)).Count() > 0) |
||
563 | { |
||
564 | selectViewOID = pathItemRows.Where(x => x.Field<string>("ViewPipeSystemNetwork_OID") == viewOID).Last().Field<string>("OID"); |
||
565 | } |
||
566 | } |
||
567 | } |
||
568 | else if (EGFlowDirection == "I") //To 이면 시작점에서 제일 가까운 값 |
||
569 | { |
||
570 | foreach (string viewOID in lstViewPipeSystemNetwork_OID) |
||
571 | { |
||
572 | if (PipeSystemNetwork.Select(string.Format("PUMP = 'PUMP' AND OID = '{0}'", viewOID)).Count() > 0) |
||
573 | { |
||
574 | selectViewOID = pathItemRows.Where(x => x.Field<string>("ViewPipeSystemNetwork_OID") == viewOID).Last().Field<string>("OID"); |
||
575 | break; |
||
576 | } |
||
577 | } |
||
578 | } |
||
579 | |||
580 | if (!string.IsNullOrEmpty(selectViewOID)) //selectViewOID 가 있으면 |
||
581 | { |
||
582 | string EqpGroupTag = string.Empty; |
||
583 | |||
584 | 63ff8e26 | 이지연 | if((EGFlowDirection == "O" && lstViewPipeSystemNetwork_OID.Contains(pathItemRows.Last().Field<string>("ViewPipeSystemNetwork_OID"))) || |
585 | (EGFlowDirection == "I" && lstViewPipeSystemNetwork_OID.Contains(pathItemRows.First().Field<string>("ViewPipeSystemNetwork_OID")))) |
||
586 | { |
||
587 | d1afd412 | 이지연 | DataRow[] viewpathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", pathItemRows.First().Field<string>("ViewPipeSystemNetwork_OID"))); |
588 | |||
589 | foreach (DataRow row in viewpathItemRows) |
||
590 | { |
||
591 | if (!string.IsNullOrEmpty(row.Field<string>("EqpGroupTag"))) |
||
592 | { |
||
593 | EqpGroupTag = row.Field<string>("EqpGroupTag"); |
||
594 | break; |
||
595 | } |
||
596 | } |
||
597 | |||
598 | foreach (DataRow dr in pathItemRows) |
||
599 | { |
||
600 | dr["EqpGroupTag"] = EqpGroupTag; |
||
601 | } |
||
602 | |||
603 | } |
||
604 | else |
||
605 | { |
||
606 | bool bCheck = false; |
||
607 | add4c093 | 이지연 | if (EGFlowDirection == "I") //To 일때 |
608 | d1afd412 | 이지연 | { |
609 | foreach (DataRow dr in pathItemRows) |
||
610 | { |
||
611 | 63ff8e26 | 이지연 | if (selectViewOID == dr["OID"].ToString()) |
612 | { |
||
613 | dr["EGTConnectedPoint"] = "1"; |
||
614 | bCheck = true; |
||
615 | } |
||
616 | |||
617 | d1afd412 | 이지연 | if (!bCheck) |
618 | { |
||
619 | add4c093 | 이지연 | dr["EqpGroupTag"] = string.Empty; |
620 | dr["MainLineTag"] = string.Empty; |
||
621 | 63ff8e26 | 이지연 | dr["EGTConnectedPoint"] = "0"; |
622 | dr["EGFlowDirection"] = string.Empty; |
||
623 | d1afd412 | 이지연 | } |
624 | else |
||
625 | { |
||
626 | add4c093 | 이지연 | dr["MainLineTag"] = "M"; |
627 | d1afd412 | 이지연 | } |
628 | 63ff8e26 | 이지연 | |
629 | d1afd412 | 이지연 | } |
630 | |||
631 | } |
||
632 | add4c093 | 이지연 | else if (EGFlowDirection == "O") //From 일 때 |
633 | d1afd412 | 이지연 | { |
634 | foreach (DataRow dr in pathItemRows) |
||
635 | { |
||
636 | add4c093 | 이지연 | if (bCheck) |
637 | d1afd412 | 이지연 | { |
638 | 63ff8e26 | 이지연 | |
639 | d1afd412 | 이지연 | dr["EqpGroupTag"] = string.Empty; |
640 | dr["MainLineTag"] = string.Empty; |
||
641 | dr["EGTConnectedPoint"] = "0"; |
||
642 | 63ff8e26 | 이지연 | dr["EGFlowDirection"] = string.Empty; |
643 | d1afd412 | 이지연 | } |
644 | else |
||
645 | { |
||
646 | dr["MainLineTag"] = "M"; |
||
647 | } |
||
648 | |||
649 | if (selectViewOID == dr["OID"].ToString()) |
||
650 | { |
||
651 | dr["EGTConnectedPoint"] = "1"; |
||
652 | bCheck = true; |
||
653 | } |
||
654 | } |
||
655 | } |
||
656 | } |
||
657 | } |
||
658 | else |
||
659 | { |
||
660 | 7d6d1693 | 이지연 | //foreach (DataRow dr in pathItemRows) |
661 | //{ |
||
662 | // dr["EqpGroupTag"] = string.Empty; |
||
663 | // dr["EGFlowDirection"] = string.Empty; |
||
664 | // dr["EGTConnectedPoint"] = "0"; |
||
665 | // dr["MainLineTag"] = string.Empty; |
||
666 | //} |
||
667 | d1afd412 | 이지연 | } |
668 | } |
||
669 | |||
670 | // 5번 |
||
671 | foreach (DataRow dataRow in pumpRows) |
||
672 | { |
||
673 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"].ToString())); |
||
674 | |||
675 | bool bCheck = false; |
||
676 | string EqpGroupTag = string.Empty; |
||
677 | |||
678 | 63ff8e26 | 이지연 | string EGFlowDirection = string.Empty; |
679 | d1afd412 | 이지연 | |
680 | 63ff8e26 | 이지연 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow.Field<string>("OID")); |
681 | d1afd412 | 이지연 | |
682 | 63ff8e26 | 이지연 | if (PSNItem.Groups.First().Items.First().Equipment != null) |
683 | { |
||
684 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
685 | { |
||
686 | EGFlowDirection = "O"; |
||
687 | } |
||
688 | } |
||
689 | 7d6d1693 | 이지연 | |
690 | if (string.IsNullOrEmpty(EGFlowDirection) && PSNItem.Groups.Last().Items.Last().Equipment != null) |
||
691 | 63ff8e26 | 이지연 | { |
692 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
693 | { |
||
694 | EGFlowDirection = "I"; |
||
695 | } |
||
696 | } |
||
697 | |||
698 | List<string> lstViewPipeSystemNetwork_OID = new List<string>(); |
||
699 | List<string> lstEqTagRows = new List<string>(); |
||
700 | d1afd412 | 이지연 | if (EGFlowDirection.Equals("I")) |
701 | { |
||
702 | foreach (DataRow dr in pathItemRows) |
||
703 | 63ff8e26 | 이지연 | { |
704 | if (!string.IsNullOrEmpty(dr.Field<string>("MainLineTag")) && dr.Field<string>("MainLineTag").Equals("M") && !string.IsNullOrEmpty(dr.Field<string>("EqpGroupTag"))) |
||
705 | { |
||
706 | d1afd412 | 이지연 | bCheck = true; |
707 | EqpGroupTag = dr.Field<string>("EqpGroupTag"); |
||
708 | 63ff8e26 | 이지연 | if(!lstEqTagRows.Contains(EqpGroupTag)) |
709 | lstEqTagRows.Add(EqpGroupTag); |
||
710 | d1afd412 | 이지연 | |
711 | 63ff8e26 | 이지연 | if(dataRow["OID"].ToString() != dr.Field<string>("ViewPipeSystemNetwork_OID")) |
712 | { |
||
713 | PSNItem viewPSNItem = PSNItems.Find(x => x.PSN_OID() == dr.Field<string>("ViewPipeSystemNetwork_OID")); |
||
714 | if (viewPSNItem.Groups.Last().Items.Last().Equipment == null) |
||
715 | continue; |
||
716 | d1afd412 | 이지연 | |
717 | 63ff8e26 | 이지연 | if (!lstEqTagRows.Contains(viewPSNItem.Groups.Last().Items.Last().Equipment.ItemTag)) |
718 | lstEqTagRows.Add(viewPSNItem.Groups.Last().Items.Last().Equipment.ItemTag); |
||
719 | } |
||
720 | |||
721 | d1afd412 | 이지연 | } |
722 | 63ff8e26 | 이지연 | |
723 | d1afd412 | 이지연 | } |
724 | 63ff8e26 | 이지연 | if(bCheck) |
725 | d1afd412 | 이지연 | { |
726 | 63ff8e26 | 이지연 | foreach (DataRow row in pumpRows) |
727 | d1afd412 | 이지연 | { |
728 | 63ff8e26 | 이지연 | if (row.Field<string>("OID").Equals(dataRow["OID"].ToString())) |
729 | continue; |
||
730 | |||
731 | PSNItem viewPSNItem = PSNItems.Find(x => x.PSN_OID() == row["OID"].ToString()); |
||
732 | |||
733 | if (viewPSNItem.Groups.First().Items.First().Equipment == null) |
||
734 | d1afd412 | 이지연 | continue; |
735 | 63ff8e26 | 이지연 | |
736 | if (lstEqTagRows.Contains(viewPSNItem.Groups.First().Items.First().Equipment.ItemTag) && !lstViewPipeSystemNetwork_OID.Contains(row.Field<string>("OID"))) |
||
737 | lstViewPipeSystemNetwork_OID.Add(row.Field<string>("OID")); |
||
738 | } |
||
739 | d1afd412 | 이지연 | |
740 | 63ff8e26 | 이지연 | |
741 | d1afd412 | 이지연 | |
742 | 63ff8e26 | 이지연 | if (lstViewPipeSystemNetwork_OID.Count() > 0) |
743 | { |
||
744 | foreach (string viewPipesystem in lstViewPipeSystemNetwork_OID) |
||
745 | d1afd412 | 이지연 | { |
746 | DataRow[] viewpathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", viewPipesystem)); |
||
747 | foreach (DataRow viewdr in viewpathItemRows) |
||
748 | { |
||
749 | if (!string.IsNullOrEmpty(viewdr["EqpGroupTag"].ToString())) |
||
750 | viewdr["EqpGroupTag"] = EqpGroupTag; |
||
751 | } |
||
752 | } |
||
753 | } |
||
754 | 63ff8e26 | 이지연 | } |
755 | } |
||
756 | d1afd412 | 이지연 | } |
757 | |||
758 | dd27861e | 이지연 | int afcTagNum = 0; |
759 | 284fa2c9 | 이지연 | DataRow[] airFinCoolerRows = PipeSystemNetwork.Select("AFC Like 'P1%'"); |
760 | Dictionary<string, string> keyValuePairs = new Dictionary<string, string>(); |
||
761 | 0eefef3d | 이지연 | foreach (DataRow dataRow in airFinCoolerRows) |
762 | { |
||
763 | 5b0805a5 | 이지연 | string EGFlowDirection = string.Empty; |
764 | bfbc9f6c | 이지연 | string EGTAG = "EGTAG"; |
765 | string Prefix = string.Empty; |
||
766 | 7d6d1693 | 이지연 | string SymbolName = string.Empty; |
767 | |||
768 | bfbc9f6c | 이지연 | //item.Attributes.Find(x => x.Name == valveitem.AttributeName).Value; |
769 | 63ff8e26 | 이지연 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
770 | if (PSNItem.Groups.First().Items.First().Equipment != null) |
||
771 | { |
||
772 | e3562345 | 이지연 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).Count() > 0) |
773 | 63ff8e26 | 이지연 | { |
774 | bfbc9f6c | 이지연 | EquipmentAirFinCoolerItem equipmentAirFinCoolerItem = EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).First(); |
775 | if(!string.IsNullOrEmpty(equipmentAirFinCoolerItem.AttributeName)) |
||
776 | EGTAG = PSNItem.Groups.First().Items.First().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName) == null |
||
777 | ? string.Empty : PSNItem.Groups.First().Items.First().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName).Value; |
||
778 | |||
779 | Prefix = equipmentAirFinCoolerItem.TagIdentifier; |
||
780 | 63ff8e26 | 이지연 | EGFlowDirection = "O"; |
781 | } |
||
782 | } |
||
783 | 7d6d1693 | 이지연 | |
784 | if (string.IsNullOrEmpty(EGFlowDirection) && PSNItem.Groups.Last().Items.Last().Equipment != null) |
||
785 | 63ff8e26 | 이지연 | { |
786 | e3562345 | 이지연 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).Count() > 0) |
787 | 63ff8e26 | 이지연 | { |
788 | bfbc9f6c | 이지연 | EquipmentAirFinCoolerItem equipmentAirFinCoolerItem = EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).First(); |
789 | if (!string.IsNullOrEmpty(equipmentAirFinCoolerItem.AttributeName)) |
||
790 | EGTAG = PSNItem.Groups.Last().Items.Last().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName) == null |
||
791 | ? string.Empty : PSNItem.Groups.Last().Items.Last().Equipment.Attributes.Find(x => x.Name == equipmentAirFinCoolerItem.AttributeName).Value; |
||
792 | |||
793 | Prefix = equipmentAirFinCoolerItem.TagIdentifier; |
||
794 | 63ff8e26 | 이지연 | EGFlowDirection = "I"; |
795 | } |
||
796 | } |
||
797 | 5b0805a5 | 이지연 | |
798 | bfbc9f6c | 이지연 | if(!string.IsNullOrEmpty(EGFlowDirection)) |
799 | { |
||
800 | string[] afcTag = dataRow.Field<string>("AFC").Split(new string[] { "\\" }, StringSplitOptions.None); |
||
801 | |||
802 | //Attribute가 세팅되어있지 않다면 |
||
803 | if (EGTAG.Equals("EGTAG")) |
||
804 | 7d6d1693 | 이지연 | { |
805 | bfbc9f6c | 이지연 | if (!keyValuePairs.ContainsKey(afcTag[1])) |
806 | { |
||
807 | 7d6d1693 | 이지연 | if (!string.IsNullOrEmpty(Prefix)) |
808 | { |
||
809 | afcTagNum++; |
||
810 | EGTAG = Prefix + string.Format("-{0}", string.Format("{0:D5}", afcTagNum)); |
||
811 | keyValuePairs.Add(afcTag[1], EGTAG); |
||
812 | } |
||
813 | else |
||
814 | { |
||
815 | keyValuePairs.Add(afcTag[1], afcTag[1]); |
||
816 | |||
817 | } |
||
818 | bfbc9f6c | 이지연 | } |
819 | else |
||
820 | { |
||
821 | EGTAG = keyValuePairs[afcTag[1]]; |
||
822 | } |
||
823 | 7d6d1693 | 이지연 | |
824 | bfbc9f6c | 이지연 | } |
825 | 85eeb2be | 이지연 | else |
826 | { |
||
827 | 7d6d1693 | 이지연 | if (!string.IsNullOrEmpty(Prefix)) |
828 | EGTAG = Prefix + "-" + EGTAG; |
||
829 | 85eeb2be | 이지연 | } |
830 | bfbc9f6c | 이지연 | |
831 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"].ToString())); |
||
832 | foreach (DataRow dr in pathItemRows) |
||
833 | { |
||
834 | dr["EqpGroupTag"] = EGTAG; |
||
835 | dr["EGFlowDirection"] = EGFlowDirection; |
||
836 | } |
||
837 | } |
||
838 | |||
839 | } |
||
840 | |||
841 | List<string> changePSN = new List<string>(); |
||
842 | foreach (DataRow dataRow in airFinCoolerRows) |
||
843 | { |
||
844 | if (changePSN.Contains(dataRow["OID"].ToString())) |
||
845 | continue; |
||
846 | |||
847 | 0eefef3d | 이지연 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"].ToString())); |
848 | bfbc9f6c | 이지연 | string AFCTag = string.Empty; |
849 | if (pathItemRows.Where(x => !string.IsNullOrEmpty(x.Field<string>("EqpGroupTag"))).Count() > 0) |
||
850 | AFCTag = pathItemRows.Where(x => !string.IsNullOrEmpty(x.Field<string>("EqpGroupTag"))).First().Field<string>("EqpGroupTag"); |
||
851 | |||
852 | List<string> lstViewPipeSystemNetwork_OID = pathItemRows.Select(x => x.Field<string>("ViewPipeSystemNetwork_OID")).Distinct().ToList(); |
||
853 | |||
854 | 0eefef3d | 이지연 | if (dataRow["Type"].ToString() == "E2E") |
855 | { |
||
856 | bfbc9f6c | 이지연 | foreach (DataRow dr in pathItemRows) |
857 | { |
||
858 | dr["MainLineTag"] = "M"; |
||
859 | } |
||
860 | dataRow["AFC"] = "P3"; |
||
861 | 0eefef3d | 이지연 | } |
862 | else if (dataRow["Type"].ToString() == "E2B" || dataRow["Type"].ToString() == "B2E") |
||
863 | { |
||
864 | bfbc9f6c | 이지연 | foreach (string lstoid in lstViewPipeSystemNetwork_OID) |
865 | 2f7c4151 | 이지연 | { |
866 | DataRow[] p2psn = PipeSystemNetwork.Select(string.Format("OID = '{0}' AND AFC = 'P2'", lstoid)); |
||
867 | |||
868 | if (p2psn.Count() > 0) |
||
869 | 0eefef3d | 이지연 | { |
870 | 2f7c4151 | 이지연 | DataRow[] viewPathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", lstoid)); |
871 | List<string> lstview = viewPathItemRows.Select(x => x.Field<string>("ViewPipeSystemNetwork_OID")).Distinct().ToList(); |
||
872 | lstview.Remove(dataRow["OID"].ToString()); // P1인 자신 제거 |
||
873 | lstview.Remove(lstoid); // P2 자신 제거 |
||
874 | |||
875 | List<string> lstnewpipe = new List<string>(); |
||
876 | foreach (string lstvw in lstview) //자신 외 P1이 있는지 확인 |
||
877 | { |
||
878 | if (airFinCoolerRows.Where(x => x.Field<string>("OID").Equals(lstvw)).Count() > 0) //P1이면 리스트에 추가 |
||
879 | lstnewpipe.Add(lstvw); |
||
880 | } |
||
881 | |||
882 | if (lstnewpipe.Count() == 0) |
||
883 | 0eefef3d | 이지연 | { |
884 | 2f7c4151 | 이지연 | foreach (DataRow dr in pathItemRows) |
885 | dd27861e | 이지연 | { |
886 | 2f7c4151 | 이지연 | dr["MainLineTag"] = "M"; |
887 | } |
||
888 | dataRow["AFC"] = "P3"; |
||
889 | } |
||
890 | else |
||
891 | { |
||
892 | // P2에 ML값 AGT값 지정 |
||
893 | DataRow[] viewpathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", lstoid)); |
||
894 | DataRow[] pipesystemRows = PipeSystemNetwork.Select(string.Format("OID = '{0}'", lstoid)); |
||
895 | foreach (DataRow viewdr in pipesystemRows) |
||
896 | { |
||
897 | viewdr["AFC"] = "P4"; |
||
898 | dd27861e | 이지연 | } |
899 | |||
900 | 2f7c4151 | 이지연 | foreach (DataRow viewdr in viewpathItemRows) |
901 | 0eefef3d | 이지연 | { |
902 | 2f7c4151 | 이지연 | viewdr["EqpGroupTag"] = AFCTag; |
903 | viewdr["MainLineTag"] = "M"; |
||
904 | bfbc9f6c | 이지연 | } |
905 | 2f7c4151 | 이지연 | // 연결된 모든 P1들의 AGT값 치환 |
906 | foreach (string pipe in lstnewpipe) |
||
907 | bfbc9f6c | 이지연 | { |
908 | 2f7c4151 | 이지연 | viewpathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", pipe)); |
909 | bfbc9f6c | 이지연 | foreach (DataRow viewdr in viewpathItemRows) |
910 | { |
||
911 | viewdr["EqpGroupTag"] = AFCTag; |
||
912 | } |
||
913 | 0eefef3d | 이지연 | } |
914 | } |
||
915 | 2f7c4151 | 이지연 | } |
916 | } |
||
917 | 0eefef3d | 이지연 | } |
918 | } |
||
919 | 2f7c4151 | 이지연 | |
920 | 284fa2c9 | 이지연 | //P3을 제외한 P1 |
921 | airFinCoolerRows = PipeSystemNetwork.Select("AFC Like 'P1%'"); |
||
922 | 0eefef3d | 이지연 | foreach (DataRow dataRow in airFinCoolerRows) |
923 | bf9e8432 | 이지연 | { |
924 | bfbc9f6c | 이지연 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"].ToString())); |
925 | |||
926 | 0eefef3d | 이지연 | if (pathItemRows.Count() > 0) |
927 | bf9e8432 | 이지연 | { |
928 | 0eefef3d | 이지연 | List<string> lstViewPipeSystemNetwork_OID = pathItemRows.Select(x => x.Field<string>("ViewPipeSystemNetwork_OID")).Distinct().ToList(); |
929 | List<string> lstpsn = new List<string>(); |
||
930 | dd27861e | 이지연 | List<string> lstAll = new List<string>(); |
931 | 0eefef3d | 이지연 | string EqpGroupTag = string.Empty; |
932 | foreach (string viewOID in lstViewPipeSystemNetwork_OID) |
||
933 | { |
||
934 | if (dataRow["OID"].ToString() == viewOID) |
||
935 | bfbc9f6c | 이지연 | { |
936 | lstAll.Add(viewOID); |
||
937 | 0eefef3d | 이지연 | continue; |
938 | bfbc9f6c | 이지연 | } |
939 | 284fa2c9 | 이지연 | |
940 | //P3이면 |
||
941 | 0eefef3d | 이지연 | DataRow viewPSN = null; |
942 | if (PipeSystemNetwork.Select(string.Format("OID = '{0}' AND AFC = 'P3'", viewOID)).Count() > 0) |
||
943 | viewPSN = PipeSystemNetwork.Select(string.Format("OID = '{0}' AND AFC = 'P3'", viewOID)).First(); |
||
944 | |||
945 | if (viewPSN != null) |
||
946 | { |
||
947 | 284fa2c9 | 이지연 | //P3의 AGT를 가져와 P1에 입력 |
948 | bfbc9f6c | 이지연 | if(string.IsNullOrEmpty(EqpGroupTag)) |
949 | EqpGroupTag = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", viewOID)).First().Field<string>("EqpGroupTag"); |
||
950 | |||
951 | 0eefef3d | 이지연 | foreach (DataRow dr in pathItemRows) |
952 | { |
||
953 | dr["EqpGroupTag"] = EqpGroupTag; |
||
954 | |||
955 | 284fa2c9 | 이지연 | //P1의 AGT와 같은 모든 AGT를 P3의 AGT로 변경하기위해 |
956 | dd27861e | 이지연 | if (!string.IsNullOrEmpty(dr.Field<string>("ViewPipeSystemNetwork_OID")) && !lstpsn.Contains(dr.Field<string>("ViewPipeSystemNetwork_OID"))) |
957 | { |
||
958 | bfbc9f6c | 이지연 | //AND MainLineTag = '' |
959 | if (PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}' ", dr.Field<string>("ViewPipeSystemNetwork_OID"))).Count() > 0) |
||
960 | { |
||
961 | lstpsn.Add(dr.Field<string>("ViewPipeSystemNetwork_OID")); |
||
962 | lstAll.Add(dr.Field<string>("ViewPipeSystemNetwork_OID")); |
||
963 | } |
||
964 | dd27861e | 이지연 | } |
965 | 0eefef3d | 이지연 | } |
966 | 7d6d1693 | 이지연 | } |
967 | 0eefef3d | 이지연 | } |
968 | |||
969 | dd27861e | 이지연 | while (lstpsn.Count() != 0) |
970 | bfbc9f6c | 이지연 | { |
971 | DataRow[] rule4pathItems = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", lstpsn[0])); |
||
972 | foreach (DataRow dr in rule4pathItems) |
||
973 | 0eefef3d | 이지연 | { |
974 | bfbc9f6c | 이지연 | if (!string.IsNullOrEmpty(dr.Field<string>("ViewPipeSystemNetwork_OID")) && !lstAll.Contains(dr.Field<string>("ViewPipeSystemNetwork_OID"))) |
975 | 0eefef3d | 이지연 | { |
976 | bfbc9f6c | 이지연 | DataRow viewPSN = null; |
977 | |||
978 | if (airFinCoolerRows.Where(x => x.Field<string>("OID") == dr.Field<string>("ViewPipeSystemNetwork_OID")).Count() > 0) |
||
979 | viewPSN = airFinCoolerRows.Where(x => x.Field<string>("OID") == dr.Field<string>("ViewPipeSystemNetwork_OID")).First(); |
||
980 | 2f7c4151 | 이지연 | |
981 | bfbc9f6c | 이지연 | if (viewPSN != null) |
982 | dd27861e | 이지연 | { |
983 | bfbc9f6c | 이지연 | lstpsn.Add(dr.Field<string>("ViewPipeSystemNetwork_OID")); |
984 | lstAll.Add(dr.Field<string>("ViewPipeSystemNetwork_OID")); |
||
985 | dd27861e | 이지연 | } |
986 | 2f7c4151 | 이지연 | } |
987 | dd27861e | 이지연 | |
988 | bfbc9f6c | 이지연 | dr["EqpGroupTag"] = EqpGroupTag; |
989 | 0eefef3d | 이지연 | |
990 | 284fa2c9 | 이지연 | } |
991 | bfbc9f6c | 이지연 | lstpsn.Remove(lstpsn[0]); |
992 | 0eefef3d | 이지연 | } |
993 | } |
||
994 | |||
995 | } |
||
996 | |||
997 | foreach(DataRow dr in PipeSystemNetwork.Rows) |
||
998 | { |
||
999 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}' AND MainLineTag = 'M'", dr["OID"].ToString())); |
||
1000 | if(pathItemRows.Count() > 0) |
||
1001 | { |
||
1002 | if(dr["Type"].ToString() == "HD2") |
||
1003 | { |
||
1004 | List<string> lstViewPipeSystemNetwork_OID = pathItemRows.Select(x => x.Field<string>("ViewPipeSystemNetwork_OID")).Distinct().ToList(); |
||
1005 | foreach(string viewpsn in lstViewPipeSystemNetwork_OID) |
||
1006 | { |
||
1007 | if (PipeSystemNetwork.Select(string.Format("OID = '{0}' AND AFC = 'P2'", viewpsn)).Count() > 0) |
||
1008 | { |
||
1009 | foreach(DataRow dataRow in pathItemRows.Where(x => x.Field<string>("ViewPipeSystemNetwork_OID") == viewpsn)) |
||
1010 | { |
||
1011 | dataRow["EGTConnectedPoint"] = "1"; |
||
1012 | } |
||
1013 | } |
||
1014 | } |
||
1015 | } |
||
1016 | else if(dr["Type"].ToString() == "E2B" || dr["Type"].ToString() == "B2E" || dr["Type"].ToString() == "E2E") |
||
1017 | { |
||
1018 | a89e25a0 | 이지연 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dr["OID"].ToString()); |
1019 | string EGFlowDirection = string.Empty; |
||
1020 | if (PSNItem.Groups.First().Items.First().Equipment != null) |
||
1021 | 0eefef3d | 이지연 | { |
1022 | a89e25a0 | 이지연 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).Count() > 0) |
1023 | { |
||
1024 | EquipmentAirFinCoolerItem equipmentAirFinCoolerItem = EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.First().Items.First().Equipment.Name.Contains(x.Name)).First(); |
||
1025 | if (equipmentAirFinCoolerItem != null) |
||
1026 | EGFlowDirection = "O"; |
||
1027 | } |
||
1028 | } |
||
1029 | 7d6d1693 | 이지연 | |
1030 | if (string.IsNullOrEmpty(EGFlowDirection) && PSNItem.Groups.Last().Items.Last().Equipment != null) |
||
1031 | a89e25a0 | 이지연 | { |
1032 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).Count() > 0) |
||
1033 | 0eefef3d | 이지연 | { |
1034 | a89e25a0 | 이지연 | EquipmentAirFinCoolerItem equipmentAirFinCoolerItem = EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && PSNItem.Groups.Last().Items.Last().Equipment.Name.Contains(x.Name)).First(); |
1035 | if(equipmentAirFinCoolerItem != null) |
||
1036 | EGFlowDirection = "I"; |
||
1037 | 0eefef3d | 이지연 | } |
1038 | } |
||
1039 | |||
1040 | a89e25a0 | 이지연 | if (!string.IsNullOrEmpty(EGFlowDirection)) |
1041 | 0eefef3d | 이지연 | { |
1042 | a89e25a0 | 이지연 | List<string> lstViewPipeSystemNetwork_OID = pathItemRows.Select(x => x.Field<string>("ViewPipeSystemNetwork_OID")).Distinct().ToList(); |
1043 | string lastP1 = string.Empty; |
||
1044 | |||
1045 | foreach (string viewpsn in lstViewPipeSystemNetwork_OID) |
||
1046 | 0eefef3d | 이지연 | { |
1047 | a89e25a0 | 이지연 | if (viewpsn == dr["OID"].ToString()) |
1048 | continue; |
||
1049 | |||
1050 | if (PipeSystemNetwork.Select(string.Format("OID = '{0}' AND AFC Like 'P1%'", viewpsn)).Length == 0) |
||
1051 | continue; |
||
1052 | |||
1053 | DataRow rows = PipeSystemNetwork.Select(string.Format("OID = '{0}' AND AFC Like 'P1%'", viewpsn)).First(); |
||
1054 | 0eefef3d | 이지연 | |
1055 | a89e25a0 | 이지연 | if (rows != null) |
1056 | 0eefef3d | 이지연 | { |
1057 | a89e25a0 | 이지연 | lastP1 = viewpsn; |
1058 | if (EGFlowDirection.Equals("I")) // To |
||
1059 | break; |
||
1060 | } |
||
1061 | 0eefef3d | 이지연 | } |
1062 | a89e25a0 | 이지연 | |
1063 | if (!string.IsNullOrEmpty(lastP1)) |
||
1064 | { |
||
1065 | bool bCheck = false; |
||
1066 | if (EGFlowDirection.Equals("O")) // From |
||
1067 | { |
||
1068 | foreach (DataRow dataRow in pathItemRows) |
||
1069 | { |
||
1070 | if (bCheck) |
||
1071 | 7d6d1693 | 이지연 | { |
1072 | a89e25a0 | 이지연 | dataRow["EqpGroupTag"] = string.Empty; |
1073 | 7d6d1693 | 이지연 | dataRow["MainLineTag"] = string.Empty; |
1074 | dataRow["EGTConnectedPoint"] = 0; |
||
1075 | dataRow["EGFlowDirection"] = string.Empty; |
||
1076 | } |
||
1077 | a89e25a0 | 이지연 | |
1078 | if (dataRow.Field<string>("ViewPipeSystemNetwork_OID").Equals(lastP1)) |
||
1079 | { |
||
1080 | bCheck = true; |
||
1081 | dataRow["EGTConnectedPoint"] = 1; |
||
1082 | } |
||
1083 | } |
||
1084 | } |
||
1085 | else |
||
1086 | { |
||
1087 | foreach (DataRow dataRow in pathItemRows) |
||
1088 | { |
||
1089 | if (dataRow.Field<string>("ViewPipeSystemNetwork_OID").Equals(lastP1)) |
||
1090 | { |
||
1091 | dataRow["EGTConnectedPoint"] = 1; |
||
1092 | break; |
||
1093 | } |
||
1094 | |||
1095 | 7d6d1693 | 이지연 | dataRow["EqpGroupTag"] = string.Empty; |
1096 | dataRow["MainLineTag"] = string.Empty; |
||
1097 | dataRow["EGTConnectedPoint"] = 0; |
||
1098 | dataRow["EGFlowDirection"] = string.Empty; |
||
1099 | |||
1100 | a89e25a0 | 이지연 | } |
1101 | } |
||
1102 | } |
||
1103 | } |
||
1104 | 0eefef3d | 이지연 | } |
1105 | bf9e8432 | 이지연 | } |
1106 | } |
||
1107 | d1afd412 | 이지연 | |
1108 | //psn data 정리 |
||
1109 | foreach(DataRow pipesystem in PipeSystemNetwork.Rows) |
||
1110 | { |
||
1111 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", pipesystem["OID"].ToString())); |
||
1112 | string EGTag = string.Empty; |
||
1113 | string HasMLTags = "False"; |
||
1114 | |||
1115 | foreach (DataRow dataRow in pathItemRows) |
||
1116 | { |
||
1117 | if (string.IsNullOrEmpty(EGTag) && !string.IsNullOrEmpty(dataRow.Field<string>("EqpGroupTag"))) |
||
1118 | EGTag = dataRow.Field<string>("EqpGroupTag"); |
||
1119 | |||
1120 | if (HasMLTags.Equals("False") && !string.IsNullOrEmpty(dataRow.Field<string>("MainLineTag")) && dataRow.Field<string>("MainLineTag").Equals("M")) |
||
1121 | HasMLTags = "True"; |
||
1122 | |||
1123 | if (!string.IsNullOrEmpty(EGTag) && HasMLTags == "True") |
||
1124 | break; |
||
1125 | } |
||
1126 | |||
1127 | pipesystem["EGTag"] = EGTag; |
||
1128 | pipesystem["HasMLTags"] = HasMLTags; |
||
1129 | } |
||
1130 | bf9e8432 | 이지연 | } |
1131 | catch (Exception ex) |
||
1132 | { |
||
1133 | MessageBox.Show(ex.Message, "ID2 ", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
1134 | } |
||
1135 | //} |
||
1136 | } |
||
1137 | 9ba9dcd2 | LJIYEON | |
1138 | 811d7949 | LJIYEON | private void UpdateValveGrouping() |
1139 | { |
||
1140 | try |
||
1141 | { |
||
1142 | #region ValveGrouping Info |
||
1143 | ValveGroupInfo ValveGrouping = new ValveGroupInfo(); |
||
1144 | DataTable dtValveGroupung = DB.SelectValveGroupItemsSetting(); |
||
1145 | foreach (DataRow row in dtValveGroupung.Rows) |
||
1146 | { |
||
1147 | ValveGrouping.ValveGroupItems.Add(new ValveGroupItem() |
||
1148 | { |
||
1149 | OID = row["OID"].ToString(), |
||
1150 | GroupType = row["GroupType"].ToString(), |
||
1151 | TagIdentifier = row["TagIdentifier"].ToString(), |
||
1152 | AttributeName = row["AttributeName"].ToString(), |
||
1153 | SppidSymbolName = row["SppidSymbolName"].ToString() |
||
1154 | }); |
||
1155 | } |
||
1156 | #endregion |
||
1157 | |||
1158 | 7106e181 | LJIYEON | |
1159 | 811d7949 | LJIYEON | int vgTagNum = 1; |
1160 | DataRow[] tagpathItemRows = PathItems.Select(string.Format("GROUPTAG Like '%\\%'")); |
||
1161 | 6805be6e | 이지연 | List<string> pathOid = new List<string>(); |
1162 | 811d7949 | LJIYEON | foreach (DataRow drPathitem in tagpathItemRows) |
1163 | { |
||
1164 | 6805be6e | 이지연 | if (pathOid.Contains(drPathitem.Field<string>("OID"))) |
1165 | continue; |
||
1166 | |||
1167 | 811d7949 | LJIYEON | string[] valvetag = drPathitem["GROUPTAG"].ToString().Split(new string[] { "\\" }, StringSplitOptions.None); |
1168 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", drPathitem["PipeSystemNetwork_OID"].ToString())); |
||
1169 | ValveGroupItem valveitem = ValveGrouping.ValveGroupItems.Where(x => x.SppidSymbolName == valvetag[0]).FirstOrDefault(); |
||
1170 | 54b6df95 | LJIYEON | if (valveitem == null || valveitem.GroupType == "Scope Break") |
1171 | 0a2fbe44 | LJIYEON | continue; |
1172 | 811d7949 | LJIYEON | Dictionary<int, List<DataRow>> keyValuePairs = new Dictionary<int, List<DataRow>>(); |
1173 | List<Item> valveGroupingItem = new List<Item>(); |
||
1174 | int bCnt = 0; |
||
1175 | |||
1176 | bfbc9f6c | 이지연 | |
1177 | 811d7949 | LJIYEON | List<DataRow> lstitem = new List<DataRow>(); |
1178 | foreach (DataRow dr in pathItemRows) |
||
1179 | { |
||
1180 | 7d6d1693 | 이지연 | if (dr["GROUPTAG"].ToString() == "Scope Break") |
1181 | { |
||
1182 | dr["GROUPTAG"] = string.Empty; |
||
1183 | keyValuePairs.Add(bCnt, lstitem.ToList()); |
||
1184 | bCnt++; |
||
1185 | lstitem.Clear(); |
||
1186 | continue; |
||
1187 | } |
||
1188 | 2327f39c | 이지연 | |
1189 | 7d6d1693 | 이지연 | |
1190 | dd27861e | 이지연 | if (!string.IsNullOrEmpty(dr["BranchTopologySet_OID"].ToString())) |
1191 | 811d7949 | LJIYEON | { |
1192 | 6805be6e | 이지연 | DataRow[] rows = TopologySet.Select(string.Format("OID = '{0}'", dr["BranchTopologySet_OID"].ToString())); |
1193 | 7d6d1693 | 이지연 | |
1194 | 6805be6e | 이지연 | if (rows.First()["SubType"].ToString() != "Bypass" && rows.First()["SubType"].ToString() != "Vent_Drain") |
1195 | { |
||
1196 | if (lstitem.ToList().Where(x => !string.IsNullOrEmpty(x.Field<string>("GROUPTAG"))).Count() > 0) |
||
1197 | dd27861e | 이지연 | { |
1198 | 6805be6e | 이지연 | lstitem.Add(dr); |
1199 | keyValuePairs.Add(bCnt, lstitem.ToList()); |
||
1200 | lstitem.Clear(); |
||
1201 | dd27861e | 이지연 | } |
1202 | else |
||
1203 | 6805be6e | 이지연 | { |
1204 | keyValuePairs.Add(bCnt, lstitem.ToList()); |
||
1205 | lstitem.Clear(); |
||
1206 | dd27861e | 이지연 | lstitem.Add(dr); |
1207 | 6805be6e | 이지연 | } |
1208 | bCnt++; |
||
1209 | |||
1210 | } |
||
1211 | else |
||
1212 | lstitem.Add(dr); |
||
1213 | 7d6d1693 | 이지연 | |
1214 | 811d7949 | LJIYEON | } |
1215 | else |
||
1216 | lstitem.Add(dr); |
||
1217 | } |
||
1218 | |||
1219 | 54b6df95 | LJIYEON | if (lstitem.Count > 0) |
1220 | 811d7949 | LJIYEON | { |
1221 | keyValuePairs.Add(bCnt, lstitem); |
||
1222 | } |
||
1223 | 9ba9dcd2 | LJIYEON | |
1224 | if (keyValuePairs.Count() == 0) |
||
1225 | continue; |
||
1226 | |||
1227 | 811d7949 | LJIYEON | string VGTag = string.Empty; |
1228 | dd27861e | 이지연 | if (valveitem.AttributeName == "NoSelection" || valveitem.AttributeName == string.Empty) |
1229 | 811d7949 | LJIYEON | { |
1230 | VGTag = valveitem.TagIdentifier + string.Format("-{0}", string.Format("{0:D5}", vgTagNum)); |
||
1231 | vgTagNum++; |
||
1232 | } |
||
1233 | else |
||
1234 | 6805be6e | 이지연 | { |
1235 | bfbc9f6c | 이지연 | VGTag = valveitem.TagIdentifier + "-" + valvetag[1]; |
1236 | 811d7949 | LJIYEON | } |
1237 | |||
1238 | foreach (KeyValuePair<int, List<DataRow>> keyValuePair in keyValuePairs) |
||
1239 | 6805be6e | 이지연 | { |
1240 | 811d7949 | LJIYEON | if (keyValuePair.Value.Where(x => x.Field<string>("OID") == drPathitem.Field<string>("OID")).Count() > 0) |
1241 | { |
||
1242 | 6805be6e | 이지연 | if (!pathOid.Contains(drPathitem.Field<string>("OID"))) |
1243 | pathOid.Add(drPathitem.Field<string>("OID")); |
||
1244 | |||
1245 | 811d7949 | LJIYEON | foreach (DataRow dr in keyValuePair.Value) |
1246 | { |
||
1247 | dr["GROUPTAG"] = VGTag; |
||
1248 | dd27861e | 이지연 | |
1249 | if(!string.IsNullOrEmpty(dr["BranchTopologySet_OID"].ToString())) |
||
1250 | { |
||
1251 | if(TopologySet.Select(string.Format("OID = '{0}'", dr["BranchTopologySet_OID"].ToString())).First().Field<string>("SubType") == "Bypass") |
||
1252 | { |
||
1253 | DataRow[] rows = keyValuePair.Value.Where(x => x.Field<string>("ViewPipeSystemNetwork_OID").Equals(dr["ViewPipeSystemNetwork_OID"].ToString())).ToArray(); |
||
1254 | foreach(DataRow path in rows) |
||
1255 | { |
||
1256 | DataRow topology = TopologySet.Select(string.Format("OID = '{0}'", path["BranchTopologySet_OID"].ToString())).First(); |
||
1257 | if (topology.Field<string>("SubType").Equals("Bypass")) |
||
1258 | { |
||
1259 | DataRow[] drPathItem = PathItems.Select(string.Format("TopologySet_OID = '{0}'", topology.Field<string>("OID"))); |
||
1260 | 6805be6e | 이지연 | //if (dr["GROUPTAG"].ToString() == "Scope Break") |
1261 | if(drPathItem.Where(x => x.Field<string>("GROUPTAG") == "Scope Break").Count() == 0) |
||
1262 | dd27861e | 이지연 | { |
1263 | 6805be6e | 이지연 | foreach (DataRow pathitem in drPathItem) |
1264 | { |
||
1265 | pathitem["GROUPTAG"] = VGTag; |
||
1266 | } |
||
1267 | dd27861e | 이지연 | } |
1268 | } |
||
1269 | } |
||
1270 | } |
||
1271 | } |
||
1272 | 811d7949 | LJIYEON | } |
1273 | } |
||
1274 | 6805be6e | 이지연 | else |
1275 | { |
||
1276 | foreach (DataRow drs in tagpathItemRows) |
||
1277 | { |
||
1278 | if (drs.Field<string>("OID").Equals(drPathitem.Field<string>("OID"))) |
||
1279 | continue; |
||
1280 | |||
1281 | if(keyValuePair.Value.Where(x => x.Field<string>("OID") == drs.Field<string>("OID")).Count() > 0) |
||
1282 | { |
||
1283 | if (!pathOid.Contains(drs.Field<string>("OID"))) |
||
1284 | { |
||
1285 | pathOid.Add(drs.Field<string>("OID")); |
||
1286 | |||
1287 | valvetag = drs["GROUPTAG"].ToString().Split(new string[] { "\\" }, StringSplitOptions.None); |
||
1288 | ValveGroupItem valveitems = ValveGrouping.ValveGroupItems.Where(x => x.SppidSymbolName == valvetag[0]).FirstOrDefault(); |
||
1289 | if (valveitems == null || valveitems.GroupType == "Scope Break") |
||
1290 | continue; |
||
1291 | |||
1292 | VGTag = string.Empty; |
||
1293 | if (valveitems.AttributeName == "NoSelection" || valveitems.AttributeName == string.Empty) |
||
1294 | { |
||
1295 | VGTag = valveitems.TagIdentifier + string.Format("-{0}", string.Format("{0:D5}", vgTagNum)); |
||
1296 | vgTagNum++; |
||
1297 | } |
||
1298 | else |
||
1299 | { |
||
1300 | VGTag = valveitems.TagIdentifier + "-" + valvetag[1]; |
||
1301 | } |
||
1302 | |||
1303 | foreach (DataRow dr in keyValuePair.Value) |
||
1304 | { |
||
1305 | dr["GROUPTAG"] = VGTag; |
||
1306 | |||
1307 | if (!string.IsNullOrEmpty(dr["BranchTopologySet_OID"].ToString())) |
||
1308 | { |
||
1309 | if (TopologySet.Select(string.Format("OID = '{0}'", dr["BranchTopologySet_OID"].ToString())).First().Field<string>("SubType") == "Bypass") |
||
1310 | { |
||
1311 | DataRow[] rows = keyValuePair.Value.Where(x => x.Field<string>("ViewPipeSystemNetwork_OID").Equals(dr["ViewPipeSystemNetwork_OID"].ToString())).ToArray(); |
||
1312 | foreach (DataRow path in rows) |
||
1313 | { |
||
1314 | DataRow topology = TopologySet.Select(string.Format("OID = '{0}'", path["BranchTopologySet_OID"].ToString())).First(); |
||
1315 | if (topology.Field<string>("SubType").Equals("Bypass")) |
||
1316 | { |
||
1317 | DataRow[] drPathItem = PathItems.Select(string.Format("TopologySet_OID = '{0}'", topology.Field<string>("OID"))); |
||
1318 | if (drPathItem.Where(x => x.Field<string>("GROUPTAG") == "Scope Break").Count() == 0) |
||
1319 | { |
||
1320 | foreach (DataRow pathitem in drPathItem) |
||
1321 | { |
||
1322 | pathitem["GROUPTAG"] = VGTag; |
||
1323 | } |
||
1324 | } |
||
1325 | } |
||
1326 | } |
||
1327 | } |
||
1328 | } |
||
1329 | } |
||
1330 | |||
1331 | if (valveitems.GroupType.Contains("PSV")) |
||
1332 | { |
||
1333 | DataRow[] psnRows = PipeSystemNetwork.Select(string.Format("OID = '{0}'", drPathitem["PipeSystemNetwork_OID"].ToString())); |
||
1334 | foreach (DataRow row in psnRows) |
||
1335 | row["Pocket"] = "Yes"; |
||
1336 | } |
||
1337 | } |
||
1338 | } |
||
1339 | } |
||
1340 | } |
||
1341 | 811d7949 | LJIYEON | } |
1342 | 6805be6e | 이지연 | |
1343 | 08b33e44 | gaqhf | if(valveitem.GroupType.Contains("PSV")) |
1344 | { |
||
1345 | DataRow[] psnRows = PipeSystemNetwork.Select(string.Format("OID = '{0}'", drPathitem["PipeSystemNetwork_OID"].ToString())); |
||
1346 | foreach (DataRow row in psnRows) |
||
1347 | row["Pocket"] = "Yes"; |
||
1348 | f2a63376 | 이지연 | } |
1349 | 811d7949 | LJIYEON | } |
1350 | 7d6d1693 | 이지연 | |
1351 | tagpathItemRows = PathItems.Select(string.Format("GROUPTAG = 'Scope Break'")); |
||
1352 | foreach (DataRow drPathitem in tagpathItemRows) |
||
1353 | { |
||
1354 | drPathitem["GROUPTAG"] = string.Empty; |
||
1355 | } |
||
1356 | 811d7949 | LJIYEON | } |
1357 | 7106e181 | LJIYEON | catch (Exception ex) |
1358 | 811d7949 | LJIYEON | { |
1359 | MessageBox.Show(ex.Message, "ID2 ", MessageBoxButtons.OK, MessageBoxIcon.Error); |
||
1360 | } |
||
1361 | 6b9e7a56 | gaqhf | } |
1362 | 7881ec8f | gaqhf | |
1363 | 6b9e7a56 | gaqhf | private void SetTopologyData() |
1364 | { |
||
1365 | 710a49f1 | gaqhf | // 13번 excel |
1366 | foreach (Group group in groups) |
||
1367 | { |
||
1368 | LineNumber prevLineNumber = null; |
||
1369 | for (int i = 0; i < group.Items.Count; i++) |
||
1370 | { |
||
1371 | Item item = group.Items[i]; |
||
1372 | LineNumber lineNumber = item.Document.LineNumbers.Find(x => x.UID == item.Owner); |
||
1373 | if (lineNumber == null) |
||
1374 | { |
||
1375 | if (prevLineNumber != null) |
||
1376 | { |
||
1377 | if (!prevLineNumber.IsCopy) |
||
1378 | { |
||
1379 | prevLineNumber = prevLineNumber.Copy(); |
||
1380 | 7d6d1693 | 이지연 | prevLineNumber.MissingLineNumber1 = true; |
1381 | 48870200 | LJIYEON | item.Document.LineNumbers.Add(prevLineNumber); |
1382 | 7d6d1693 | 이지연 | //item.LineNumber.MissingLineNumber1 = true; |
1383 | 710a49f1 | gaqhf | } |
1384 | item.Owner = prevLineNumber.UID; |
||
1385 | } |
||
1386 | } |
||
1387 | else |
||
1388 | prevLineNumber = lineNumber; |
||
1389 | } |
||
1390 | |||
1391 | prevLineNumber = null; |
||
1392 | for (int i = group.Items.Count - 1; i > -1; i--) |
||
1393 | { |
||
1394 | Item item = group.Items[i]; |
||
1395 | LineNumber lineNumber = item.Document.LineNumbers.Find(x => x.UID == item.Owner); |
||
1396 | if (lineNumber == null) |
||
1397 | { |
||
1398 | if (prevLineNumber != null) |
||
1399 | { |
||
1400 | if (!prevLineNumber.IsCopy) |
||
1401 | { |
||
1402 | prevLineNumber = prevLineNumber.Copy(); |
||
1403 | 7d6d1693 | 이지연 | prevLineNumber.MissingLineNumber1 = true; |
1404 | 710a49f1 | gaqhf | item.Document.LineNumbers.Add(prevLineNumber); |
1405 | 7d6d1693 | 이지연 | //item.LineNumber.MissingLineNumber1 = true; |
1406 | 710a49f1 | gaqhf | } |
1407 | |||
1408 | item.Owner = prevLineNumber.UID; |
||
1409 | } |
||
1410 | } |
||
1411 | else |
||
1412 | prevLineNumber = lineNumber; |
||
1413 | } |
||
1414 | |||
1415 | if (prevLineNumber == null) |
||
1416 | { |
||
1417 | List<LineNumber> lineNumbers = group.Document.LineNumbers.FindAll(x => !x.IsCopy); |
||
1418 | Random random = new Random(); |
||
1419 | a89e25a0 | 이지연 | |
1420 | LineNumber cLineNumber = null; |
||
1421 | |||
1422 | if (lineNumbers.Count == 0) |
||
1423 | { |
||
1424 | var _groups = groups.Where(w => w != group).ToList(); |
||
1425 | while (cLineNumber == null) |
||
1426 | { |
||
1427 | int _index = random.Next(_groups.Count - 1); |
||
1428 | List<LineNumber> _lineNumbers = groups[_index].Document.LineNumbers.FindAll(x => !x.IsCopy); |
||
1429 | if (_lineNumbers.Count != 0) |
||
1430 | { |
||
1431 | _index = random.Next(_lineNumbers.Count - 1); |
||
1432 | |||
1433 | // Copy |
||
1434 | cLineNumber = _lineNumbers[_index].Copy(); |
||
1435 | } |
||
1436 | } |
||
1437 | } |
||
1438 | else |
||
1439 | { |
||
1440 | int index = random.Next(lineNumbers.Count - 1); |
||
1441 | |||
1442 | // Copy |
||
1443 | cLineNumber = lineNumbers[index].Copy(); |
||
1444 | } |
||
1445 | |||
1446 | 7d6d1693 | 이지연 | cLineNumber.MissingLineNumber2 = true; |
1447 | 710a49f1 | gaqhf | group.Document.LineNumbers.Add(cLineNumber); |
1448 | 7106e181 | LJIYEON | |
1449 | 710a49f1 | gaqhf | foreach (Item item in group.Items) |
1450 | a2973aa3 | LJIYEON | { |
1451 | 7d6d1693 | 이지연 | item.Owner = cLineNumber.UID; |
1452 | 7106e181 | LJIYEON | } |
1453 | 710a49f1 | gaqhf | } |
1454 | a89e25a0 | 이지연 | |
1455 | //if (prevLineNumber == null) |
||
1456 | //{ |
||
1457 | // List<LineNumber> lineNumbers = group.Document.LineNumbers.FindAll(x => !x.IsCopy); |
||
1458 | // Random random = new Random(); |
||
1459 | // int index = random.Next(lineNumbers.Count - 1); |
||
1460 | |||
1461 | // // Copy |
||
1462 | // LineNumber cLineNumber = lineNumbers[index].Copy(); |
||
1463 | // group.Document.LineNumbers.Add(cLineNumber); |
||
1464 | |||
1465 | // foreach (Item item in group.Items) |
||
1466 | // { |
||
1467 | // item.Owner = cLineNumber.UID; |
||
1468 | // item.Document.MissingLineNumber2 = true; |
||
1469 | // } |
||
1470 | //} |
||
1471 | 710a49f1 | gaqhf | } |
1472 | |||
1473 | 6b9e7a56 | gaqhf | foreach (Document document in Documents) |
1474 | { |
||
1475 | foreach (Item item in document.Items) |
||
1476 | { |
||
1477 | item.TopologyData = string.Empty; |
||
1478 | 8f24b438 | gaqhf | item.PSNPipeLineID = string.Empty; |
1479 | 33cee849 | LJIYEON | List<string> pipeLineID = new List<string>(); |
1480 | 6b9e7a56 | gaqhf | LineNumber lineNumber = document.LineNumbers.Find(x => x.UID == item.Owner); |
1481 | 85eeb2be | 이지연 | |
1482 | 6b9e7a56 | gaqhf | if (lineNumber != null) |
1483 | { |
||
1484 | item.LineNumber = lineNumber; |
||
1485 | |||
1486 | foreach (DataRow row in topologyRuleDT.Rows) |
||
1487 | { |
||
1488 | string uid = row["UID"].ToString(); |
||
1489 | 33cee849 | LJIYEON | //if (uid == "-") |
1490 | // pipeLineID.Add(item.TopologyData);//item.TopologyData += "-"; |
||
1491 | if (uid != "-") |
||
1492 | 6b9e7a56 | gaqhf | { |
1493 | 7106e181 | LJIYEON | Attribute itemAttr = item.Attributes.Find(x => x.Name == uid); |
1494 | f25b787a | gaqhf | |
1495 | dd27861e | 이지연 | Attribute attribute = lineNumber.Attributes.Find(x => x.DisplayName == uid); |
1496 | 33cee849 | LJIYEON | if (attribute != null && !string.IsNullOrEmpty(attribute.Value)) |
1497 | 85eeb2be | 이지연 | { |
1498 | 33cee849 | LJIYEON | pipeLineID.Add(attribute.Value);//item.TopologyData += attribute.Value; |
1499 | 7d6d1693 | 이지연 | //if (uid.Equals("Tag Seq No") && attribute.Value.ToString().Substring(attribute.Value.ToString().Length - 1, 1).Equals("V")) |
1500 | //{ |
||
1501 | if (item.LineNumber.MissingLineNumber1 && item.LineNumber.MissingLineNumber2) |
||
1502 | 85eeb2be | 이지연 | { |
1503 | 7d6d1693 | 이지연 | |
1504 | 85eeb2be | 이지연 | } |
1505 | 7d6d1693 | 이지연 | |
1506 | 85eeb2be | 이지연 | } |
1507 | bd86dd48 | 이지연 | else |
1508 | { |
||
1509 | |||
1510 | } |
||
1511 | |||
1512 | 6b9e7a56 | gaqhf | } |
1513 | } |
||
1514 | 85eeb2be | 이지연 | |
1515 | 7106e181 | LJIYEON | if (topologyRuleDT.Select(string.Format("UID = '{0}'", "InsulationPurpose")) == null) |
1516 | 3210f690 | LJIYEON | { |
1517 | Attribute insulAttr = item.LineNumber.Attributes.Find(x => x.Name == "InsulationPurpose"); |
||
1518 | if (insulAttr != null && !string.IsNullOrEmpty(insulAttr.Value)) |
||
1519 | pipeLineID.Add(insulAttr.Value); //item.PSNPipeLineID = item.TopologyData + "-" + insulAttr.Value; |
||
1520 | //else |
||
1521 | // item.PSNPipeLineID = item.TopologyData; |
||
1522 | } |
||
1523 | |||
1524 | 33cee849 | LJIYEON | item.PSNPipeLineID = string.Join("-", pipeLineID); |
1525 | item.TopologyData = string.Join("-", pipeLineID); |
||
1526 | 85eeb2be | 이지연 | |
1527 | 6b9e7a56 | gaqhf | } |
1528 | 0f07fa34 | gaqhf | else |
1529 | { |
||
1530 | item.TopologyData = "Empty LineNumber"; |
||
1531 | item.LineNumber = new LineNumber(); |
||
1532 | } |
||
1533 | 6b9e7a56 | gaqhf | } |
1534 | } |
||
1535 | |||
1536 | 0f07fa34 | gaqhf | int emptyIndex = 1; |
1537 | foreach (Group group in groups) |
||
1538 | { |
||
1539 | List<Item> groupItems = group.Items.FindAll(x => x.TopologyData == "Empty LineNumber"); |
||
1540 | if (groupItems.Count > 0) |
||
1541 | { |
||
1542 | foreach (var item in groupItems) |
||
1543 | item.TopologyData += string.Format("-{0}", emptyIndex); |
||
1544 | emptyIndex++; |
||
1545 | } |
||
1546 | } |
||
1547 | 6b9e7a56 | gaqhf | |
1548 | } |
||
1549 | 7106e181 | LJIYEON | |
1550 | 6b9e7a56 | gaqhf | private void ConnectByOPC() |
1551 | { |
||
1552 | 21edb7bc | LJIYEON | try |
1553 | 6b9e7a56 | gaqhf | { |
1554 | 21edb7bc | LJIYEON | foreach (Group group in groups.FindAll(x => x.Items.Last().SubItemType == SubItemType.OPC)) |
1555 | 6b9e7a56 | gaqhf | { |
1556 | 21edb7bc | LJIYEON | Item opcItem = group.Items.Last(); |
1557 | bd86dd48 | 이지연 | if(opcDT.Select(string.Format("FromOPCUID = '{0}'", opcItem.UID)) != null) |
1558 | 21edb7bc | LJIYEON | { |
1559 | bd86dd48 | 이지연 | DataRow[] fromRows = opcDT.Select(string.Format("FromOPCUID = '{0}'", opcItem.UID)); |
1560 | if (fromRows.Length.Equals(1)) |
||
1561 | 710a49f1 | gaqhf | { |
1562 | bd86dd48 | 이지연 | DataRow opcRow = fromRows.First(); |
1563 | string toDrawing = opcRow["ToDrawing"].ToString(); |
||
1564 | string toOPCUID = opcRow["ToOPCUID"].ToString(); |
||
1565 | |||
1566 | Document toDocument = Documents.Find(x => x.DrawingName == toDrawing); |
||
1567 | if (toDocument != null) |
||
1568 | 21edb7bc | LJIYEON | { |
1569 | bd86dd48 | 이지연 | Group toGroup = toDocument.Groups.Find(x => x.Items.Find(y => y.UID == toOPCUID) != null); |
1570 | |||
1571 | if (toGroup != null && opcDT.Select(string.Format("ToOPCUID = '{0}'", toGroup.Items.First().UID)) != null) |
||
1572 | { |
||
1573 | DataRow[] toRows = opcDT.Select(string.Format("ToOPCUID = '{0}'", toGroup.Items.First().UID)); |
||
1574 | //1대1 매칭이 아닐때 걸림 (2개 이상일 때) 2021.11.07 |
||
1575 | if (toRows.Length > 1) |
||
1576 | { |
||
1577 | //throw new Exception("OPC error(multi connect)"); |
||
1578 | MessageBox.Show("OPC error(multi connect)", "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
1579 | return; |
||
1580 | } |
||
1581 | group.EndGroup = toGroup; |
||
1582 | toGroup.StartGroup = group; |
||
1583 | } |
||
1584 | |||
1585 | 21edb7bc | LJIYEON | } |
1586 | 710a49f1 | gaqhf | } |
1587 | bd86dd48 | 이지연 | } |
1588 | 6b9e7a56 | gaqhf | } |
1589 | } |
||
1590 | 21edb7bc | LJIYEON | catch (Exception ex) |
1591 | { |
||
1592 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1593 | //MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
1594 | } |
||
1595 | 6b9e7a56 | gaqhf | } |
1596 | 5e4c2ad1 | LJIYEON | |
1597 | 6b9e7a56 | gaqhf | private void SetPSNItem() |
1598 | { |
||
1599 | 7106e181 | LJIYEON | Dictionary<Group, string> groupDic = new Dictionary<Group, string>(); |
1600 | 6b9e7a56 | gaqhf | foreach (Group group in groups) |
1601 | groupDic.Add(group, Guid.NewGuid().ToString()); |
||
1602 | |||
1603 | foreach (Group group in groups) |
||
1604 | { |
||
1605 | string groupKey = groupDic[group]; |
||
1606 | if (group.StartGroup != null) |
||
1607 | { |
||
1608 | string otherKey = groupDic[group.StartGroup]; |
||
1609 | ChangeGroupID(otherKey, groupKey); |
||
1610 | } |
||
1611 | } |
||
1612 | |||
1613 | // PSN 정리 |
||
1614 | foreach (var item in groupDic) |
||
1615 | { |
||
1616 | Group group = item.Key; |
||
1617 | string uid = item.Value; |
||
1618 | PSNItem PSNItem = PSNItems.Find(x => x.UID == uid); |
||
1619 | if (PSNItem == null) |
||
1620 | { |
||
1621 | 8f24b438 | gaqhf | PSNItem = new PSNItem(PSNItems.Count, Revision) { UID = uid }; |
1622 | 6b9e7a56 | gaqhf | PSNItems.Add(PSNItem); |
1623 | } |
||
1624 | PSNItem.Groups.Add(group); |
||
1625 | 36a45f13 | gaqhf | foreach (Item groupItem in group.Items) |
1626 | groupItem.PSNItem = PSNItem; |
||
1627 | 6b9e7a56 | gaqhf | } |
1628 | |||
1629 | // Sort PSN |
||
1630 | foreach (PSNItem PSNItem in PSNItems) |
||
1631 | { |
||
1632 | List<Group> _groups = new List<Group>(); |
||
1633 | |||
1634 | Stack<Group> stacks = new Stack<Group>(); |
||
1635 | stacks.Push(PSNItem.Groups.First()); |
||
1636 | while (stacks.Count > 0) |
||
1637 | { |
||
1638 | Group stack = stacks.Pop(); |
||
1639 | if (_groups.Contains(stack)) |
||
1640 | continue; |
||
1641 | |||
1642 | if (_groups.Count == 0) |
||
1643 | _groups.Add(stack); |
||
1644 | else |
||
1645 | { |
||
1646 | if (stack.StartGroup != null && _groups.Contains(stack.StartGroup)) |
||
1647 | { |
||
1648 | int index = _groups.IndexOf(stack.StartGroup); |
||
1649 | _groups.Insert(index + 1, stack); |
||
1650 | } |
||
1651 | else if (stack.EndGroup != null && _groups.Contains(stack.EndGroup)) |
||
1652 | { |
||
1653 | int index = _groups.IndexOf(stack.EndGroup); |
||
1654 | _groups.Insert(index, stack); |
||
1655 | } |
||
1656 | } |
||
1657 | |||
1658 | if (stack.StartGroup != null) |
||
1659 | stacks.Push(stack.StartGroup); |
||
1660 | if (stack.EndGroup != null) |
||
1661 | stacks.Push(stack.EndGroup); |
||
1662 | } |
||
1663 | |||
1664 | PSNItem.Groups.Clear(); |
||
1665 | PSNItem.Groups.AddRange(_groups); |
||
1666 | } |
||
1667 | |||
1668 | void ChangeGroupID(string from, string to) |
||
1669 | { |
||
1670 | if (from.Equals(to)) |
||
1671 | return; |
||
1672 | |||
1673 | List<Group> changeItems = new List<Group>(); |
||
1674 | foreach (var _item in groupDic) |
||
1675 | if (_item.Value.Equals(from)) |
||
1676 | changeItems.Add(_item.Key); |
||
1677 | foreach (var _item in changeItems) |
||
1678 | groupDic[_item] = to; |
||
1679 | } |
||
1680 | } |
||
1681 | 5e4c2ad1 | LJIYEON | |
1682 | 6b9e7a56 | gaqhf | private void SetPSNType() |
1683 | { |
||
1684 | foreach (PSNItem PSNItem in PSNItems) |
||
1685 | { |
||
1686 | Group firstGroup = PSNItem.Groups.First(); |
||
1687 | Group lastGroup = PSNItem.Groups.Last(); |
||
1688 | |||
1689 | Item firstItem = firstGroup.Items.First(); |
||
1690 | Item lastItem = lastGroup.Items.Last(); |
||
1691 | |||
1692 | PSNItem.StartType = GetPSNType(firstItem, true); |
||
1693 | PSNItem.EndType = GetPSNType(lastItem, false); |
||
1694 | 528aa878 | 이지연 | |
1695 | 6b9e7a56 | gaqhf | } |
1696 | |||
1697 | PSNType GetPSNType(Item item, bool bFirst = true) |
||
1698 | { |
||
1699 | PSNType type = PSNType.None; |
||
1700 | |||
1701 | if (item.ItemType == ItemType.Line) |
||
1702 | { |
||
1703 | Group group = groups.Find(x => x.Items.Contains(item)); |
||
1704 | if (bFirst && item.Relations[0].Item != null && !group.Items.Contains(item.Relations[0].Item)) |
||
1705 | { |
||
1706 | Item connItem = item.Relations[0].Item; |
||
1707 | if (connItem.ItemType == ItemType.Line && !IsConnected(item, connItem)) |
||
1708 | type = PSNType.Branch; |
||
1709 | else if (connItem.ItemType == ItemType.Symbol) |
||
1710 | type = PSNType.Symbol; |
||
1711 | } |
||
1712 | else if (!bFirst && item.Relations[1].Item != null && !group.Items.Contains(item.Relations[1].Item)) |
||
1713 | { |
||
1714 | Item connItem = item.Relations[1].Item; |
||
1715 | if (connItem.ItemType == ItemType.Line && !IsConnected(item, connItem)) |
||
1716 | type = PSNType.Branch; |
||
1717 | else if (connItem.ItemType == ItemType.Symbol) |
||
1718 | type = PSNType.Symbol; |
||
1719 | } |
||
1720 | } |
||
1721 | else if (item.ItemType == ItemType.Symbol) |
||
1722 | { |
||
1723 | if (item.SubItemType == SubItemType.Nozzle) |
||
1724 | type = PSNType.Equipment; |
||
1725 | else if (item.SubItemType == SubItemType.Header) |
||
1726 | type = PSNType.Header; |
||
1727 | else if (item.SubItemType == SubItemType.OPC) |
||
1728 | type = PSNType.OPC; |
||
1729 | d6ef5842 | 이지연 | else |
1730 | { |
||
1731 | Group group = groups.Find(x => x.Items.Contains(item)); |
||
1732 | List<Item> fromItems = item.Relations.Select(w => w.Item).ToList(); |
||
1733 | foreach (var fromItem in fromItems) |
||
1734 | { |
||
1735 | if (fromItem != null) |
||
1736 | { |
||
1737 | Group _group = groups.Find(x => x.Items.Contains(fromItem)); |
||
1738 | if (_group.UID != group.UID && fromItem.ItemType == ItemType.Symbol) |
||
1739 | { |
||
1740 | type = PSNType.Branch; |
||
1741 | break; |
||
1742 | } |
||
1743 | } |
||
1744 | } |
||
1745 | } |
||
1746 | bd86dd48 | 이지연 | } |
1747 | 6b9e7a56 | gaqhf | |
1748 | return type; |
||
1749 | } |
||
1750 | } |
||
1751 | 5e4c2ad1 | LJIYEON | |
1752 | 6b9e7a56 | gaqhf | private void SetBranchInfo() |
1753 | { |
||
1754 | foreach (Document document in Documents) |
||
1755 | { |
||
1756 | List<Item> lines = document.Items.FindAll(x => x.ItemType == ItemType.Line).ToList(); |
||
1757 | foreach (Item line in lines) |
||
1758 | { |
||
1759 | double[] point = line.Relations[0].Point; |
||
1760 | List<Item> connLines = lines.FindAll(x => x.Relations.Find(y => y.UID == line.UID) != null && line.Relations.Find(y => y.UID == x.UID) == null); |
||
1761 | connLines.Sort(SortBranchLine); |
||
1762 | line.BranchItems.AddRange(connLines); |
||
1763 | |||
1764 | int SortBranchLine(Item a, Item b) |
||
1765 | { |
||
1766 | double[] pointA = a.Relations[0].UID == line.UID ? a.Relations[0].Point : a.Relations[1].Point; |
||
1767 | double distanceA = CalcPointToPointdDistance(point[0], point[1], pointA[0], pointA[1]); |
||
1768 | |||
1769 | double[] pointB = b.Relations[0].UID == line.UID ? b.Relations[0].Point : b.Relations[1].Point; |
||
1770 | double distanceB = CalcPointToPointdDistance(point[0], point[1], pointB[0], pointB[1]); |
||
1771 | |||
1772 | // 내림차순 |
||
1773 | return distanceA.CompareTo(distanceB); |
||
1774 | } |
||
1775 | double CalcPointToPointdDistance(double x1, double y1, double x2, double y2) |
||
1776 | { |
||
1777 | return Math.Pow(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2), 0.5); |
||
1778 | } |
||
1779 | } |
||
1780 | d6ef5842 | 이지연 | |
1781 | List<Item> symbols = document.Items.FindAll(x => x.ItemType == ItemType.Symbol && x.Relations.Count > 2).ToList(); |
||
1782 | foreach (var symbol in symbols) |
||
1783 | { |
||
1784 | List<Item> connLines = symbol.Relations.FindAll(x => x.Item != null && x.Item.Group != symbol.Group).Select(x => x.Item).ToList(); |
||
1785 | symbol.BranchItems.AddRange(connLines); |
||
1786 | } |
||
1787 | 6b9e7a56 | gaqhf | } |
1788 | } |
||
1789 | 5e4c2ad1 | LJIYEON | |
1790 | 6b9e7a56 | gaqhf | private void SetTopology() |
1791 | { |
||
1792 | 27d06aa8 | LJIYEON | try |
1793 | 6b9e7a56 | gaqhf | { |
1794 | 27d06aa8 | LJIYEON | #region 기본 topology 정리 |
1795 | foreach (PSNItem PSNItem in PSNItems) |
||
1796 | 6b9e7a56 | gaqhf | { |
1797 | 27d06aa8 | LJIYEON | Topology topology = null; |
1798 | foreach (Group group in PSNItem.Groups) |
||
1799 | 6b9e7a56 | gaqhf | { |
1800 | 27d06aa8 | LJIYEON | foreach (Item item in group.Items) |
1801 | 6b9e7a56 | gaqhf | { |
1802 | 27d06aa8 | LJIYEON | if (string.IsNullOrEmpty(item.TopologyData)) |
1803 | topology = null; |
||
1804 | 6b9e7a56 | gaqhf | else |
1805 | { |
||
1806 | 27d06aa8 | LJIYEON | if (topology == null) |
1807 | 6b9e7a56 | gaqhf | { |
1808 | topology = new Topology() |
||
1809 | { |
||
1810 | ID = item.TopologyData |
||
1811 | }; |
||
1812 | Topologies.Add(topology); |
||
1813 | |||
1814 | if (!PSNItem.Topologies.Contains(topology)) |
||
1815 | PSNItem.Topologies.Add(topology); |
||
1816 | } |
||
1817 | 27d06aa8 | LJIYEON | else |
1818 | { |
||
1819 | if (topology.ID != item.TopologyData) |
||
1820 | { |
||
1821 | topology = new Topology() |
||
1822 | { |
||
1823 | ID = item.TopologyData |
||
1824 | }; |
||
1825 | Topologies.Add(topology); |
||
1826 | |||
1827 | if (!PSNItem.Topologies.Contains(topology)) |
||
1828 | PSNItem.Topologies.Add(topology); |
||
1829 | } |
||
1830 | } |
||
1831 | bd86dd48 | 이지연 | if (topology == null) |
1832 | { |
||
1833 | 6b9e7a56 | gaqhf | |
1834 | bd86dd48 | 이지연 | } |
1835 | 27d06aa8 | LJIYEON | item.Topology = topology; |
1836 | topology.Items.Add(item); |
||
1837 | } |
||
1838 | 6b9e7a56 | gaqhf | } |
1839 | } |
||
1840 | bd86dd48 | 이지연 | |
1841 | 6b9e7a56 | gaqhf | } |
1842 | 27d06aa8 | LJIYEON | #endregion |
1843 | 6b9e7a56 | gaqhf | |
1844 | 27d06aa8 | LJIYEON | #region Type |
1845 | List<string> ids = Topologies.Select(x => x.ID).Distinct().ToList(); |
||
1846 | foreach (string id in ids) |
||
1847 | { |
||
1848 | try |
||
1849 | { |
||
1850 | 678760c6 | gaqhf | |
1851 | 6b9e7a56 | gaqhf | |
1852 | 27d06aa8 | LJIYEON | List<Topology> topologies = Topologies.FindAll(x => x.ID == id); |
1853 | |||
1854 | // Main |
||
1855 | List<Topology> mainTopologies = FindMainTopology(topologies); |
||
1856 | foreach (Topology topology in mainTopologies) |
||
1857 | topology.Type = "M"; |
||
1858 | |||
1859 | // Branch |
||
1860 | List<Topology> branchToplogies = topologies.FindAll(x => string.IsNullOrEmpty(x.Type)); |
||
1861 | foreach (Topology topology in branchToplogies) |
||
1862 | topology.Type = "B"; |
||
1863 | } |
||
1864 | catch (Exception ex) |
||
1865 | { |
||
1866 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1867 | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
1868 | } |
||
1869 | } |
||
1870 | #endregion |
||
1871 | } |
||
1872 | catch (Exception ex) |
||
1873 | { |
||
1874 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1875 | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
1876 | 6b9e7a56 | gaqhf | } |
1877 | 27d06aa8 | LJIYEON | |
1878 | 6b9e7a56 | gaqhf | } |
1879 | 5e4c2ad1 | LJIYEON | |
1880 | 7881ec8f | gaqhf | private void SetTopologyIndex() |
1881 | { |
||
1882 | List<string> ids = Topologies.Select(x => x.ID).Distinct().ToList(); |
||
1883 | foreach (string id in ids) |
||
1884 | { |
||
1885 | List<Topology> topologies = Topologies.FindAll(x => x.ID == id); |
||
1886 | |||
1887 | // Main |
||
1888 | List<Topology> mainTopologies = topologies.FindAll(x => x.Type == "M"); |
||
1889 | foreach (Topology topology in mainTopologies) |
||
1890 | topology.Index = mainTopologies.IndexOf(topology).ToString(); |
||
1891 | |||
1892 | // Branch |
||
1893 | List<Topology> branchToplogies = topologies.FindAll(x => x.Type == "B"); |
||
1894 | foreach (Topology topology in branchToplogies) |
||
1895 | topology.Index = (branchToplogies.IndexOf(topology) + 1).ToString(); |
||
1896 | } |
||
1897 | } |
||
1898 | 5e4c2ad1 | LJIYEON | |
1899 | 7881ec8f | gaqhf | private void SetPSNBypass() |
1900 | { |
||
1901 | foreach (PSNItem PSNItem in PSNItems) |
||
1902 | PSNItem.IsBypass = IsBypass(PSNItem); |
||
1903 | } |
||
1904 | 5e4c2ad1 | LJIYEON | |
1905 | 6b9e7a56 | gaqhf | private List<Topology> FindMainTopology(List<Topology> data) |
1906 | { |
||
1907 | 678760c6 | gaqhf | DataTable nominalDiameterDT = DB.SelectNominalDiameter(); |
1908 | DataTable PMCDT = DB.SelectPSNPIPINGMATLCLASS(); |
||
1909 | a36541fb | LJIYEON | //2021.11.17 안쓰네 JY |
1910 | //DataTable fluidCodeDT = DB.SelectPSNFluidCode(); |
||
1911 | 678760c6 | gaqhf | |
1912 | List<Topology> main = new List<Topology>(); |
||
1913 | main.AddRange(data); |
||
1914 | 6b9e7a56 | gaqhf | // |
1915 | 678760c6 | gaqhf | main = GetNozzleTopology(data); |
1916 | if (main.Count == 1) |
||
1917 | return main; |
||
1918 | else |
||
1919 | { |
||
1920 | if (main.Count > 0) |
||
1921 | main = GetPMCTopology(main); |
||
1922 | else |
||
1923 | main = GetPMCTopology(data); |
||
1924 | |||
1925 | if (main.Count == 1) |
||
1926 | return main; |
||
1927 | else |
||
1928 | { |
||
1929 | if (main.Count > 0) |
||
1930 | main = GetDiaTopology(main); |
||
1931 | else |
||
1932 | main = GetDiaTopology(data); |
||
1933 | |||
1934 | |||
1935 | if (main.Count == 1) |
||
1936 | return main; |
||
1937 | else |
||
1938 | { |
||
1939 | if (main.Count > 0) |
||
1940 | main = GetItemTopology(main); |
||
1941 | else |
||
1942 | main = GetItemTopology(data); |
||
1943 | } |
||
1944 | } |
||
1945 | } |
||
1946 | |||
1947 | List<Topology> GetNozzleTopology(List<Topology> topologies) |
||
1948 | { |
||
1949 | return topologies.FindAll(x => x.Items.Find(y => y.SubItemType == SubItemType.Nozzle) != null); |
||
1950 | } |
||
1951 | 6b9e7a56 | gaqhf | |
1952 | 678760c6 | gaqhf | List<Topology> GetPMCTopology(List<Topology> topologies) |
1953 | { |
||
1954 | List<Topology> result = new List<Topology>(); |
||
1955 | foreach (DataRow row in PMCDT.Rows) |
||
1956 | { |
||
1957 | string value = row["CODE"].ToString(); |
||
1958 | foreach (Topology topology in topologies) |
||
1959 | { |
||
1960 | foreach (Item item in topology.Items) |
||
1961 | { |
||
1962 | if (item.LineNumber == null) |
||
1963 | continue; |
||
1964 | 0f07fa34 | gaqhf | Attribute attribute = item.LineNumber.Attributes.Find(x => x.Name == "PipingMaterialsClass"); |
1965 | if (attribute != null && value == attribute.Value) |
||
1966 | 678760c6 | gaqhf | { |
1967 | result.Add(topology); |
||
1968 | break; |
||
1969 | } |
||
1970 | } |
||
1971 | } |
||
1972 | |||
1973 | if (result.Count > 0) |
||
1974 | break; |
||
1975 | } |
||
1976 | |||
1977 | return result; |
||
1978 | } |
||
1979 | |||
1980 | List<Topology> GetDiaTopology(List<Topology> topologies) |
||
1981 | { |
||
1982 | List<Topology> result = new List<Topology>(); |
||
1983 | foreach (DataRow row in nominalDiameterDT.Rows) |
||
1984 | { |
||
1985 | string inchValue = row["InchStr"].ToString(); |
||
1986 | string metricValue = row["MetricStr"].ToString(); |
||
1987 | foreach (Topology topology in topologies) |
||
1988 | { |
||
1989 | foreach (Item item in topology.Items) |
||
1990 | { |
||
1991 | if (item.LineNumber == null) |
||
1992 | continue; |
||
1993 | 0f07fa34 | gaqhf | Attribute attribute = item.LineNumber.Attributes.Find(x => x.Name == "NominalDiameter"); |
1994 | if (attribute != null && (inchValue == attribute.Value || metricValue == attribute.Value)) |
||
1995 | 678760c6 | gaqhf | { |
1996 | result.Add(topology); |
||
1997 | break; |
||
1998 | } |
||
1999 | } |
||
2000 | } |
||
2001 | |||
2002 | if (result.Count > 0) |
||
2003 | break; |
||
2004 | } |
||
2005 | |||
2006 | return result; |
||
2007 | } |
||
2008 | |||
2009 | List<Topology> GetItemTopology(List<Topology> topologies) |
||
2010 | { |
||
2011 | return new List<Topology>() { topologies.OrderByDescending(x => x.Items.Count).ToList().First() }; |
||
2012 | } |
||
2013 | 6b9e7a56 | gaqhf | |
2014 | 678760c6 | gaqhf | return main; |
2015 | 6b9e7a56 | gaqhf | } |
2016 | |||
2017 | private DataTable GetOPCInfo() |
||
2018 | { |
||
2019 | DataTable opc = DB.SelectOPCRelations(); |
||
2020 | ec1cc293 | LJIYEON | DataTable drawing = DB.AllDrawings(); |
2021 | 6b9e7a56 | gaqhf | |
2022 | DataTable dt = new DataTable(); |
||
2023 | dt.Columns.Add("FromDrawing", typeof(string)); |
||
2024 | dt.Columns.Add("FromDrawingUID", typeof(string)); |
||
2025 | dt.Columns.Add("FromOPCUID", typeof(string)); |
||
2026 | dt.Columns.Add("ToDrawing", typeof(string)); |
||
2027 | dt.Columns.Add("ToDrawingUID", typeof(string)); |
||
2028 | dt.Columns.Add("ToOPCUID", typeof(string)); |
||
2029 | foreach (DataRow row in opc.Rows) |
||
2030 | { |
||
2031 | string fromDrawingUID = row["From_Drawings_UID"] == null ? string.Empty : row["From_Drawings_UID"].ToString(); |
||
2032 | 7106e181 | LJIYEON | string fromOPCUID = row["From_OPC_UID"] == null ? string.Empty : row["From_OPC_UID"].ToString(); |
2033 | string toDrawingUID = row["To_Drawings_UID"] == null ? string.Empty : row["To_Drawings_UID"].ToString(); |
||
2034 | 6b9e7a56 | gaqhf | string toOPCUID = row["To_OPC_UID"] == null ? string.Empty : row["To_OPC_UID"].ToString(); |
2035 | if (!string.IsNullOrEmpty(toOPCUID)) |
||
2036 | { |
||
2037 | DataRow[] fromRows = drawing.Select(string.Format("UID = '{0}'", fromDrawingUID)); |
||
2038 | DataRow[] toRows = drawing.Select(string.Format("UID = '{0}'", toDrawingUID)); |
||
2039 | if (fromRows.Length.Equals(1) && toRows.Length.Equals(1)) |
||
2040 | { |
||
2041 | string fromDrawingName = Path.GetFileNameWithoutExtension(fromRows.First()["NAME"].ToString()); |
||
2042 | string toDrawingName = Path.GetFileNameWithoutExtension(toRows.First()["NAME"].ToString()); |
||
2043 | |||
2044 | DataRow newRow = dt.NewRow(); |
||
2045 | newRow["FromDrawing"] = fromDrawingName; |
||
2046 | newRow["FromDrawingUID"] = fromDrawingUID; |
||
2047 | newRow["FromOPCUID"] = fromOPCUID; |
||
2048 | newRow["ToDrawing"] = toDrawingName; |
||
2049 | newRow["ToDrawingUID"] = toDrawingUID; |
||
2050 | newRow["ToOPCUID"] = toOPCUID; |
||
2051 | |||
2052 | dt.Rows.Add(newRow); |
||
2053 | } |
||
2054 | } |
||
2055 | } |
||
2056 | |||
2057 | return dt; |
||
2058 | } |
||
2059 | 5e4c2ad1 | LJIYEON | |
2060 | 6b9e7a56 | gaqhf | private DataTable GetTopologyRule() |
2061 | { |
||
2062 | DataTable dt = DB.SelectTopologyRule(); |
||
2063 | |||
2064 | return dt; |
||
2065 | } |
||
2066 | 5e4c2ad1 | LJIYEON | |
2067 | 6b9e7a56 | gaqhf | private bool IsConnected(Item item1, Item item2) |
2068 | { |
||
2069 | if (item1.Relations.Find(x => x.UID.Equals(item2.UID)) != null && |
||
2070 | item2.Relations.Find(x => x.UID.Equals(item1.UID)) != null) |
||
2071 | return true; |
||
2072 | else |
||
2073 | return false; |
||
2074 | } |
||
2075 | |||
2076 | private void SaveNozzleAndEquipment() |
||
2077 | { |
||
2078 | bd86dd48 | 이지연 | Dictionary<string, int> globalNozzleCount = new Dictionary<string, int>(); |
2079 | |||
2080 | 6b9e7a56 | gaqhf | List<Item> nozzles = new List<Item>(); |
2081 | List<Equipment> equipments = new List<Equipment>(); |
||
2082 | foreach (Document document in Documents) |
||
2083 | { |
||
2084 | nozzles.AddRange(document.Items.FindAll(x => x.SubItemType == SubItemType.Nozzle)); |
||
2085 | equipments.AddRange(document.Equipments); |
||
2086 | } |
||
2087 | 7106e181 | LJIYEON | |
2088 | bd86dd48 | 이지연 | DataTable equipDT = new DataTable(); |
2089 | equipDT.Columns.Add("OID", typeof(string)); |
||
2090 | equipDT.Columns.Add("ITEMTAG", typeof(string)); |
||
2091 | equipDT.Columns.Add("XCOORDS", typeof(string)); |
||
2092 | equipDT.Columns.Add("YCOORDS", typeof(string)); |
||
2093 | |||
2094 | foreach (Equipment equipment in equipments) |
||
2095 | { |
||
2096 | DataRow row = equipDT.NewRow(); |
||
2097 | row["OID"] = equipment.UID; |
||
2098 | if (!string.IsNullOrEmpty(EquipTagNoAttributeName)) |
||
2099 | { |
||
2100 | Attribute attribute = equipment.Attributes.Find(x => x.Name == EquipTagNoAttributeName); |
||
2101 | if (attribute != null && attribute.Value != "None") |
||
2102 | equipment.ItemTag = attribute.Value; |
||
2103 | else |
||
2104 | { |
||
2105 | equipment.ItemTag = equipment.Name; |
||
2106 | } |
||
2107 | } |
||
2108 | else |
||
2109 | equipment.ItemTag = equipment.Name; |
||
2110 | |||
2111 | if (!string.IsNullOrEmpty(equipment.ItemTag)) |
||
2112 | { |
||
2113 | if (!globalNozzleCount.ContainsKey(equipment.ItemTag)) |
||
2114 | { |
||
2115 | globalNozzleCount[equipment.ItemTag] = 0; |
||
2116 | } |
||
2117 | } |
||
2118 | |||
2119 | row["ITEMTAG"] = equipment.ItemTag; |
||
2120 | List<double> xList = equipment.POINT.Select(x => x[0]).ToList(); |
||
2121 | row["XCOORDS"] = (xList.Sum() / (double)xList.Count) / DrawingWidth; |
||
2122 | |||
2123 | List<double> yList = equipment.POINT.Select(x => x[1]).ToList(); |
||
2124 | row["YCOORDS"] = (yList.Sum() / (double)yList.Count) / DrawingHeight; |
||
2125 | |||
2126 | equipDT.Rows.Add(row); |
||
2127 | } |
||
2128 | 6b9e7a56 | gaqhf | |
2129 | DataTable nozzleDT = new DataTable(); |
||
2130 | nozzleDT.Columns.Add("OID", typeof(string)); |
||
2131 | nozzleDT.Columns.Add("ITEMTAG", typeof(string)); |
||
2132 | nozzleDT.Columns.Add("XCOORDS", typeof(string)); |
||
2133 | nozzleDT.Columns.Add("YCOORDS", typeof(string)); |
||
2134 | nozzleDT.Columns.Add("Equipment_OID", typeof(string)); |
||
2135 | nozzleDT.Columns.Add("FLUID", typeof(string)); |
||
2136 | nozzleDT.Columns.Add("NPD", typeof(string)); |
||
2137 | 33cee849 | LJIYEON | nozzleDT.Columns.Add("PMC", typeof(string)); |
2138 | 6b9e7a56 | gaqhf | nozzleDT.Columns.Add("ROTATION", typeof(string)); |
2139 | nozzleDT.Columns.Add("FlowDirection", typeof(string)); |
||
2140 | |||
2141 | foreach (Item item in nozzles) |
||
2142 | { |
||
2143 | DataRow row = nozzleDT.NewRow(); |
||
2144 | row["OID"] = item.UID; |
||
2145 | |||
2146 | Relation relation = item.Relations.Find(x => equipments.Find(y => y.UID == x.UID) != null); |
||
2147 | if (relation != null) |
||
2148 | { |
||
2149 | Equipment equipment = equipments.Find(x => x.UID == relation.UID); |
||
2150 | equipment.Nozzles.Add(item); |
||
2151 | bd86dd48 | 이지연 | //row["ITEMTAG"] = string.Format("N{0}", string.Format("{0:D3}", equipment.Nozzles.Count + 100)); |
2152 | |||
2153 | int nozzleCount = equipment.Nozzles.Count; |
||
2154 | if (globalNozzleCount.ContainsKey(equipment.ItemTag)) |
||
2155 | { |
||
2156 | nozzleCount = globalNozzleCount[equipment.ItemTag]; |
||
2157 | } |
||
2158 | row["ITEMTAG"] = string.Format("N{0}", string.Format("{0:D3}", nozzleCount + 100)); |
||
2159 | if (globalNozzleCount.ContainsKey(equipment.ItemTag)) |
||
2160 | { |
||
2161 | globalNozzleCount[equipment.ItemTag] += 1; |
||
2162 | } |
||
2163 | |||
2164 | 7106e181 | LJIYEON | row["Equipment_OID"] = equipment.UID; |
2165 | 4c76a67a | gaqhf | item.Equipment = equipment; |
2166 | 6b9e7a56 | gaqhf | } |
2167 | 8f24b438 | gaqhf | row["XCOORDS"] = (item.POINT[0] / DrawingWidth).ToString(); |
2168 | row["YCOORDS"] = (item.POINT[1] / DrawingHeight).ToString(); |
||
2169 | 6b9e7a56 | gaqhf | Attribute fluidAttr = item.LineNumber.Attributes.Find(x => x.Name == "FluidCode"); |
2170 | row["FLUID"] = fluidAttr != null ? fluidAttr.Value : string.Empty; |
||
2171 | Attribute npdAttr = item.LineNumber.Attributes.Find(x => x.Name == "NominalDiameter"); |
||
2172 | row["NPD"] = npdAttr != null ? npdAttr.Value : string.Empty; |
||
2173 | 33cee849 | LJIYEON | Attribute pmcAttr = item.LineNumber.Attributes.Find(x => x.Name == "PipingMaterialsClass"); |
2174 | row["PMC"] = pmcAttr != null ? pmcAttr.Value : string.Empty; |
||
2175 | f25b787a | gaqhf | |
2176 | double angle = Math.PI * 2 - Convert.ToDouble(item.ANGLE); |
||
2177 | if (angle >= Math.PI * 2) |
||
2178 | angle = angle - Math.PI * 2; |
||
2179 | row["ROTATION"] = angle.ToString(); |
||
2180 | 6b9e7a56 | gaqhf | |
2181 | if (item.Topology.Items.First().Equals(item)) |
||
2182 | row["FlowDirection"] = "Outlet"; |
||
2183 | else if (item.Topology.Items.Last().Equals(item)) |
||
2184 | row["FlowDirection"] = "Inlet"; |
||
2185 | else |
||
2186 | row["FlowDirection"] = string.Empty; |
||
2187 | |||
2188 | nozzleDT.Rows.Add(row); |
||
2189 | } |
||
2190 | |||
2191 | bd86dd48 | 이지연 | //DataTable equipDT = new DataTable(); |
2192 | //equipDT.Columns.Add("OID", typeof(string)); |
||
2193 | //equipDT.Columns.Add("ITEMTAG", typeof(string)); |
||
2194 | //equipDT.Columns.Add("XCOORDS", typeof(string)); |
||
2195 | //equipDT.Columns.Add("YCOORDS", typeof(string)); |
||
2196 | |||
2197 | //foreach (Equipment equipment in equipments) |
||
2198 | //{ |
||
2199 | // DataRow row = equipDT.NewRow(); |
||
2200 | // row["OID"] = equipment.UID; |
||
2201 | // if (!string.IsNullOrEmpty(EquipTagNoAttributeName)) |
||
2202 | // { |
||
2203 | // Attribute attribute = equipment.Attributes.Find(x => x.Name == EquipTagNoAttributeName); |
||
2204 | // if (attribute != null) |
||
2205 | // equipment.ItemTag = attribute.Value; |
||
2206 | // } |
||
2207 | // else |
||
2208 | // equipment.ItemTag = equipment.Name; |
||
2209 | |||
2210 | // row["ITEMTAG"] = equipment.ItemTag; |
||
2211 | // List<double> xList = equipment.POINT.Select(x => x[0]).ToList(); |
||
2212 | // row["XCOORDS"] = (xList.Sum() / (double)xList.Count) / DrawingWidth; |
||
2213 | |||
2214 | // List<double> yList = equipment.POINT.Select(x => x[1]).ToList(); |
||
2215 | // row["YCOORDS"] = (yList.Sum() / (double)yList.Count) / DrawingHeight; |
||
2216 | |||
2217 | // equipDT.Rows.Add(row); |
||
2218 | //} |
||
2219 | 6b9e7a56 | gaqhf | |
2220 | Equipment = equipDT; |
||
2221 | Nozzle = nozzleDT; |
||
2222 | } |
||
2223 | 5e4c2ad1 | LJIYEON | |
2224 | 6b9e7a56 | gaqhf | private void SavePSNData() |
2225 | { |
||
2226 | 2c46461b | LJIYEON | try |
2227 | 36a45f13 | gaqhf | { |
2228 | 2c46461b | LJIYEON | DataTable pathItemsDT = new DataTable(); |
2229 | pathItemsDT.Columns.Add("OID", typeof(string)); |
||
2230 | pathItemsDT.Columns.Add("SequenceData_OID", typeof(string)); |
||
2231 | pathItemsDT.Columns.Add("TopologySet_OID", typeof(string)); |
||
2232 | pathItemsDT.Columns.Add("BranchTopologySet_OID", typeof(string)); |
||
2233 | pathItemsDT.Columns.Add("PipeLine_OID", typeof(string)); |
||
2234 | pathItemsDT.Columns.Add("ITEMNAME", typeof(string)); |
||
2235 | pathItemsDT.Columns.Add("ITEMTAG", typeof(string)); |
||
2236 | 7106e181 | LJIYEON | pathItemsDT.Columns.Add("DESCRIPTION", typeof(string)); |
2237 | 2c46461b | LJIYEON | pathItemsDT.Columns.Add("Class", typeof(string)); |
2238 | pathItemsDT.Columns.Add("SubClass", typeof(string)); |
||
2239 | pathItemsDT.Columns.Add("TYPE", typeof(string)); |
||
2240 | d6ef5842 | 이지연 | pathItemsDT.Columns.Add("MULTIWAY", typeof(string)); |
2241 | 2c46461b | LJIYEON | pathItemsDT.Columns.Add("PIDNAME", typeof(string)); |
2242 | a36541fb | LJIYEON | pathItemsDT.Columns.Add("Equipment_OID", typeof(string)); |
2243 | 2c46461b | LJIYEON | pathItemsDT.Columns.Add("NPD", typeof(string)); |
2244 | 811d7949 | LJIYEON | pathItemsDT.Columns.Add("GROUPTAG", typeof(string)); |
2245 | 2c46461b | LJIYEON | pathItemsDT.Columns.Add("PipeSystemNetwork_OID", typeof(string)); |
2246 | pathItemsDT.Columns.Add("ViewPipeSystemNetwork_OID", typeof(string)); |
||
2247 | pathItemsDT.Columns.Add("PipeRun_OID", typeof(string)); |
||
2248 | bf9e8432 | 이지연 | pathItemsDT.Columns.Add("EqpGroupTag", typeof(string)); |
2249 | pathItemsDT.Columns.Add("MainLineTag", typeof(string)); |
||
2250 | pathItemsDT.Columns.Add("EGTConnectedPoint", typeof(string)); |
||
2251 | pathItemsDT.Columns.Add("EGFlowDirection", typeof(string)); |
||
2252 | 2c46461b | LJIYEON | |
2253 | DataTable sequenceDataDT = new DataTable(); |
||
2254 | sequenceDataDT.Columns.Add("OID", typeof(string)); |
||
2255 | sequenceDataDT.Columns.Add("SERIALNUMBER", typeof(string)); |
||
2256 | sequenceDataDT.Columns.Add("PathItem_OID", typeof(string)); |
||
2257 | sequenceDataDT.Columns.Add("TopologySet_OID_Key", typeof(string)); |
||
2258 | |||
2259 | DataTable pipeSystemNetworkDT = new DataTable(); |
||
2260 | pipeSystemNetworkDT.Columns.Add("OID", typeof(string)); |
||
2261 | pipeSystemNetworkDT.Columns.Add("Type", typeof(string)); |
||
2262 | pipeSystemNetworkDT.Columns.Add("OrderNumber", typeof(string)); |
||
2263 | pipeSystemNetworkDT.Columns.Add("Pipeline_OID", typeof(string)); |
||
2264 | pipeSystemNetworkDT.Columns.Add("FROM_DATA", typeof(string)); |
||
2265 | pipeSystemNetworkDT.Columns.Add("TO_DATA", typeof(string)); |
||
2266 | pipeSystemNetworkDT.Columns.Add("TopologySet_OID_Key", typeof(string)); |
||
2267 | pipeSystemNetworkDT.Columns.Add("PSNRevisionNumber", typeof(string)); |
||
2268 | pipeSystemNetworkDT.Columns.Add("PBS", typeof(string)); |
||
2269 | 72775f2e | LJIYEON | pipeSystemNetworkDT.Columns.Add("Drawings", typeof(string)); |
2270 | pipeSystemNetworkDT.Columns.Add("IsValid", typeof(string)); |
||
2271 | 2c46461b | LJIYEON | pipeSystemNetworkDT.Columns.Add("Status", typeof(string)); |
2272 | ddc1c369 | LJIYEON | pipeSystemNetworkDT.Columns.Add("IncludingVirtualData", typeof(string)); |
2273 | pipeSystemNetworkDT.Columns.Add("PSNAccuracy", typeof(string)); |
||
2274 | 08b33e44 | gaqhf | pipeSystemNetworkDT.Columns.Add("Pocket", typeof(string)); |
2275 | d1afd412 | 이지연 | pipeSystemNetworkDT.Columns.Add("EGTag", typeof(string)); |
2276 | pipeSystemNetworkDT.Columns.Add("HasMLTags", typeof(string)); |
||
2277 | 4842b66a | 이지연 | pipeSystemNetworkDT.Columns.Add("GroundLevel", typeof(string)); |
2278 | 0eefef3d | 이지연 | pipeSystemNetworkDT.Columns.Add("AFC", typeof(string)); |
2279 | d1afd412 | 이지연 | pipeSystemNetworkDT.Columns.Add("PUMP", typeof(string)); |
2280 | 2c46461b | LJIYEON | |
2281 | DataTable topologySetDT = new DataTable(); |
||
2282 | topologySetDT.Columns.Add("OID", typeof(string)); |
||
2283 | topologySetDT.Columns.Add("Type", typeof(string)); |
||
2284 | topologySetDT.Columns.Add("SubType", typeof(string)); |
||
2285 | topologySetDT.Columns.Add("HeadItemTag", typeof(string)); |
||
2286 | topologySetDT.Columns.Add("TailItemTag", typeof(string)); |
||
2287 | 72775f2e | LJIYEON | topologySetDT.Columns.Add("HeadItemSPID", typeof(string)); |
2288 | topologySetDT.Columns.Add("TailItemSPID", typeof(string)); |
||
2289 | 2c46461b | LJIYEON | |
2290 | f9f2787b | LJIYEON | DataTable pipelineDT = new DataTable(); |
2291 | pipelineDT.Columns.Add("OID", typeof(string)); |
||
2292 | pipelineDT.Columns.Add("PipeSystem_OID", typeof(string)); |
||
2293 | pipelineDT.Columns.Add("FLUID", typeof(string)); |
||
2294 | pipelineDT.Columns.Add("PMC", typeof(string)); |
||
2295 | pipelineDT.Columns.Add("SEQNUMBER", typeof(string)); |
||
2296 | pipelineDT.Columns.Add("INSULATION", typeof(string)); |
||
2297 | pipelineDT.Columns.Add("FROM_DATA", typeof(string)); |
||
2298 | pipelineDT.Columns.Add("TO_DATA", typeof(string)); |
||
2299 | pipelineDT.Columns.Add("Unit", typeof(string)); |
||
2300 | |||
2301 | 531fb158 | LJIYEON | DataTable pipesystemDT = new DataTable(); |
2302 | pipesystemDT.Columns.Add("OID", typeof(string)); |
||
2303 | pipesystemDT.Columns.Add("DESCRIPTION", typeof(string)); |
||
2304 | pipesystemDT.Columns.Add("FLUID", typeof(string)); |
||
2305 | pipesystemDT.Columns.Add("PMC", typeof(string)); |
||
2306 | pipesystemDT.Columns.Add("PipeLineQty", typeof(string)); |
||
2307 | pipesystemDT.Columns.Add("GroundLevel", typeof(string)); |
||
2308 | |||
2309 | 879ce10b | LJIYEON | // Set Vent/Drain Info |
2310 | 2c46461b | LJIYEON | List<VentDrainInfo> VentDrainInfos = new List<VentDrainInfo>(); |
2311 | DataTable dt = DB.SelectVentDrainSetting(); |
||
2312 | foreach (DataRow row in dt.Rows) |
||
2313 | 36a45f13 | gaqhf | { |
2314 | 2c46461b | LJIYEON | string groupID = row["GROUP_ID"].ToString(); |
2315 | string desc = row["DESCRIPTION"].ToString(); |
||
2316 | int index = Convert.ToInt32(row["INDEX"]); |
||
2317 | string name = row["NAME"].ToString(); |
||
2318 | 36a45f13 | gaqhf | |
2319 | 2c46461b | LJIYEON | VentDrainInfo ventDrainInfo = VentDrainInfos.Find(x => x.UID.Equals(groupID)); |
2320 | if (ventDrainInfo == null) |
||
2321 | 36a45f13 | gaqhf | { |
2322 | 2c46461b | LJIYEON | ventDrainInfo = new VentDrainInfo(groupID); |
2323 | ventDrainInfo.Description = desc; |
||
2324 | VentDrainInfos.Add(ventDrainInfo); |
||
2325 | 36a45f13 | gaqhf | } |
2326 | |||
2327 | 2c46461b | LJIYEON | ventDrainInfo.VentDrainItems.Add(new VentDrainItem() |
2328 | { |
||
2329 | Index = index, |
||
2330 | Name = name |
||
2331 | }); |
||
2332 | } |
||
2333 | 51974d2b | LJIYEON | foreach (VentDrainInfo ventDrainInfo in VentDrainInfos) |
2334 | ventDrainInfo.VentDrainItems = ventDrainInfo.VentDrainItems.OrderBy(x => x.Index).ToList(); |
||
2335 | 2c46461b | LJIYEON | |
2336 | 879ce10b | LJIYEON | #region Keyword Info |
2337 | eb44d82c | LJIYEON | KeywordInfo KeywordInfos = new KeywordInfo(); |
2338 | 879ce10b | LJIYEON | DataTable dtKeyword = DB.SelectKeywordsSetting(); |
2339 | foreach (DataRow row in dtKeyword.Rows) |
||
2340 | { |
||
2341 | int index = Convert.ToInt32(row["INDEX"]); |
||
2342 | string name = row["NAME"].ToString(); |
||
2343 | string keyword = row["KEYWORD"].ToString(); |
||
2344 | |||
2345 | eb44d82c | LJIYEON | //KeywordInfo keywordInfo = new KeywordInfo(); |
2346 | KeywordInfos.KeywordItems.Add(new KeywordItem() |
||
2347 | 879ce10b | LJIYEON | { |
2348 | Index = index, |
||
2349 | Name = name, |
||
2350 | Keyword = keyword |
||
2351 | }); |
||
2352 | 811d7949 | LJIYEON | } |
2353 | #endregion |
||
2354 | |||
2355 | #region ValveGrouping Info |
||
2356 | ValveGroupInfo ValveGrouping = new ValveGroupInfo(); |
||
2357 | DataTable dtValveGroupung = DB.SelectValveGroupItemsSetting(); |
||
2358 | foreach (DataRow row in dtValveGroupung.Rows) |
||
2359 | { |
||
2360 | ValveGrouping.ValveGroupItems.Add(new ValveGroupItem() |
||
2361 | { |
||
2362 | OID = row["OID"].ToString(), |
||
2363 | GroupType = row["GroupType"].ToString(), |
||
2364 | TagIdentifier = row["TagIdentifier"].ToString(), |
||
2365 | AttributeName = row["AttributeName"].ToString(), |
||
2366 | SppidSymbolName = row["SppidSymbolName"].ToString() |
||
2367 | }); |
||
2368 | } |
||
2369 | 879ce10b | LJIYEON | #endregion |
2370 | |||
2371 | 08b33e44 | gaqhf | #region EquipmentNoPocket Info |
2372 | EquipmentNoPocketInfo EquipmentNoPocket = new EquipmentNoPocketInfo(); |
||
2373 | DataTable dtEquipmentNoPocket = DB.SelectEquipmentNoPocketSetting(); |
||
2374 | foreach (DataRow row in dtEquipmentNoPocket.Rows) |
||
2375 | { |
||
2376 | EquipmentNoPocket.EquipmentNoPocketItem.Add(new EquipmentNoPocketItem() |
||
2377 | { |
||
2378 | Index = Convert.ToInt32(row["INDEX"]), |
||
2379 | Type = row["TYPE"].ToString(), |
||
2380 | Name = row["NAME"].ToString() |
||
2381 | }); |
||
2382 | } |
||
2383 | #endregion |
||
2384 | |||
2385 | 0eefef3d | 이지연 | #region EquipmentAirFinCooler Info |
2386 | EquipmentAirFinCoolerInfo EquipmentAirFinCooler = new EquipmentAirFinCoolerInfo(); |
||
2387 | DataTable dtEquipmentAirFinCooler = DB.SelectAirFinCoolerSetting(); |
||
2388 | foreach (DataRow row in dtEquipmentAirFinCooler.Rows) |
||
2389 | { |
||
2390 | EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Add(new EquipmentAirFinCoolerItem() |
||
2391 | { |
||
2392 | Type = row["Type"].ToString(), |
||
2393 | Name = row["Name"].ToString() |
||
2394 | }); |
||
2395 | } |
||
2396 | #endregion |
||
2397 | |||
2398 | 2c46461b | LJIYEON | // key = 미입력 branch |
2399 | Dictionary<Item, Item> startBranchDic = new Dictionary<Item, Item>(); |
||
2400 | Dictionary<Item, Item> endBranchDic = new Dictionary<Item, Item>(); |
||
2401 | 531fb158 | LJIYEON | DataTable PSNFluidDT = DB.SelectPSNFluidCode(); |
2402 | DataTable PSNPMCDT = DB.SelectPSNPIPINGMATLCLASS(); |
||
2403 | 2c46461b | LJIYEON | foreach (PSNItem PSNItem in PSNItems) |
2404 | { |
||
2405 | 3210f690 | LJIYEON | try |
2406 | 36a45f13 | gaqhf | { |
2407 | 3210f690 | LJIYEON | int psnOrder = 0; |
2408 | int index = 0; |
||
2409 | bool bPSNStart = true; |
||
2410 | string sPSNData = string.Empty; |
||
2411 | bool bVentDrain = false; |
||
2412 | 7106e181 | LJIYEON | |
2413 | 23204ef6 | 이지연 | List<Group> Groups = PSNItem.Groups; |
2414 | 811d7949 | LJIYEON | Dictionary<string, List<Item>> keyValuePairs = new Dictionary<string, List<Item>>(); |
2415 | 7106e181 | LJIYEON | List<Item> valveGroupingItem = new List<Item>(); |
2416 | |||
2417 | 3210f690 | LJIYEON | //VentDrain 검사 |
2418 | if (PSNItem.Groups.Count.Equals(1)) |
||
2419 | 36a45f13 | gaqhf | { |
2420 | 7106e181 | LJIYEON | List<VentDrainInfo> endInfos = new List<VentDrainInfo>(); |
2421 | for (int g = 0; g < Groups.Count; g++) |
||
2422 | 2c46461b | LJIYEON | { |
2423 | 51974d2b | LJIYEON | Group group = Groups[g]; |
2424 | 7d6d1693 | 이지연 | |
2425 | foreach (VentDrainInfo ventDrainInfo in VentDrainInfos) |
||
2426 | 2c46461b | LJIYEON | { |
2427 | 7d6d1693 | 이지연 | if(!bVentDrain) |
2428 | 27d06aa8 | LJIYEON | { |
2429 | 7d6d1693 | 이지연 | for (int i = 0; i < group.Items.Count; i++) |
2430 | 3210f690 | LJIYEON | { |
2431 | 7d6d1693 | 이지연 | Item item = group.Items[i]; |
2432 | if (ventDrainInfo.VentDrainItems[endInfos.Count()].Name.Equals(item.Name)) |
||
2433 | endInfos.Add(ventDrainInfo); |
||
2434 | else |
||
2435 | { |
||
2436 | endInfos.Clear(); |
||
2437 | if (ventDrainInfo.VentDrainItems[endInfos.Count()].Name.Equals(item.Name)) |
||
2438 | endInfos.Add(ventDrainInfo); |
||
2439 | } |
||
2440 | 6b9e7a56 | gaqhf | |
2441 | 7d6d1693 | 이지연 | if (ventDrainInfo.VentDrainItems.Count().Equals(endInfos.Count())) |
2442 | { |
||
2443 | bVentDrain = true; |
||
2444 | break; |
||
2445 | } |
||
2446 | 3210f690 | LJIYEON | } |
2447 | 7d6d1693 | 이지연 | } |
2448 | } |
||
2449 | 51974d2b | LJIYEON | |
2450 | if (!bVentDrain) |
||
2451 | { |
||
2452 | endInfos = new List<VentDrainInfo>(); |
||
2453 | 7d6d1693 | 이지연 | |
2454 | foreach (VentDrainInfo ventDrainInfo in VentDrainInfos) |
||
2455 | 51974d2b | LJIYEON | { |
2456 | 7d6d1693 | 이지연 | if (!bVentDrain) |
2457 | 51974d2b | LJIYEON | { |
2458 | 7d6d1693 | 이지연 | for (int i = 0; i < group.Items.Count; i++) |
2459 | 51974d2b | LJIYEON | { |
2460 | 7d6d1693 | 이지연 | Item item = group.Items[group.Items.Count - i - 1]; |
2461 | 51974d2b | LJIYEON | |
2462 | 7d6d1693 | 이지연 | if (ventDrainInfo.VentDrainItems[endInfos.Count()].Name.Equals(item.Name)) |
2463 | endInfos.Add(ventDrainInfo); |
||
2464 | else |
||
2465 | { |
||
2466 | endInfos.Clear(); |
||
2467 | if (ventDrainInfo.VentDrainItems[endInfos.Count()].Name.Equals(item.Name)) |
||
2468 | endInfos.Add(ventDrainInfo); |
||
2469 | } |
||
2470 | |||
2471 | if (ventDrainInfo.VentDrainItems.Count().Equals(endInfos.Count())) |
||
2472 | { |
||
2473 | bVentDrain = true; |
||
2474 | break; |
||
2475 | } |
||
2476 | 51974d2b | LJIYEON | } |
2477 | } |
||
2478 | } |
||
2479 | 27d06aa8 | LJIYEON | } |
2480 | 3210f690 | LJIYEON | } |
2481 | } |
||
2482 | 7106e181 | LJIYEON | |
2483 | a5616391 | LJIYEON | try |
2484 | 7106e181 | LJIYEON | { |
2485 | a5616391 | LJIYEON | foreach (Group group in PSNItem.Groups) |
2486 | 7106e181 | LJIYEON | { |
2487 | a5616391 | LJIYEON | foreach (Item item in group.Items) |
2488 | 7106e181 | LJIYEON | { |
2489 | 811d7949 | LJIYEON | string VgTag = string.Empty; |
2490 | 0eefef3d | 이지연 | |
2491 | 7106e181 | LJIYEON | if (ValveGrouping.ValveGroupItems.Where(x => x.SppidSymbolName == item.Name).Count() > 0) |
2492 | 811d7949 | LJIYEON | { |
2493 | ValveGroupItem valveitem = ValveGrouping.ValveGroupItems.Where(x => x.SppidSymbolName == item.Name).First(); |
||
2494 | 7106e181 | LJIYEON | string value = string.Empty; |
2495 | |||
2496 | dd27861e | 이지연 | if (valveitem.GroupType == "Scope Break" || valveitem.AttributeName == "NoSelection" || valveitem.AttributeName == string.Empty) |
2497 | 54b6df95 | LJIYEON | value = "NoSelection"; |
2498 | else |
||
2499 | dd27861e | 이지연 | { |
2500 | if(item.Attributes.Find(x => x.Name == valveitem.AttributeName) == null) |
||
2501 | value = "NoSelection"; |
||
2502 | else |
||
2503 | value = item.Attributes.Find(x => x.Name == valveitem.AttributeName).Value; |
||
2504 | } |
||
2505 | 54b6df95 | LJIYEON | |
2506 | if (valveitem.GroupType == "Scope Break") |
||
2507 | VgTag = "Scope Break"; |
||
2508 | else |
||
2509 | VgTag = valveitem.SppidSymbolName + "\\" + value; |
||
2510 | 7106e181 | LJIYEON | |
2511 | 811d7949 | LJIYEON | } |
2512 | |||
2513 | a5616391 | LJIYEON | string PathitemUID = string.Empty; |
2514 | if (item.BranchItems.Count == 0) |
||
2515 | a36541fb | LJIYEON | { |
2516 | a5616391 | LJIYEON | PathitemUID = item.UID; |
2517 | 811d7949 | LJIYEON | CreatePathItemsDataRow(PathitemUID, item.ID2DBType, VgTag); |
2518 | a5616391 | LJIYEON | CreateSequenceDataDataRow(PathitemUID); |
2519 | index++; |
||
2520 | } |
||
2521 | else |
||
2522 | { |
||
2523 | d6ef5842 | 이지연 | if (item.ItemType == ItemType.Line) |
2524 | 3210f690 | LJIYEON | { |
2525 | d6ef5842 | 이지연 | PathitemUID = item.UID + "_L1"; |
2526 | CreatePathItemsDataRow(PathitemUID, item.ID2DBType, VgTag); |
||
2527 | CreateSequenceDataDataRow(PathitemUID); |
||
2528 | 3210f690 | LJIYEON | index++; |
2529 | d6ef5842 | 이지연 | for (int i = 0; i < item.BranchItems.Count; i++) |
2530 | { |
||
2531 | CreatePathItemsDataRow(string.Format(item.UID + "_B{0}", i + 1), "Branch", string.Empty, item.BranchItems[i].Topology.FullName, item.BranchItems[i]); |
||
2532 | CreateSequenceDataDataRow(string.Format(item.UID + "_B{0}", i + 1)); |
||
2533 | index++; |
||
2534 | |||
2535 | CreatePathItemsDataRow(string.Format(item.UID + "_L{0}", i + 2), item.ID2DBType); |
||
2536 | CreateSequenceDataDataRow(string.Format(item.UID + "_L{0}", i + 2)); |
||
2537 | index++; |
||
2538 | |||
2539 | if (item.BranchItems[i].Relations[0].Item != null && item.BranchItems[i].Relations[0].Item == item) |
||
2540 | startBranchDic.Add(item.BranchItems[i], item); |
||
2541 | else if (item.BranchItems[i].Relations[1].Item != null && item.BranchItems[i].Relations[1].Item == item) |
||
2542 | endBranchDic.Add(item.BranchItems[i], item); |
||
2543 | } |
||
2544 | } |
||
2545 | else |
||
2546 | { |
||
2547 | PathitemUID = item.UID + "_M1"; |
||
2548 | |||
2549 | dicMultiwaySymbolUID.Add(item.UID, 1); // 에러나면 이상한거임 |
||
2550 | 7106e181 | LJIYEON | |
2551 | d6ef5842 | 이지연 | CreatePathItemsDataRow(PathitemUID, item.ID2DBType, multiwaysymbol: true); |
2552 | CreateSequenceDataDataRow(PathitemUID); |
||
2553 | a5616391 | LJIYEON | index++; |
2554 | a36541fb | LJIYEON | |
2555 | d6ef5842 | 이지연 | for (int i = 0; i < item.BranchItems.Count; i++) |
2556 | { |
||
2557 | if (item.BranchItems[i].ItemType == ItemType.Line) |
||
2558 | { |
||
2559 | if (item.BranchItems[i].Relations[0].Item != null && item.BranchItems[i].Relations[0].Item == item) |
||
2560 | startBranchDic.Add(item.BranchItems[i], item); |
||
2561 | else if (item.BranchItems[i].Relations[1].Item != null && item.BranchItems[i].Relations[1].Item == item) |
||
2562 | endBranchDic.Add(item.BranchItems[i], item); |
||
2563 | } |
||
2564 | else if (item.BranchItems[i].ItemType == ItemType.Symbol) |
||
2565 | { |
||
2566 | Group _group = groups.Find(x => x.Items.Select(w => w.UID).Contains(item.BranchItems[i].UID)); |
||
2567 | if (_group != null) //심볼로 끝났을 경우 그룹이없어서 생성 |
||
2568 | { |
||
2569 | if (_group.Items.First() == item.BranchItems[i]) |
||
2570 | startBranchDic.Add(item.BranchItems[i], item); |
||
2571 | else if (_group.Items.Last() == item.BranchItems[i]) |
||
2572 | endBranchDic.Add(item.BranchItems[i], item); |
||
2573 | } |
||
2574 | else |
||
2575 | { |
||
2576 | Log.Write("Error Item : " + item.BranchItems[i].UID); |
||
2577 | } |
||
2578 | } |
||
2579 | } |
||
2580 | a5616391 | LJIYEON | } |
2581 | } |
||
2582 | 7106e181 | LJIYEON | |
2583 | a5616391 | LJIYEON | if (bPSNStart) |
2584 | 7106e181 | LJIYEON | { |
2585 | a5616391 | LJIYEON | CreatePipeSystemNetworkDataRow(); |
2586 | 7106e181 | LJIYEON | sPSNData = item.TopologyData; |
2587 | a5616391 | LJIYEON | psnOrder++; |
2588 | bPSNStart = false; |
||
2589 | } |
||
2590 | else |
||
2591 | { |
||
2592 | if (item.TopologyData != sPSNData) |
||
2593 | 3210f690 | LJIYEON | { |
2594 | CreatePipeSystemNetworkDataRow(); |
||
2595 | sPSNData = item.TopologyData; |
||
2596 | psnOrder++; |
||
2597 | } |
||
2598 | a5616391 | LJIYEON | } |
2599 | 7106e181 | LJIYEON | |
2600 | d6ef5842 | 이지연 | void CreatePathItemsDataRow(string itemOID, string itemType, string GROUPTAG = "", string branchTopologyName = "", Item branchItem = null, bool multiwaysymbol = false) |
2601 | a5616391 | LJIYEON | { |
2602 | DataRow newRow = pathItemsDT.NewRow(); |
||
2603 | |||
2604 | if (itemType == "Nozzles") |
||
2605 | 3210f690 | LJIYEON | { |
2606 | 485040d4 | esham21 | newRow["Equipment_OID"] = item.Equipment != null ? item.Equipment.UID : ""; |
2607 | 3210f690 | LJIYEON | } |
2608 | 7106e181 | LJIYEON | |
2609 | bd86dd48 | 이지연 | //string topologyFullName = |
2610 | |||
2611 | a5616391 | LJIYEON | newRow["OID"] = itemOID; |
2612 | newRow["SequenceData_OID"] = string.Format(item.Topology.FullName + "_{0}", index); |
||
2613 | newRow["TopologySet_OID"] = item.Topology.FullName; |
||
2614 | newRow["BranchTopologySet_OID"] = branchTopologyName; |
||
2615 | newRow["PipeLine_OID"] = item.PSNPipeLineID; |
||
2616 | bd86dd48 | 이지연 | |
2617 | d6ef5842 | 이지연 | if(multiwaysymbol) |
2618 | { |
||
2619 | if (!dicMultiwaySymbolNameTag.ContainsKey(item.Name)) |
||
2620 | { |
||
2621 | dicMultiwaySymbolNameTag.Add(item.Name, 1); |
||
2622 | |||
2623 | } |
||
2624 | |||
2625 | newRow["MULTIWAY"] = string.Format("M_" + item.Name + "_{0:D3}", dicMultiwaySymbolNameTag[item.Name]); |
||
2626 | dicMultiwaySymbolNameTag[item.Name] = dicMultiwaySymbolNameTag[item.Name] + 1; |
||
2627 | } |
||
2628 | |||
2629 | |||
2630 | ecdd26cc | 이지연 | if (item.Name.ToUpper().Equals("TIEINPOINT")) |
2631 | { |
||
2632 | bd86dd48 | 이지연 | newRow["ITEMNAME"] = "PipingComp"; |
2633 | ecdd26cc | 이지연 | |
2634 | string value = string.Empty; |
||
2635 | if (string.IsNullOrEmpty(TieInPointAttributeName)) |
||
2636 | value = string.Format("TIEINPOINT_{0:D3}", tieInPointSymbolIndex); |
||
2637 | bd86dd48 | 이지연 | else |
2638 | ecdd26cc | 이지연 | value = item.Attributes.Find(x => x.Name == TieInPointAttributeName).Value; |
2639 | |||
2640 | |||
2641 | newRow["ITEMTAG"] = value; |
||
2642 | newRow["DESCRIPTION"] = value; |
||
2643 | bd86dd48 | 이지연 | newRow["Class"] = "In-Line Fitting"; |
2644 | newRow["SubClass"] = ""; |
||
2645 | newRow["TYPE"] = "End"; |
||
2646 | tieInPointSymbolIndex++; |
||
2647 | } |
||
2648 | else |
||
2649 | { |
||
2650 | newRow["ITEMNAME"] = GetItemName(item, itemOID); |
||
2651 | newRow["ITEMTAG"] = GetItemTag(item); |
||
2652 | newRow["Class"] = GetClass(item, itemOID); |
||
2653 | string subClass = GetSubClass(item, itemOID); |
||
2654 | newRow["SubClass"] = subClass; |
||
2655 | |||
2656 | if (item.ItemType == ItemType.Symbol) |
||
2657 | newRow["TYPE"] = item.ID2DBName; |
||
2658 | else if (item.ItemType == ItemType.Line) |
||
2659 | newRow["TYPE"] = item.ID2DBType; |
||
2660 | } |
||
2661 | |||
2662 | |||
2663 | |||
2664 | a5616391 | LJIYEON | newRow["PIDNAME"] = group.Document.DrawingName; |
2665 | |||
2666 | // NPD |
||
2667 | if (item.LineNumber != null) |
||
2668 | { |
||
2669 | Attribute attribute = item.LineNumber.Attributes.Find(x => x.Name == "NominalDiameter"); |
||
2670 | if (attribute != null) |
||
2671 | newRow["NPD"] = attribute.Value; |
||
2672 | } |
||
2673 | else |
||
2674 | newRow["NPD"] = null; |
||
2675 | 7881ec8f | gaqhf | |
2676 | 811d7949 | LJIYEON | newRow["GROUPTAG"] = GROUPTAG; |
2677 | a5616391 | LJIYEON | newRow["PipeSystemNetwork_OID"] = PSNItem.PSN_OID(); |
2678 | if (branchItem == null) |
||
2679 | newRow["ViewPipeSystemNetwork_OID"] = PSNItem.PSN_OID(); |
||
2680 | else |
||
2681 | newRow["ViewPipeSystemNetwork_OID"] = branchItem.PSNItem.PSN_OID(); |
||
2682 | 27d06aa8 | LJIYEON | |
2683 | a5616391 | LJIYEON | newRow["PipeRun_OID"] = item.LineNumber != null ? item.LineNumber.Name : string.Empty; |
2684 | 0eefef3d | 이지연 | newRow["EGTConnectedPoint"] = 0; |
2685 | a5616391 | LJIYEON | pathItemsDT.Rows.Add(newRow); |
2686 | 7106e181 | LJIYEON | } |
2687 | 0eefef3d | 이지연 | |
2688 | |||
2689 | a5616391 | LJIYEON | void CreateSequenceDataDataRow(string itemOID) |
2690 | { |
||
2691 | DataRow newRow = sequenceDataDT.NewRow(); |
||
2692 | newRow["OID"] = string.Format(item.Topology.FullName + "_{0}", index); |
||
2693 | newRow["SERIALNUMBER"] = string.Format("{0}", index); |
||
2694 | newRow["PathItem_OID"] = itemOID; |
||
2695 | newRow["TopologySet_OID_Key"] = item.Topology.FullName; |
||
2696 | 839708c6 | LJIYEON | |
2697 | a5616391 | LJIYEON | sequenceDataDT.Rows.Add(newRow); |
2698 | } |
||
2699 | 0eefef3d | 이지연 | |
2700 | a5616391 | LJIYEON | void CreatePipeSystemNetworkDataRow() |
2701 | 7106e181 | LJIYEON | { |
2702 | a5616391 | LJIYEON | LineNumber lineNumber = item.Document.LineNumbers.Find(x => x.UID == item.Owner); |
2703 | 08b33e44 | gaqhf | string FluidCode = string.Empty; |
2704 | 4842b66a | 이지연 | string GroundLevel = string.Empty; |
2705 | a5616391 | LJIYEON | if (lineNumber != null) |
2706 | 3210f690 | LJIYEON | { |
2707 | a5616391 | LJIYEON | List<Attribute> att = lineNumber.Attributes; |
2708 | if (att != null) |
||
2709 | 3210f690 | LJIYEON | { |
2710 | a5616391 | LJIYEON | List<string> oid = new List<string>(); |
2711 | 08b33e44 | gaqhf | FluidCode = att.Where(x => x.Name.ToUpper().Equals("FLUIDCODE")).FirstOrDefault() != null ? att.Where(x => x.Name.ToUpper().Equals("FLUIDCODE")).FirstOrDefault().Value : string.Empty; |
2712 | a5616391 | LJIYEON | string PMC = lineNumber.Attributes.Where(x => x.Name.ToUpper().Equals("PIPINGMATERIALSCLASS")).FirstOrDefault() != null ? lineNumber.Attributes.Where(x => x.Name.ToUpper().Equals("PIPINGMATERIALSCLASS")).FirstOrDefault().Value : string.Empty; |
2713 | string SEQNUMBER = lineNumber.Attributes.Where(x => x.Name.ToUpper().Equals("TAG SEQ NO")).FirstOrDefault() != null ? lineNumber.Attributes.Where(x => x.Name.ToUpper().Equals("TAG SEQ NO")).FirstOrDefault().Value : string.Empty; |
||
2714 | string INSULATION = lineNumber.Attributes.Where(x => x.Name.ToUpper().Equals("INSULATIONPURPOSE")).FirstOrDefault() != null ? lineNumber.Attributes.Where(x => x.Name.ToUpper().Equals("INSULATIONPURPOSE")).FirstOrDefault().Value : string.Empty; |
||
2715 | //InsulationPurpose |
||
2716 | if (!string.IsNullOrEmpty(FluidCode)) oid.Add(FluidCode); |
||
2717 | if (!string.IsNullOrEmpty(PMC)) oid.Add(PMC); |
||
2718 | |||
2719 | string PipeSystem_OID = string.Join("-", oid); |
||
2720 | |||
2721 | if (!string.IsNullOrEmpty(SEQNUMBER)) oid.Add(SEQNUMBER); |
||
2722 | if (!string.IsNullOrEmpty(INSULATION)) oid.Add(INSULATION); |
||
2723 | |||
2724 | string OID = string.Join("-", oid); |
||
2725 | 531fb158 | LJIYEON | string FluidCodeGL = string.Empty; |
2726 | string PMCGL = string.Empty; |
||
2727 | 7106e181 | LJIYEON | |
2728 | a5616391 | LJIYEON | if (pipelineDT.Select(string.Format("OID = '{0}'", OID)).Count() == 0) |
2729 | { |
||
2730 | DataRow newPipelineRow = pipelineDT.NewRow(); |
||
2731 | newPipelineRow["OID"] = OID; |
||
2732 | newPipelineRow["PipeSystem_OID"] = PipeSystem_OID; |
||
2733 | newPipelineRow["FLUID"] = FluidCode; |
||
2734 | newPipelineRow["PMC"] = PMC; |
||
2735 | newPipelineRow["SEQNUMBER"] = SEQNUMBER; |
||
2736 | newPipelineRow["INSULATION"] = INSULATION; |
||
2737 | newPipelineRow["FROM_DATA"] = string.Empty; |
||
2738 | newPipelineRow["TO_DATA"] = string.Empty; |
||
2739 | newPipelineRow["Unit"] = PSNItem.GetPBSData(); |
||
2740 | 7106e181 | LJIYEON | pipelineDT.Rows.Add(newPipelineRow); |
2741 | 531fb158 | LJIYEON | } |
2742 | |||
2743 | if (pipesystemDT.Select(string.Format("OID = '{0}'", PipeSystem_OID)).Count() == 0) |
||
2744 | { |
||
2745 | 54b6df95 | LJIYEON | DataRow newPipesystemRow = pipesystemDT.NewRow(); |
2746 | newPipesystemRow["OID"] = PipeSystem_OID; |
||
2747 | newPipesystemRow["DESCRIPTION"] = string.Empty; |
||
2748 | newPipesystemRow["FLUID"] = FluidCode; |
||
2749 | newPipesystemRow["PMC"] = PMC; |
||
2750 | newPipesystemRow["PipeLineQty"] = string.Empty; |
||
2751 | 4842b66a | 이지연 | |
2752 | 54b6df95 | LJIYEON | if (!string.IsNullOrEmpty(FluidCode) && !string.IsNullOrEmpty(PMC)) |
2753 | { |
||
2754 | FluidCodeGL = PSNFluidDT.Select(string.Format("Code = '{0}'", FluidCode)).FirstOrDefault().Field<string>("GroundLevel"); |
||
2755 | PMCGL = PSNPMCDT.Select(string.Format("Code= '{0}'", PMC)).FirstOrDefault().Field<string>("GroundLevel"); |
||
2756 | if (FluidCodeGL == "AG" && PMCGL == "AG") |
||
2757 | GroundLevel = "AG"; |
||
2758 | else if (FluidCodeGL == "UG" && PMCGL == "UG") |
||
2759 | GroundLevel = "UG"; |
||
2760 | else |
||
2761 | GroundLevel = "AG_UG"; |
||
2762 | } |
||
2763 | newPipesystemRow["GroundLevel"] = GroundLevel; |
||
2764 | pipesystemDT.Rows.Add(newPipesystemRow); |
||
2765 | 3210f690 | LJIYEON | } |
2766 | 4842b66a | 이지연 | else |
2767 | { |
||
2768 | GroundLevel = pipesystemDT.Select(string.Format("OID = '{0}'", PipeSystem_OID)).First().Field<string>("GroundLevel"); |
||
2769 | } |
||
2770 | 3210f690 | LJIYEON | } |
2771 | a5616391 | LJIYEON | } |
2772 | 3210f690 | LJIYEON | |
2773 | a5616391 | LJIYEON | DataRow newRow = pipeSystemNetworkDT.NewRow(); |
2774 | newRow["OID"] = PSNItem.PSN_OID(); |
||
2775 | 7106e181 | LJIYEON | |
2776 | a5616391 | LJIYEON | newRow["OrderNumber"] = psnOrder; |
2777 | newRow["Pipeline_OID"] = item.PSNPipeLineID; |
||
2778 | PSNItem.KeywordInfos = KeywordInfos; |
||
2779 | PSNItem.Nozzle = Nozzle; |
||
2780 | 7106e181 | LJIYEON | |
2781 | a5616391 | LJIYEON | string FromType = string.Empty; |
2782 | Item From_item = new Item(); |
||
2783 | 7106e181 | LJIYEON | |
2784 | 23204ef6 | 이지연 | string oStatus = string.Empty; |
2785 | string FROM_DATA = PSNItem.GetFromData(ref FromType, ref From_item, item, ref oStatus); |
||
2786 | 51974d2b | LJIYEON | string status = string.Empty; |
2787 | 23204ef6 | 이지연 | if (psnOrder == 0) |
2788 | status = PSNItem.Status; |
||
2789 | 51974d2b | LJIYEON | |
2790 | a5616391 | LJIYEON | if (PSNItem.IsKeyword) |
2791 | { |
||
2792 | e552da48 | LJIYEON | PSNItem.StartType = PSNType.Equipment; |
2793 | a5616391 | LJIYEON | } |
2794 | string ToType = string.Empty; |
||
2795 | Item To_item = new Item(); |
||
2796 | 23204ef6 | 이지연 | string TO_DATA = PSNItem.GetToData(ref ToType, ref To_item, item); |
2797 | a5616391 | LJIYEON | if (PSNItem.IsKeyword) |
2798 | { |
||
2799 | e552da48 | LJIYEON | PSNItem.EndType = PSNType.Equipment; |
2800 | a5616391 | LJIYEON | } |
2801 | 7d6d1693 | 이지연 | |
2802 | e552da48 | LJIYEON | newRow["FROM_DATA"] = FROM_DATA; |
2803 | 7106e181 | LJIYEON | newRow["TO_DATA"] = TO_DATA; |
2804 | 7d6d1693 | 이지연 | |
2805 | a5616391 | LJIYEON | newRow["Type"] = PSNItem.GetPSNType(); |
2806 | e552da48 | LJIYEON | |
2807 | 23204ef6 | 이지연 | if (psnOrder == 0) //order 0일땐 그냥 붙여줌 |
2808 | 7d6d1693 | 이지연 | { |
2809 | a653883a | 이지연 | status += oStatus + PSNItem.Status; |
2810 | 7d6d1693 | 이지연 | } |
2811 | else if (psnOrder > 0) //0보다 크면 |
||
2812 | e552da48 | LJIYEON | { |
2813 | 7106e181 | LJIYEON | DataRow dr = pipeSystemNetworkDT.Select(string.Format("OID = '{0}' AND OrderNumber = {1}", PSNItem.PSN_OID(), psnOrder - 1)).FirstOrDefault(); |
2814 | 23204ef6 | 이지연 | |
2815 | if (psnOrder >= 1) |
||
2816 | e552da48 | LJIYEON | { |
2817 | a653883a | 이지연 | if (!string.IsNullOrEmpty(PSNItem.Status)) |
2818 | 23204ef6 | 이지연 | { |
2819 | a653883a | 이지연 | if (dr["Status"].ToString().Contains(PSNItem.Status)) |
2820 | { |
||
2821 | dr["Status"] = dr["Status"].ToString().Replace(PSNItem.Status, string.Empty); |
||
2822 | } |
||
2823 | else |
||
2824 | { |
||
2825 | dr["Status"] = dr["Status"].ToString().Replace(PSNItem.Status.Remove(0, 2), string.Empty); |
||
2826 | } |
||
2827 | 23204ef6 | 이지연 | } |
2828 | } |
||
2829 | |||
2830 | status = oStatus + PSNItem.Status; |
||
2831 | 6805be6e | 이지연 | if (dr != null) |
2832 | { |
||
2833 | newRow["FROM_DATA"] = dr.Field<string>("FROM_DATA"); |
||
2834 | newRow["TO_DATA"] = dr.Field<string>("TO_DATA"); |
||
2835 | newRow["Type"] = dr.Field<string>("Type"); |
||
2836 | } |
||
2837 | 23204ef6 | 이지연 | } |
2838 | 7d6d1693 | 이지연 | |
2839 | 48870200 | LJIYEON | status = !string.IsNullOrEmpty(status) ? status.Remove(0, 2) : string.Empty; |
2840 | 7d6d1693 | 이지연 | string[] st = status.Split(new string[] { ", " }, StringSplitOptions.None); |
2841 | if (st.Count() > 1) |
||
2842 | 48870200 | LJIYEON | { |
2843 | 7d6d1693 | 이지연 | status = string.Join(", ", st.Distinct()); |
2844 | 48870200 | LJIYEON | } |
2845 | newRow["Status"] = status; |
||
2846 | 23204ef6 | 이지연 | newRow["IsValid"] = PSNItem.IsValid; |
2847 | |||
2848 | newRow["TopologySet_OID_Key"] = item.Topology.FullName; |
||
2849 | newRow["PSNRevisionNumber"] = string.Format("V{0:D4}", Revision); |
||
2850 | a5616391 | LJIYEON | newRow["PBS"] = PSNItem.GetPBSData(); |
2851 | 7106e181 | LJIYEON | |
2852 | a5616391 | LJIYEON | List<string> drawingNames = new List<string>(); |
2853 | foreach (Group _group in PSNItem.Groups) |
||
2854 | { |
||
2855 | if (!drawingNames.Contains(_group.Document.DrawingName)) |
||
2856 | 3210f690 | LJIYEON | { |
2857 | a5616391 | LJIYEON | if (drawingNames.Count == 0) |
2858 | newRow["Drawings"] = _group.Document.DrawingName; |
||
2859 | else |
||
2860 | newRow["Drawings"] = newRow["Drawings"] + ", " + _group.Document.DrawingName; |
||
2861 | drawingNames.Add(_group.Document.DrawingName); |
||
2862 | 3210f690 | LJIYEON | } |
2863 | 27d06aa8 | LJIYEON | } |
2864 | 419055fa | LJIYEON | |
2865 | // VentDrain의 경우 제외 요청 (데이터를 아예 제거하였을 경우 후 가공에서 문제가 생김 마지막에 지우는것으로 변경) |
||
2866 | if (bVentDrain) |
||
2867 | newRow["IncludingVirtualData"] = "Vent_Drain"; |
||
2868 | else |
||
2869 | newRow["IncludingVirtualData"] = "No"; |
||
2870 | 23204ef6 | 이지연 | |
2871 | a5616391 | LJIYEON | newRow["PSNAccuracy"] = "100"; |
2872 | 08b33e44 | gaqhf | |
2873 | string Pocket = "No"; |
||
2874 | string Condition = PSNFluidDT.Select(string.Format("Code = '{0}'", FluidCode)).FirstOrDefault().Field<string>("Condition"); |
||
2875 | if (Condition.Equals("Flare")) |
||
2876 | Pocket = "Yes"; |
||
2877 | |||
2878 | 485040d4 | esham21 | if (item.ID2DBType == "Nozzles" && PSNItem.StartType == PSNType.Equipment && From_item.Equipment != null) |
2879 | 08b33e44 | gaqhf | { |
2880 | 23204ef6 | 이지연 | Equipment Equipment = From_item.Equipment; |
2881 | 91c75c0b | 이지연 | EquipmentNoPocketItem nopocket = EquipmentNoPocket.EquipmentNoPocketItem.Where(x => x.Name == Equipment.Name && x.Type != "Pump").FirstOrDefault(); |
2882 | |||
2883 | if (nopocket != null) |
||
2884 | 08b33e44 | gaqhf | { |
2885 | 91c75c0b | 이지연 | DataRow bNozzle = null; |
2886 | if (nopocket.Type.Equals("Vertical Vessel")) |
||
2887 | { |
||
2888 | DataRow drNozzle = Nozzle.Select(string.Format("Equipment_OID = '{0}' AND OID = '{1}'", Equipment.UID, From_item.UID)).FirstOrDefault(); |
||
2889 | if (drNozzle != null) |
||
2890 | { |
||
2891 | if (drNozzle.Field<string>("Rotation").Length >= 4 && drNozzle.Field<string>("Rotation").Substring(0, 4) == "4.71") |
||
2892 | { |
||
2893 | bNozzle = drNozzle; |
||
2894 | } |
||
2895 | |||
2896 | if (bNozzle == null) |
||
2897 | { |
||
2898 | DataRow[] nozzleRows = Nozzle.Select(string.Format("Equipment_OID = '{0}'", Equipment.UID)); |
||
2899 | |||
2900 | if (drNozzle != null) |
||
2901 | { |
||
2902 | bNozzle = drNozzle; |
||
2903 | foreach (DataRow it in nozzleRows) |
||
2904 | { |
||
2905 | if (Convert.ToDecimal(drNozzle.Field<string>("Ycoords")) > Convert.ToDecimal(it.Field<string>("Ycoords"))) |
||
2906 | { |
||
2907 | bNozzle = null; |
||
2908 | break; |
||
2909 | } |
||
2910 | } |
||
2911 | } |
||
2912 | } |
||
2913 | } |
||
2914 | |||
2915 | if (bNozzle != null) |
||
2916 | Pocket = "Yes"; |
||
2917 | } |
||
2918 | else |
||
2919 | Pocket = "Yes"; |
||
2920 | 08b33e44 | gaqhf | } |
2921 | } |
||
2922 | 91c75c0b | 이지연 | |
2923 | 485040d4 | esham21 | if (item.ID2DBType == "Nozzles" && PSNItem.EndType == PSNType.Equipment && To_item.Equipment != null) //To는 전체 |
2924 | 08b33e44 | gaqhf | { |
2925 | Equipment Equipment = To_item.Equipment; |
||
2926 | EquipmentNoPocketItem nopocket = EquipmentNoPocket.EquipmentNoPocketItem.Where(x => x.Name == Equipment.Name).FirstOrDefault(); |
||
2927 | if (nopocket != null) |
||
2928 | { |
||
2929 | 91c75c0b | 이지연 | DataRow bNozzle = null; |
2930 | if (nopocket.Type.Equals("Vertical Vessel")) |
||
2931 | { |
||
2932 | DataRow drNozzle = Nozzle.Select(string.Format("Equipment_OID = '{0}' AND OID = '{1}'", Equipment.UID, To_item.UID)).FirstOrDefault(); |
||
2933 | if(drNozzle != null) |
||
2934 | { |
||
2935 | if (drNozzle.Field<string>("Rotation").Length >= 4 && drNozzle.Field<string>("Rotation").Substring(0, 4) == "4.71") |
||
2936 | { |
||
2937 | bNozzle = drNozzle; |
||
2938 | } |
||
2939 | |||
2940 | if (bNozzle == null) |
||
2941 | { |
||
2942 | DataRow[] nozzleRows = Nozzle.Select(string.Format("Equipment_OID = '{0}'", Equipment.UID)); |
||
2943 | |||
2944 | if (drNozzle != null) |
||
2945 | { |
||
2946 | bNozzle = drNozzle; |
||
2947 | foreach (DataRow it in nozzleRows) |
||
2948 | { |
||
2949 | if (Convert.ToDecimal(drNozzle.Field<string>("Ycoords")) > Convert.ToDecimal(it.Field<string>("Ycoords"))) |
||
2950 | { |
||
2951 | bNozzle = null; |
||
2952 | break; |
||
2953 | } |
||
2954 | } |
||
2955 | } |
||
2956 | } |
||
2957 | } |
||
2958 | |||
2959 | if (bNozzle != null) |
||
2960 | Pocket = "Yes"; |
||
2961 | } |
||
2962 | else |
||
2963 | Pocket = "Yes"; |
||
2964 | 08b33e44 | gaqhf | } |
2965 | } |
||
2966 | 91c75c0b | 이지연 | |
2967 | 08b33e44 | gaqhf | newRow["Pocket"] = Pocket; |
2968 | 0eefef3d | 이지연 | string AFC = "P2"; |
2969 | 23204ef6 | 이지연 | if (PSNItem.StartType == PSNType.Equipment && From_item.Equipment != null) |
2970 | 0eefef3d | 이지연 | { |
2971 | d1afd412 | 이지연 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && x.Name.Equals(From_item.Equipment.Name)).Count() > 0) |
2972 | 284fa2c9 | 이지연 | AFC = "P1\\" + From_item.Equipment.Name; |
2973 | d1afd412 | 이지연 | else if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && x.Name.Equals(From_item.Equipment.Name)).Count() > 0) |
2974 | newRow["PUMP"] = "PUMP"; |
||
2975 | 0eefef3d | 이지연 | } |
2976 | |||
2977 | if (PSNItem.EndType == PSNType.Equipment && To_item.Equipment != null) |
||
2978 | { |
||
2979 | d1afd412 | 이지연 | if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type != "Pump" && x.Name.Equals(To_item.Equipment.Name)).Count() > 0) |
2980 | 284fa2c9 | 이지연 | AFC = "P1\\" + To_item.Equipment.Name; |
2981 | d1afd412 | 이지연 | else if (EquipmentAirFinCooler.EquipmentAirFinCoolerItem.Where(x => x.Type == "Pump" && x.Name.Equals(To_item.Equipment.Name)).Count() > 0) |
2982 | newRow["PUMP"] = "PUMP"; |
||
2983 | 0eefef3d | 이지연 | } |
2984 | |||
2985 | newRow["AFC"] = AFC; |
||
2986 | d1afd412 | 이지연 | |
2987 | newRow["EGTag"] = string.Empty; |
||
2988 | newRow["HasMLTags"] = "False"; |
||
2989 | 4842b66a | 이지연 | newRow["GroundLevel"] = GroundLevel; |
2990 | a5616391 | LJIYEON | pipeSystemNetworkDT.Rows.Add(newRow); |
2991 | 2c46461b | LJIYEON | } |
2992 | 27d06aa8 | LJIYEON | } |
2993 | 23204ef6 | 이지연 | } |
2994 | a5616391 | LJIYEON | } |
2995 | catch (Exception ex) |
||
2996 | { |
||
2997 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2998 | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
2999 | } |
||
3000 | 3210f690 | LJIYEON | |
3001 | a5616391 | LJIYEON | //TopologySet 관련 |
3002 | foreach (Topology topology in PSNItem.Topologies) |
||
3003 | { |
||
3004 | DataRow newRow = topologySetDT.NewRow(); |
||
3005 | newRow["OID"] = topology.FullName; |
||
3006 | newRow["Type"] = topology.FullName.Split(new char[] { '-' }).Last().StartsWith("M") ? "Main" : "Branch"; |
||
3007 | if (bVentDrain) |
||
3008 | newRow["SubType"] = "Vent_Drain"; |
||
3009 | else |
||
3010 | newRow["SubType"] = null; |
||
3011 | newRow["HeadItemTag"] = GetItemTag(topology.Items.Last()); |
||
3012 | newRow["TailItemTag"] = GetItemTag(topology.Items.First()); |
||
3013 | newRow["HeadItemSPID"] = topology.Items.Last().UID; |
||
3014 | newRow["TailItemSPID"] = topology.Items.First().UID; |
||
3015 | topologySetDT.Rows.Add(newRow); |
||
3016 | 94a117ca | gaqhf | } |
3017 | 7106e181 | LJIYEON | |
3018 | 6b9e7a56 | gaqhf | } |
3019 | 7106e181 | LJIYEON | catch (Exception ee) |
3020 | 27d06aa8 | LJIYEON | { |
3021 | 879ce10b | LJIYEON | |
3022 | 2c46461b | LJIYEON | } |
3023 | 6b9e7a56 | gaqhf | } |
3024 | |||
3025 | 3210f690 | LJIYEON | |
3026 | 2c46461b | LJIYEON | foreach (var item in startBranchDic) |
3027 | 5c248ee3 | gaqhf | { |
3028 | 2c46461b | LJIYEON | string uid = item.Key.UID; |
3029 | string topologyName = item.Value.Topology.FullName; |
||
3030 | DataRow[] rows = pathItemsDT.Select(string.Format("OID LIKE '{0}%'", uid)); |
||
3031 | 7106e181 | LJIYEON | |
3032 | 2c46461b | LJIYEON | if (rows.Length == 1) |
3033 | 9c151350 | gaqhf | { |
3034 | 2c46461b | LJIYEON | rows.First()["BranchTopologySet_OID"] = topologyName; |
3035 | 9c151350 | gaqhf | rows.First()["ViewPipeSystemNetwork_OID"] = item.Value.PSNItem.PSN_OID(); |
3036 | } |
||
3037 | 2c46461b | LJIYEON | else if (rows.Length > 1) |
3038 | 5c248ee3 | gaqhf | { |
3039 | 2c46461b | LJIYEON | DataRow targetRow = null; |
3040 | int index = int.MaxValue; |
||
3041 | foreach (DataRow row in rows) |
||
3042 | 5c248ee3 | gaqhf | { |
3043 | 2c46461b | LJIYEON | string split = row["OID"].ToString().Split(new char[] { '_' })[1]; |
3044 | if (split.StartsWith("L")) |
||
3045 | 5c248ee3 | gaqhf | { |
3046 | 2c46461b | LJIYEON | int num = Convert.ToInt32(split.Remove(0, 1)); |
3047 | if (index > num) |
||
3048 | { |
||
3049 | index = num; |
||
3050 | targetRow = row; |
||
3051 | } |
||
3052 | 5c248ee3 | gaqhf | } |
3053 | } |
||
3054 | |||
3055 | 2c46461b | LJIYEON | if (targetRow != null) |
3056 | 9c151350 | gaqhf | { |
3057 | 2c46461b | LJIYEON | targetRow["BranchTopologySet_OID"] = topologyName; |
3058 | 9c151350 | gaqhf | targetRow["ViewPipeSystemNetwork_OID"] = item.Value.PSNItem.PSN_OID(); |
3059 | } |
||
3060 | 2c46461b | LJIYEON | } |
3061 | 5c248ee3 | gaqhf | } |
3062 | f9f2787b | LJIYEON | |
3063 | 2c46461b | LJIYEON | foreach (var item in endBranchDic) |
3064 | 5c248ee3 | gaqhf | { |
3065 | 2c46461b | LJIYEON | string uid = item.Key.UID; |
3066 | string topologyName = item.Value.Topology.FullName; |
||
3067 | DataRow[] rows = pathItemsDT.Select(string.Format("OID LIKE '{0}%'", uid)); |
||
3068 | if (rows.Length == 1) |
||
3069 | 9c151350 | gaqhf | { |
3070 | 2c46461b | LJIYEON | rows.First()["BranchTopologySet_OID"] = topologyName; |
3071 | 9c151350 | gaqhf | rows.First()["ViewPipeSystemNetwork_OID"] = item.Value.PSNItem.PSN_OID(); |
3072 | } |
||
3073 | 2c46461b | LJIYEON | else if (rows.Length > 1) |
3074 | 5c248ee3 | gaqhf | { |
3075 | 2c46461b | LJIYEON | DataRow targetRow = null; |
3076 | int index = int.MinValue; |
||
3077 | foreach (DataRow row in rows) |
||
3078 | 5c248ee3 | gaqhf | { |
3079 | 2c46461b | LJIYEON | string split = row["OID"].ToString().Split(new char[] { '_' })[1]; |
3080 | if (split.StartsWith("L")) |
||
3081 | 5c248ee3 | gaqhf | { |
3082 | 2c46461b | LJIYEON | int num = Convert.ToInt32(split.Remove(0, 1)); |
3083 | if (index < num) |
||
3084 | { |
||
3085 | index = num; |
||
3086 | targetRow = row; |
||
3087 | } |
||
3088 | 5c248ee3 | gaqhf | } |
3089 | } |
||
3090 | |||
3091 | 2c46461b | LJIYEON | if (targetRow != null) |
3092 | 9c151350 | gaqhf | { |
3093 | 2c46461b | LJIYEON | targetRow["BranchTopologySet_OID"] = topologyName; |
3094 | 9c151350 | gaqhf | targetRow["ViewPipeSystemNetwork_OID"] = item.Value.PSNItem.PSN_OID(); |
3095 | } |
||
3096 | 2c46461b | LJIYEON | } |
3097 | 5c248ee3 | gaqhf | } |
3098 | |||
3099 | 2c46461b | LJIYEON | PathItems = pathItemsDT; |
3100 | SequenceData = sequenceDataDT; |
||
3101 | PipeSystemNetwork = pipeSystemNetworkDT; |
||
3102 | TopologySet = topologySetDT; |
||
3103 | f9f2787b | LJIYEON | PipeLine = pipelineDT; |
3104 | 531fb158 | LJIYEON | PipeSystem = pipesystemDT; |
3105 | 2c46461b | LJIYEON | } |
3106 | catch (Exception ex) |
||
3107 | { |
||
3108 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
3109 | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
3110 | } |
||
3111 | 36a45f13 | gaqhf | } |
3112 | 2ada3be8 | LJIYEON | |
3113 | 5e4c2ad1 | LJIYEON | private double AccuracyCalculation(List<double> lstAcc, double acc) |
3114 | 2ada3be8 | LJIYEON | { |
3115 | 7106e181 | LJIYEON | foreach (double lacc in lstAcc) |
3116 | 2ada3be8 | LJIYEON | { |
3117 | acc *= lacc; |
||
3118 | } |
||
3119 | return acc; |
||
3120 | } |
||
3121 | |||
3122 | 7881ec8f | gaqhf | private void UpdateSubType() |
3123 | 36a45f13 | gaqhf | { |
3124 | 27d06aa8 | LJIYEON | try |
3125 | 36a45f13 | gaqhf | { |
3126 | 27d06aa8 | LJIYEON | foreach (PSNItem PSNItem in PSNItems) |
3127 | 36a45f13 | gaqhf | { |
3128 | 27d06aa8 | LJIYEON | if (PSNItem.IsBypass) |
3129 | 36a45f13 | gaqhf | { |
3130 | 27d06aa8 | LJIYEON | foreach (Topology topology in PSNItem.Topologies) |
3131 | { |
||
3132 | DataRow[] rows = TopologySet.Select(string.Format("OID = '{0}'", topology.FullName)); |
||
3133 | if (rows.Length.Equals(1)) |
||
3134 | rows.First()["SubType"] = "Bypass"; |
||
3135 | } |
||
3136 | } |
||
3137 | |||
3138 | if (PSNItem.StartType == PSNType.Header) |
||
3139 | { |
||
3140 | Topology topology = PSNItem.Topologies.First(); |
||
3141 | DataRow[] rows = TopologySet.Select(string.Format("OID = '{0}'", topology.FullName)); |
||
3142 | if (rows.Length.Equals(1)) |
||
3143 | rows.First()["SubType"] = "Header"; |
||
3144 | } |
||
3145 | else if (PSNItem.EndType == PSNType.Header) |
||
3146 | { |
||
3147 | Topology topology = PSNItem.Topologies.Last(); |
||
3148 | 7881ec8f | gaqhf | DataRow[] rows = TopologySet.Select(string.Format("OID = '{0}'", topology.FullName)); |
3149 | if (rows.Length.Equals(1)) |
||
3150 | 27d06aa8 | LJIYEON | rows.First()["SubType"] = "Header"; |
3151 | 36a45f13 | gaqhf | } |
3152 | } |
||
3153 | 7881ec8f | gaqhf | |
3154 | 36a45f13 | gaqhf | |
3155 | 27d06aa8 | LJIYEON | foreach (Topology topology in Topologies) |
3156 | 7881ec8f | gaqhf | { |
3157 | 27d06aa8 | LJIYEON | try |
3158 | { |
||
3159 | DataRow[] rows = TopologySet.Select(string.Format("OID = '{0}'", topology.FullName)); |
||
3160 | 7106e181 | LJIYEON | |
3161 | if (rows.Count() > 0) |
||
3162 | 27d06aa8 | LJIYEON | { |
3163 | 3210f690 | LJIYEON | if (rows.Length.Equals(1) && rows.First()["SubType"] == null || string.IsNullOrEmpty(rows.First()["SubType"].ToString())) |
3164 | { |
||
3165 | if (topology.Items == null) |
||
3166 | continue; |
||
3167 | 27d06aa8 | LJIYEON | |
3168 | 3210f690 | LJIYEON | Item firstItem = topology.Items.First(); |
3169 | Item lastItem = topology.Items.Last(); |
||
3170 | 27d06aa8 | LJIYEON | |
3171 | 3210f690 | LJIYEON | List<Relation> relations = new List<Relation>(); |
3172 | 7881ec8f | gaqhf | |
3173 | bd86dd48 | 이지연 | if (firstItem.Relations.FindAll(x => x.Item == null).Count() != 0 && firstItem.Relations.FindAll(x => x.Item != null && x.Item.Topology != null && x.Item.Topology.ID != topology.ID) != null ) |
3174 | relations.AddRange(firstItem.Relations.FindAll(x => x.Item != null && x.Item.Topology != null && x.Item.Topology.ID != topology.ID)); |
||
3175 | 7881ec8f | gaqhf | |
3176 | bd86dd48 | 이지연 | if (lastItem.Relations.FindAll(x => x.Item == null).Count() != 0 && lastItem.Relations.FindAll(x => x.Item != null && x.Item.Topology != null && x.Item.Topology.ID != topology.ID) != null) |
3177 | relations.AddRange(lastItem.Relations.FindAll(x => x.Item != null && x.Item.Topology != null && x.Item.Topology.ID != topology.ID)); |
||
3178 | 3210f690 | LJIYEON | |
3179 | if (relations.Count > 0) |
||
3180 | rows.First()["SubType"] = "OtherSystem"; |
||
3181 | } |
||
3182 | 27d06aa8 | LJIYEON | } |
3183 | } |
||
3184 | catch (Exception ex) |
||
3185 | { |
||
3186 | 7106e181 | LJIYEON | |
3187 | 27d06aa8 | LJIYEON | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
3188 | } |
||
3189 | 7881ec8f | gaqhf | } |
3190 | |||
3191 | 7106e181 | LJIYEON | foreach (DataRow row in TopologySet.Rows) |
3192 | 27d06aa8 | LJIYEON | if (row["SubType"] == null || string.IsNullOrEmpty(row["SubType"].ToString())) |
3193 | row["SubType"] = "Normal"; |
||
3194 | } |
||
3195 | catch (Exception ex) |
||
3196 | { |
||
3197 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
3198 | MessageBox.Show(ex.Message, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
||
3199 | } |
||
3200 | 7881ec8f | gaqhf | } |
3201 | 5e4c2ad1 | LJIYEON | |
3202 | 7881ec8f | gaqhf | private bool IsBypass(PSNItem PSNItem) |
3203 | { |
||
3204 | bool bResult = false; |
||
3205 | |||
3206 | if (PSNItem.GetPSNType() == "B2B") |
||
3207 | { |
||
3208 | Group firstGroup = PSNItem.Groups.First(); |
||
3209 | Group lastGroup = PSNItem.Groups.Last(); |
||
3210 | Item firstItem = firstGroup.Items.First(); |
||
3211 | Item lastItem = lastGroup.Items.Last(); |
||
3212 | |||
3213 | Item connectedFirstItem = GetConnectedItemByPSN(firstItem); |
||
3214 | Item connectedLastItem = GetConnectedItemByPSN(lastItem); |
||
3215 | 36a45f13 | gaqhf | |
3216 | 7881ec8f | gaqhf | if (connectedFirstItem.LineNumber != null && connectedLastItem.LineNumber != null && |
3217 | !string.IsNullOrEmpty(connectedFirstItem.LineNumber.Name) && !string.IsNullOrEmpty(connectedLastItem.LineNumber.Name) && |
||
3218 | connectedFirstItem.LineNumber.Name == connectedLastItem.LineNumber.Name) |
||
3219 | bResult = true; |
||
3220 | else if (connectedFirstItem.PSNItem == connectedLastItem.PSNItem) |
||
3221 | bResult = true; |
||
3222 | } |
||
3223 | 36a45f13 | gaqhf | |
3224 | Item GetConnectedItemByPSN(Item item) |
||
3225 | { |
||
3226 | Item result = null; |
||
3227 | |||
3228 | Relation relation = item.Relations.Find(x => x.Item != null && x.Item.PSNItem != item.PSNItem); |
||
3229 | if (relation != null) |
||
3230 | result = relation.Item; |
||
3231 | |||
3232 | 3210f690 | LJIYEON | |
3233 | 36a45f13 | gaqhf | return result; |
3234 | } |
||
3235 | 7881ec8f | gaqhf | |
3236 | return bResult; |
||
3237 | } |
||
3238 | 5e4c2ad1 | LJIYEON | |
3239 | 419055fa | LJIYEON | private void DeleteVentDrain() |
3240 | { |
||
3241 | DataRow[] ventdrainRows = PipeSystemNetwork.Select(" IncludingVirtualData = 'Vent_Drain'"); |
||
3242 | 7106e181 | LJIYEON | |
3243 | 419055fa | LJIYEON | foreach (DataRow dataRow in ventdrainRows) |
3244 | { |
||
3245 | 7106e181 | LJIYEON | dataRow.Delete(); |
3246 | } |
||
3247 | 419055fa | LJIYEON | } |
3248 | |||
3249 | 5e4c2ad1 | LJIYEON | private void UpdateAccuracy() |
3250 | { |
||
3251 | 54b6df95 | LJIYEON | //DataRow[] statusRows = PipeSystemNetwork.Select(" Type = 'Error' OR IsValid = 'Error'"); |
3252 | DataRow[] statusRows = PipeSystemNetwork.Select(" Type = 'Error' OR IsValid = 'Error'"); |
||
3253 | 5e4c2ad1 | LJIYEON | List<double> lstAcc = null; |
3254 | string Status = string.Empty; |
||
3255 | f9f2787b | LJIYEON | |
3256 | 5e4c2ad1 | LJIYEON | foreach (DataRow dataRow in statusRows) |
3257 | { |
||
3258 | lstAcc = new List<double>(); |
||
3259 | Status = dataRow.Field<string>("Status"); |
||
3260 | if (!string.IsNullOrEmpty(Status)) |
||
3261 | { |
||
3262 | 51974d2b | LJIYEON | string[] arrStatus = Status.Split(','); |
3263 | 7106e181 | LJIYEON | foreach (string arrstr in arrStatus) |
3264 | 51974d2b | LJIYEON | { |
3265 | if (arrstr.Contains(Rule1)) //Missing LineNumber_1 |
||
3266 | lstAcc.Add(0.75); |
||
3267 | f9f2787b | LJIYEON | |
3268 | 51974d2b | LJIYEON | if (arrstr.Contains(Rule2)) //Missing LineNumber_2 |
3269 | lstAcc.Add(0.7); |
||
3270 | f9f2787b | LJIYEON | |
3271 | 51974d2b | LJIYEON | if (arrstr.Contains(Rule3)) // OPC Disconnected |
3272 | lstAcc.Add(0.5); |
||
3273 | f9f2787b | LJIYEON | |
3274 | 51974d2b | LJIYEON | if (arrstr.Contains(Rule4)) //Missing ItemTag or Description |
3275 | lstAcc.Add(0.65); |
||
3276 | |||
3277 | if (arrstr.Contains(Rule5)) //Line Disconnected |
||
3278 | lstAcc.Add(0.6); |
||
3279 | } |
||
3280 | 5e4c2ad1 | LJIYEON | } |
3281 | |||
3282 | string PSNAccuracy = dataRow["PSNAccuracy"].ToString(); |
||
3283 | if (PSNAccuracy == "100") |
||
3284 | PSNAccuracy = "1"; |
||
3285 | |||
3286 | 51974d2b | LJIYEON | PSNAccuracy = Convert.ToString(Convert.ToDecimal(AccuracyCalculation(lstAcc, Convert.ToDouble(PSNAccuracy)))); |
3287 | //if (PSNAccuracy != "100") |
||
3288 | //{ |
||
3289 | // //dataRow["IncludingVirtualData"] = "No"; |
||
3290 | 7106e181 | LJIYEON | dataRow["PSNAccuracy"] = PSNAccuracy; |
3291 | 51974d2b | LJIYEON | //} |
3292 | 5e4c2ad1 | LJIYEON | } |
3293 | bfe278bb | LJIYEON | DataTable dt = PipeSystemNetwork.DefaultView.ToTable(true, new string[] { "OID" }); |
3294 | foreach (DataRow dr in dt.Rows) |
||
3295 | { |
||
3296 | string oid = dr.Field<string>("OID"); |
||
3297 | DataRow[] select = PipeSystemNetwork.Select(string.Format("OID = '{0}'", oid)); |
||
3298 | double totalDdr = 0; |
||
3299 | foreach (DataRow ddr in select) |
||
3300 | { |
||
3301 | double acc = Convert.ToDouble(ddr.Field<string>("PSNAccuracy")); |
||
3302 | if (acc == 100) acc = 1; |
||
3303 | if (totalDdr == 0) totalDdr = acc; |
||
3304 | else totalDdr *= acc; |
||
3305 | } |
||
3306 | |||
3307 | totalDdr *= 100; |
||
3308 | |||
3309 | 7106e181 | LJIYEON | if (totalDdr != 100) |
3310 | bfe278bb | LJIYEON | { |
3311 | f9f2787b | LJIYEON | foreach (DataRow ddr in select) |
3312 | { |
||
3313 | ddr["IncludingVirtualData"] = "Yes"; |
||
3314 | 51974d2b | LJIYEON | ddr["PSNAccuracy"] = String.Format("{0:0.00}", Math.Round(totalDdr, 2)); |
3315 | 7d6d1693 | 이지연 | ddr["IsValid"] = "Error"; |
3316 | 51974d2b | LJIYEON | } |
3317 | } |
||
3318 | else |
||
3319 | { |
||
3320 | foreach (DataRow ddr in select) |
||
3321 | { |
||
3322 | ddr["IncludingVirtualData"] = "No"; |
||
3323 | ddr["PSNAccuracy"] = String.Format("{0:0.00}", Math.Round(totalDdr, 2)); |
||
3324 | f9f2787b | LJIYEON | } |
3325 | bfe278bb | LJIYEON | } |
3326 | } |
||
3327 | |||
3328 | 5e4c2ad1 | LJIYEON | } |
3329 | |||
3330 | a5616391 | LJIYEON | private void UpdateKeywordForPSN() |
3331 | { |
||
3332 | #region Keyword Info |
||
3333 | KeywordInfo KeywordInfos = new KeywordInfo(); |
||
3334 | DataTable dtKeyword = DB.SelectKeywordsSetting(); |
||
3335 | foreach (DataRow row in dtKeyword.Rows) |
||
3336 | { |
||
3337 | int index = Convert.ToInt32(row["INDEX"]); |
||
3338 | string name = row["NAME"].ToString(); |
||
3339 | string keyword = row["KEYWORD"].ToString(); |
||
3340 | |||
3341 | //KeywordInfo keywordInfo = new KeywordInfo(); |
||
3342 | KeywordInfos.KeywordItems.Add(new KeywordItem() |
||
3343 | { |
||
3344 | Index = index, |
||
3345 | Name = name, |
||
3346 | Keyword = keyword |
||
3347 | }); |
||
3348 | } |
||
3349 | #endregion |
||
3350 | |||
3351 | a2973aa3 | LJIYEON | DataRow[] endofHeaderRows = PipeSystemNetwork.Select(string.Format(" From_Data = '{0}' OR To_Data = '{0}'", "ENDOFHEADER")); |
3352 | foreach (DataRow dataRow in endofHeaderRows) |
||
3353 | { |
||
3354 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
||
3355 | |||
3356 | if (dataRow.Field<string>("From_Data") == "ENDOFHEADER") |
||
3357 | { |
||
3358 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"])); |
||
3359 | DataRow dr = pathItemRows.First(); |
||
3360 | dr["CLASS"] = PSNItem.Groups.First().Items.First().ID2DBName; |
||
3361 | dr["TYPE"] = "End"; |
||
3362 | dr["ITEMTAG"] = "ENDOFHEADER"; |
||
3363 | dr["DESCRIPTION"] = "ENDOFHEADER"; |
||
3364 | } |
||
3365 | |||
3366 | if (dataRow.Field<string>("To_Data") == "ENDOFHEADER") |
||
3367 | { |
||
3368 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"])); |
||
3369 | DataRow dr = pathItemRows.Last(); |
||
3370 | dr["CLASS"] = PSNItem.Groups.Last().Items.Last().ID2DBName; |
||
3371 | dr["TYPE"] = "End"; |
||
3372 | dr["ITEMTAG"] = "ENDOFHEADER"; |
||
3373 | dr["DESCRIPTION"] = "ENDOFHEADER"; |
||
3374 | } |
||
3375 | } |
||
3376 | |||
3377 | a5616391 | LJIYEON | foreach (KeywordItem keyitem in KeywordInfos.KeywordItems) |
3378 | { |
||
3379 | a2973aa3 | LJIYEON | DataRow[] keywordRows = PipeSystemNetwork.Select(string.Format(" From_Data = '{0}' OR To_Data = '{0}'", keyitem.Keyword)); |
3380 | a5616391 | LJIYEON | foreach (DataRow dataRow in keywordRows) |
3381 | 7106e181 | LJIYEON | { |
3382 | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
||
3383 | a5616391 | LJIYEON | |
3384 | 7106e181 | LJIYEON | if (dataRow.Field<string>("From_Data") == keyitem.Keyword) |
3385 | { |
||
3386 | a5616391 | LJIYEON | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"])); |
3387 | 7106e181 | LJIYEON | |
3388 | a2973aa3 | LJIYEON | // |
3389 | //if(.) |
||
3390 | 7106e181 | LJIYEON | if (PSNItem.Groups.First().Items.First().Name.Equals(keyitem.Name)) |
3391 | a5616391 | LJIYEON | { |
3392 | DataRow dr = pathItemRows.First(); |
||
3393 | //dr["CLASS"] = ""; //Type |
||
3394 | dr["TYPE"] = "End"; |
||
3395 | dr["ITEMTAG"] = keyitem.Keyword; |
||
3396 | dr["DESCRIPTION"] = keyitem.Keyword; |
||
3397 | } |
||
3398 | 7106e181 | LJIYEON | |
3399 | a5616391 | LJIYEON | } |
3400 | |||
3401 | a2973aa3 | LJIYEON | if (dataRow.Field<string>("To_Data") == keyitem.Keyword) |
3402 | a5616391 | LJIYEON | { |
3403 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"])); |
||
3404 | |||
3405 | a2973aa3 | LJIYEON | if (PSNItem.Groups.Last().Items.Last().Name.Equals(keyitem.Name)) |
3406 | a5616391 | LJIYEON | { |
3407 | DataRow dr = pathItemRows.Last(); |
||
3408 | //dr["CLASS"] = ""; //Type |
||
3409 | dr["TYPE"] = "End"; |
||
3410 | dr["ITEMTAG"] = keyitem.Keyword; |
||
3411 | dr["DESCRIPTION"] = keyitem.Keyword; |
||
3412 | //dr.Field<string>("Type") |
||
3413 | } |
||
3414 | |||
3415 | 7106e181 | LJIYEON | } |
3416 | a5616391 | LJIYEON | } |
3417 | 7106e181 | LJIYEON | } |
3418 | a5616391 | LJIYEON | } |
3419 | |||
3420 | 7881ec8f | gaqhf | private void UpdateErrorForPSN() |
3421 | { |
||
3422 | 45529c16 | LJIYEON | DataRow[] errorRows = PipeSystemNetwork.Select(string.Format(" Type = '{0}'", ErrorType.Error)); |
3423 | 7881ec8f | gaqhf | foreach (DataRow dataRow in errorRows) |
3424 | { |
||
3425 | eb44d82c | LJIYEON | try |
3426 | 710a49f1 | gaqhf | { |
3427 | eb44d82c | LJIYEON | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
3428 | dd27861e | 이지연 | |
3429 | eb44d82c | LJIYEON | bool change = false; |
3430 | aa195a5b | LJIYEON | bool bCheck = false; |
3431 | eb44d82c | LJIYEON | if (!PSNItem.EnableType(PSNItem.StartType)) |
3432 | 710a49f1 | gaqhf | { |
3433 | ecdd26cc | 이지연 | |
3434 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"])); |
||
3435 | int insertIndex = PathItems.Rows.IndexOf(pathItemRows.First()); |
||
3436 | 7106e181 | LJIYEON | |
3437 | ecdd26cc | 이지연 | Item item = PSNItem.Groups.First().Items.First(); |
3438 | try |
||
3439 | { |
||
3440 | d6ef5842 | 이지연 | if (PSNItem.StartType == PSNType.Symbol && item.Relations != null && item.Relations[0].Item.Relations != null && item.Relations[0].Item.Relations.Count() > 2) |
3441 | { |
||
3442 | PSNItem.StartType = PSNType.Branch; |
||
3443 | } |
||
3444 | else |
||
3445 | eb44d82c | LJIYEON | { |
3446 | d6ef5842 | 이지연 | if (!item.Name.ToUpper().Equals("TIEINPOINT")) |
3447 | { |
||
3448 | change = true; |
||
3449 | ecdd26cc | 이지연 | |
3450 | d6ef5842 | 이지연 | string FROM_DATA = string.Format("TIEINPOINT_{0:D5}V", tieInPointIndex); |
3451 | bd86dd48 | 이지연 | |
3452 | d6ef5842 | 이지연 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
3453 | 48870200 | LJIYEON | { |
3454 | d6ef5842 | 이지연 | loopRow["FROM_DATA"] = FROM_DATA; |
3455 | if (item.ItemType == ItemType.Line) |
||
3456 | bd86dd48 | 이지연 | { |
3457 | d6ef5842 | 이지연 | if (loopRow.Field<string>("OrderNumber") == "0") |
3458 | { |
||
3459 | string status = loopRow.Field<string>("Status"); |
||
3460 | //string isvali |
||
3461 | if (string.IsNullOrEmpty(status)) |
||
3462 | status = "Line Disconnected"; |
||
3463 | else if (!status.Contains("Line Disconnected")) |
||
3464 | status += ", Line Disconnected"; |
||
3465 | loopRow["Status"] = status; |
||
3466 | if (!string.IsNullOrEmpty(status)) |
||
3467 | loopRow["IsValid"] = "Error"; |
||
3468 | } |
||
3469 | bd86dd48 | 이지연 | } |
3470 | 48870200 | LJIYEON | } |
3471 | dd27861e | 이지연 | |
3472 | d6ef5842 | 이지연 | tieInPointIndex++; |
3473 | dd27861e | 이지연 | |
3474 | d6ef5842 | 이지연 | if (item.ItemType == ItemType.Line) |
3475 | { |
||
3476 | PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.First(), FROM_DATA), insertIndex); |
||
3477 | } |
||
3478 | else |
||
3479 | { |
||
3480 | PathItems.Rows.InsertAt(createLineRow(PathItems.Select(string.Format("PipeLine_OID = '{0}' AND PipeSystemNetwork_OID = '{1}'", item.PSNPipeLineID, dataRow["OID"])).First()), insertIndex); |
||
3481 | PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.First(), FROM_DATA), insertIndex); |
||
3482 | bd86dd48 | 이지연 | |
3483 | d6ef5842 | 이지연 | bCheck = true; |
3484 | } |
||
3485 | bd86dd48 | 이지연 | } |
3486 | d6ef5842 | 이지연 | else |
3487 | ecdd26cc | 이지연 | { |
3488 | d6ef5842 | 이지연 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
3489 | ecdd26cc | 이지연 | { |
3490 | d6ef5842 | 이지연 | loopRow["FROM_DATA"] = pathItemRows.First().Field<string>("ITEMTAG"); |
3491 | ecdd26cc | 이지연 | |
3492 | d6ef5842 | 이지연 | if (loopRow.Field<string>("OrderNumber") == "0") |
3493 | { |
||
3494 | if (loopRow["Status"].ToString().Contains(", Missing ItemTag or Description")) |
||
3495 | loopRow["Status"] = loopRow["Status"].ToString().Replace(", Missing ItemTag or Description", ""); |
||
3496 | else if (loopRow["Status"].ToString().Contains("Missing ItemTag or Description")) |
||
3497 | loopRow["Status"] = loopRow["Status"].ToString().Replace("Missing ItemTag or Description", ""); |
||
3498 | ecdd26cc | 이지연 | |
3499 | d6ef5842 | 이지연 | if (!string.IsNullOrEmpty(loopRow["Status"].ToString()) && loopRow["Status"].ToString().Substring(0, 2).Equals(", ")) |
3500 | loopRow["Status"] = loopRow["Status"].ToString().Remove(0, 2); |
||
3501 | } |
||
3502 | } |
||
3503 | |||
3504 | bool bStatus = false; |
||
3505 | ecdd26cc | 이지연 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
3506 | { |
||
3507 | d6ef5842 | 이지연 | if (!string.IsNullOrEmpty(loopRow["Status"].ToString())) |
3508 | bStatus = true; |
||
3509 | ecdd26cc | 이지연 | } |
3510 | |||
3511 | d6ef5842 | 이지연 | if (!bStatus) |
3512 | { |
||
3513 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
||
3514 | { |
||
3515 | loopRow["IsValid"] = string.Empty; |
||
3516 | } |
||
3517 | } |
||
3518 | } |
||
3519 | PSNItem.StartType = PSNType.Equipment; |
||
3520 | } |
||
3521 | ecdd26cc | 이지연 | } |
3522 | catch (Exception ex) |
||
3523 | { |
||
3524 | MessageBox.Show("Please check the item.\r\nDrawingName : " + item.Document.DrawingName + "\r\nUID : " + item.UID, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
3525 | return; |
||
3526 | } |
||
3527 | eb44d82c | LJIYEON | } |
3528 | 710a49f1 | gaqhf | |
3529 | eb44d82c | LJIYEON | if (!PSNItem.EnableType(PSNItem.EndType)) |
3530 | bd86dd48 | 이지연 | { |
3531 | ecdd26cc | 이지연 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", dataRow["OID"])); |
3532 | //int insertIndex = PathItems.Rows.IndexOf(pathItemRows.First()) + pathItemRows.Count() - 1; |
||
3533 | DataRow dr = pathItemRows.Last(); |
||
3534 | if (change) |
||
3535 | { |
||
3536 | if (bCheck) |
||
3537 | dr = pathItemRows[pathItemRows.Count() - 3]; |
||
3538 | else |
||
3539 | dd27861e | 이지연 | { |
3540 | ecdd26cc | 이지연 | dr = pathItemRows[pathItemRows.Count() - 2]; |
3541 | dd27861e | 이지연 | } |
3542 | ecdd26cc | 이지연 | } |
3543 | f6c9db1a | 이지연 | |
3544 | ecdd26cc | 이지연 | change = true; |
3545 | int insertIndex = PathItems.Rows.IndexOf(dr) + 1; |
||
3546 | a36541fb | LJIYEON | |
3547 | ecdd26cc | 이지연 | Item item = PSNItem.Groups.Last().Items.Last(); |
3548 | |||
3549 | try |
||
3550 | { |
||
3551 | d6ef5842 | 이지연 | if (PSNItem.EndType == PSNType.Symbol && item.Relations != null && item.Relations[item.Relations.Count - 1].Item.Relations != null && item.Relations[item.Relations.Count - 1].Item.Relations.Count() > 2) |
3552 | 51974d2b | LJIYEON | { |
3553 | d6ef5842 | 이지연 | PSNItem.EndType = PSNType.Branch; |
3554 | } |
||
3555 | else |
||
3556 | { |
||
3557 | if (!item.Name.ToUpper().Equals("TIEINPOINT")) |
||
3558 | 51974d2b | LJIYEON | { |
3559 | d6ef5842 | 이지연 | |
3560 | string TO_DATA = string.Format("TIEINPOINT_{0:D5}V", tieInPointIndex); |
||
3561 | |||
3562 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
||
3563 | 48870200 | LJIYEON | { |
3564 | d6ef5842 | 이지연 | loopRow["TO_DATA"] = TO_DATA; |
3565 | if (item.ItemType == ItemType.Line) |
||
3566 | bd86dd48 | 이지연 | { |
3567 | d6ef5842 | 이지연 | if (loopRow.Field<string>("OrderNumber") == Convert.ToString(PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID())).Count() - 1)) |
3568 | { |
||
3569 | string status = loopRow.Field<string>("Status"); |
||
3570 | if (string.IsNullOrEmpty(status)) |
||
3571 | status = "Line Disconnected"; |
||
3572 | else if (!status.Contains("Line Disconnected")) |
||
3573 | status += ", Line Disconnected"; |
||
3574 | loopRow["Status"] = status; |
||
3575 | if (!string.IsNullOrEmpty(status)) |
||
3576 | loopRow["IsValid"] = "Error"; |
||
3577 | } |
||
3578 | bd86dd48 | 이지연 | } |
3579 | 48870200 | LJIYEON | } |
3580 | 7d6d1693 | 이지연 | |
3581 | d6ef5842 | 이지연 | tieInPointIndex++; |
3582 | 48870200 | LJIYEON | |
3583 | d6ef5842 | 이지연 | if (item.ItemType == ItemType.Line) |
3584 | { |
||
3585 | PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.Last(), TO_DATA), insertIndex); |
||
3586 | } |
||
3587 | else |
||
3588 | { |
||
3589 | PathItems.Rows.InsertAt(createTerminatorRow(pathItemRows.Last(), TO_DATA), insertIndex); |
||
3590 | PathItems.Rows.InsertAt(createLineRow(PathItems.Select(string.Format("PipeLine_OID = '{0}' AND PipeSystemNetwork_OID = '{1}'", item.PSNPipeLineID, dataRow["OID"])).Last()), insertIndex); |
||
3591 | } |
||
3592 | bd86dd48 | 이지연 | } |
3593 | else |
||
3594 | { |
||
3595 | d6ef5842 | 이지연 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
3596 | ecdd26cc | 이지연 | { |
3597 | d6ef5842 | 이지연 | loopRow["TO_DATA"] = dr.Field<string>("ITEMTAG"); |
3598 | ecdd26cc | 이지연 | |
3599 | d6ef5842 | 이지연 | if (loopRow.Field<string>("OrderNumber") == Convert.ToString(PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID())).Count() - 1)) |
3600 | { |
||
3601 | if (loopRow["Status"].ToString().Contains(", Missing ItemTag or Description")) |
||
3602 | loopRow["Status"] = loopRow["Status"].ToString().Replace(", Missing ItemTag or Description", ""); |
||
3603 | else if (loopRow["Status"].ToString().Contains("Missing ItemTag or Description")) |
||
3604 | loopRow["Status"] = loopRow["Status"].ToString().Replace("Missing ItemTag or Description", ""); |
||
3605 | ecdd26cc | 이지연 | |
3606 | d6ef5842 | 이지연 | if (!string.IsNullOrEmpty(loopRow["Status"].ToString()) && loopRow["Status"].ToString().Substring(0, 2).Equals(", ")) |
3607 | loopRow["Status"] = loopRow["Status"].ToString().Remove(0, 2); |
||
3608 | } |
||
3609 | } |
||
3610 | ecdd26cc | 이지연 | |
3611 | d6ef5842 | 이지연 | bool bStatus = false; |
3612 | ecdd26cc | 이지연 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
3613 | { |
||
3614 | d6ef5842 | 이지연 | if (!string.IsNullOrEmpty(loopRow["Status"].ToString())) |
3615 | bStatus = true; |
||
3616 | } |
||
3617 | |||
3618 | if (!bStatus) |
||
3619 | { |
||
3620 | foreach (DataRow loopRow in PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID()))) |
||
3621 | { |
||
3622 | loopRow["IsValid"] = string.Empty; |
||
3623 | } |
||
3624 | ecdd26cc | 이지연 | } |
3625 | } |
||
3626 | d6ef5842 | 이지연 | PSNItem.EndType = PSNType.Equipment; |
3627 | eb44d82c | LJIYEON | } |
3628 | d6ef5842 | 이지연 | |
3629 | ecdd26cc | 이지연 | } |
3630 | catch (Exception ex) |
||
3631 | { |
||
3632 | MessageBox.Show("Please check the item.\r\nDrawingName : " + item.Document.DrawingName + "\r\nUID : " + item.UID, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
||
3633 | return; |
||
3634 | } |
||
3635 | |||
3636 | 710a49f1 | gaqhf | } |
3637 | eb44d82c | LJIYEON | |
3638 | dataRow["Type"] = PSNItem.GetPSNType(); |
||
3639 | if (change) |
||
3640 | 710a49f1 | gaqhf | { |
3641 | eb44d82c | LJIYEON | int rowIndex = 0; |
3642 | for (int i = 0; i < PathItems.Rows.Count; i++) |
||
3643 | { |
||
3644 | DataRow row = PathItems.Rows[i]; |
||
3645 | if (row["PipeSystemNetwork_OID"].ToString() != dataRow["OID"].ToString()) |
||
3646 | continue; |
||
3647 | string sequenceData = row["SequenceData_OID"].ToString(); |
||
3648 | string[] split = sequenceData.Split(new char[] { '_' }); |
||
3649 | |||
3650 | StringBuilder sb = new StringBuilder(); |
||
3651 | for (int j = 0; j < split.Length - 1; j++) |
||
3652 | sb.Append(split[j] + "_"); |
||
3653 | sb.Append(rowIndex++); |
||
3654 | row["SequenceData_OID"] = sb.ToString(); |
||
3655 | a36541fb | LJIYEON | |
3656 | 3210f690 | LJIYEON | DataRow seqItemRows = SequenceData.Select(string.Format("PathItem_OID = '{0}'", row["OID"])).FirstOrDefault(); |
3657 | int insertSeqIndex = SequenceData.Rows.IndexOf(seqItemRows); |
||
3658 | |||
3659 | string[] splitseq = sb.ToString().Split(new char[] { '_' }); |
||
3660 | |||
3661 | if (seqItemRows == null) |
||
3662 | { |
||
3663 | 7106e181 | LJIYEON | DataRow newRow = SequenceData.NewRow(); |
3664 | 3210f690 | LJIYEON | newRow["OID"] = sb.ToString(); |
3665 | newRow["SERIALNUMBER"] = splitseq[splitseq.Length - 1]; |
||
3666 | newRow["PathItem_OID"] = row["OID"]; |
||
3667 | newRow["TopologySet_OID_Key"] = row["TopologySet_OID"]; |
||
3668 | SequenceData.Rows.InsertAt(newRow, Convert.ToInt32(splitseq[splitseq.Length - 1])); |
||
3669 | } |
||
3670 | else |
||
3671 | { |
||
3672 | seqItemRows["OID"] = sb.ToString(); |
||
3673 | seqItemRows["SERIALNUMBER"] = splitseq[splitseq.Length - 1]; |
||
3674 | seqItemRows["PathItem_OID"] = row["OID"]; |
||
3675 | seqItemRows["TopologySet_OID_Key"] = row["TopologySet_OID"]; |
||
3676 | 7106e181 | LJIYEON | } |
3677 | } |
||
3678 | eb44d82c | LJIYEON | } |
3679 | 5e4c2ad1 | LJIYEON | |
3680 | a36541fb | LJIYEON | DataRow createTerminatorRow(DataRow itemRow, string DATA) |
3681 | eb44d82c | LJIYEON | { |
3682 | DataRow newRow = PathItems.NewRow(); |
||
3683 | newRow["OID"] = Guid.NewGuid().ToString(); |
||
3684 | newRow["SequenceData_OID"] = itemRow["SequenceData_OID"]; |
||
3685 | newRow["TopologySet_OID"] = itemRow["TopologySet_OID"]; |
||
3686 | newRow["BranchTopologySet_OID"] = itemRow["BranchTopologySet_OID"]; |
||
3687 | 7106e181 | LJIYEON | newRow["PipeLine_OID"] = itemRow["PipeLine_OID"]; |
3688 | a36541fb | LJIYEON | newRow["ITEMNAME"] = "PipingComp"; //newRow["ITEMNAME"] = "End of line terminator"; |
3689 | newRow["ITEMTAG"] = DATA; //itemRow["ITEMTAG"]; |
||
3690 | 7106e181 | LJIYEON | newRow["DESCRIPTION"] = DATA; |
3691 | eb44d82c | LJIYEON | newRow["Class"] = "End of line terminator"; |
3692 | newRow["SubClass"] = "End of line terminator"; |
||
3693 | a36541fb | LJIYEON | newRow["TYPE"] = "End"; |
3694 | d6ef5842 | 이지연 | newRow["MULTIWAY"] = ""; |
3695 | eb44d82c | LJIYEON | newRow["PIDNAME"] = itemRow["PIDNAME"]; |
3696 | newRow["NPD"] = itemRow["NPD"]; |
||
3697 | newRow["PipeSystemNetwork_OID"] = itemRow["PipeSystemNetwork_OID"]; |
||
3698 | newRow["ViewPipeSystemNetwork_OID"] = itemRow["ViewPipeSystemNetwork_OID"]; |
||
3699 | 7106e181 | LJIYEON | newRow["PipeRun_OID"] = itemRow["PipeRun_OID"]; |
3700 | 0d4b3dee | 이지연 | newRow["EGTConnectedPoint"] = "0"; |
3701 | a36541fb | LJIYEON | return newRow; |
3702 | } |
||
3703 | |||
3704 | eb44d82c | LJIYEON | DataRow createLineRow(DataRow itemRow) |
3705 | 710a49f1 | gaqhf | { |
3706 | eb44d82c | LJIYEON | DataRow newRow = PathItems.NewRow(); |
3707 | newRow["OID"] = Guid.NewGuid().ToString(); |
||
3708 | newRow["SequenceData_OID"] = itemRow["SequenceData_OID"]; |
||
3709 | newRow["TopologySet_OID"] = itemRow["TopologySet_OID"]; |
||
3710 | bd86dd48 | 이지연 | newRow["BranchTopologySet_OID"] = ""; |
3711 | eb44d82c | LJIYEON | newRow["PipeLine_OID"] = itemRow["PipeLine_OID"]; |
3712 | bd86dd48 | 이지연 | newRow["ITEMNAME"] = "PipeRun"; |
3713 | newRow["ITEMTAG"] = itemRow["PipeRun_OID"]; |
||
3714 | newRow["Class"] = "Piping"; |
||
3715 | newRow["SubClass"] = ""; |
||
3716 | newRow["TYPE"] = "Secondary"; |
||
3717 | d6ef5842 | 이지연 | newRow["MULTIWAY"] = ""; |
3718 | eb44d82c | LJIYEON | newRow["PIDNAME"] = itemRow["PIDNAME"]; |
3719 | newRow["NPD"] = itemRow["NPD"]; |
||
3720 | newRow["PipeSystemNetwork_OID"] = itemRow["PipeSystemNetwork_OID"]; |
||
3721 | newRow["ViewPipeSystemNetwork_OID"] = itemRow["ViewPipeSystemNetwork_OID"]; |
||
3722 | newRow["PipeRun_OID"] = itemRow["PipeRun_OID"]; |
||
3723 | 0d4b3dee | 이지연 | newRow["EGTConnectedPoint"] = "0"; |
3724 | eb44d82c | LJIYEON | return newRow; |
3725 | 710a49f1 | gaqhf | } |
3726 | } |
||
3727 | 7106e181 | LJIYEON | catch (Exception ex) |
3728 | 5e4c2ad1 | LJIYEON | { |
3729 | 710a49f1 | gaqhf | |
3730 | } |
||
3731 | eb44d82c | LJIYEON | } |
3732 | 6b9e7a56 | gaqhf | } |
3733 | 4e2e0aa1 | LJIYEON | |
3734 | private void InsertTeePSN() |
||
3735 | { |
||
3736 | 3f5cb4dc | LJIYEON | DataTable dt = PipeSystemNetwork.DefaultView.ToTable(true, new string[] { "OID", "Type" }); |
3737 | DataRow[] branchRows = dt.Select("Type Like '%B%'"); |
||
3738 | 820e283f | LJIYEON | bool change = false; |
3739 | 4e2e0aa1 | LJIYEON | foreach (DataRow dataRow in branchRows) |
3740 | { |
||
3741 | try |
||
3742 | 7106e181 | LJIYEON | { |
3743 | 4e2e0aa1 | LJIYEON | PSNItem PSNItem = PSNItems.Find(x => x.PSN_OID() == dataRow["OID"].ToString()); |
3744 | 820e283f | LJIYEON | change = false; |
3745 | d6ef5842 | 이지연 | DataRow[] pipeSystem = PipeSystemNetwork.Select(string.Format("OID = '{0}'", PSNItem.PSN_OID())); |
3746 | 4e2e0aa1 | LJIYEON | if (PSNItem.StartType == PSNType.Branch) |
3747 | { |
||
3748 | 820e283f | LJIYEON | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", PSNItem.PSN_OID())); |
3749 | 4e2e0aa1 | LJIYEON | int insertIndex = PathItems.Rows.IndexOf(pathItemRows.First()); |
3750 | 820e283f | LJIYEON | Item Teeitem = PSNItem.Groups.First().Items.First(); |
3751 | 4e2e0aa1 | LJIYEON | try |
3752 | 820e283f | LJIYEON | { |
3753 | if (Teeitem.ItemType == ItemType.Line) |
||
3754 | 4e2e0aa1 | LJIYEON | { |
3755 | d6ef5842 | 이지연 | //if (pathItemRows.First().Field<string>("SubClass") != "Tee") |
3756 | //{ |
||
3757 | if (Teeitem.Relations[0].Item.ItemType == ItemType.Line) |
||
3758 | 7106e181 | LJIYEON | { |
3759 | 4e2e0aa1 | LJIYEON | PathItems.Rows.InsertAt(createTeeRow(pathItemRows.First()), insertIndex); |
3760 | d6ef5842 | 이지연 | change = true; |
3761 | 0e9d868c | LJIYEON | pathItemRows.First().SetField("BranchTopologySet_OID", string.Empty); |
3762 | d6ef5842 | 이지연 | pathItemRows.First().SetField("ViewPipeSystemNetwork_OID", dataRow["OID"].ToString()); |
3763 | } |
||
3764 | else |
||
3765 | { //dicMultiwaySymbolUID.Add(item.UID, 1); |
||
3766 | int index = dicMultiwaySymbolUID[Teeitem.Relations[0].Item.UID] + 1; |
||
3767 | string multiItemOID = Teeitem.Relations[0].Item.UID + "_M" + index; |
||
3768 | dicMultiwaySymbolUID[Teeitem.Relations[0].Item.UID] = index; |
||
3769 | |||
3770 | PathItems.Rows.InsertAt(createMultiWayConnRow(PathItems.Select(string.Format("OID = '{0}'", Teeitem.Relations[0].Item.UID + "_M1")).First(), multiItemOID, pathItemRows.First()), insertIndex); |
||
3771 | 820e283f | LJIYEON | change = true; |
3772 | d6ef5842 | 이지연 | pathItemRows.First().SetField("BranchTopologySet_OID", string.Empty); |
3773 | pathItemRows.First().SetField("ViewPipeSystemNetwork_OID", dataRow["OID"].ToString()); |
||
3774 | |||
3775 | SequenceData.Rows.InsertAt(CreateSequenceDataDataRow(pathItemRows.First(), multiItemOID, 0), 0); |
||
3776 | |||
3777 | foreach(DataRow pipedr in pipeSystem) |
||
3778 | { |
||
3779 | pipedr["FROM_DATA"] = PathItems.Select(string.Format("OID = '{0}'", Teeitem.Relations[0].Item.UID + "_M1")).First().Field<string>("MULTIWAY"); |
||
3780 | } |
||
3781 | 4e2e0aa1 | LJIYEON | } |
3782 | d6ef5842 | 이지연 | } |
3783 | else if (Teeitem.ItemType == ItemType.Symbol) |
||
3784 | { |
||
3785 | Group _group = groups.Find(x => x.Items.Select(w => w.UID).Contains(Teeitem.UID)); |
||
3786 | var _items = Teeitem.Relations.Where(w => w.Item != null && !_group.Items.Contains(w.Item)).Select(w => w.Item).ToList(); |
||
3787 | if (_items.Count > 0) |
||
3788 | { |
||
3789 | int index = dicMultiwaySymbolUID[_items[0].UID] + 1; |
||
3790 | string multiItemOID = _items[0].UID + "_M" + index; |
||
3791 | dicMultiwaySymbolUID[_items[0].UID] = index; |
||
3792 | PathItems.Rows.InsertAt(createMultiWayConnRow(PathItems.Select(string.Format("OID = '{0}'", _items[0].UID + "_M1")).First(), multiItemOID, pathItemRows.First()), insertIndex); |
||
3793 | pathItemRows.First().SetField("BranchTopologySet_OID", string.Empty); |
||
3794 | pathItemRows.First().SetField("ViewPipeSystemNetwork_OID", dataRow["OID"].ToString()); |
||
3795 | |||
3796 | change = true; |
||
3797 | |||
3798 | SequenceData.Rows.InsertAt(CreateSequenceDataDataRow(pathItemRows.First(), multiItemOID, 0), 0); |
||
3799 | 4e2e0aa1 | LJIYEON | |
3800 | d6ef5842 | 이지연 | foreach (DataRow pipedr in pipeSystem) |
3801 | { |
||
3802 | pipedr["FROM_DATA"] = PathItems.Select(string.Format("OID = '{0}'", _items[0].UID + "_M1")).First().Field<string>("MULTIWAY"); |
||
3803 | } |
||
3804 | |||
3805 | } |
||
3806 | 820e283f | LJIYEON | } |
3807 | 4e2e0aa1 | LJIYEON | } |
3808 | catch (Exception ex) |
||
3809 | { |
||
3810 | 820e283f | LJIYEON | MessageBox.Show("Please check the item.\r\nDrawingName : " + Teeitem.Document.DrawingName + "\r\nUID : " + Teeitem.UID, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
3811 | 4e2e0aa1 | LJIYEON | return; |
3812 | } |
||
3813 | } |
||
3814 | |||
3815 | if (PSNItem.EndType == PSNType.Branch) |
||
3816 | { |
||
3817 | 820e283f | LJIYEON | //change = true; |
3818 | DataRow[] pathItemRows = PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", PSNItem.PSN_OID())); |
||
3819 | 7106e181 | LJIYEON | |
3820 | 820e283f | LJIYEON | Item Teeitem = PSNItem.Groups.Last().Items.Last(); |
3821 | 4e2e0aa1 | LJIYEON | |
3822 | 820e283f | LJIYEON | DataRow dr = pathItemRows.Last(); |
3823 | if (change) |
||
3824 | dr = pathItemRows[pathItemRows.Count() - 2]; |
||
3825 | e36ca22f | LJIYEON | |
3826 | b683578e | LJIYEON | int insertIndex = PathItems.Rows.IndexOf(dr) + 1; |
3827 | e36ca22f | LJIYEON | |
3828 | 4e2e0aa1 | LJIYEON | try |
3829 | { |
||
3830 | 820e283f | LJIYEON | if (Teeitem.ItemType == ItemType.Line) |
3831 | 4e2e0aa1 | LJIYEON | { |
3832 | d6ef5842 | 이지연 | if (dr.Field<string>("SubClass").ToUpper() != "TEE") |
3833 | { |
||
3834 | if (Teeitem.Relations[1].Item.ItemType == ItemType.Line) |
||
3835 | { |
||
3836 | PathItems.Rows.InsertAt(createTeeRow(dr), insertIndex); |
||
3837 | change = true; |
||
3838 | dr.SetField("BranchTopologySet_OID", string.Empty); |
||
3839 | dr.SetField("ViewPipeSystemNetwork_OID", dataRow["OID"].ToString()); |
||
3840 | } |
||
3841 | else |
||
3842 | { |
||
3843 | int index = dicMultiwaySymbolUID[Teeitem.Relations[1].Item.UID] + 1; |
||
3844 | string multiItemOID = Teeitem.Relations[1].Item.UID + "_M" + index; |
||
3845 | dicMultiwaySymbolUID[Teeitem.Relations[1].Item.UID] = index; |
||
3846 | PathItems.Rows.InsertAt(createMultiWayConnRow(PathItems.Select(string.Format("OID = '{0}'", Teeitem.Relations[1].Item.UID + "_M1")).First(), multiItemOID, dr), insertIndex); |
||
3847 | change = true; |
||
3848 | dr.SetField("BranchTopologySet_OID", string.Empty); |
||
3849 | dr.SetField("ViewPipeSystemNetwork_OID", dataRow["OID"].ToString()); |
||
3850 | |||
3851 | SequenceData.Rows.InsertAt(CreateSequenceDataDataRow(dr, multiItemOID, PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", PSNItem.PSN_OID())).Count()), 0); |
||
3852 | |||
3853 | foreach (DataRow pipedr in pipeSystem) |
||
3854 | { |
||
3855 | pipedr["TO_DATA"] = PathItems.Select(string.Format("OID = '{0}'", Teeitem.Relations[1].Item.UID + "_M1")).First().Field<string>("MULTIWAY"); |
||
3856 | } |
||
3857 | } |
||
3858 | } |
||
3859 | |||
3860 | } |
||
3861 | else if (Teeitem.ItemType == ItemType.Symbol) |
||
3862 | { |
||
3863 | Group _group = groups.Find(x => x.Items.Select(w => w.UID).Contains(Teeitem.UID)); |
||
3864 | var _items = Teeitem.Relations.Where(w => w.Item != null && !_group.Items.Contains(w.Item)).Select(w => w.Item).ToList(); |
||
3865 | if (_items.Count > 0) |
||
3866 | 820e283f | LJIYEON | { |
3867 | d6ef5842 | 이지연 | int index = dicMultiwaySymbolUID[_items[0].UID] + 1; |
3868 | string multiItemOID = _items[0].UID + "_M" + index; |
||
3869 | dicMultiwaySymbolUID[_items[0].UID] = index; |
||
3870 | //newRow["SequenceData_OID"] = string.Format(item.Topology.FullName + "_{0}", index); |
||
3871 | PathItems.Rows.InsertAt(createMultiWayConnRow(PathItems.Select(string.Format("OID = '{0}'", _items[0].UID + "_M1")).First(), multiItemOID, dr), insertIndex); |
||
3872 | 820e283f | LJIYEON | change = true; |
3873 | 0e9d868c | LJIYEON | dr.SetField("BranchTopologySet_OID", string.Empty); |
3874 | dr.SetField("ViewPipeSystemNetwork_OID", dataRow["OID"].ToString()); |
||
3875 | d6ef5842 | 이지연 | SequenceData.Rows.InsertAt(CreateSequenceDataDataRow(dr, multiItemOID, PathItems.Select(string.Format("PipeSystemNetwork_OID = '{0}'", PSNItem.PSN_OID())).Count()), 0); |
3876 | 820e283f | LJIYEON | |
3877 | d6ef5842 | 이지연 | foreach (DataRow pipedr in pipeSystem) |
3878 | { |
||
3879 | pipedr["TO_DATA"] = PathItems.Select(string.Format("OID = '{0}'", _items[0].UID + "_M1")).First().Field<string>("MULTIWAY"); |
||
3880 | } |
||
3881 | } |
||
3882 | 4e2e0aa1 | LJIYEON | } |
3883 | } |
||
3884 | catch (Exception ex) |
||
3885 | { |
||
3886 | 820e283f | LJIYEON | MessageBox.Show("Please check the item.\r\nDrawingName : " + Teeitem.Document.DrawingName + "\r\nUID : " + Teeitem.UID, "ID2 " + id2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Warning); |
3887 | 4e2e0aa1 | LJIYEON | return; |
3888 | } |
||
3889 | } |
||
3890 | |||
3891 | if (change) |
||
3892 | { |
||
3893 | 820e283f | LJIYEON | //DataRow[] pathItemRows = pathItemsDT.Select(string.Format("PipeSystemNetwork_OID = '{0}'", PSNItem.PSN_OID())); |
3894 | 4e2e0aa1 | LJIYEON | int rowIndex = 0; |
3895 | for (int i = 0; i < PathItems.Rows.Count; i++) |
||
3896 | { |
||
3897 | DataRow row = PathItems.Rows[i]; |
||
3898 | 820e283f | LJIYEON | if (row["PipeSystemNetwork_OID"].ToString() != PSNItem.PSN_OID()) |
3899 | 4e2e0aa1 | LJIYEON | continue; |
3900 | string sequenceData = row["SequenceData_OID"].ToString(); |
||
3901 | string[] split = sequenceData.Split(new char[] { '_' }); |
||
3902 | |||
3903 | StringBuilder sb = new StringBuilder(); |
||
3904 | for (int j = 0; j < split.Length - 1; j++) |
||
3905 | sb.Append(split[j] + "_"); |
||
3906 | sb.Append(rowIndex++); |
||
3907 | row["SequenceData_OID"] = sb.ToString(); |
||
3908 | |||
3909 | DataRow seqItemRows = SequenceData.Select(string.Format("PathItem_OID = '{0}'", row["OID"])).FirstOrDefault(); |
||
3910 | int insertSeqIndex = SequenceData.Rows.IndexOf(seqItemRows); |
||
3911 | |||
3912 | string[] splitseq = sb.ToString().Split(new char[] { '_' }); |
||
3913 | |||
3914 | if (seqItemRows == null) |
||
3915 | { |
||
3916 | DataRow newRow = SequenceData.NewRow(); |
||
3917 | newRow["OID"] = sb.ToString(); |
||
3918 | newRow["SERIALNUMBER"] = splitseq[splitseq.Length - 1]; |
||
3919 | newRow["PathItem_OID"] = row["OID"]; |
||
3920 | newRow["TopologySet_OID_Key"] = row["TopologySet_OID"]; |
||
3921 | SequenceData.Rows.InsertAt(newRow, Convert.ToInt32(splitseq[splitseq.Length - 1])); |
||
3922 | } |
||
3923 | else |
||
3924 | { |
||
3925 | seqItemRows["OID"] = sb.ToString(); |
||
3926 | seqItemRows["SERIALNUMBER"] = splitseq[splitseq.Length - 1]; |
||
3927 | seqItemRows["PathItem_OID"] = row["OID"]; |
||
3928 | seqItemRows["TopologySet_OID_Key"] = row["TopologySet_OID"]; |
||
3929 | } |
||
3930 | } |
||
3931 | 820e283f | LJIYEON | } |
3932 | 7106e181 | LJIYEON | |
3933 | 4e2e0aa1 | LJIYEON | DataRow createTeeRow(DataRow itemRow) |
3934 | { |
||
3935 | DataRow newRow = PathItems.NewRow(); |
||
3936 | newRow["OID"] = Guid.NewGuid().ToString(); |
||
3937 | newRow["SequenceData_OID"] = itemRow["SequenceData_OID"]; |
||
3938 | newRow["TopologySet_OID"] = itemRow["TopologySet_OID"]; |
||
3939 | newRow["BranchTopologySet_OID"] = itemRow["BranchTopologySet_OID"]; |
||
3940 | newRow["PipeLine_OID"] = itemRow["PipeLine_OID"]; |
||
3941 | newRow["ITEMNAME"] = "Branch"; //newRow["ITEMNAME"] = "End of line terminator"; |
||
3942 | newRow["ITEMTAG"] = itemRow["ITEMTAG"]; |
||
3943 | newRow["DESCRIPTION"] = ""; |
||
3944 | newRow["Class"] = "Branch"; |
||
3945 | newRow["SubClass"] = "Tee"; |
||
3946 | newRow["TYPE"] = itemRow["TYPE"]; |
||
3947 | d6ef5842 | 이지연 | newRow["MULTIWAY"] = itemRow["MULTIWAY"]; |
3948 | 4e2e0aa1 | LJIYEON | newRow["PIDNAME"] = itemRow["PIDNAME"]; |
3949 | newRow["NPD"] = itemRow["NPD"]; |
||
3950 | newRow["PipeSystemNetwork_OID"] = itemRow["PipeSystemNetwork_OID"]; |
||
3951 | newRow["ViewPipeSystemNetwork_OID"] = itemRow["ViewPipeSystemNetwork_OID"]; |
||
3952 | newRow["PipeRun_OID"] = itemRow["PipeRun_OID"]; |
||
3953 | 0eefef3d | 이지연 | |
3954 | newRow["EGTConnectedPoint"] = 0; |
||
3955 | 4e2e0aa1 | LJIYEON | return newRow; |
3956 | } |
||
3957 | d6ef5842 | 이지연 | |
3958 | DataRow CreateSequenceDataDataRow(DataRow itemRow, string multiItemOID, int index) |
||
3959 | { |
||
3960 | DataRow newRow = SequenceData.NewRow(); |
||
3961 | newRow["OID"] = string.Format(itemRow["TopologySet_OID"].ToString() + "_{0}", index); // string.Format(); |
||
3962 | newRow["SERIALNUMBER"] = string.Format("{0}", index); |
||
3963 | newRow["PathItem_OID"] = multiItemOID; |
||
3964 | newRow["TopologySet_OID_Key"] = itemRow["TopologySet_OID"].ToString();//item.Topology.FullName; |
||
3965 | |||
3966 | return newRow; |
||
3967 | } |
||
3968 | |||
3969 | DataRow createMultiWayConnRow(DataRow itemRow, string multiItemOID, DataRow itemRow2) |
||
3970 | { |
||
3971 | DataRow newRow = PathItems.NewRow(); |
||
3972 | newRow["OID"] = multiItemOID; |
||
3973 | newRow["SequenceData_OID"] = itemRow2["SequenceData_OID"]; |
||
3974 | newRow["TopologySet_OID"] = itemRow2["TopologySet_OID"]; |
||
3975 | newRow["BranchTopologySet_OID"] = itemRow2["BranchTopologySet_OID"]; |
||
3976 | newRow["PipeLine_OID"] = itemRow2["PipeLine_OID"]; |
||
3977 | newRow["ITEMNAME"] = itemRow["ITEMNAME"];// = "End of line terminator"; |
||
3978 | newRow["ITEMTAG"] = itemRow["ITEMTAG"]; |
||
3979 | newRow["DESCRIPTION"] = itemRow["DESCRIPTION"]; |
||
3980 | newRow["Class"] = itemRow["Class"]; |
||
3981 | newRow["SubClass"] = itemRow["SubClass"]; |
||
3982 | newRow["TYPE"] = itemRow["TYPE"]; |
||
3983 | newRow["MULTIWAY"] = itemRow["MULTIWAY"]; |
||
3984 | newRow["PIDNAME"] = itemRow["PIDNAME"]; |
||
3985 | newRow["NPD"] = itemRow["NPD"]; |
||
3986 | newRow["PipeSystemNetwork_OID"] = itemRow2["PipeSystemNetwork_OID"]; |
||
3987 | newRow["ViewPipeSystemNetwork_OID"] = itemRow2["ViewPipeSystemNetwork_OID"]; |
||
3988 | newRow["PipeRun_OID"] = itemRow2["PipeRun_OID"]; |
||
3989 | newRow["EGTConnectedPoint"] = itemRow["EGTConnectedPoint"]; |
||
3990 | return newRow; |
||
3991 | } |
||
3992 | 4e2e0aa1 | LJIYEON | } |
3993 | catch (Exception ex) |
||
3994 | { |
||
3995 | |||
3996 | } |
||
3997 | } |
||
3998 | } |
||
3999 | 6b9e7a56 | gaqhf | } |
4000 | |||
4001 | public class PSNItem |
||
4002 | { |
||
4003 | 8f24b438 | gaqhf | public PSNItem(int count, int Revision) |
4004 | 6b9e7a56 | gaqhf | { |
4005 | Groups = new List<Group>(); |
||
4006 | Topologies = new List<Topology>(); |
||
4007 | 94a117ca | gaqhf | |
4008 | Index = count + 1; |
||
4009 | 8f24b438 | gaqhf | this.Revision = Revision; |
4010 | 6b9e7a56 | gaqhf | } |
4011 | eb44d82c | LJIYEON | |
4012 | 8f24b438 | gaqhf | private int Revision; |
4013 | 6b9e7a56 | gaqhf | public string UID { get; set; } |
4014 | public List<Group> Groups { get; set; } |
||
4015 | public List<Topology> Topologies { get; set; } |
||
4016 | public PSNType StartType { get; set; } |
||
4017 | public PSNType EndType { get; set; } |
||
4018 | 94a117ca | gaqhf | public int Index { get; set; } |
4019 | 72775f2e | LJIYEON | public string IsValid { get; set; } |
4020 | a36541fb | LJIYEON | public bool IsKeyword { get; set; } |
4021 | 36a45f13 | gaqhf | public string Status { get; set; } |
4022 | ddc1c369 | LJIYEON | public string IncludingVirtualData { get; set; } |
4023 | public string PSNAccuracy { get; set; } |
||
4024 | eb44d82c | LJIYEON | public KeywordInfo KeywordInfos = new KeywordInfo(); |
4025 | a36541fb | LJIYEON | public DataTable Nozzle = new DataTable(); |
4026 | ddc1c369 | LJIYEON | |
4027 | 94a117ca | gaqhf | public string PSN_OID() |
4028 | { |
||
4029 | 36a45f13 | gaqhf | return string.Format("V{0}-PSN-{1}", string.Format("{0:D4}", Revision), string.Format("{0:D5}", Index)); |
4030 | 94a117ca | gaqhf | } |
4031 | 3610fd3f | LJIYEON | |
4032 | 94a117ca | gaqhf | public string GetPSNType() |
4033 | { |
||
4034 | string result = string.Empty; |
||
4035 | |||
4036 | if (EnableType(StartType) && EnableType(EndType)) |
||
4037 | { |
||
4038 | if (StartType == PSNType.Equipment && EndType == PSNType.Equipment) |
||
4039 | result = "E2E"; |
||
4040 | else if (StartType == PSNType.Branch && EndType == PSNType.Branch) |
||
4041 | result = "B2B"; |
||
4042 | else if (StartType == PSNType.Header && EndType == PSNType.Header) |
||
4043 | result = "HD2"; |
||
4044 | |||
4045 | else if (StartType == PSNType.Equipment && EndType == PSNType.Branch) |
||
4046 | result = "E2B"; |
||
4047 | else if (StartType == PSNType.Branch && EndType == PSNType.Equipment) |
||
4048 | result = "B2E"; |
||
4049 | |||
4050 | else if (StartType == PSNType.Header && EndType == PSNType.Branch) |
||
4051 | result = "HDB"; |
||
4052 | else if (StartType == PSNType.Branch && EndType == PSNType.Header) |
||
4053 | result = "HDB"; |
||
4054 | |||
4055 | else if (StartType == PSNType.Header && EndType == PSNType.Equipment) |
||
4056 | result = "HDE"; |
||
4057 | else if (StartType == PSNType.Equipment && EndType == PSNType.Header) |
||
4058 | result = "HDE"; |
||
4059 | else |
||
4060 | result = "Error"; |
||
4061 | } |
||
4062 | else |
||
4063 | result = "Error"; |
||
4064 | |||
4065 | return result; |
||
4066 | |||
4067 | 7106e181 | LJIYEON | |
4068 | 94a117ca | gaqhf | } |
4069 | 3610fd3f | LJIYEON | |
4070 | 710a49f1 | gaqhf | public bool EnableType(PSNType type) |
4071 | 94a117ca | gaqhf | { |
4072 | bool result = false; |
||
4073 | |||
4074 | if (type == PSNType.Branch || |
||
4075 | type == PSNType.Equipment || |
||
4076 | type == PSNType.Header) |
||
4077 | { |
||
4078 | result = true; |
||
4079 | } |
||
4080 | |||
4081 | return result; |
||
4082 | } |
||
4083 | 3610fd3f | LJIYEON | |
4084 | 7881ec8f | gaqhf | public bool IsBypass { get; set; } |
4085 | 94a117ca | gaqhf | |
4086 | 23204ef6 | 이지연 | public string GetFromData(ref string Type, ref Item item, Item oItem, ref string OStatus) |
4087 | 94a117ca | gaqhf | { |
4088 | 51974d2b | LJIYEON | Status = string.Empty; |
4089 | 94a117ca | gaqhf | string result = string.Empty; |
4090 | a36541fb | LJIYEON | if (IsKeyword) |
4091 | IsKeyword = false; |
||
4092 | 27d06aa8 | LJIYEON | try |
4093 | 36a45f13 | gaqhf | { |
4094 | 08b33e44 | gaqhf | item = Groups.First().Items.First(); |
4095 | |||
4096 | 27d06aa8 | LJIYEON | if (StartType == PSNType.Header) |
4097 | result = "ENDOFHEADER"; |
||
4098 | else if (StartType == PSNType.Branch) |
||
4099 | { |
||
4100 | dd27861e | 이지연 | if (item.Relations.First().Item.LineNumber != null && !string.IsNullOrEmpty(item.Relations.First().Item.LineNumber.Name)) |
4101 | 27d06aa8 | LJIYEON | result = item.Relations.First().Item.LineNumber.Name; |
4102 | else |
||
4103 | { |
||
4104 | 7106e181 | LJIYEON | IsValid = "Error"; |
4105 | 27d06aa8 | LJIYEON | result = "Empty LineNumber"; |
4106 | } |
||
4107 | 23204ef6 | 이지연 | |
4108 | |||
4109 | |||
4110 | //if (item.Relations.First().Item.LineNumber != null && !string.IsNullOrEmpty(item.Relations.First().Item.LineNumber.Name)) |
||
4111 | //{ |
||
4112 | // result = item.Relations.First().Item.LineNumber.Name; |
||
4113 | // if (item.Relations.First().Item.LineNumber.MissingLineNumber2) |
||
4114 | // { |
||
4115 | // Status += ", Missing LineNumber_2"; |
||
4116 | // IsValid = "Error"; |
||
4117 | // } |
||
4118 | // if (item.Relations.First().Item.LineNumber.MissingLineNumber1) |
||
4119 | // { |
||
4120 | // Status += ", Missing LineNumber_1"; |
||
4121 | // IsValid = "Error"; |
||
4122 | // } |
||
4123 | //} |
||
4124 | //else |
||
4125 | //{ |
||
4126 | // IsValid = "Error"; |
||
4127 | // result = "Empty LineNumber"; |
||
4128 | //} |
||
4129 | 27d06aa8 | LJIYEON | } |
4130 | else if (StartType == PSNType.Equipment) |
||
4131 | a36541fb | LJIYEON | { |
4132 | 3210f690 | LJIYEON | if (Groups.First().Items.First().Equipment != null) |
4133 | result = Groups.First().Items.First().Equipment.ItemTag; |
||
4134 | a36541fb | LJIYEON | DataRow drNozzle = Nozzle.Select(string.Format("OID = '{0}'", Groups.First().Items.First().UID)).FirstOrDefault(); |
4135 | |||
4136 | if (drNozzle != null) |
||
4137 | 7106e181 | LJIYEON | result += " [" + drNozzle.Field<string>("ITEMTAG") + "]"; |
4138 | } |
||
4139 | 36a45f13 | gaqhf | else |
4140 | { |
||
4141 | 2f7c4151 | 이지연 | |
4142 | a5616391 | LJIYEON | item = Groups.First().Items.First(); |
4143 | 27d06aa8 | LJIYEON | if (item.ItemType == ItemType.Symbol) |
4144 | { |
||
4145 | 8ab98ea3 | LJIYEON | string keyword = string.Empty; |
4146 | a5616391 | LJIYEON | keyword = GetFromKeywordData(ref Type, item); |
4147 | 8ab98ea3 | LJIYEON | |
4148 | if (string.IsNullOrEmpty(keyword)) |
||
4149 | { |
||
4150 | if (item.ID2DBType.Contains("OPC's")) |
||
4151 | 51974d2b | LJIYEON | Status += ", OPC Disconnected"; |
4152 | 8ab98ea3 | LJIYEON | else |
4153 | Status += ", Missing ItemTag or Description"; |
||
4154 | |||
4155 | result = item.ID2DBName; |
||
4156 | 2f7c4151 | 이지연 | IsValid = "Error"; |
4157 | 8ab98ea3 | LJIYEON | } |
4158 | else |
||
4159 | eb44d82c | LJIYEON | { |
4160 | 8ab98ea3 | LJIYEON | result = keyword; |
4161 | a36541fb | LJIYEON | IsKeyword = true; |
4162 | eb44d82c | LJIYEON | } |
4163 | 7106e181 | LJIYEON | |
4164 | 27d06aa8 | LJIYEON | } |
4165 | else if (item.ItemType == ItemType.Line) |
||
4166 | { |
||
4167 | 85eeb2be | 이지연 | if (item.LineNumber != null && !string.IsNullOrEmpty(item.LineNumber.Name)) |
4168 | 48870200 | LJIYEON | { |
4169 | 85eeb2be | 이지연 | result = item.LineNumber.Name; |
4170 | 48870200 | LJIYEON | } |
4171 | f6c9db1a | 이지연 | else |
4172 | 85eeb2be | 이지연 | { |
4173 | IsValid = "Error"; |
||
4174 | result = "Empty LineNumber"; |
||
4175 | } |
||
4176 | 23204ef6 | 이지연 | |
4177 | |||
4178 | |||
4179 | 27d06aa8 | LJIYEON | } |
4180 | else |
||
4181 | result = "Unknown"; |
||
4182 | 36a45f13 | gaqhf | } |
4183 | 23204ef6 | 이지연 | |
4184 | if (oItem.LineNumber != null && !string.IsNullOrEmpty(oItem.LineNumber.Name)) |
||
4185 | { |
||
4186 | if (oItem.LineNumber.MissingLineNumber2) |
||
4187 | { |
||
4188 | OStatus += ", Missing LineNumber_2"; |
||
4189 | IsValid = "Error"; |
||
4190 | } |
||
4191 | if (oItem.LineNumber.MissingLineNumber1) |
||
4192 | { |
||
4193 | OStatus += ", Missing LineNumber_1"; |
||
4194 | IsValid = "Error"; |
||
4195 | } |
||
4196 | } |
||
4197 | 36a45f13 | gaqhf | } |
4198 | 7106e181 | LJIYEON | catch (Exception ex) |
4199 | 36a45f13 | gaqhf | { |
4200 | |||
4201 | } |
||
4202 | 94a117ca | gaqhf | |
4203 | return result; |
||
4204 | } |
||
4205 | |||
4206 | a5616391 | LJIYEON | public string GetFromKeywordData(ref string Type, Item item) |
4207 | 879ce10b | LJIYEON | { |
4208 | string result = string.Empty; |
||
4209 | 7106e181 | LJIYEON | |
4210 | foreach (KeywordItem keyitem in KeywordInfos.KeywordItems) |
||
4211 | 879ce10b | LJIYEON | { |
4212 | 7106e181 | LJIYEON | if (keyitem.Name.Equals(item.Name)) |
4213 | a5616391 | LJIYEON | { |
4214 | eb44d82c | LJIYEON | result = keyitem.Keyword; |
4215 | a5616391 | LJIYEON | Type = item.ID2DBType; |
4216 | a2973aa3 | LJIYEON | break; |
4217 | a5616391 | LJIYEON | } |
4218 | 879ce10b | LJIYEON | } |
4219 | 7106e181 | LJIYEON | |
4220 | 879ce10b | LJIYEON | return result; |
4221 | } |
||
4222 | |||
4223 | a5616391 | LJIYEON | public string GetToKeywordData(ref string Type, Item item) |
4224 | 879ce10b | LJIYEON | { |
4225 | string result = string.Empty; |
||
4226 | |||
4227 | eb44d82c | LJIYEON | foreach (KeywordItem keyitem in KeywordInfos.KeywordItems) |
4228 | 879ce10b | LJIYEON | { |
4229 | eb44d82c | LJIYEON | if (keyitem.Name.Equals(item.Name)) |
4230 | a5616391 | LJIYEON | { |
4231 | eb44d82c | LJIYEON | result = keyitem.Keyword; |
4232 | a5616391 | LJIYEON | Type = item.ID2DBType; |
4233 | a2973aa3 | LJIYEON | break; |
4234 | a5616391 | LJIYEON | } |
4235 | 879ce10b | LJIYEON | } |
4236 | return result; |
||
4237 | } |
||
4238 | |||
4239 | 23204ef6 | 이지연 | public string GetToData(ref string ToType, ref Item item, Item oItem) |
4240 | 94a117ca | gaqhf | { |
4241 | string result = string.Empty; |
||
4242 | 51974d2b | LJIYEON | Status = string.Empty; |
4243 | eb44d82c | LJIYEON | |
4244 | a2973aa3 | LJIYEON | if (IsKeyword) |
4245 | IsKeyword = false; |
||
4246 | 3210f690 | LJIYEON | |
4247 | 08b33e44 | gaqhf | item = Groups.Last().Items.Last(); |
4248 | |||
4249 | a2973aa3 | LJIYEON | if (EndType == PSNType.Header) |
4250 | result = "ENDOFHEADER"; |
||
4251 | else if (EndType == PSNType.Branch) |
||
4252 | { |
||
4253 | dd27861e | 이지연 | if (item.Relations.Last().Item.LineNumber != null && !string.IsNullOrEmpty(item.Relations.Last().Item.LineNumber.Name)) |
4254 | a2973aa3 | LJIYEON | result = item.Relations.Last().Item.LineNumber.Name; |
4255 | else |
||
4256 | 36a45f13 | gaqhf | { |
4257 | 85eeb2be | 이지연 | IsValid = "Error"; |
4258 | a2973aa3 | LJIYEON | result = "Empty LineNumber"; |
4259 | 23204ef6 | 이지연 | } |
4260 | |||
4261 | |||
4262 | |||
4263 | //if (item.Relations.Last().Item.LineNumber != null && !string.IsNullOrEmpty(item.Relations.Last().Item.LineNumber.Name)) |
||
4264 | //{ |
||
4265 | // result = item.Relations.Last().Item.LineNumber.Name; |
||
4266 | // if (item.Relations.Last().Item.LineNumber.MissingLineNumber2) |
||
4267 | // { |
||
4268 | // Status += ", Missing LineNumber_2"; |
||
4269 | // IsValid = "Error"; |
||
4270 | // } |
||
4271 | // if (item.Relations.Last().Item.LineNumber.MissingLineNumber1) |
||
4272 | // { |
||
4273 | // Status += ", Missing LineNumber_1"; |
||
4274 | // IsValid = "Error"; |
||
4275 | // } |
||
4276 | //} |
||
4277 | //else |
||
4278 | //{ |
||
4279 | // IsValid = "Error"; |
||
4280 | // result = "Empty LineNumber"; |
||
4281 | //} |
||
4282 | a2973aa3 | LJIYEON | } |
4283 | else if (EndType == PSNType.Equipment) |
||
4284 | { |
||
4285 | 7106e181 | LJIYEON | if (Groups.Last().Items.Last().Equipment != null) |
4286 | a2973aa3 | LJIYEON | result = Groups.Last().Items.Last().Equipment.ItemTag; |
4287 | 8ab98ea3 | LJIYEON | |
4288 | a2973aa3 | LJIYEON | DataRow drNozzle = Nozzle.Select(string.Format("OID = '{0}'", Groups.Last().Items.Last().UID)).FirstOrDefault(); |
4289 | 3210f690 | LJIYEON | |
4290 | a2973aa3 | LJIYEON | if (drNozzle != null) |
4291 | result += " [" + drNozzle.Field<string>("ITEMTAG") + "]"; |
||
4292 | } |
||
4293 | else |
||
4294 | { |
||
4295 | 2f7c4151 | 이지연 | |
4296 | a2973aa3 | LJIYEON | item = Groups.Last().Items.Last(); |
4297 | if (item.ItemType == ItemType.Symbol) |
||
4298 | 3210f690 | LJIYEON | { |
4299 | a2973aa3 | LJIYEON | string keyword = string.Empty; |
4300 | keyword = GetToKeywordData(ref ToType, item); |
||
4301 | 3210f690 | LJIYEON | |
4302 | a2973aa3 | LJIYEON | if (string.IsNullOrEmpty(keyword)) |
4303 | { |
||
4304 | if (item.ID2DBType.Contains("OPC's")) |
||
4305 | 51974d2b | LJIYEON | Status += ", OPC Disconnected"; |
4306 | 8ab98ea3 | LJIYEON | else |
4307 | a2973aa3 | LJIYEON | Status += ", Missing ItemTag or Description"; |
4308 | 8ab98ea3 | LJIYEON | |
4309 | a2973aa3 | LJIYEON | result = item.ID2DBName; |
4310 | 2f7c4151 | 이지연 | IsValid = "Error"; |
4311 | 8ab98ea3 | LJIYEON | } |
4312 | a2973aa3 | LJIYEON | else |
4313 | eb44d82c | LJIYEON | { |
4314 | a2973aa3 | LJIYEON | result = keyword; |
4315 | IsKeyword = true; |
||
4316 | eb44d82c | LJIYEON | } |
4317 | a2973aa3 | LJIYEON | |
4318 | } |
||
4319 | else if (item.ItemType == ItemType.Line) |
||
4320 | { |
||
4321 | 85eeb2be | 이지연 | if (item.LineNumber != null && !string.IsNullOrEmpty(item.LineNumber.Name)) |
4322 | 48870200 | LJIYEON | { |
4323 | 85eeb2be | 이지연 | result = item.LineNumber.Name; |
4324 | 48870200 | LJIYEON | } |
4325 | f6c9db1a | 이지연 | else |
4326 | 85eeb2be | 이지연 | { |
4327 | IsValid = "Error"; |
||
4328 | result = "Empty LineNumber"; |
||
4329 | } |
||
4330 | 23204ef6 | 이지연 | |
4331 | |||
4332 | |||
4333 | 36a45f13 | gaqhf | } |
4334 | a2973aa3 | LJIYEON | else |
4335 | result = "Unknown"; |
||
4336 | } |
||
4337 | 23204ef6 | 이지연 | |
4338 | 94a117ca | gaqhf | return result; |
4339 | } |
||
4340 | 7881ec8f | gaqhf | |
4341 | public string GetPBSData() |
||
4342 | { |
||
4343 | string result = string.Empty; |
||
4344 | List<string> PBSList = new List<string>(); |
||
4345 | if (Settings.Default.PBSSetting.Equals("Line Number")) |
||
4346 | { |
||
4347 | string attrValue = Settings.Default.PBSSettingValue; |
||
4348 | |||
4349 | foreach (Group group in Groups) |
||
4350 | { |
||
4351 | 7106e181 | LJIYEON | List<LineNumber> lineNumbers = group.Items.Select(x => x.LineNumber).Distinct().ToList(); |
4352 | 7881ec8f | gaqhf | foreach (LineNumber lineNumber in lineNumbers) |
4353 | { |
||
4354 | Attribute attribute = lineNumber.Attributes.Find(x => x.Name == attrValue && !string.IsNullOrEmpty(x.Value)); |
||
4355 | if (attribute != null) |
||
4356 | { |
||
4357 | string value = attribute.Value; |
||
4358 | if (!PBSList.Contains(value)) |
||
4359 | PBSList.Add(value); |
||
4360 | } |
||
4361 | } |
||
4362 | } |
||
4363 | } |
||
4364 | else if (Settings.Default.PBSSetting.Equals("Item Attribute")) |
||
4365 | { |
||
4366 | string attrValue = Settings.Default.PBSSettingValue; |
||
4367 | |||
4368 | foreach (Group group in Groups) |
||
4369 | { |
||
4370 | List<Item> items = group.Items.FindAll(x => x.Attributes.Find(y => y.Name == attrValue && !string.IsNullOrEmpty(y.Value)) != null); |
||
4371 | foreach (Item item in items) |
||
4372 | { |
||
4373 | string value = item.Attributes.Find(x => x.Name == attrValue).Value; |
||
4374 | if (!PBSList.Contains(value)) |
||
4375 | PBSList.Add(value); |
||
4376 | } |
||
4377 | } |
||
4378 | } |
||
4379 | else if (Settings.Default.PBSSetting.Equals("Drawing No")) |
||
4380 | { |
||
4381 | string attrValue = Settings.Default.PBSSettingValue; |
||
4382 | |||
4383 | foreach (Group group in Groups) |
||
4384 | { |
||
4385 | List<Document> documents = group.Items.Select(x => x.Document).Distinct().ToList(); |
||
4386 | foreach (Document document in documents) |
||
4387 | { |
||
4388 | string name = document.DrawingName; |
||
4389 | |||
4390 | int startIndex = Settings.Default.PBSSettingStartValue; |
||
4391 | int endIndex = Settings.Default.PBSSettingEndValue; |
||
4392 | |||
4393 | string subStr = name.Substring(startIndex - 1, endIndex - startIndex + 1); |
||
4394 | if (!PBSList.Contains(subStr)) |
||
4395 | PBSList.Add(subStr); |
||
4396 | } |
||
4397 | } |
||
4398 | } |
||
4399 | else if (Settings.Default.PBSSetting.Equals("Unit Area")) |
||
4400 | { |
||
4401 | foreach (Group group in Groups) |
||
4402 | { |
||
4403 | List<Document> documents = group.Items.Select(x => x.Document).Distinct().ToList(); |
||
4404 | foreach (Document document in documents) |
||
4405 | { |
||
4406 | List<TextInfo> textInfos = document.TextInfos.FindAll(x => x.Area == "Unit"); |
||
4407 | foreach (TextInfo textInfo in textInfos) |
||
4408 | { |
||
4409 | if (!PBSList.Contains(textInfo.Value)) |
||
4410 | PBSList.Add(textInfo.Value); |
||
4411 | } |
||
4412 | } |
||
4413 | } |
||
4414 | } |
||
4415 | |||
4416 | foreach (var item in PBSList) |
||
4417 | { |
||
4418 | if (string.IsNullOrEmpty(result)) |
||
4419 | result = item; |
||
4420 | else |
||
4421 | result += ", " + item; |
||
4422 | } |
||
4423 | return result; |
||
4424 | } |
||
4425 | 6b9e7a56 | gaqhf | } |
4426 | } |