프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / BaseModel / Document.cs @ 0860c756

이력 | 보기 | 이력해설 | 다운로드 (22.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
10
namespace Converter.BaseModel
11
{
12
    public class Document
13
    {
14
        private string _DWGNAME;
15
        private string _SIZE;
16 39a2a688 gaqhf
        private double _SIZE_WIDTH;
17
        private double _SIZE_HEIGHT;
18 60244a8b gaqhf
        private List<Symbol> _SYMBOLS = new List<Symbol>();
19
        private List<Text> _TEXTINFOS = new List<Text>();
20
        private List<Note> _NOTES = new List<Note>();
21
        private List<Line> _LINES = new List<Line>();
22
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
23 8aa6f2db gaqhf
        private List<TrimLine> _TRIMLINES = new List<TrimLine>();
24 f1c9dbaa gaqhf
        private List<EndBreak> _EndBreaks = new List<EndBreak>();
25 53c81765 gaqhf
        private List<SpecBreak> _SpecBreaks = new List<SpecBreak>();
26 f1c9dbaa gaqhf
        private List<Equipment> _Equipments = new List<Equipment>();
27 60244a8b gaqhf
        private bool _Enable;
28
29
        public bool Enable { get { return _Enable; } }
30 96a2080c gaqhf
31
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
32
        public List<Text> TEXTINFOS { get => _TEXTINFOS; set => _TEXTINFOS = value; }
33
        public List<Note> NOTES { get => _NOTES; set => _NOTES = value; }
34
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
35
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
36 f1c9dbaa gaqhf
        public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; }
37 53c81765 gaqhf
        public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; }
38 f1c9dbaa gaqhf
        public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; }
39 96a2080c gaqhf
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
40 39a2a688 gaqhf
        public string SIZE
41
        {
42
            get
43
            {
44
                return _SIZE;
45
            }
46
            set
47
            {
48
                _SIZE = value;
49
                string[] pointArr = _SIZE.Split(new char[] { ',' });
50
                if (pointArr.Length == 2)
51
                {
52
                    _SIZE_WIDTH = Convert.ToDouble(pointArr[0]);
53
                    _SIZE_HEIGHT = Convert.ToDouble(pointArr[1]);
54
                }
55
            }
56
        }
57
        public double SIZE_WIDTH { get => _SIZE_WIDTH; }
58
        public double SIZE_HEIGHT { get => _SIZE_HEIGHT; }
59 8aa6f2db gaqhf
        public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; }
60 e8536f2b gaqhf
        public string PATH { get; set; }
61 96a2080c gaqhf
62
        public Document(string xmlPath)
63
        {
64
            try
65
            {
66 e8536f2b gaqhf
                PATH = xmlPath;
67 96a2080c gaqhf
                XElement xml = XElement.Load(xmlPath);
68
                DWGNAME = xml.Element("DWGNAME").Value;
69
                SIZE = xml.Element("SIZE").Value;
70
71 ea80efaa gaqhf
                SetText(xml.Element("TEXTINFOS"));
72
                SetNote(xml.Element("NOTES"));
73 96a2080c gaqhf
                SetSymbol(xml.Element("SYMBOLS"));
74
                SetLine(xml.Element("LINEINFOS"));
75
                SetLineNumber(xml.Element("LINENOS"));
76 8aa6f2db gaqhf
                SetTrimLine(xml.Element("TRIMLINENOS"));
77 60244a8b gaqhf
78
                _Enable = true;
79 96a2080c gaqhf
            }
80
            catch (Exception ex)
81
            {
82 60244a8b gaqhf
                _Enable = false;
83 96a2080c gaqhf
                MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
84
            }
85
        }
86
87 60244a8b gaqhf
        #region READ XML
88 96a2080c gaqhf
        private void SetSymbol(XElement node)
