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