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