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