프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDConverter / SPPIDModel / SPPID_Document.cs @ baa87c88

이력 | 보기 | 이력해설 | 다운로드 (28.6 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.Data;
7
using Converter.BaseModel;
8
using Converter.SPPID.Util;
9

    
10
namespace Converter.SPPID.Model
11
{
12
    public class SPPID_Document : Document
13
    {
14
        public SPPID_Document(string xmlPath, DataTable ID2SymbolTypeDT) : base(xmlPath, ID2SymbolTypeDT)
15
        {
16
            
17
        }
18

    
19
        public List<SymbolMapping> SymbolMappings;
20
        public List<ChildSymbolMapping> ChildSymbolMappings;
21
        public List<LineMapping> LineMappings;
22
        public List<LineNumberMapping> LineNumberMappings;
23
        public List<AttributeMapping> AttributeMappings;
24
        public ETCSetting ETCSetting;
25
        
26
        public DataTable SymbolTable { get; set; }
27

    
28
        public List<Group> GROUPS = new List<Group>();
29

    
30
        public string DrawingName { get; set; }
31
        public string DrawingNumber { get; set; }
32
        public string Unit { get; set; }
33
        public string Template { get; set; }
34
        public string SPPID_DrawingNumber { get; set; }
35
        public string SPPID_DrawingName { get; set; }
36
        public string BulkAttributeName { get; set; }
37
        public void SetSPPIDInfo()
38
        {
39
            foreach (var item in SYMBOLS)
40
            {
41
                if (item.SPPID == null)
42
                    item.SPPID = new SPPIDSymbolInfo();
43

    
44
                foreach (var childSymbol in item.ChildSymbols)
45
                {
46
                    if (childSymbol.SPPID == null)
47
                        childSymbol.SPPID = new SPPIDSymbolInfo();
48
                    SetChildSymbolSPPIDInfo(childSymbol);
49
                }
50
            }
51

    
52
            foreach (var item in LINES)
53
            {
54
                if (item.SPPID == null)
55
                    item.SPPID = new SPPIDLineInfo();
56
            }
57

    
58
            foreach (var item in Equipments)
59
            {
60
                if (item.SPPID == null)
61
                    item.SPPID = new SPPIDSymbolInfo();
62
            }
63

    
64
            foreach (var item in EndBreaks)
65
            {
66
                if (item.SPPID == null)
67
                    item.SPPID = new SPPIDSymbolInfo();
68
            }
69

    
70
            foreach (var item in SpecBreaks)
71
            {
72
                if (item.SPPID == null)
73
                    item.SPPID = new SPPIDSymbolInfo();
74
            }
75

    
76
            foreach (var item in LINENUMBERS)
77
            {
78
                if (item.SPPID == null)
79
                    item.SPPID = new SPPIDSymbolInfo();
80
            }
81

    
82
            foreach (var item in TEXTINFOS)
83
            {
84
                if (item.SPPID == null)
85
                    item.SPPID = new SPPIDSymbolInfo();
86
            }
87

    
88
            foreach (var item in NOTES)
89
            {
90
                if (item.SPPID == null)
91
                    item.SPPID = new SPPIDSymbolInfo();
92
            }
93

    
94
            foreach (var item in Graphics)
95
            {
96
                if (item.SPPID == null)
97
                    item.SPPID = new SPPIDSymbolInfo();
98
            }
99
        }
100

    
101
        public void SetSPPIDLocation(double SPPIDDocumentX, double SPPIDDocumentY)
102
        {
103
            foreach (var item in SYMBOLS)
104
            {
105
                double x = double.NaN;
106
                double y = double.NaN;
107
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
108
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
109

    
110
                item.SPPID.ORIGINAL_X = x;
111
                item.SPPID.ORIGINAL_Y = y;
112
            }
113

    
114
            foreach (var item in LINES)
115
            {
116
                double startX = double.NaN;
117
                double startY = double.NaN;
118

    
119
                SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref startX, ref startY);
120
                SPPIDUtil.ConvertSPPIDPoint(ref startX, ref startY, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
121
                item.SPPID.START_X = startX;
122
                item.SPPID.START_Y = startY;
123

    
124
                double endX = double.NaN;
125
                double endY = double.NaN;
126

    
127
                SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref endX, ref endY);
128
                SPPIDUtil.ConvertSPPIDPoint(ref endX, ref endY, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
129
                item.SPPID.END_X = endX;
130
                item.SPPID.END_Y = endY;
131

    
132
                item.SlopeType = SPPIDUtil.CalcSlope(startX, startY, endX, endY);
133
            }
134

    
135
            foreach (var item in Equipments)
136
            {
137
                double x = double.NaN;
138
                double y = double.NaN;
139
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
140
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
141

    
142
                item.SPPID.ORIGINAL_X = x;
143
                item.SPPID.ORIGINAL_Y = y;
144
            }
145

    
146
            foreach (var item in EndBreaks)
147
            {
148
                double x = double.NaN;
149
                double y = double.NaN;
150
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
151
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
152
                item.SPPID.ORIGINAL_X = x;
153
                item.SPPID.ORIGINAL_Y = y;
154
            }
155

    
156
            foreach (var item in SpecBreaks)
157
            {
158
                double x = double.NaN;
159
                double y = double.NaN;
160
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
161
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
162

    
163
                item.SPPID.ORIGINAL_X = x;
164
                item.SPPID.ORIGINAL_Y = y;
165
            }
166

    
167
            foreach (var item in LINENUMBERS)
168
            {
169
                double x = double.NaN;
170
                double y = double.NaN;
171
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
172
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
173
                item.SPPID.ORIGINAL_X = x;
174
                item.SPPID.ORIGINAL_Y = y;
175

    
176
                item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
177
                double x1 = item.X1;
178
                double y1 = item.Y1;
179
                double x2 = item.X2;
180
                double y2 = item.Y2;
181
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
182
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
183
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
184
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
185
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
186
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
187
            }
188

    
189
            foreach (var item in TEXTINFOS)
190
            {
191
                double x = double.NaN;
192
                double y = double.NaN;
193
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
194
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
195
                item.SPPID.ORIGINAL_X = x;
196
                item.SPPID.ORIGINAL_Y = y;
197

    
198
                item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
199
                double x1 = item.X1;
200
                double y1 = item.Y1;
201
                double x2 = item.X2;
202
                double y2 = item.Y2;
203
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
204
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
205
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
206
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
207
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
208
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
209
            }
210

    
211
            foreach (var item in NOTES)
212
            {
213
                double x = double.NaN;
214
                double y = double.NaN;
215
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
216
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
217
                item.SPPID.ORIGINAL_X = x;
218
                item.SPPID.ORIGINAL_Y = y;
219

    
220
                item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
221
                double x1 = item.X1;
222
                double y1 = item.Y1;
223
                double x2 = item.X2;
224
                double y2 = item.Y2;
225
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
226
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
227
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
228
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
229
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
230
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
231
            }
232

    
233
            foreach (var item in VendorPackages)
234
            {
235
                double x = item.CenterPoint[0];
236
                double y = item.CenterPoint[1];
237
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
238
                item.SPPID.ORIGINAL_X = x;
239
                item.SPPID.ORIGINAL_Y = y;
240
            }
241

    
242
            foreach (var item in Graphics)
243
            {
244
                item.SPPIDGraphicLocation = new SPPIDEtcLocationInfo();
245
                double x1 = item.X1;
246
                double y1 = item.Y1;
247
                double x2 = item.X2;
248
                double y2 = item.Y2;
249
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
250
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
251
                item.SPPIDGraphicLocation.X1 = Math.Min(x1, x2);
252
                item.SPPIDGraphicLocation.Y1 = Math.Min(y1, y2);
253
                item.SPPIDGraphicLocation.X2 = Math.Max(x1, x2);
254
                item.SPPIDGraphicLocation.Y2 = Math.Max(y1, y2);
255
            }
256
        }
257

    
258
        /// <summary>
259
        /// 좌표 보정
260
        /// </summary>
261
        public void CoordinateCorrection()
262
        {
263
            List<Symbol> symbols = SYMBOLS;
264
            symbols.Sort(SPPIDUtil.SortSymbolPriority);
265
            foreach (Symbol symbol in symbols)
266
            {
267
                if (!symbol.SPPID.IsCorrectionX)
268
                {
269
                    List<object> group = new List<object>();
270
                    group.Add(symbol);
271
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.VERTICAL);
272

    
273
                    List<Symbol> groupSymbols = (from sym in @group
274
                                                 where sym.GetType() == typeof(Symbol)
275
                                                 select sym as Symbol).OrderBy(o => o.SPPID.ORIGINAL_Y).ToList();
276

    
277
                    // X 좌표만 보정
278
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionX);
279
                    double value = symbol.SPPID.ORIGINAL_X;
280
                    if (correctionSymbol == null)
281
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
282
                    else
283
                        value = correctionSymbol.SPPID.ORIGINAL_X;
284

    
285
                    for (int i = 0; i < groupSymbols.Count; i++)
286
                    {
287
                        var item = groupSymbols[i];
288
                    
289
                        item.SPPID.IsCorrectionX = true;
290
                        item.SPPID.ORIGINAL_X = value;
291
                        item.SPPID.CorrectionX_GroupSymbols = groupSymbols;                    
292

    
293
                        if (i > 1)
294
                        {
295
                            double pGap = groupSymbols[i - 2].SPPID.ORIGINAL_Y - groupSymbols[i - 1].SPPID.ORIGINAL_Y;
296
                            double cGap = groupSymbols[i - 1].SPPID.ORIGINAL_Y - groupSymbols[i].SPPID.ORIGINAL_Y;
297
                            if (SPPIDUtil.EqualSpacing(pGap, cGap))
298
                                item.SPPID.IsEqualSpacingY = true;
299
                        }
300
                    }
301
                }
302

    
303
                if (!symbol.SPPID.IsCorrectionY)
304
                {
305
                    List<object> group = new List<object>();
306
                    group.Add(symbol);
307
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.HORIZONTAL);
308

    
309
                    List<Symbol> groupSymbols = (from sym in @group
310
                                                 where sym.GetType() == typeof(Symbol)
311
                                                 select sym as Symbol).OrderBy(o => o.SPPID.ORIGINAL_X).ToList();
312

    
313
                    // Y 좌표만 보정
314
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionY);
315
                    double value = symbol.SPPID.ORIGINAL_Y;
316
                    if (correctionSymbol == null)
317
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
318
                    else
319
                        value = correctionSymbol.SPPID.ORIGINAL_Y;
320

    
321
                    for (int i = 0; i < groupSymbols.Count; i++)
322
                    {
323
                        var item = groupSymbols[i];
324
                    
325
                        item.SPPID.IsCorrectionY = true;
326
                        item.SPPID.ORIGINAL_Y = value;
327
                        item.SPPID.CorrectionY_GroupSymbols = groupSymbols;
328

    
329
                        if (i > 1)
330
                        {
331
                            double pGap = groupSymbols[i - 2].SPPID.ORIGINAL_X - groupSymbols[i - 1].SPPID.ORIGINAL_X;
332
                            double cGap = groupSymbols[i - 1].SPPID.ORIGINAL_X - groupSymbols[i].SPPID.ORIGINAL_X;
333
                            if (SPPIDUtil.EqualSpacing(pGap, cGap))
334
                                item.SPPID.IsEqualSpacingX = true;
335
                        }
336
                    }
337
                }
338
            }
