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