89
        {
90
            foreach (XElement item in node.Elements("SYMBOL"))
91
            {
92 f1c9dbaa gaqhf
                string sType = item.Element("TYPE").Value;
93
                if (sType == "Segment Breaks")
94 96a2080c gaqhf
                {
95 53c81765 gaqhf
                    SpecBreak specBreak = new SpecBreak()
96
                    {
97
                        UID = item.Element("UID").Value,
98
                        DBUID = item.Element("DBUID").Value,
99
                        NAME = item.Element("NAME").Value,
100
                        TYPE = item.Element("TYPE").Value,
101
                        OWNER = item.Element("OWNER").Value,
102
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
103
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
104
                        LOCATION = item.Element("LOCATION").Value,
105
                        SIZE = item.Element("SIZE").Value,
106
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
107
                        PARENT = item.Element("PARENT").Value,
108
                        CHILD = item.Element("CHILD").Value,
109
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
110
                        AREA = item.Element("AREA").Value,
111
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
112
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
113
                    };
114
                    SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS);
115
                    SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT);
116
                    SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES);
117
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES);
118
                    SetSpecBreakAttribute(specBreak);
119
120
                    SpecBreaks.Add(specBreak);
121 f1c9dbaa gaqhf
                }
122
                else if (sType == "End Break")
123
                {
124
                    EndBreak endBreak = new EndBreak()
125
                    {
126
                        UID = item.Element("UID").Value,
127
                        DBUID = item.Element("DBUID").Value,
128
                        NAME = item.Element("NAME").Value,
129
                        TYPE = item.Element("TYPE").Value,
130
                        OWNER = item.Element("OWNER").Value,
131
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
132
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
133
                        LOCATION = item.Element("LOCATION").Value,
134
                        SIZE = item.Element("SIZE").Value,
135
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
136
                        PARENT = item.Element("PARENT").Value,
137
                        CHILD = item.Element("CHILD").Value,
138
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
139
                        AREA = item.Element("AREA").Value,
140
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
141
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
142
                    };
143
                    SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS);
144
                    SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT);
145
                    SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES);
146
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES);
147
148
                    EndBreaks.Add(endBreak);
149
                }
150
                else if (sType == "Black Box System" ||
151
                    sType == "GGO_Equipment" ||
152
                    sType == "Heat Transfer Equipment" ||
153
                    sType == "Mechanical" ||
154
                    sType == "Other Equipment" ||
155
                    sType == "Vessels")
156
                {
157
                    Equipment equipment = new Equipment()
158
                    {
159
                        UID = item.Element("UID").Value,
160
                        DBUID = item.Element("DBUID").Value,
161
                        NAME = item.Element("NAME").Value,
162
                        TYPE = item.Element("TYPE").Value,
163
                        OWNER = item.Element("OWNER").Value,
164
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
165
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
166
                        LOCATION = item.Element("LOCATION").Value,
167
                        SIZE = item.Element("SIZE").Value,
168
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
169
                        PARENT = item.Element("PARENT").Value,
170
                        CHILD = item.Element("CHILD").Value,
171
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
172
                        AREA = item.Element("AREA").Value,
173
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
174
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
175
                    };
176
                    SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS);
177
                    SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT);
178
                    SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES);
179
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES);
180 bca81f4c gaqhf
181 f1c9dbaa gaqhf
                    Equipments.Add(equipment);
182
                }
183
                else
184
                {
185
                    Symbol symbol = new Symbol()
186
                    {
187
                        UID = item.Element("UID").Value,
188
                        DBUID = item.Element("DBUID").Value,
189
                        NAME = item.Element("NAME").Value,
190
                        TYPE = item.Element("TYPE").Value,
191
                        OWNER = item.Element("OWNER").Value,
192
                        ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
193
                        CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
194
                        LOCATION = item.Element("LOCATION").Value,
195
                        SIZE = item.Element("SIZE").Value,
196
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
197
                        PARENT = item.Element("PARENT").Value,
198
                        CHILD = item.Element("CHILD").Value,
199
                        HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
200
                        AREA = item.Element("AREA").Value,
201
                        FLIP = Convert.ToInt32(item.Element("FLIP").Value),
202
                        CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
203
                    };
204 8aa6f2db gaqhf
205 f1c9dbaa gaqhf
                    SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
206
                    SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
207
                    SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
208
                    SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
209
                    SetChildSymbol(symbol);
210
211
                    SYMBOLS.Add(symbol);
212
                }
213 96a2080c gaqhf
            }
214
        }
215
216
        private void SetLine(XElement node)
