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