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