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