217
        {
218
            foreach (XElement item in node.Elements("LINE"))
219
            {
220 60244a8b gaqhf
                Line line = new Line()
221 96a2080c gaqhf
                {
222 60244a8b gaqhf
                    OWNER = item.Attribute("OWNER").Value,
223
                    UID = item.Element("UID").Value,
224
                    STARTPOINT = item.Element("STARTPOINT").Value,
225
                    ENDPOINT = item.Element("ENDPOINT").Value,
226
                    TYPE = item.Element("TYPE").Value,
227 30d2cfcc gaqhf
                    TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value,
228 60244a8b gaqhf
                    AREA = item.Element("AREA").Value,
229
                    THICKNESS = item.Element("THICKNESS").Value,
230
                };
231 b2d1c1aa gaqhf
                int flowMarkPercent = 0;
232
                if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent))
233
                {
234
                    line.FLOWMARK = true;
235
                    line.FLOWMARK_PERCENT = flowMarkPercent;
236
                }
237
                else
238
                    line.FLOWMARK = false;
239
240 0860c756 gaqhf
                SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS);
241 cfda1fed gaqhf
                SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS);
242 0860c756 gaqhf
                SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES);
243 60244a8b gaqhf
                LINES.Add(line);
244 96a2080c gaqhf
            }
245
        }
246
247
        private void SetLineNumber(XElement node)
248
        {
249
            foreach (XElement item in node.Elements("LINE_NO"))
250
            {
251 4d2571ab gaqhf
                try
252 96a2080c gaqhf
                {
253 4d2571ab gaqhf
                    LineNumber lineNumber = new LineNumber()
254
                    {
255
                        UID = item.Element("UID").Value,
256
                        TEXT = item.Element("TEXT").Value,
257
                        LOCATION = item.Element("LOCATION").Value,
258
                        WIDTH = item.Element("WIDTH").Value,
259
                        HEIGHT = item.Element("HEIGHT").Value,
260
                        ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
261
                        AREA = item.Element("AREA").Value,
262
                        CONNLINE = item.Element("CONNLINE").Value,
263
                        SCENE = item.Element("SCENE").Value
264
                    };
265
                    SetLineNumberRuns(item, lineNumber.RUNS);
266
                    SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES);
267
                    SetAttributes(item, lineNumber.ATTRIBUTES);
268
                    LINENUMBERS.Add(lineNumber);
269
                }
270
                catch (Exception ex)
271
                {
272
                    StringBuilder sb = new StringBuilder();
273
                    sb.AppendLine(item.Element("UID").Value);
274
                    sb.AppendLine("");
275
                    sb.AppendLine(ex.Message);
276
                    sb.AppendLine(ex.StackTrace);
277
                    MessageBox.Show(sb.ToString());
278
                }
279 96a2080c gaqhf
            }
280
        }
281
282
        private void SetText(XElement node)
283
        {
284
            foreach (XElement item in node.Elements("ATTRIBUTE"))
285
            {
286 60244a8b gaqhf
                Text text = new Text()
287 96a2080c gaqhf
                {
288 60244a8b gaqhf
                    UID = item.Element("UID").Value,
289 ea80efaa gaqhf
                    OWNER = item.Element("OWNER").Value,
290 60244a8b gaqhf
                    ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
291
                    NAME = item.Element("NAME").Value,
292
                    LOCATION = item.Element("LOCATION").Value,
293
                    VALUE = item.Element("VALUE").Value,
294
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
295
                    WIDTH = item.Element("WIDTH").Value,
296
                    HEIGHT = item.Element("HEIGHT").Value,
297 1a3a74a8 gaqhf
                    AREA = item.Element("AREA").Value,
298
                    SCENE = item.Element("SCENE").Value
299 60244a8b gaqhf
                };
300 96a2080c gaqhf
301 60244a8b gaqhf
                TEXTINFOS.Add(text);
302 96a2080c gaqhf
            }
303
        }
304
305
        private void SetNote(XElement node)
