프로젝트

일반

사용자정보

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

hytos / DTI_PID / SPPIDConverter / BaseModel / Document.cs @ 919bb48e

이력 | 보기 | 이력해설 | 다운로드 (52.5 KB)

1
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
using Converter.SPPID.Util;
10
using System.Data;
11

    
12
namespace Converter.BaseModel
13
{
14
    public class Document
15
    {
16
        public List<Line> VentDrainLine = new List<Line>();
17
        public List<Symbol> VentDrainSymbol = new List<Symbol>();
18

    
19
        private string _DWGNAME;
20
        private string _SIZE;
21
        private double _SIZE_WIDTH;
22
        private double _SIZE_HEIGHT;
23
        private string _UID;
24
        private List<Symbol> _SYMBOLS = new List<Symbol>();
25
        private List<Text> _TEXTINFOS = new List<Text>();
26
        private List<Note> _NOTES = new List<Note>();
27
        private List<Line> _LINES = new List<Line>();
28
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
29
        private List<TrimLine> _TRIMLINES = new List<TrimLine>();
30
        private List<EndBreak> _EndBreaks = new List<EndBreak>();
31
        private List<SpecBreak> _SpecBreaks = new List<SpecBreak>();
32
        private List<Equipment> _Equipments = new List<Equipment>();
33
        private List<VendorPackage> _VendorPackages = new List<VendorPackage>();
34
        private List<Graphic> _Graphics = new List<Graphic>();
35
        private bool _Enable;
36
        private bool _Validation;
37
        private bool _MappingValidation;
38
        private string _ValidationMessage = string.Empty;
39
        bool validationResult = false;
40
        private DataTable ID2SymbolTypeDT;
41

    
42
        public string ValidationMessage { get => _ValidationMessage; set => _ValidationMessage = value; }
43

    
44
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
45
        public List<Text> TEXTINFOS { get => _TEXTINFOS; set => _TEXTINFOS = value; }
46
        public List<Note> NOTES { get => _NOTES; set => _NOTES = value; }
47
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
48
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
49
        public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; }
50
        public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; }
51
        public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; }
52
        public List<VendorPackage> VendorPackages { get => _VendorPackages; set => _VendorPackages = value; }
53
        public List<Graphic> Graphics { get => _Graphics; set => _Graphics = value; }
54
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
55
        public string SIZE
56
        {
57
            get
58
            {
59
                return _SIZE;
60
            }
61
            set
62
            {
63
                _SIZE = value;
64
                string[] pointArr = _SIZE.Split(new char[] { ',' });
65
                if (pointArr.Length == 2)
66
                {
67
                    _SIZE_WIDTH = Convert.ToDouble(pointArr[0]);
68
                    _SIZE_HEIGHT = Convert.ToDouble(pointArr[1]);
69
                }
70
            }
71
        }
72
        public double SIZE_WIDTH { get => _SIZE_WIDTH; }
73
        public double SIZE_HEIGHT { get => _SIZE_HEIGHT; }
74
        public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; }
75
        public string PATH { get; set; }
76
        public bool Enable { get => _Enable; set => _Enable = value; }
77
        public bool Validation { get => _Validation; set => _Validation = value; }
78
        public bool MappingValidation { get => _MappingValidation; set => _MappingValidation = value; }
79
        public string UID { get => _UID; set => _UID = value; }
80

    
81
        StringBuilder validationStringBuilder = new StringBuilder();
82

    
83
        public Document(string xmlPath, DataTable ID2SymbolTypeDT)
84
        {
85
            this.ID2SymbolTypeDT = ID2SymbolTypeDT;
86
            validationStringBuilder.AppendLine("Document Path : " + xmlPath);
87
            validationStringBuilder.AppendLine("");
88
            try
89
            {
90
                if (xmlPath != null)
91
                {
92
                    PATH = xmlPath;
93
                    XElement xml = XElement.Load(xmlPath);
94
                    DWGNAME = xml.Element("DWGNAME").Value;
95
                    SIZE = xml.Element("SIZE").Value;
96

    
97
                    validationStringBuilder.AppendLine("Drawing Name : " + DWGNAME);
98
                    validationStringBuilder.AppendLine("");
99

    
100
                    SetText(xml.Element("TEXTINFOS"));
101
                    SetNote(xml.Element("NOTES"));
102
                    SetSymbol(xml.Element("SYMBOLS"));
103
                    SetLine(xml.Element("LINEINFOS"));
104
                    SetLineNumber(xml.Element("LINENOS"));
105
                    SetTrimLine(xml.Element("TRIMLINENOS"));
106
                    SetVendorPackage(xml.Element("VENDORS"));
107
                    SetGraphic(xml.Element("GRAPHICS"));
108

    
109
                    SetAllConnectors();
110
                    Enable = true;
111
                    ValidationCheck();
112
                    SetVentDrainItem();
113
                }
114
            }
115
            catch (Exception ex)
116
            {
117
                Enable = false;
118
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
119
            }
120
        }
121

    
122
        #region READ XML
123
        private void SetSymbol(XElement node)
