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