306
        {
307
            foreach (XElement item in node.Elements("ATTRIBUTE"))
308
            {
309 60244a8b gaqhf
                Note note = new Note()
310 96a2080c gaqhf
                {
311 60244a8b gaqhf
                    UID = item.Element("UID").Value,
312
                    ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
313
                    NAME = item.Element("NAME").Value,
314
                    LOCATION = item.Element("LOCATION").Value,
315
                    VALUE = item.Element("VALUE").Value,
316
                    ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
317
                    WIDTH = item.Element("WIDTH").Value,
318
                    HEIGHT = item.Element("HEIGHT").Value,
319 1a3a74a8 gaqhf
                    AREA = item.Element("AREA").Value,
320
                    SCENE = item.Element("SCENE").Value
321 60244a8b gaqhf
                };
322 96a2080c gaqhf
323 60244a8b gaqhf
                NOTES.Add(note);
324
            }
325
        }
326 8aa6f2db gaqhf
327
        private void SetTrimLine(XElement node)
328
        {
329
            foreach (XElement item in node.Elements("TRIM_LINE_NO"))
330
            {
331
                TrimLine trimLine = new TrimLine()
332
                {
333
                    UID = item.Element("UID").Value,
334
                };
335
                SetLineNumberRuns(item, trimLine.RUNS);
336
                TRIMLINES.Add(trimLine);
337
            }
338
        }
339
340 60244a8b gaqhf
        private void SetAssociations(XElement node, List<Association> associations)
341
        {
342
            foreach (XElement item in node.Elements("ASSOCIATION"))
343
            {
344 ea80efaa gaqhf
                Association association = new Association()
345 60244a8b gaqhf
                {
346
                    TYPE = item.Attribute("TYPE").Value,
347
                    VALUE = item.Value
348 ea80efaa gaqhf
                };
349
350
                associations.Add(association);
351 96a2080c gaqhf
            }
352
        }
353 60244a8b gaqhf
354
        private void SetConnectors(XElement node, List<Connector> connectors)
355
        {
356
            foreach (XElement item in node.Elements("CONNECTOR"))
357
            {
358
                connectors.Add(new Connector()
359
                {
360
                    UID = item.Attribute("UID").Value,
361
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
362 bca81f4c gaqhf
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
363
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
364
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
365
                });
366
            }
367
        }
368
369
        private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT)
370
        {
371
            foreach (XElement item in node.Elements("CONNECTOR"))
372
            {
373
                connectors.Add(new Connector()
374
                {
375
                    UID = item.Attribute("UID").Value,
376
                    CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
377 60244a8b gaqhf
                    CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
378
                    CONNECTPOINT = item.Element("CONNECTPOINT").Value,
379
                    SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
380
                });
381
            }
382
        }
383
384
        private void SetProperties(XElement node, List<Property> properties)
385
        {
386
            foreach (XElement item in node.Elements("PROPERTY"))
387
            {
388 30d2cfcc gaqhf
                properties.Add(new Property()
389 60244a8b gaqhf
                {
390 30d2cfcc gaqhf
                    UID = item.Attribute("UID").Value,
391
                    LENGTH = item.Attribute("Length").Value,
392
                    EXPRESSION = item.Attribute("Expression").Value,
393
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
394
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
395
                    ATTRIBUTE = item.Attribute("Attribute").Value,
396
                    VALUE = item.Value
397
                });
398 60244a8b gaqhf
            }
399
        }
400
401
        private void SetAttributes(XElement node, List<Attribute> attributes)
402
        {
403 30d2cfcc gaqhf
            foreach (XElement item in node.Elements("ATTRIBUTE"))
404 60244a8b gaqhf
            {
405 73415441 gaqhf
                Attribute attribute = new Attribute()
406 60244a8b gaqhf
                {
407
                    UID = item.Attribute("UID").Value,
408
                    LENGTH = item.Attribute("Length").Value,
409
                    EXPRESSION = item.Attribute("Expression").Value,
410
                    DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
411
                    ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
412
                    ATTRIBUTE = item.Attribute("Attribute").Value,
413 30d2cfcc gaqhf
                    ATTRAT = item.Attribute("AttrAt").Value,
414 73415441 gaqhf
                    ASSOCITEM = item.Attribute("AssocItem").Value,
415 60244a8b gaqhf
                    VALUE = item.Value
416 73415441 gaqhf
                };
417
418
                attributes.Add(attribute);
419
420
                if (!string.IsNullOrEmpty(attribute.ASSOCITEM) && attribute.ASSOCITEM != "None")
421
                {
422
                    Text text = _TEXTINFOS.Find(x => x.UID == attribute.ASSOCITEM);
423
                    if (text != null)
424
                        text.ASSOCIATION = true;
425
                }
426 60244a8b gaqhf
            }
427
        }