124
        {
125
            foreach (XElement item in node.Elements("SYMBOL"))
126
            {
127
                string sType = item.Element("TYPE").Value;
128

    
129
                DataRow[] rows = ID2SymbolTypeDT.Select(string.Format("Type = '{0}'", sType.Replace("'", "''")));
130
                string sCategory = rows[0]["Category"].ToString();
131

    
132
                if (sType == "Segment Breaks")
133
                {
134
                    SpecBreak specBreak = new SpecBreak()
135
                    {
136
                        UID = item.Element("UID").Value,
137
                        DBUID = item.Element("DBUID").Value,
138
                        NAME = item.Element("NAME").Value,
139
                        TYPE = item.Element("TYPE").Value,
140
                        OWNER = item.Element("OWNER").Value,
141
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
142
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
143
                        LOCATION = item.Element("LOCATION").Value,
144
                        SIZE = item.Element("SIZE").Value,
145
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
146
                        PARENT = item.Element("PARENT").Value,
147
                        CHILD = item.Element("CHILD").Value,
148
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
149
                        AREA = item.Element("AREA").Value,
150
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
151
                        //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
152
                    };
153
                    SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS);
154
                    SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT);
155
                    SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES);
156
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES);
157
                    SetSpecBreakAttribute(specBreak);
158

    
159
                    SpecBreaks.Add(specBreak);
160
                }
161
                else if (sType == "End Break")
162
                {
163
                    EndBreak endBreak = new EndBreak()
164
                    {
165
                        UID = item.Element("UID").Value,
166
                        DBUID = item.Element("DBUID").Value,
167
                        NAME = item.Element("NAME").Value,
168
                        TYPE = item.Element("TYPE").Value,
169
                        OWNER = item.Element("OWNER").Value,
170
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
171
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
172
                        LOCATION = item.Element("LOCATION").Value,
173
                        SIZE = item.Element("SIZE").Value,
174
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
175
                        PARENT = item.Element("PARENT").Value,
176
                        CHILD = item.Element("CHILD").Value,
177
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
178
                        AREA = item.Element("AREA").Value,
179
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
180
                        //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
181
                    };
182
                    SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS);
183
                    SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT);
184
                    SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES);
185
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES);
186

    
187
                    EndBreaks.Add(endBreak);
188
                }
189
                else if (sCategory == "Equipment" ||
190
                    sCategory == "Equipment Components")
191
                {
192
                    Equipment equipment = new Equipment()
193
                    {
194
                        UID = item.Element("UID").Value,
195
                        DBUID = item.Element("DBUID").Value,
196
                        NAME = item.Element("NAME").Value,
197
                        TYPE = item.Element("TYPE").Value,
198
                        OWNER = item.Element("OWNER").Value,
199
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
200
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
201
                        LOCATION = item.Element("LOCATION").Value,
202
                        SIZE = item.Element("SIZE").Value,
203
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
204
                        PARENT = item.Element("PARENT").Value,
205
                        CHILD = item.Element("CHILD").Value,
206
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
207
                        AREA = item.Element("AREA").Value,
208
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
209
                        //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
210
                    };
211
                    SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS);
212
                    SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT);
213
                    SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES);
214
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES);
215

    
216
                    Equipments.Add(equipment);
217
                }
218
                else
219
                {
220
                    Symbol symbol = new Symbol()
221
                    {
222
                        UID = item.Element("UID").Value,
223
                        DBUID = item.Element("DBUID").Value,
224
                        NAME = item.Element("NAME").Value,
225
                        TYPE = item.Element("TYPE").Value,
226
                        OWNER = item.Element("OWNER").Value,
227
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
228
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
229
                        LOCATION = item.Element("LOCATION").Value,
230
                        SIZE = item.Element("SIZE").Value,
231
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
232
                        PARENT = item.Element("PARENT").Value,
233
                        CHILD = item.Element("CHILD").Value,
234
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
235
                        AREA = item.Element("AREA").Value,
236
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
237
                        //CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
238
                    };
239

    
240
                    SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
241
                    SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
242
                    SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
243
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
244
                    SetChildSymbol(symbol);
245

    
246
                    SYMBOLS.Add(symbol);
247
                }
248
            }
249
        }
250

    
251
        private void SetLine(XElement node)
252
        {
253
            foreach (XElement item in node.Elements("LINE"))
254
            {
255
                Line line = new Line()
256
                {
257
                    OWNER = item.Attribute("OWNER").Value,
258
                    UID = item.Element("UID").Value,
259
                    STARTPOINT = item.Element("STARTPOINT").Value,
260
                    ENDPOINT = item.Element("ENDPOINT").Value,
261
                    TYPE = item.Element("TYPE").Value,
262
                    TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value,
263
                    AREA = item.Element("AREA").Value,
264
                    THICKNESS = item.Element("THICKNESS").Value,
265
                };
266
                int flowMarkPercent = 0;
267
                if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent))
268
                {
269
                    line.FLOWMARK = true;
270
                    line.FLOWMARK_PERCENT = flowMarkPercent;
271
                }
272
                else
273
                    line.FLOWMARK = false;
274

    
275
                SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS);
276
                SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS);
277
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES);
278
                LINES.Add(line);
279
            }
280
        }
281

    
282
        private void SetLineNumber(XElement node)
