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