428
429 53c81765 gaqhf
        private void SetSpecBreakAttribute(SpecBreak specBreak)
430
        {
431
            string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE;
432
            string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE;
433
434
            specBreak.UpStreamUID = upStream;
435
            specBreak.DownStreamUID = downStream;
436
        }
437
438 8aa6f2db gaqhf
        private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns)
439 60244a8b gaqhf
        {
440
            foreach (XElement item in node.Elements("RUN"))
441
            {
442 8aa6f2db gaqhf
                LineRun run = new LineRun()
443 60244a8b gaqhf
                {
444
                    TYPE = item.Attribute("TYPE").Value
445
                };
446
447
                foreach (XElement element in item.Elements())
448
                {
449
                    if (element.Name == "SYMBOL")
450
                    {
451 c3d2e266 gaqhf
                        Symbol symbol = GetSymbolByUID(element.Element("UID").Value);
452
                        if (symbol == null)
453
                            throw new Exception(element.Element("UID").Value);
454
                        run.RUNITEMS.Add(symbol);
455 60244a8b gaqhf
                    }
456
                    else if (element.Name == "LINE")
457
                    {
458 c3d2e266 gaqhf
                        Line line = GetLineByUID(element.Element("UID").Value);
459
                        if (line == null)
460
                            throw new Exception(element.Element("UID").Value);
461
                        run.RUNITEMS.Add(line);
462 60244a8b gaqhf
                    }
463
                }
464
                lineNumberRuns.Add(run);
465
            }
466
        }
467 30d2cfcc gaqhf
468
        private void SetChildSymbol(Symbol symbol)
469
        {
470
            List<ChildSymbol> childList = new List<ChildSymbol>();
471
            if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None")
472
            {
473
                string[] childArray = symbol.CHILD.Split(new char[] { '/' });
474
                foreach (string sChild in childArray)
475
                {
476
                    string[] sChildInfo = sChild.Split(new char[] { ',' });
477
                    childList.Add(new ChildSymbol()
478
                    {
479
                        ParentAt = Convert.ToInt32(sChildInfo[0]),
480
                        Direction = sChildInfo[1],
481
                        NAME = sChildInfo[2]
482
                    });
483
                }
484
485
                foreach (ChildSymbol child in childList)
486
                {
487
                    if (child.ParentAt == 0)
488
                        symbol.ChildSymbols.Add(child);
489
                    else
490
                        childList[child.ParentAt - 1].ChildSymbols.Add(child);
491
                }
492
            }
493
            if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None")
494
            {
495 f1c9dbaa gaqhf
                // 현재 부모 Symbol에 자식 Connector까지 들어가 있음
496 30d2cfcc gaqhf
                string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
497
                string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
498
                for (int i = 0; i < array.Length; i++)
499
                {
500
                    string[] arrConn = array[i].Split(new char[] { ',' });
501
                    int connIndex = Convert.ToInt32(arrConn[3]);
502
                    if (connIndex != 0)
503 5dfb8a24 gaqhf
                    {
504 30d2cfcc gaqhf
                        childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
505 f1c9dbaa gaqhf
                        symbol.CONNECTORS[i].Index = connIndex;
506 5dfb8a24 gaqhf
                    }
507
                }
508 30d2cfcc gaqhf
            }
509
        }
510 60244a8b gaqhf
        #endregion
511
512
        public Symbol GetSymbolByUID(string uid)
513
        {
514
            return SYMBOLS.Find(x => x.UID == uid);
515
        }
516
517
        public Line GetLineByUID(string uid)
518
        {
519
            return LINES.Find(x => x.UID == uid);
520
        }
521 96a2080c gaqhf
    }
522
}
클립보드 이미지 추가 (최대 크기: 500 MB)