283
        {
284
            foreach (XElement item in node.Elements("LINE_NO"))
285
            {
286
                LineNumber lineNumber = new LineNumber()
287
                {
288
                    UID = item.Element("UID").Value,
289
                    TEXT = item.Element("TEXT").Value,
290
                    LOCATION = item.Element("LOCATION").Value,
291
                    WIDTH = item.Element("WIDTH").Value,
292
                    HEIGHT = item.Element("HEIGHT").Value,
293
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
294
                    AREA = item.Element("AREA").Value,
295
                    SCENE = item.Element("SCENE").Value
296
                };
297
                if (item.Element("CONNLINE") != null)
298
                    lineNumber.CONNLINE = item.Element("CONNLINE").Value;
299
                else
300
                {
301
                    validationStringBuilder.AppendLine("Not exist CONNLINE!" + "\r\nLineNumber UID : " + lineNumber.UID);
302
                    validationStringBuilder.AppendLine();
303
                    validationResult = true;
304
                }
305

    
306
                SetLineNumberRuns(item, lineNumber.RUNS);
307
                SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES);
308
                SetAttributes(item, lineNumber.ATTRIBUTES);
309
                LINENUMBERS.Add(lineNumber);
310
            }
311
        }
312

    
313
        private void SetText(XElement node)
314
        {
315
            foreach (XElement item in node.Elements("ATTRIBUTE"))
316
            {
317
                Text text = new Text()
318
                {
319
                    UID = item.Element("UID").Value,
320
                    OWNER = item.Element("OWNER").Value,
321
                    ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
322
                    NAME = item.Element("NAME").Value,
323
                    LOCATION = item.Element("LOCATION").Value,
324
                    VALUE = item.Element("VALUE").Value,
325
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
326
                    WIDTH = item.Element("WIDTH").Value,
327
                    HEIGHT = item.Element("HEIGHT").Value,
328
                    AREA = item.Element("AREA").Value,
329
                    SCENE = item.Element("SCENE").Value
330
                };
331
                TEXTINFOS.Add(text);
332
            }
333
        }
334

    
335
        private void SetNote(XElement node)
336
        {
337
            foreach (XElement item in node.Elements("ATTRIBUTE"))
338
            {
339
                Note note = new Note()
340
                {
341
                    UID = item.Element("UID").Value,
342
                    ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
343
                    NAME = item.Element("NAME").Value,
344
                    LOCATION = item.Element("LOCATION").Value,
345
                    VALUE = item.Element("VALUE").Value,
346
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
347
                    WIDTH = item.Element("WIDTH").Value,
348
                    HEIGHT = item.Element("HEIGHT").Value,
349
                    AREA = item.Element("AREA").Value,
350
                    SCENE = item.Element("SCENE").Value,
351
                    OWNER = item.Element("OWNER").Value
352
                };
353

    
354
                NOTES.Add(note);
355
            }
356
        }
357

    
358
        private void SetTrimLine(XElement node)
359
        {
360
            foreach (XElement item in node.Elements("TRIM_LINE_NO"))
361
            {
362
                TrimLine trimLine = new TrimLine()
363
                {
364
                    UID = item.Element("UID").Value,
365
                };
366
                SetLineNumberRuns(item, trimLine.RUNS);
367
                TRIMLINES.Add(trimLine);
368
            }
369
        }
370

    
371
        private void SetVendorPackage(XElement node)
372
        {
373
            foreach (XElement item in node.Elements("VENDOR"))
374
            {
375
                VendorPackage vendorPackage = new VendorPackage()
376
                {
377
                    UID = item.Element("UID").Value,
378
                    AREA = item.Element("AREA").Value,
379
                    POINT = item.Element("POINT").Value
380
                };
381
                _VendorPackages.Add(vendorPackage);
382
            }
383
        }
384

    
385
        private void SetGraphic(XElement node)
386
        {
387
            foreach (XElement item in node.Elements("GRAPHIC"))
388
            {
389
                Graphic graphic = new Graphic()
390
                {
391
                    UID = item.Element("UID").Value,
392
                    NAME = item.Element("NAME").Value,
393
                    LOCATION_1 = item.Element("LOCATION1").Value,
394
                    LOCATION_2 = item.Element("LOCATION2").Value,
395
                };
396
                Graphics.Add(graphic);
397
            }
398
        }
399

    
400
        private void SetAssociations(XElement node, List<Association> associations)
401
        {
402
            foreach (XElement item in node.Elements("ASSOCIATION"))
403
            {
404
                Association association = new Association()
405
                {
406
                    TYPE = item.Attribute("TYPE").Value,
407
                    VALUE = item.Value
408
                };
409

    
410
                associations.Add(association);
411
            }
412
        }
413

    
414
        private void SetConnectors(XElement node, List<Connector> connectors)
415
        {
416
            foreach (XElement item in node.Elements("CONNECTOR"))
417
            {
418
                connectors.Add(new Connector()
419
                {
420
                    UID = item.Attribute("UID").Value,
421
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
422
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
423
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
424
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
425
                });
426
            }
427
        }
428

    
429
        private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT)
430
        {
431
            foreach (XElement item in node.Elements("CONNECTOR"))
432
            {
433
                connectors.Add(new Connector()
434
                {
435
                    UID = item.Attribute("UID").Value,
436
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
437
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
438
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
439
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
440
                });
441
            }
442
        }
443

    
444
        private void SetProperties(XElement node, List<Property> properties)