339

    
340
            foreach (Line line in LINES)
341
            {
342
                double tempX = line.SPPID.START_X;
343
                double tempY = line.SPPID.START_Y;
344
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
345
                line.SPPID.START_X = tempX;
346
                line.SPPID.START_Y = tempY;
347

    
348
                tempX = line.SPPID.END_X;
349
                tempY = line.SPPID.END_Y;
350
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
351
                line.SPPID.END_X = tempX;
352
                line.SPPID.END_Y = tempY;
353

    
354
                if (line.SlopeType == SlopeType.HORIZONTAL)
355
                    line.SPPID.END_Y = line.SPPID.START_Y;
356
                else if (line.SlopeType == SlopeType.VERTICAL)
357
                    line.SPPID.END_X = line.SPPID.START_X;
358
            }
359
        }
360

    
361
        private void FindGroupBySymbolAndSlopeType(Symbol symbol, List<object> group, SlopeType searchType)
362
        {
363
            foreach (var connector in symbol.CONNECTORS)
364
            {
365
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
366
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
367
                {
368
                    Symbol connSymbol = connectedItem as Symbol;
369
                    SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y);
370
                    if (slopeType == searchType)
371
                    {
372
                        if (!group.Contains(connSymbol))
373
                        {
374
                            group.Add(connSymbol);
375
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
376
                        }
377
                    }
378
                }
379
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
380
                {
381
                    Line connLine = connectedItem as Line;
382

    
383
                    Connector otherConnector = connLine.CONNECTORS.Find(x => x.CONNECTEDITEM != symbol.UID);
384
                    int connectorIndex = connLine.CONNECTORS.IndexOf(otherConnector);
385
                    double lineX = double.NaN;
386
                    double lineY = double.NaN;
387
                    // Symbol의 Connector ScenePoint
388
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? connLine.STARTPOINT : connLine.ENDPOINT, ref lineX, ref lineY);
389
                    double symbolX = double.NaN;
390
                    double symbolY = double.NaN;
391
                    SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref symbolX, ref symbolY);
