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