445
        {
446
            foreach (XElement item in node.Elements("PROPERTY"))
447
            {
448
                properties.Add(new Property()
449
                {
450
                    UID = item.Attribute("UID").Value,
451
                    LENGTH = item.Attribute("Length").Value,
452
                    EXPRESSION = item.Attribute("Expression").Value,
453
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
454
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
455
                    ATTRIBUTE = item.Attribute("Attribute").Value,
456
                    VALUE = item.Value
457
                });
458
            }
459
        }
460

    
461
        private void SetAttributes(XElement node, List<Attribute> attributes)
462
        {
463
            foreach (XElement item in node.Elements("ATTRIBUTE"))
464
            {
465
                Attribute attribute = new Attribute()
466
                {
467
                    UID = item.Attribute("UID").Value,
468
                    LENGTH = item.Attribute("Length").Value,
469
                    EXPRESSION = item.Attribute("Expression").Value,
470
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
471
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
472
                    ATTRIBUTE = item.Attribute("Attribute").Value,
473
                    ATTRAT = item.Attribute("AttrAt").Value,
474
                    ASSOCITEM = item.Attribute("AssocItem").Value,
475
                    VALUE = item.Value
476
                };
477

    
478
                attributes.Add(attribute);
479

    
480
                if (!string.IsNullOrEmpty(attribute.ASSOCITEM) && attribute.ASSOCITEM != "None")
481
                {
482
                    Text text = _TEXTINFOS.Find(x => x.UID == attribute.ASSOCITEM);
483
                    if (text != null)
484
                        text.ASSOCIATION = true;
485
                }
486
            }
487
        }
488

    
489
        private void SetSpecBreakAttribute(SpecBreak specBreak)
490
        {
491
            string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE;
492
            string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE;
493

    
494
            specBreak.UpStreamUID = upStream;
495
            specBreak.DownStreamUID = downStream;
496
        }
497

    
498
        private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns)
499
        {
500
            foreach (XElement item in node.Elements("RUN"))
501
            {
502
                LineRun run = new LineRun()
503
                {
504
                    TYPE = item.Attribute("TYPE").Value
505
                };
506

    
507
                foreach (XElement element in item.Elements())
508
                {
509
                    if (element.Name == "SYMBOL")
510
                    {
511
                        Symbol symbol = GetSymbolByUID(element.Element("UID").Value);
512
                        Equipment equipment = GetEquipmentByUID(element.Element("UID").Value);
513
                        if (symbol == null && equipment == null)
514
                        {
515
                            validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
516
                            validationStringBuilder.AppendLine();
517
                            validationResult = true;
518
                        }
519
                        if (symbol != null)
520
                            run.RUNITEMS.Add(symbol);
521
                        else if (equipment != null)
522
                            run.RUNITEMS.Add(equipment);
523
                    }
524
                    else if (element.Name == "LINE")
525
                    {
526
                        Line line = GetLineByUID(element.Element("UID").Value);
527
                        if (line == null)
528
                        {
529
                            validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
530
                            validationStringBuilder.AppendLine();
531
                            validationResult = true;
532
                        }
533
                        run.RUNITEMS.Add(line);
534
                    }
535
                }
536
                lineNumberRuns.Add(run);
537
            }
538
        }
539

    
540
        private void SetChildSymbol(Symbol symbol)
541
        {
542
            List<ChildSymbol> childList = new List<ChildSymbol>();
543
            if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None")
544
            {
545
                string[] childArray = symbol.CHILD.Split(new char[] { '/' });
546
                foreach (string sChild in childArray)
547
                {
548
                    string[] sChildInfo = sChild.Split(new char[] { ',' });
549
                    childList.Add(new ChildSymbol()
550
                    {
551
                        ParentAt = Convert.ToInt32(sChildInfo[0]),
552
                        Direction = sChildInfo[1],
553
                        NAME = sChildInfo[2]
554
                    });
555
                }
556

    
557
                foreach (ChildSymbol child in childList)
558
                {
559
                    if (child.ParentAt == 0)
560
                        symbol.ChildSymbols.Add(child);
561
                    else
562
                        childList[child.ParentAt - 1].ChildSymbols.Add(child);
563
                }
564
            }
565
            if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None")
566
            {
567
                // 현재 부모 Symbol에 자식 Connector까지 들어가 있음
568
                string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
569
                string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
570
                for (int i = 0; i < array.Length; i++)
571
                {
572
                    string[] arrConn = array[i].Split(new char[] { ',' });
573
                    int connIndex = Convert.ToInt32(arrConn[3]);
574
                    if (connIndex != 0)
575
                    {
576
                        childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
577
                        symbol.CONNECTORS[i].Index = connIndex;
578
                    }
579
                }
580
            }
581
        }
582
        #endregion
583

    
584
        public Symbol GetSymbolByUID(string uid)
585
        {
586
            return SYMBOLS.Find(x => x.UID == uid);
587
        }
588

    
589
        public Equipment GetEquipmentByUID(string uid)
590
        {
591
            return Equipments.Find(x => x.UID == uid);
592
        }
593

    
594
        public Line GetLineByUID(string uid)
595
        {
596
            return LINES.Find(x => x.UID == uid);
597
        }
598

    
599
        public void SetAllConnectors()