392

    
393
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
394
                    if (slopeType == searchType)
395
                    {
396
                        if (!group.Contains(connLine))
397
                        {
398
                            group.Add(connLine);
399
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
400
                        }
401
                    }
402
                }
403
            }
404
        }
405

    
406
        private void FindGroupByLineAndSlopeType(Line line, List<object> group, SlopeType searchType)
407
        {
408
            foreach (var connector in line.CONNECTORS)
409
            {
410
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
411
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
412
                {
413
                    Symbol connSymbol = connectedItem as Symbol;
414

    
415
                    Connector otherConnector = line.CONNECTORS.Find(x => x.CONNECTEDITEM != connSymbol.UID);
416
                    int connectorIndex = line.CONNECTORS.IndexOf(otherConnector);
417
                    double lineX = double.NaN;
418
                    double lineY = double.NaN;
419
                    // Line의 Connector ScenePoint
420
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? line.STARTPOINT : line.ENDPOINT, ref lineX, ref lineY);
421
                    double symbolX = double.NaN;
422
                    double symbolY = double.NaN;
423
                    SPPIDUtil.ConvertPointBystring(connSymbol.ORIGINALPOINT, ref symbolX, ref symbolY);
424

    
425
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
426
                    if (slopeType == searchType)
427
                    {
428
                        if (!group.Contains(connSymbol))
429
                        {
430
                            group.Add(connSymbol);
431
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
432
                        }
433
                    }
434
                }
435
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
436
                {
437
                    Line connLine = connectedItem as Line;
438
                    SlopeType slopeType = SPPIDUtil.CalcSlope(connLine.SPPID.START_X, connLine.SPPID.START_Y, connLine.SPPID.END_X, connLine.SPPID.END_Y);
439
                    if (slopeType == searchType)
440
                    {
441
                        if (!group.Contains(connLine))
442
                        {
443
                            group.Add(connLine);
444
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
445
                        }
446
                    }
447
                }
448
            }
