프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / DTI_PID / SPPIDConverter / BaseModel / Document.cs @ a560e00a

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