600
        {
601
            foreach (var item in SYMBOLS)
602
                foreach (var connector in item.CONNECTORS)
603
                    connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
604

    
605
            foreach (var item in LINES)
606
                foreach (var connector in item.CONNECTORS)
607
                    connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
608

    
609
            foreach (var item in Equipments)
610
                foreach (var connector in item.CONNECTORS)
611
                    connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
612
        }
613

    
614
        public void ValidationCheck()
615
        {
616
           
617
            #region Connection Check / Symbol의 SceneConnectPoint Check
618
            foreach (var item in _SYMBOLS)
619
            {
620
                foreach (var connector in item.CONNECTORS)
621
                {
622
                    if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Line))
623
                    {
624
                        Line line = connector.ConnectedObject as Line;
625
                        if (line.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
626
                        {
627
                            validationStringBuilder.AppendLine("Check connection!");
628
                            validationStringBuilder.AppendLine("Symbol UID : " + item.UID);
629
                            validationStringBuilder.AppendLine("Line UID : " + line.UID);
630
                            validationStringBuilder.AppendLine();
631
                            validationResult = true;
632
                        }
633
                    }
634

    
635
                    if (connector.SCENECONNECTPOINT == connector.CONNECTPOINT)
636
                    {
637
                        validationStringBuilder.AppendLine("Check Symbol SceneConnectPoint!");
638
                        validationStringBuilder.AppendLine("Symbol UID : " + item.UID);
639
                        validationStringBuilder.AppendLine();
640
                        validationResult = true;
641
                    }
642
                }
643
            }
644

    
645
            foreach (var item in _LINES)
646
            {
647
                foreach (var connector in item.CONNECTORS)
648
                {
649
                    if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Symbol))
650
                    {
651
                        Symbol symbol = connector.ConnectedObject as Symbol;
652
                        if (symbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
653
                        {
654
                            validationStringBuilder.AppendLine("Check connection!");
655
                            validationStringBuilder.AppendLine("Symbol UID : " + symbol.UID);
656
                            validationStringBuilder.AppendLine("Line UID : " + item.UID);
657
                            validationStringBuilder.AppendLine();
658
                            validationResult = true;
659
                        }
660
                    }
661
                }
662
            }
663
            #endregion
664

    
665
            #region Symbol Size Check
666
            foreach (var item in _SYMBOLS)
667
            {
668
                if (item.SIZE == "0,0")
669
                {
670
                    validationStringBuilder.AppendLine("Check symbol size!");
671
                    validationStringBuilder.AppendLine("Symbol UID : " + item.UID);
672
                    validationStringBuilder.AppendLine();
673
                    validationResult = true;
674
                }
675
            }
676
            #endregion
677

    
678
            #region SpecBreak, EndBreak Check
679
            foreach (var item in SpecBreaks)
680
            {
681
                object obj1 = SPPIDUtil.FindObjectByUID(this, item.UpStreamUID);
682
                object obj2 = SPPIDUtil.FindObjectByUID(this, item.DownStreamUID);
683
                if (obj1 == null || obj2 == null)
684
                {
685
                    validationStringBuilder.AppendLine("Check SpecBreak UpStream, DownStream!");
686
                    validationStringBuilder.AppendLine("UID : " + item.UID);
687
                    validationStringBuilder.AppendLine();
688
                    validationResult = true;
689
                }
690
                else
691
                {
692

    
693
                    bool result = false;
694
                    if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Symbol))
695
                    {
696
                        Symbol symbol1 = obj1 as Symbol;
697
                        Symbol symbol2 = obj2 as Symbol;
698
                        if (symbol1.CONNECTORS.Find(x => x.ConnectedObject == symbol2) == null || symbol2.CONNECTORS.Find(x => x.ConnectedObject == symbol1) == null)
699
                            result = true;
700
                    }
701
                    else if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Line))
702
                    {
703
                        Symbol symbol = obj1 as Symbol;
704
                        Line line = obj2 as Line;
705
                        if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
706
                            result = true;
707
                    }
708
                    else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Symbol))
709
                    {
710
                        Symbol symbol = obj2 as Symbol;
711
                        Line line = obj1 as Line;
712
                        if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
713
                            result = true;
714
                    }
715
                    else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
716
                    {
717
                        Line line1 = obj2 as Line;
718
                        Line line2 = obj1 as Line;
719
                        Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
720
                        Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
721
                        if (connector1 == null && connector2 == null)
722
                            result = true;
723
                    }
724

    
725
                    if (result)
726
                    {
727
                        validationStringBuilder.AppendLine("Check SpecBreak UpStream, DownStream!");
728
                        validationStringBuilder.AppendLine("UID : " + item.UID);
729
                        validationStringBuilder.AppendLine();
730
                        validationResult = true;
731
                    }
732

    
733
                    // Rule
734
                    if (!result)
