hytos / DTI_PID / SPPIDConverter / BaseModel / Document.cs @ 68e9394a
이력 | 보기 | 이력해설 | 다운로드 (42.1 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.IO; |
7 |
using System.Xml.Linq; |
8 |
using System.Windows.Forms; |
9 |
using Converter.SPPID.Util; |
10 |
|
11 |
namespace Converter.BaseModel |
12 |
{ |
13 |
public class Document |
14 |
{ |
15 |
private string _DWGNAME; |
16 |
private string _SIZE; |
17 |
private double _SIZE_WIDTH; |
18 |
private double _SIZE_HEIGHT; |
19 |
private List<Symbol> _SYMBOLS = new List<Symbol>(); |
20 |
private List<Text> _TEXTINFOS = new List<Text>(); |
21 |
private List<Note> _NOTES = new List<Note>(); |
22 |
private List<Line> _LINES = new List<Line>(); |
23 |
private List<LineNumber> _LINENUMBERS = new List<LineNumber>(); |
24 |
private List<TrimLine> _TRIMLINES = new List<TrimLine>(); |
25 |
private List<EndBreak> _EndBreaks = new List<EndBreak>(); |
26 |
private List<SpecBreak> _SpecBreaks = new List<SpecBreak>(); |
27 |
private List<Equipment> _Equipments = new List<Equipment>(); |
28 |
private bool _Enable; |
29 |
private bool _Validation; |
30 |
private bool _MappingValidation; |
31 |
private string _ValidationMessage = string.Empty; |
32 |
bool validationResult = false; |
33 |
|
34 |
public string ValidationMessage { get => _ValidationMessage; set => _ValidationMessage = value; } |
35 |
|
36 |
public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
37 |
public List<Text> TEXTINFOS { get => _TEXTINFOS; set => _TEXTINFOS = value; } |
38 |
public List<Note> NOTES { get => _NOTES; set => _NOTES = value; } |
39 |
public List<Line> LINES { get => _LINES; set => _LINES = value; } |
40 |
public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
41 |
public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; } |
42 |
public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; } |
43 |
public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; } |
44 |
public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; } |
45 |
public string SIZE |
46 |
{ |
47 |
get |
48 |
{ |
49 |
return _SIZE; |
50 |
} |
51 |
set |
52 |
{ |
53 |
_SIZE = value; |
54 |
string[] pointArr = _SIZE.Split(new char[] { ',' }); |
55 |
if (pointArr.Length == 2) |
56 |
{ |
57 |
_SIZE_WIDTH = Convert.ToDouble(pointArr[0]); |
58 |
_SIZE_HEIGHT = Convert.ToDouble(pointArr[1]); |
59 |
} |
60 |
} |
61 |
} |
62 |
public double SIZE_WIDTH { get => _SIZE_WIDTH; } |
63 |
public double SIZE_HEIGHT { get => _SIZE_HEIGHT; } |
64 |
public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; } |
65 |
public string PATH { get; set; } |
66 |
public bool Enable { get => _Enable; set => _Enable = value; } |
67 |
public bool Validation { get => _Validation; set => _Validation = value; } |
68 |
public bool MappingValidation { get => _MappingValidation; set => _MappingValidation = value; } |
69 |
|
70 |
StringBuilder validationStringBuilder = new StringBuilder(); |
71 |
|
72 |
public Document(string xmlPath) |
73 |
{ |
74 |
validationStringBuilder.AppendLine("Document Path : " + xmlPath); |
75 |
validationStringBuilder.AppendLine(""); |
76 |
try |
77 |
{ |
78 |
if (xmlPath != null) |
79 |
{ |
80 |
PATH = xmlPath; |
81 |
XElement xml = XElement.Load(xmlPath); |
82 |
DWGNAME = xml.Element("DWGNAME").Value; |
83 |
SIZE = xml.Element("SIZE").Value; |
84 |
|
85 |
validationStringBuilder.AppendLine("Drawing Name : " + DWGNAME); |
86 |
validationStringBuilder.AppendLine(""); |
87 |
|
88 |
SetText(xml.Element("TEXTINFOS")); |
89 |
SetNote(xml.Element("NOTES")); |
90 |
SetSymbol(xml.Element("SYMBOLS")); |
91 |
SetLine(xml.Element("LINEINFOS")); |
92 |
SetLineNumber(xml.Element("LINENOS")); |
93 |
SetTrimLine(xml.Element("TRIMLINENOS")); |
94 |
|
95 |
SetAllConnectors(); |
96 |
Enable = true; |
97 |
ValidationCheck(); |
98 |
} |
99 |
} |
100 |
catch (Exception ex) |
101 |
{ |
102 |
Enable = false; |
103 |
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
104 |
} |
105 |
} |
106 |
|
107 |
#region READ XML |
108 |
private void SetSymbol(XElement node) |
109 |
{ |
110 |
foreach (XElement item in node.Elements("SYMBOL")) |
111 |
{ |
112 |
string sType = item.Element("TYPE").Value; |
113 |
if (sType == "Segment Breaks") |
114 |
{ |
115 |
SpecBreak specBreak = new SpecBreak() |
116 |
{ |
117 |
UID = item.Element("UID").Value, |
118 |
DBUID = item.Element("DBUID").Value, |
119 |
NAME = item.Element("NAME").Value, |
120 |
TYPE = item.Element("TYPE").Value, |
121 |
OWNER = item.Element("OWNER").Value, |
122 |
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
123 |
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
124 |
LOCATION = item.Element("LOCATION").Value, |
125 |
SIZE = item.Element("SIZE").Value, |
126 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
127 |
PARENT = item.Element("PARENT").Value, |
128 |
CHILD = item.Element("CHILD").Value, |
129 |
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
130 |
AREA = item.Element("AREA").Value, |
131 |
FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
132 |
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
133 |
}; |
134 |
SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS); |
135 |
SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT); |
136 |
SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES); |
137 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES); |
138 |
SetSpecBreakAttribute(specBreak); |
139 |
|
140 |
SpecBreaks.Add(specBreak); |
141 |
} |
142 |
else if (sType == "End Break") |
143 |
{ |
144 |
EndBreak endBreak = new EndBreak() |
145 |
{ |
146 |
UID = item.Element("UID").Value, |
147 |
DBUID = item.Element("DBUID").Value, |
148 |
NAME = item.Element("NAME").Value, |
149 |
TYPE = item.Element("TYPE").Value, |
150 |
OWNER = item.Element("OWNER").Value, |
151 |
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
152 |
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
153 |
LOCATION = item.Element("LOCATION").Value, |
154 |
SIZE = item.Element("SIZE").Value, |
155 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
156 |
PARENT = item.Element("PARENT").Value, |
157 |
CHILD = item.Element("CHILD").Value, |
158 |
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
159 |
AREA = item.Element("AREA").Value, |
160 |
FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
161 |
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
162 |
}; |
163 |
SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS); |
164 |
SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT); |
165 |
SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES); |
166 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES); |
167 |
|
168 |
EndBreaks.Add(endBreak); |
169 |
} |
170 |
else if (sType == "Black Box System" || |
171 |
sType == "GGO_Equipment" || |
172 |
sType == "Heat Transfer Equipment" || |
173 |
sType == "Mechanical" || |
174 |
sType == "Other Equipment" || |
175 |
sType == "Vessels") |
176 |
{ |
177 |
Equipment equipment = new Equipment() |
178 |
{ |
179 |
UID = item.Element("UID").Value, |
180 |
DBUID = item.Element("DBUID").Value, |
181 |
NAME = item.Element("NAME").Value, |
182 |
TYPE = item.Element("TYPE").Value, |
183 |
OWNER = item.Element("OWNER").Value, |
184 |
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
185 |
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
186 |
LOCATION = item.Element("LOCATION").Value, |
187 |
SIZE = item.Element("SIZE").Value, |
188 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
189 |
PARENT = item.Element("PARENT").Value, |
190 |
CHILD = item.Element("CHILD").Value, |
191 |
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
192 |
AREA = item.Element("AREA").Value, |
193 |
FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
194 |
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
195 |
}; |
196 |
SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS); |
197 |
SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT); |
198 |
SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES); |
199 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES); |
200 |
|
201 |
Equipments.Add(equipment); |
202 |
} |
203 |
else |
204 |
{ |
205 |
Symbol symbol = new Symbol() |
206 |
{ |
207 |
UID = item.Element("UID").Value, |
208 |
DBUID = item.Element("DBUID").Value, |
209 |
NAME = item.Element("NAME").Value, |
210 |
TYPE = item.Element("TYPE").Value, |
211 |
OWNER = item.Element("OWNER").Value, |
212 |
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
213 |
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
214 |
LOCATION = item.Element("LOCATION").Value, |
215 |
SIZE = item.Element("SIZE").Value, |
216 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
217 |
PARENT = item.Element("PARENT").Value, |
218 |
CHILD = item.Element("CHILD").Value, |
219 |
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
220 |
AREA = item.Element("AREA").Value, |
221 |
FLIP = Convert.ToInt32(item.Element("FLIP").Value), |
222 |
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value) |
223 |
}; |
224 |
|
225 |
SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS); |
226 |
SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT); |
227 |
SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES); |
228 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES); |
229 |
SetChildSymbol(symbol); |
230 |
|
231 |
SYMBOLS.Add(symbol); |
232 |
} |
233 |
} |
234 |
} |
235 |
|
236 |
private void SetLine(XElement node) |
237 |
{ |
238 |
foreach (XElement item in node.Elements("LINE")) |
239 |
{ |
240 |
Line line = new Line() |
241 |
{ |
242 |
OWNER = item.Attribute("OWNER").Value, |
243 |
UID = item.Element("UID").Value, |
244 |
STARTPOINT = item.Element("STARTPOINT").Value, |
245 |
ENDPOINT = item.Element("ENDPOINT").Value, |
246 |
TYPE = item.Element("TYPE").Value, |
247 |
TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value, |
248 |
AREA = item.Element("AREA").Value, |
249 |
THICKNESS = item.Element("THICKNESS").Value, |
250 |
}; |
251 |
int flowMarkPercent = 0; |
252 |
if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent)) |
253 |
{ |
254 |
line.FLOWMARK = true; |
255 |
line.FLOWMARK_PERCENT = flowMarkPercent; |
256 |
} |
257 |
else |
258 |
line.FLOWMARK = false; |
259 |
|
260 |
SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS); |
261 |
SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS); |
262 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES); |
263 |
LINES.Add(line); |
264 |
} |
265 |
} |
266 |
|
267 |
private void SetLineNumber(XElement node) |
268 |
{ |
269 |
foreach (XElement item in node.Elements("LINE_NO")) |
270 |
{ |
271 |
LineNumber lineNumber = new LineNumber() |
272 |
{ |
273 |
UID = item.Element("UID").Value, |
274 |
TEXT = item.Element("TEXT").Value, |
275 |
LOCATION = item.Element("LOCATION").Value, |
276 |
WIDTH = item.Element("WIDTH").Value, |
277 |
HEIGHT = item.Element("HEIGHT").Value, |
278 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
279 |
AREA = item.Element("AREA").Value, |
280 |
SCENE = item.Element("SCENE").Value |
281 |
}; |
282 |
if (item.Element("CONNLINE") != null) |
283 |
lineNumber.CONNLINE = item.Element("CONNLINE").Value; |
284 |
else |
285 |
{ |
286 |
validationStringBuilder.AppendLine("Not exist CONNLINE!" + "\r\nLineNumber UID : " + lineNumber.UID); |
287 |
validationStringBuilder.AppendLine(); |
288 |
validationResult = true; |
289 |
} |
290 |
|
291 |
SetLineNumberRuns(item, lineNumber.RUNS); |
292 |
SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES); |
293 |
SetAttributes(item, lineNumber.ATTRIBUTES); |
294 |
LINENUMBERS.Add(lineNumber); |
295 |
} |
296 |
} |
297 |
|
298 |
private void SetText(XElement node) |
299 |
{ |
300 |
foreach (XElement item in node.Elements("ATTRIBUTE")) |
301 |
{ |
302 |
Text text = new Text() |
303 |
{ |
304 |
UID = item.Element("UID").Value, |
305 |
OWNER = item.Element("OWNER").Value, |
306 |
ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value, |
307 |
NAME = item.Element("NAME").Value, |
308 |
LOCATION = item.Element("LOCATION").Value, |
309 |
VALUE = item.Element("VALUE").Value, |
310 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
311 |
WIDTH = item.Element("WIDTH").Value, |
312 |
HEIGHT = item.Element("HEIGHT").Value, |
313 |
AREA = item.Element("AREA").Value, |
314 |
SCENE = item.Element("SCENE").Value |
315 |
}; |
316 |
|
317 |
TEXTINFOS.Add(text); |
318 |
} |
319 |
} |
320 |
|
321 |
private void SetNote(XElement node) |
322 |
{ |
323 |
foreach (XElement item in node.Elements("ATTRIBUTE")) |
324 |
{ |
325 |
Note note = new Note() |
326 |
{ |
327 |
UID = item.Element("UID").Value, |
328 |
ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value, |
329 |
NAME = item.Element("NAME").Value, |
330 |
LOCATION = item.Element("LOCATION").Value, |
331 |
VALUE = item.Element("VALUE").Value, |
332 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
333 |
WIDTH = item.Element("WIDTH").Value, |
334 |
HEIGHT = item.Element("HEIGHT").Value, |
335 |
AREA = item.Element("AREA").Value, |
336 |
SCENE = item.Element("SCENE").Value, |
337 |
OWNER = item.Element("OWNER").Value |
338 |
}; |
339 |
|
340 |
NOTES.Add(note); |
341 |
} |
342 |
} |
343 |
|
344 |
private void SetTrimLine(XElement node) |
345 |
{ |
346 |
foreach (XElement item in node.Elements("TRIM_LINE_NO")) |
347 |
{ |
348 |
TrimLine trimLine = new TrimLine() |
349 |
{ |
350 |
UID = item.Element("UID").Value, |
351 |
}; |
352 |
SetLineNumberRuns(item, trimLine.RUNS); |
353 |
TRIMLINES.Add(trimLine); |
354 |
} |
355 |
} |
356 |
|
357 |
private void SetAssociations(XElement node, List<Association> associations) |
358 |
{ |
359 |
foreach (XElement item in node.Elements("ASSOCIATION")) |
360 |
{ |
361 |
Association association = new Association() |
362 |
{ |
363 |
TYPE = item.Attribute("TYPE").Value, |
364 |
VALUE = item.Value |
365 |
}; |
366 |
|
367 |
associations.Add(association); |
368 |
} |
369 |
} |
370 |
|
371 |
private void SetConnectors(XElement node, List<Connector> connectors) |
372 |
{ |
373 |
foreach (XElement item in node.Elements("CONNECTOR")) |
374 |
{ |
375 |
connectors.Add(new Connector() |
376 |
{ |
377 |
UID = item.Attribute("UID").Value, |
378 |
CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
379 |
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
380 |
CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
381 |
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
382 |
}); |
383 |
} |
384 |
} |
385 |
|
386 |
private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT) |
387 |
{ |
388 |
foreach (XElement item in node.Elements("CONNECTOR")) |
389 |
{ |
390 |
connectors.Add(new Connector() |
391 |
{ |
392 |
UID = item.Attribute("UID").Value, |
393 |
CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value), |
394 |
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
395 |
CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
396 |
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
397 |
}); |
398 |
} |
399 |
} |
400 |
|
401 |
private void SetProperties(XElement node, List<Property> properties) |
402 |
{ |
403 |
foreach (XElement item in node.Elements("PROPERTY")) |
404 |
{ |
405 |
properties.Add(new Property() |
406 |
{ |
407 |
UID = item.Attribute("UID").Value, |
408 |
LENGTH = item.Attribute("Length").Value, |
409 |
EXPRESSION = item.Attribute("Expression").Value, |
410 |
DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value, |
411 |
ATTRIBUTETYPE = item.Attribute("AttributeType").Value, |
412 |
ATTRIBUTE = item.Attribute("Attribute").Value, |
413 |
VALUE = item.Value |
414 |
}); |
415 |
} |
416 |
} |
417 |
|
418 |
private void SetAttributes(XElement node, List<Attribute> attributes) |
419 |
{ |
420 |
foreach (XElement item in node.Elements("ATTRIBUTE")) |
421 |
{ |
422 |
Attribute attribute = new Attribute() |
423 |
{ |
424 |
UID = item.Attribute("UID").Value, |
425 |
LENGTH = item.Attribute("Length").Value, |
426 |
EXPRESSION = item.Attribute("Expression").Value, |
427 |
DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value, |
428 |
ATTRIBUTETYPE = item.Attribute("AttributeType").Value, |
429 |
ATTRIBUTE = item.Attribute("Attribute").Value, |
430 |
ATTRAT = item.Attribute("AttrAt").Value, |
431 |
ASSOCITEM = item.Attribute("AssocItem").Value, |
432 |
VALUE = item.Value |
433 |
}; |
434 |
|
435 |
attributes.Add(attribute); |
436 |
|
437 |
if (!string.IsNullOrEmpty(attribute.ASSOCITEM) && attribute.ASSOCITEM != "None") |
438 |
{ |
439 |
Text text = _TEXTINFOS.Find(x => x.UID == attribute.ASSOCITEM); |
440 |
if (text != null) |
441 |
text.ASSOCIATION = true; |
442 |
} |
443 |
} |
444 |
} |
445 |
|
446 |
private void SetSpecBreakAttribute(SpecBreak specBreak) |
447 |
{ |
448 |
string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE; |
449 |
string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE; |
450 |
|
451 |
specBreak.UpStreamUID = upStream; |
452 |
specBreak.DownStreamUID = downStream; |
453 |
} |
454 |
|
455 |
private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns) |
456 |
{ |
457 |
foreach (XElement item in node.Elements("RUN")) |
458 |
{ |
459 |
LineRun run = new LineRun() |
460 |
{ |
461 |
TYPE = item.Attribute("TYPE").Value |
462 |
}; |
463 |
|
464 |
foreach (XElement element in item.Elements()) |
465 |
{ |
466 |
if (element.Name == "SYMBOL") |
467 |
{ |
468 |
Symbol symbol = GetSymbolByUID(element.Element("UID").Value); |
469 |
if (symbol == null) |
470 |
{ |
471 |
validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value); |
472 |
validationStringBuilder.AppendLine(); |
473 |
validationResult = true; |
474 |
} |
475 |
run.RUNITEMS.Add(symbol); |
476 |
} |
477 |
else if (element.Name == "LINE") |
478 |
{ |
479 |
Line line = GetLineByUID(element.Element("UID").Value); |
480 |
if (line == null) |
481 |
{ |
482 |
validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value); |
483 |
validationStringBuilder.AppendLine(); |
484 |
validationResult = true; |
485 |
} |
486 |
run.RUNITEMS.Add(line); |
487 |
} |
488 |
} |
489 |
lineNumberRuns.Add(run); |
490 |
} |
491 |
} |
492 |
|
493 |
private void SetChildSymbol(Symbol symbol) |
494 |
{ |
495 |
List<ChildSymbol> childList = new List<ChildSymbol>(); |
496 |
if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None") |
497 |
{ |
498 |
string[] childArray = symbol.CHILD.Split(new char[] { '/' }); |
499 |
foreach (string sChild in childArray) |
500 |
{ |
501 |
string[] sChildInfo = sChild.Split(new char[] { ',' }); |
502 |
childList.Add(new ChildSymbol() |
503 |
{ |
504 |
ParentAt = Convert.ToInt32(sChildInfo[0]), |
505 |
Direction = sChildInfo[1], |
506 |
NAME = sChildInfo[2] |
507 |
}); |
508 |
} |
509 |
|
510 |
foreach (ChildSymbol child in childList) |
511 |
{ |
512 |
if (child.ParentAt == 0) |
513 |
symbol.ChildSymbols.Add(child); |
514 |
else |
515 |
childList[child.ParentAt - 1].ChildSymbols.Add(child); |
516 |
} |
517 |
} |
518 |
if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None") |
519 |
{ |
520 |
// 현재 부모 Symbol에 자식 Connector까지 들어가 있음 |
521 |
string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
522 |
string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' }); |
523 |
for (int i = 0; i < array.Length; i++) |
524 |
{ |
525 |
string[] arrConn = array[i].Split(new char[] { ',' }); |
526 |
int connIndex = Convert.ToInt32(arrConn[3]); |
527 |
if (connIndex != 0) |
528 |
{ |
529 |
childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]); |
530 |
symbol.CONNECTORS[i].Index = connIndex; |
531 |
} |
532 |
} |
533 |
} |
534 |
} |
535 |
#endregion |
536 |
|
537 |
public Symbol GetSymbolByUID(string uid) |
538 |
{ |
539 |
return SYMBOLS.Find(x => x.UID == uid); |
540 |
} |
541 |
|
542 |
public Line GetLineByUID(string uid) |
543 |
{ |
544 |
return LINES.Find(x => x.UID == uid); |
545 |
} |
546 |
|
547 |
public void SetAllConnectors() |
548 |
{ |
549 |
foreach (var item in SYMBOLS) |
550 |
foreach (var connector in item.CONNECTORS) |
551 |
connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
552 |
|
553 |
foreach (var item in LINES) |
554 |
foreach (var connector in item.CONNECTORS) |
555 |
connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
556 |
|
557 |
foreach (var item in Equipments) |
558 |
foreach (var connector in item.CONNECTORS) |
559 |
connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
560 |
} |
561 |
|
562 |
|
563 |
|
564 |
public void ValidationCheck() |
565 |
{ |
566 |
|
567 |
#region Connection Check / Symbol의 SceneConnectPoint Check |
568 |
foreach (var item in _SYMBOLS) |
569 |
{ |
570 |
foreach (var connector in item.CONNECTORS) |
571 |
{ |
572 |
if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Line)) |
573 |
{ |
574 |
Line line = connector.ConnectedObject as Line; |
575 |
if (line.CONNECTORS.Find(x => x.ConnectedObject == item) == null) |
576 |
{ |
577 |
validationStringBuilder.AppendLine("Check connection!"); |
578 |
validationStringBuilder.AppendLine("Symbol UID : " + item.UID); |
579 |
validationStringBuilder.AppendLine("Line UID : " + line.UID); |
580 |
validationStringBuilder.AppendLine(); |
581 |
validationResult = true; |
582 |
} |
583 |
} |
584 |
|
585 |
if (connector.SCENECONNECTPOINT == connector.CONNECTPOINT) |
586 |
{ |
587 |
validationStringBuilder.AppendLine("Check Symbol SceneConnectPoint!"); |
588 |
validationStringBuilder.AppendLine("Symbol UID : " + item.UID); |
589 |
validationStringBuilder.AppendLine(); |
590 |
validationResult = true; |
591 |
} |
592 |
} |
593 |
} |
594 |
|
595 |
foreach (var item in _LINES) |
596 |
{ |
597 |
foreach (var connector in item.CONNECTORS) |
598 |
{ |
599 |
if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Symbol)) |
600 |
{ |
601 |
Symbol symbol = connector.ConnectedObject as Symbol; |
602 |
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null) |
603 |
{ |
604 |
validationStringBuilder.AppendLine("Check connection!"); |
605 |
validationStringBuilder.AppendLine("Symbol UID : " + symbol.UID); |
606 |
validationStringBuilder.AppendLine("Line UID : " + item.UID); |
607 |
validationStringBuilder.AppendLine(); |
608 |
validationResult = true; |
609 |
} |
610 |
} |
611 |
} |
612 |
} |
613 |
#endregion |
614 |
|
615 |
#region Symbol Size Check |
616 |
foreach (var item in _SYMBOLS) |
617 |
{ |
618 |
if (item.SIZE == "0,0") |
619 |
{ |
620 |
validationStringBuilder.AppendLine("Check symbol size!"); |
621 |
validationStringBuilder.AppendLine("Symbol UID : " + item.UID); |
622 |
validationStringBuilder.AppendLine(); |
623 |
validationResult = true; |
624 |
} |
625 |
} |
626 |
#endregion |
627 |
|
628 |
#region SpecBreak, EndBreak Check |
629 |
foreach (var item in SpecBreaks) |
630 |
{ |
631 |
object obj1 = SPPIDUtil.FindObjectByUID(this, item.UpStreamUID); |
632 |
object obj2 = SPPIDUtil.FindObjectByUID(this, item.DownStreamUID); |
633 |
if (obj1 == null || obj2 == null) |
634 |
{ |
635 |
validationStringBuilder.AppendLine("Check SpecBreak UpStream, DownStream!"); |
636 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
637 |
validationStringBuilder.AppendLine(); |
638 |
validationResult = true; |
639 |
} |
640 |
else |
641 |
{ |
642 |
|
643 |
bool result = false; |
644 |
if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Symbol)) |
645 |
{ |
646 |
Symbol symbol1 = obj1 as Symbol; |
647 |
Symbol symbol2 = obj2 as Symbol; |
648 |
if (symbol1.CONNECTORS.Find(x => x.ConnectedObject == symbol2) == null || symbol2.CONNECTORS.Find(x => x.ConnectedObject == symbol1) == null) |
649 |
result = true; |
650 |
} |
651 |
else if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Line)) |
652 |
{ |
653 |
Symbol symbol = obj1 as Symbol; |
654 |
Line line = obj2 as Line; |
655 |
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null) |
656 |
result = true; |
657 |
} |
658 |
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Symbol)) |
659 |
{ |
660 |
Symbol symbol = obj2 as Symbol; |
661 |
Line line = obj1 as Line; |
662 |
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null) |
663 |
result = true; |
664 |
} |
665 |
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line)) |
666 |
{ |
667 |
Line line1 = obj2 as Line; |
668 |
Line line2 = obj1 as Line; |
669 |
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2); |
670 |
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1); |
671 |
if (connector1 == null && connector2 == null) |
672 |
result = true; |
673 |
} |
674 |
|
675 |
if (result) |
676 |
{ |
677 |
validationStringBuilder.AppendLine("Check SpecBreak UpStream, DownStream!"); |
678 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
679 |
validationStringBuilder.AppendLine(); |
680 |
validationResult = true; |
681 |
} |
682 |
|
683 |
// Rule |
684 |
if (!result) |
685 |
{ |
686 |
if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line)) |
687 |
{ |
688 |
Line line1 = obj1 as Line; |
689 |
Line line2 = obj2 as Line; |
690 |
|
691 |
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2); |
692 |
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1); |
693 |
if (connector1 != null && connector2 != null) |
694 |
{ |
695 |
int connectorIndex = line1.CONNECTORS.IndexOf(connector1); |
696 |
if (connectorIndex != 0 && !SPPIDUtil.IsBranchLine(line1)) |
697 |
result = true; |
698 |
else if (connectorIndex == 0 && !SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2)) |
699 |
result = true; |
700 |
|
701 |
if (result) |
702 |
{ |
703 |
validationStringBuilder.AppendLine("Check Segment Rule!"); |
704 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
705 |
validationStringBuilder.AppendLine(); |
706 |
validationResult = true; |
707 |
} |
708 |
} |
709 |
} |
710 |
} |
711 |
} |
712 |
} |
713 |
|
714 |
foreach (var item in EndBreaks) |
715 |
{ |
716 |
object obj1 = SPPIDUtil.FindObjectByUID(this, item.OWNER); |
717 |
object obj2 = SPPIDUtil.FindObjectByUID(this, item.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE); |
718 |
if (obj1 == null || obj2 == null) |
719 |
{ |
720 |
validationStringBuilder.AppendLine("Check EndBreak Owner, Connected Item!"); |
721 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
722 |
validationStringBuilder.AppendLine(); |
723 |
validationResult = true; |
724 |
} |
725 |
else |
726 |
{ |
727 |
bool result = false; |
728 |
if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Symbol)) |
729 |
{ |
730 |
Symbol symbol1 = obj1 as Symbol; |
731 |
Symbol symbol2 = obj2 as Symbol; |
732 |
if (symbol1.CONNECTORS.Find(x => x.ConnectedObject == symbol2) == null || symbol2.CONNECTORS.Find(x => x.ConnectedObject == symbol1) == null) |
733 |
result = true; |
734 |
} |
735 |
else if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Line)) |
736 |
{ |
737 |
Symbol symbol = obj1 as Symbol; |
738 |
Line line = obj2 as Line; |
739 |
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null) |
740 |
result = true; |
741 |
} |
742 |
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Symbol)) |
743 |
{ |
744 |
Symbol symbol = obj2 as Symbol; |
745 |
Line line = obj1 as Line; |
746 |
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null) |
747 |
result = true; |
748 |
} |
749 |
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line)) |
750 |
{ |
751 |
Line line1 = obj2 as Line; |
752 |
Line line2 = obj1 as Line; |
753 |
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2); |
754 |
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1); |
755 |
if (connector1 == null && connector2 == null) |
756 |
result = true; |
757 |
} |
758 |
|
759 |
if (result) |
760 |
{ |
761 |
validationStringBuilder.AppendLine("Check EndBreak Owner, Connected Item!"); |
762 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
763 |
validationStringBuilder.AppendLine(); |
764 |
validationResult = true; |
765 |
} |
766 |
|
767 |
// Rule |
768 |
if (!result) |
769 |
{ |
770 |
if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line)) |
771 |
{ |
772 |
Line line1 = obj1 as Line; |
773 |
Line line2 = obj2 as Line; |
774 |
|
775 |
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2); |
776 |
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1); |
777 |
|
778 |
if (connector1 != null && connector2 != null) |
779 |
{ |
780 |
int connectorIndex = line1.CONNECTORS.IndexOf(connector1); |
781 |
if (connectorIndex != 0 && !SPPIDUtil.IsBranchLine(line1)) |
782 |
result = true; |
783 |
else if (connectorIndex != 0 && SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2)) |
784 |
result = true; |
785 |
else if (connectorIndex == 0 && !SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2)) |
786 |
result = true; |
787 |
} |
788 |
else if (SPPIDUtil.IsBranchLine(line1, line2)) |
789 |
{ |
790 |
if (connector1 == null) |
791 |
result = true; |
792 |
} |
793 |
|
794 |
if (result) |
795 |
{ |
796 |
validationStringBuilder.AppendLine("Check Segment Rule!"); |
797 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
798 |
validationStringBuilder.AppendLine(); |
799 |
validationResult = true; |
800 |
} |
801 |
} |
802 |
} |
803 |
} |
804 |
} |
805 |
|
806 |
#endregion |
807 |
|
808 |
#region Check Flow Direction |
809 |
List<string[]> flowDirectionCheck = new List<string[]>(); |
810 |
foreach (var line in LINES) |
811 |
{ |
812 |
foreach (var connector in line.CONNECTORS) |
813 |
{ |
814 |
if (connector.ConnectedObject != null && |
815 |
connector.ConnectedObject.GetType() == typeof(Line) && |
816 |
!SPPIDUtil.IsBranchLine(line, connector.ConnectedObject as Line)) |
817 |
{ |
818 |
Line connLine = connector.ConnectedObject as Line; |
819 |
int lineIndex1 = line.CONNECTORS.IndexOf(connector); |
820 |
int lineIndex2 = connLine.CONNECTORS.IndexOf(connLine.CONNECTORS.Find(x => x.ConnectedObject == line)); |
821 |
if (lineIndex1 == lineIndex2 && flowDirectionCheck.Find(x => (x[0] == line.UID || x[1] == connLine.UID) || (x[1] == line.UID || x[0] == connLine.UID)) == null) |
822 |
{ |
823 |
validationStringBuilder.AppendLine("Check line flow direction!"); |
824 |
validationStringBuilder.AppendLine("UID : " + line.UID); |
825 |
validationStringBuilder.AppendLine("UID : " + connLine.UID); |
826 |
validationStringBuilder.AppendLine(); |
827 |
validationResult = true; |
828 |
flowDirectionCheck.Add(new string[] { line.UID, connLine.UID }); |
829 |
} |
830 |
} |
831 |
} |
832 |
} |
833 |
|
834 |
foreach (var item in SYMBOLS.FindAll(x => x.CONNECTORS.Count == 2 && |
835 |
x.CONNECTORS[0].ConnectedObject != null && x.CONNECTORS[0].ConnectedObject.GetType() == typeof(Line) && |
836 |
x.CONNECTORS[1].ConnectedObject != null && x.CONNECTORS[1].ConnectedObject.GetType() == typeof(Line))) |
837 |
{ |
838 |
Line line1 = item.CONNECTORS[0].ConnectedObject as Line; |
839 |
Line line2 = item.CONNECTORS[1].ConnectedObject as Line; |
840 |
if (line1.TYPE == line2.TYPE) |
841 |
{ |
842 |
int index1 = line1.CONNECTORS.IndexOf(line1.CONNECTORS.Find(x => x.ConnectedObject == item)); |
843 |
int index2 = line2.CONNECTORS.IndexOf(line2.CONNECTORS.Find(x => x.ConnectedObject == item)); |
844 |
if (index1 == index2) |
845 |
{ |
846 |
validationStringBuilder.AppendLine("Check line flow direction!"); |
847 |
validationStringBuilder.AppendLine("UID : " + line1.UID); |
848 |
validationStringBuilder.AppendLine("UID : " + line2.UID); |
849 |
validationStringBuilder.AppendLine(); |
850 |
validationResult = true; |
851 |
} |
852 |
} |
853 |
} |
854 |
#endregion |
855 |
|
856 |
#region Association Check |
857 |
foreach (var item in TEXTINFOS) |
858 |
{ |
859 |
if (item.ASSOCIATION) |
860 |
{ |
861 |
object owner = SPPIDUtil.FindObjectByUID(this, item.OWNER); |
862 |
if (owner == null) |
863 |
{ |
864 |
validationStringBuilder.AppendLine("Check text owner!"); |
865 |
validationStringBuilder.AppendLine("Text UID : " + item.UID); |
866 |
foreach (var associationItem in SYMBOLS.FindAll(x => x.ATTRIBUTES.Find(y => y.ASSOCITEM == item.UID) != null)) |
867 |
validationStringBuilder.AppendLine("Association UID : " + associationItem.UID); |
868 |
|
869 |
validationStringBuilder.AppendLine(); |
870 |
validationResult = true; |
871 |
} |
872 |
} |
873 |
} |
874 |
#endregion |
875 |
|
876 |
#region Line To Line Type Check |
877 |
List<string[]> typeCheck = new List<string[]>(); |
878 |
foreach (var item in LINES) |
879 |
{ |
880 |
foreach (var connector in item.CONNECTORS) |
881 |
{ |
882 |
Line connLine = connector.ConnectedObject as Line; |
883 |
if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) != null && |
884 |
connLine.TYPE != item.TYPE && |
885 |
typeCheck.Find(x => (x[0] == item.UID || x[1] == connLine.UID) || (x[1] == item.UID || x[0] == connLine.UID)) == null) |
886 |
{ |
887 |
validationStringBuilder.AppendLine("Check line type!"); |
888 |
validationStringBuilder.AppendLine("UID : " + item.UID); |
889 |
validationStringBuilder.AppendLine("UID : " + connLine.UID); |
890 |
validationStringBuilder.AppendLine(); |
891 |
validationResult = true; |
892 |
typeCheck.Add(new string[] { item.UID, connLine.UID }); |
893 |
} |
894 |
} |
895 |
} |
896 |
#endregion |
897 |
|
898 |
if (validationResult) |
899 |
{ |
900 |
Validation = false; |
901 |
Enable = false; |
902 |
_ValidationMessage += validationStringBuilder.ToString(); |
903 |
} |
904 |
else |
905 |
{ |
906 |
Validation = true; |
907 |
Enable = true; |
908 |
} |
909 |
} |
910 |
} |
911 |
} |