프로젝트

일반

사용자정보

통계
| 개정판:

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

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

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