449
        }
450

    
451
        private void SetChildSymbolSPPIDInfo(ChildSymbol item)
452
        {
453
            foreach (var childSymbol in item.ChildSymbols)
454
            {
455
                if (childSymbol.SPPID == null)
456
                    childSymbol.SPPID = new SPPIDSymbolInfo();
457
                SetChildSymbolSPPIDInfo(childSymbol);
458
            }
459
        }
460
      
461
        public bool SetSPPIDMapping()
462
        {
463
            bool result = true;
464
            StringBuilder sb = new StringBuilder();
465
            foreach (var item in SYMBOLS)
466
            {
467
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
468
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
469
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
470
                {
471
                    result = false;
472
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
473
                }
474
                    
475

    
476
                foreach (var childSymbol in item.ChildSymbols)
477
                {
478
                    ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
479
                    childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
480
                    if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol))
481
                    {
482
                        result = false;
483
                        sb.AppendLine("Need Mapping Symbol Name : " + childSymbol.NAME);
484
                    }
485
                }
486
            }
487

    
488
            foreach (var item in LINES)
489
            {
490
                LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID);
491
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
492
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
493
                {
494
                    result = false;
495
                    sb.AppendLine("Need Mapping Line Type : " + item.TYPE);
496
                }
497
            }
498

    
499
            foreach (var item in Equipments)
500
            {
501
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
502
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
503
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
504
                {
505
                    result = false;
506
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
507
                }
508
            }
509

    
510
            foreach (var item in EndBreaks)
511
            {
512
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
513
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
514
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
515
                {
516
                    result = false;
517
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
518
                }
519
            }
520

    
521
            foreach (var item in LINENUMBERS)
522
            {
523
                if (LineNumberMappings.Count > 0)
524
                    item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME;
525
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
526
                {
527
                    result = false;
528
                    sb.AppendLine("Need Mapping LineNumber Mapping");
529
                }
530
            }
531

    
532
            ETCSetting etc = ETCSetting.GetInstance();
533
            foreach (var item in NOTES)
534
            {
535
                item.SPPID.MAPPINGNAME = etc.NoteSymbolPath;
536
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
537
                {
538
                    result = false;
539
                    sb.AppendLine("Need Mapping Note Mapping");
540
                }
541
            }
542

    
543
            foreach (var item in TEXTINFOS)
544
            {
545
                item.SPPID.MAPPINGNAME = etc.TextSymbolPath;
546
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
547
                {
548
                    result = false;
549
                    sb.AppendLine("Need Mapping Text Mapping");
550
                }
551
            }
552

    
553
            if (!result)
554
                ValidationMessage += sb.ToString();
555
            else
556
                MappingValidation = true;
557

    
558
            return result;
559
        }
560

    
561
        private bool SetChildSymbolMapping(ChildSymbol item)