735
                    {
736
                        if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
737
                        {
738
                            Line line1 = obj1 as Line;
739
                            Line line2 = obj2 as Line;
740

    
741
                            Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
742
                            Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
743

    
744
                            if (connector1 != null && connector2 != null)
745
                            {
746
                                int connectorIndex = line1.CONNECTORS.IndexOf(connector1);
747
                                if (connectorIndex != 0 && !SPPIDUtil.IsBranchLine(line1))
748
                                    result = true;
749
                                else if (connectorIndex != 0 && SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
750
                                    result = true;
751
                                else if (connectorIndex == 0 && !SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
752
                                    result = true;
753
                            }
754
                            else if (SPPIDUtil.IsBranchLine(line1, line2))
755
                            {
756
                                if (connector1 == null)
757
                                    result = true;
758
                            }
759

    
760
                            if (result)
761
                            {
762
                                validationStringBuilder.AppendLine("Check Segment Rule!");
763
                                validationStringBuilder.AppendLine("UID : " + item.UID);
764
                                validationStringBuilder.AppendLine();
765
                                validationResult = true;
766
                            }
767
                        }
768
                    }
769
                }
770
            }
771

    
772
            foreach (var item in EndBreaks)
773
            {
774
                object obj1 = SPPIDUtil.FindObjectByUID(this, item.OWNER);
775
                object obj2 = SPPIDUtil.FindObjectByUID(this, item.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE);
776
                if (obj1 == null || obj2 == null)
777
                {
778
                    validationStringBuilder.AppendLine("Check EndBreak Owner, Connected Item!");
779
                    validationStringBuilder.AppendLine("UID : " + item.UID);
780
                    validationStringBuilder.AppendLine();
781
                    validationResult = true;
782
                }
783
                else
784
                {
785
                    bool result = false;
786
                    if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Symbol))
787
                    {
788
                        Symbol symbol1 = obj1 as Symbol;
789
                        Symbol symbol2 = obj2 as Symbol;
790
                        if (symbol1.CONNECTORS.Find(x => x.ConnectedObject == symbol2) == null || symbol2.CONNECTORS.Find(x => x.ConnectedObject == symbol1) == null)
791
                            result = true;
792
                    }
793
                    else if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Line))
794
                    {
795
                        Symbol symbol = obj1 as Symbol;
796
                        Line line = obj2 as Line;
797
                        if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
798
                            result = true;
799
                    }
800
                    else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Symbol))
801
                    {
802
                        Symbol symbol = obj2 as Symbol;
803
                        Line line = obj1 as Line;
804
                        if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
805
                            result = true;
806
                    }
807
                    else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
808
                    {
809
                        Line line1 = obj2 as Line;
810
                        Line line2 = obj1 as Line;
811
                        Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
812
                        Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
813
                        if (connector1 == null && connector2 == null)
814
                            result = true;
815
                    }
816

    
817
                    if (result)
818
                    {
819
                        validationStringBuilder.AppendLine("Check EndBreak Owner, Connected Item!");
820
                        validationStringBuilder.AppendLine("UID : " + item.UID);
821
                        validationStringBuilder.AppendLine();
822
                        validationResult = true;
823
                    }
824

    
825
                    // Rule
826
                    if (!result) 
827
                    {
828
                        if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
829
                        {
830
                            Line line1 = obj1 as Line;
831
                            Line line2 = obj2 as Line;
832

    
833
                            Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
834
                            Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
835

    
836
                            if (connector1 != null && connector2 != null)
837
                            {
838
                                int connectorIndex = line1.CONNECTORS.IndexOf(connector1);
839
                                if (connectorIndex != 0 && !SPPIDUtil.IsBranchLine(line1))
840
                                    result = true;
841
                                else if (connectorIndex != 0 && SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
842
                                    result = true;
843
                                else if (connectorIndex == 0 && !SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
844
                                    result = true;
845
                            }
846
                            else if (SPPIDUtil.IsBranchLine(line1, line2))
847
                            {
848
                                if (connector1 == null)
849
                                    result = true;
850
                            }
851

    
852
                            if (result)
853
                            {
854
                                validationStringBuilder.AppendLine("Check Segment Rule!");
855
                                validationStringBuilder.AppendLine("UID : " + item.UID);
856
                                validationStringBuilder.AppendLine();
857
                                validationResult = true;
858
                            }
859
                        }
860
                    }
861
                }
862
            }
863

    
864
            #endregion
865

    
866
            #region Check Flow Direction
867
            List<string[]> flowDirectionCheck = new List<string[]>();
868
            foreach (var line in LINES)
869
            {
870
                if (line.TYPE != "Secondary" && line.TYPE != "Primary")
871
                    continue;
872

    
873
                foreach (var connector in line.CONNECTORS)
874
                {
875
                    if (connector.ConnectedObject != null &&
876
                        connector.ConnectedObject.GetType() == typeof(Line) &&
877
                        !SPPIDUtil.IsBranchLine(line, connector.ConnectedObject as Line))
878
                    {
879
                        Line connLine = connector.ConnectedObject as Line;
880
                        if (connLine.TYPE != "Secondary" && connLine.TYPE != "Primary")
881
                            continue;
882
                        int lineIndex1 = line.CONNECTORS.IndexOf(connector);
883
                        int lineIndex2 = connLine.CONNECTORS.IndexOf(connLine.CONNECTORS.Find(x => x.ConnectedObject == line));
884
                        if (lineIndex1 == lineIndex2 && flowDirectionCheck.Find(x => (x[0] == line.UID || x[1] == connLine.UID) || (x[1] == line.UID || x[0] == connLine.UID)) == null)
885
                        {
886
                            validationStringBuilder.AppendLine("Check line flow direction!");
887
                            validationStringBuilder.AppendLine("UID : " + line.UID);
888
                            validationStringBuilder.AppendLine("UID : " + connLine.UID);
889
                            validationStringBuilder.AppendLine();
890
                            validationResult = true;
891
                            flowDirectionCheck.Add(new string[] { line.UID, connLine.UID });
892
                        }
893
                    }
894
                }
895
            }