562
        {
563
            bool res = true;
564

    
565
            foreach (var childSymbol in item.ChildSymbols)
566
            {
567
                ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
568
                childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
569
                if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME))
570
                    return false;
571
                else
572
                {
573
                    res = SetChildSymbolMapping(childSymbol);
574
                    if (!res)
575
                        return false;
576
                }                    
577
            }
578

    
579
            return res;
580
        }
581

    
582
        public void CheckModelingResult()
583
        {
584
            StringBuilder sb = new StringBuilder();
585
            sb.AppendLine("Modeling Result");
586
            int failSymbolCnt = 0;
587
            int failLineCnt = 0;
588
            int failTextCnt = 0;
589
            int failGraphicCnt = 0;
590
            foreach (var item in Equipments)
591
            {
592
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
593
                {
594
                    sb.AppendLine("Fail Equipment Modeling UID : " + item.UID);
595
                    failSymbolCnt++;
596
                }
597
            }
598
            foreach (var item in SYMBOLS)
599
            {
600
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
601
                {
602
                    sb.AppendLine("Fail Symbol Modeling UID : " + item.UID);
603
                    failSymbolCnt++;
604
                }
605
                foreach (var child in item.ChildSymbols)
606
                {
607
                    if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
608
                    {
609
                        sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
610
                        sb.AppendLine("Fail Child Symbol Name : " + child.NAME);
611
                    }
612
                    loop(child, item, sb);
613
                }
614
            }
615
            foreach (var item in LINES)
616
            {
617
                if (string.IsNullOrEmpty(item.SPPID.ModelItemId))
618
                {
619
                    sb.AppendLine("Fail Line Modeling UID : " + item.UID);
620
                    failLineCnt++;
621
                }
622
            }
623
            foreach (var item in LINENUMBERS)
624
            {
625
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
626
                    sb.AppendLine("Fail Line Number Modeling UID : " + item.UID);
627
            }
628
            foreach (var item in NOTES)
629
            {
630
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
631
                {
632
                    sb.AppendLine("Fail Note Text Modeling UID : " + item.UID);
633
                    failTextCnt++;
634
                }
635
            }
636
            foreach (var item in TEXTINFOS)
637
            {
638
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
639
                {
640
                    sb.AppendLine("Fail Text Modeling UID : " + item.UID);
641
                    failTextCnt++;
642
                }
643
            }
644
            foreach (var item in EndBreaks)
645
            {
646
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
647
                {
648
                    sb.AppendLine("Fail End Break Modeling UID : " + item.UID);
649
                    failSymbolCnt++;
650
                }
651
            }
652
            foreach (var item in SpecBreaks)
653
            {
654
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
655
                {
656
                    sb.AppendLine("Fail SpecBreak Modeling UID : " + item.UID);
657
                    failSymbolCnt++;
658
                }
659
            }
660
            foreach (var item in Graphics)
661
            {
662
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
663
                {
664
                    sb.AppendLine("Fail Grphic Modeling UID : " + item.UID);
665
                    failGraphicCnt++;
666
                }
667
            }
668
            sb.AppendLine("End Modeling Result");
669
            Log.Write(sb.ToString());
670

    
671
            int allSymbol = Equipments.Count + SYMBOLS.Count + EndBreaks.Count + SpecBreaks.Count + Graphics.Count;
672

    
673
            Log.Write("Success Symbol Modeling : " + (allSymbol - failSymbolCnt));
674
            Log.Write("Fail Symbol Modeling : " + failSymbolCnt);
675
            Log.Write("Success Line Modeling : " + (LINES.Count - failLineCnt));
676
            Log.Write("Fail Line Modeling : " + failLineCnt);
677
            Log.Write("Success Text/Note Modeling : " + (TEXTINFOS.Count + NOTES.Count - failTextCnt));
678
            Log.Write("Fail Text/Note Modeling : " + failTextCnt);
679
            Log.Write("Success Graphic Modeling : " + (Graphics.Count - failGraphicCnt));
680
            Log.Write("Fail Graphic Modeling : " + failGraphicCnt);
681
        }
682

    
683
        private void loop(ChildSymbol childLoop, Symbol item, StringBuilder sb)
684
        {
685
            foreach (var childLoopLoop in childLoop.ChildSymbols)
686
            {
687
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
688
                {
689
                    sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
690
                    sb.AppendLine("Fail Child Symbol Name : " + childLoopLoop.NAME);
691
                }
692
                loop(childLoopLoop, item, sb);
693
            }
694
        }
695
    }
696
}
클립보드 이미지 추가 (최대 크기: 500 MB)