896

    
897
            foreach (var item in SYMBOLS.FindAll(x => x.CONNECTORS.Count == 2 &&
898
            x.CONNECTORS[0].ConnectedObject != null && x.CONNECTORS[0].ConnectedObject.GetType() == typeof(Line) &&
899
            x.CONNECTORS[1].ConnectedObject != null && x.CONNECTORS[1].ConnectedObject.GetType() == typeof(Line)))
900
            {
901
                Line line1 = item.CONNECTORS[0].ConnectedObject as Line;
902
                Line line2 = item.CONNECTORS[1].ConnectedObject as Line;
903
                if (line1.TYPE == line2.TYPE)
904
                {
905
                    int index1 = line1.CONNECTORS.IndexOf(line1.CONNECTORS.Find(x => x.ConnectedObject == item));
906
                    int index2 = line2.CONNECTORS.IndexOf(line2.CONNECTORS.Find(x => x.ConnectedObject == item));
907
                    if (index1 == index2)
908
                    {
909
                        validationStringBuilder.AppendLine("Check line flow direction!");
910
                        validationStringBuilder.AppendLine("UID : " + line1.UID);
911
                        validationStringBuilder.AppendLine("UID : " + line2.UID);
912
                        validationStringBuilder.AppendLine();
913
                        validationResult = true;
914
                    }
915
                }
916
            }
917
            #endregion
918

    
919
            #region Association Check
920
            foreach (var item in TEXTINFOS)
921
            {
922
                if (item.ASSOCIATION)
923
                {
924
                    object owner = SPPIDUtil.FindObjectByUID(this, item.OWNER);
925
                    if (owner == null)
926
                    {
927
                        validationStringBuilder.AppendLine("Check text owner!");
928
                        validationStringBuilder.AppendLine("Text UID : " + item.UID);
929
                        foreach (var associationItem in SYMBOLS.FindAll(x => x.ATTRIBUTES.Find(y => y.ASSOCITEM == item.UID) != null))
930
                            validationStringBuilder.AppendLine("Association UID : " + associationItem.UID);
931

    
932
                        validationStringBuilder.AppendLine();
933
                        validationResult = true;
934
                    }
935
                }
936
            }
937
            #endregion
938

    
939
            #region Line To Line Type Check
940
            List<string[]> typeCheck = new List<string[]>();
941
            foreach (var item in LINES)
942
            {
943
                foreach (var connector in item.CONNECTORS)
944
                {
945
                    Line connLine = connector.ConnectedObject as Line;
946
                    if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) != null && 
947
                        connLine.TYPE != item.TYPE &&
948
                        typeCheck.Find(x => (x[0] == item.UID || x[1] == connLine.UID) || (x[1] == item.UID || x[0] == connLine.UID)) == null)
949
                    {
950
                        validationStringBuilder.AppendLine("Check line type!");
951
                        validationStringBuilder.AppendLine("UID : " + item.UID);
952
                        validationStringBuilder.AppendLine("UID : " + connLine.UID);
953
                        validationStringBuilder.AppendLine();
954
                        validationResult = true;
955
                        typeCheck.Add(new string[] { item.UID, connLine.UID });
956
                    }
957
                }
958
            }
959
            #endregion
960

    
961
            #region ConnenctionCheck
962
            List<string[]> connectionCheck = new List<string[]>();
963
            foreach (var item in _LINES)
964
            {
965
                List<string> connectedItem = new List<string>();
966
                foreach (var connector in item.CONNECTORS)
967
                {
968
                    if (connector.ConnectedObject != null)
969
                    {
970
                        Symbol connSymbol = connector.ConnectedObject as Symbol;
971
                        Line connLine = connector.ConnectedObject as Line;
972
                        string connUID = string.Empty;
973
                        bool result = false;
974
                        if (connSymbol != null && connSymbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
975
                        {
976
                            result = true;
977
                            connUID = connSymbol.UID;
978
                        }
979
                        else if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) == null && !SPPIDUtil.IsBranchLine(connLine, item))
980
                        {
981
                            result = true;
982
                            connUID = connLine.UID;
983
                        }
984

    
985
                        if (result && connectionCheck.Find(x => (x[0] == item.UID || x[1] == connUID) || (x[1] == item.UID || x[0] == connUID)) == null)
986
                        {
987
                            validationStringBuilder.AppendLine("Check connection!");
988
                            validationStringBuilder.AppendLine("UID : " + item.UID);
989
                            validationStringBuilder.AppendLine("UID : " + connUID);
990
                            validationStringBuilder.AppendLine();
991
                            validationResult = true;
992
                            connectionCheck.Add(new string[] { item.UID, connUID });
993
                        }
994

    
995
                        if (!connectedItem.Contains(connector.CONNECTEDITEM))
996
                            connectedItem.Add(connector.CONNECTEDITEM);
997
                        else
998
                        {
999
                            validationStringBuilder.AppendLine("Check connection!");
1000
                            validationStringBuilder.AppendLine("UID : " + item.UID);
1001
                            validationStringBuilder.AppendLine();
1002
                        }
1003
                    }
1004
                }
1005

    
1006
                if (item.CONNECTORS.Find(x => x.CONNECTEDITEM == item.UID) != null)
1007
                {
1008
                    validationStringBuilder.AppendLine("Check connection!");
1009
                    validationStringBuilder.AppendLine("UID : " + item.UID);
1010
                    validationStringBuilder.AppendLine();
1011
                    validationResult = true;
1012
                }
1013
            }
1014
            foreach (var item in _SYMBOLS)
1015
            {
1016
                List<string> connectedItem = new List<string>();
1017
                foreach (var connector in item.CONNECTORS)
1018
                {
1019
                    if (connector.ConnectedObject != null)
1020
                    {
1021
                        Symbol connSymbol = connector.ConnectedObject as Symbol;
1022
                        Line connLine = connector.ConnectedObject as Line;
1023
                        string connUID = string.Empty;
1024
                        bool result = false;
1025
                        if (connSymbol != null && connSymbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
1026
                        {
1027
                            result = true;
1028
                            connUID = connSymbol.UID;
1029
                        }
1030
                        else if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
1031
                        {
1032
                            result = true;
1033
                            connUID = connLine.UID;
1034
                        }
1035

    
1036
                        if (result && connectionCheck.Find(x => (x[0] == item.UID || x[1] == connUID) || (x[1] == item.UID || x[0] == connUID)) == null)
1037
                        {
1038
                            validationStringBuilder.AppendLine("Check connection!");
1039
                            validationStringBuilder.AppendLine("UID : " + item.UID);
1040
                            validationStringBuilder.AppendLine("UID : " + connUID);
1041
                            validationStringBuilder.AppendLine();
1042
                            validationResult = true;
1043
                            connectionCheck.Add(new string[] { item.UID, connUID });
1044
                        }
1045

    
1046
                        if (!connectedItem.Contains(connector.CONNECTEDITEM))
1047
                            connectedItem.Add(connector.CONNECTEDITEM);
1048
                        else
1049
                        {
1050
                            validationStringBuilder.AppendLine("Check connection!");
1051
                            validationStringBuilder.AppendLine("UID : " + item.UID);
1052
                            validationStringBuilder.AppendLine();
1053
                        }
1054
                    }
1055
                }
1056

    
1057
                if (item.CONNECTORS.Find(x => x.CONNECTEDITEM == item.UID) != null)
1058
                {
1059
                    validationStringBuilder.AppendLine("Check connection!");
1060
                    validationStringBuilder.AppendLine("UID : " + item.UID);
1061
                    validationStringBuilder.AppendLine();
1062
                    validationResult = true;
1063
                }
1064
            }
1065
            #endregion
1066

    
1067
            if (validationResult)
1068
            {
1069
                Validation = false;
1070
                Enable = false;
1071
                _ValidationMessage += validationStringBuilder.ToString();
1072
            }
1073
            else
1074
            {
1075
                Validation = true;
1076
                Enable = true;
1077
            }
1078
        }
1079

    
1080
        private void SetVentDrainItem()
1081
        {
1082
            foreach (var item in SYMBOLS)
1083
            {
1084
                if (item.TYPE == "Valves")
1085
                {
1086
                    List<Symbol> group = new List<Symbol>();
1087
                    SPPIDUtil.FindConnectedSymbolGroup(this, item, group);
1088
                    List<Line> lines = new List<Line>();
1089
                    foreach (var symbol in group)
1090
                    {
1091
                        foreach (var connector in symbol.CONNECTORS)
1092
                        {
1093
                            if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Line))
1094
                            {
1095
                                Line line = connector.ConnectedObject as Line;
1096
                                if (!lines.Contains(line))
1097
                                    lines.Add(line);
1098

    
1099
                            }
1100
                        }
1101
                    }
1102

    
1103
                    if (lines.Count == 1 && !SPPIDUtil.IsBranchedLine(this, lines[0]) && SPPIDUtil.IsBranchLine(lines[0]))
1104
                    {
1105
                        Line line = lines[0];
1106
                        if (line.TYPE == "Secondary" || line.TYPE == "Primary")
1107
                        {
1108
                            double startX = 0;
1109
                            double startY = 0;
1110
                            double endX = 0;
1111
                            double endY = 0;
1112
                            SPPIDUtil.ConvertPointBystring(line.STARTPOINT, ref startX, ref startY);
1113
                            SPPIDUtil.ConvertPointBystring(line.ENDPOINT, ref endX, ref endY);
1114
                            SlopeType slopeType = SPPIDUtil.CalcSlope(startX, startY, endX, endY);
1115
                            if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
1116
                            {
1117
                                foreach (var symbol in group)
1118
                                {
1119
                                    if (!VentDrainSymbol.Contains(symbol))
1120
                                        VentDrainSymbol.Add(symbol);
1121
                                }
1122
                                if (!VentDrainLine.Contains(lines[0]))
1123
                                    VentDrainLine.Add(lines[0]);
1124
                            }
1125
                        }
1126
                    }
1127
                }
1128
            }
1129
        }
1130
    }
1131
}
클립보드 이미지 추가 (최대 크기: 500 MB)