프로젝트

일반

사용자정보

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

hytos / DTI_PID / SPPIDConverter / SPPIDModel / SPPID_Document.cs @ 12b7a2a8

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

1 bca86986 gaqhf
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6 f1c9dbaa gaqhf
using System.Data;
7 bca86986 gaqhf
using Converter.BaseModel;
8 bca81f4c gaqhf
using Converter.SPPID.Util;
9 bca86986 gaqhf
10 b8e2644e gaqhf
namespace Converter.SPPID.Model
11 bca86986 gaqhf
{
12
    public class SPPID_Document : Document
13
    {
14
        public SPPID_Document(string xmlPath) : base(xmlPath)
15
        {
16 f1c9dbaa gaqhf
            
17 bca86986 gaqhf
        }
18 88365b05 gaqhf
19 39a2a688 gaqhf
        public List<SymbolMapping> SymbolMappings;
20 4b4dbca9 gaqhf
        public List<ChildSymbolMapping> ChildSymbolMappings;
21 39a2a688 gaqhf
        public List<LineMapping> LineMappings;
22
        public List<LineNumberMapping> LineNumberMappings;
23 1efc25a3 gaqhf
        public List<AttributeMapping> AttributeMappings;
24 39a2a688 gaqhf
        public ETCSetting ETCSetting;
25 4d2571ab gaqhf
        public DataTable SymbolTable { get; set; }
26 39a2a688 gaqhf
27 f1c9dbaa gaqhf
        public List<Group> GROUPS = new List<Group>();
28 5dfb8a24 gaqhf
29 bca86986 gaqhf
        public string DrawingName { get; set; }
30
        public string DrawingNumber { get; set; }
31
        public string Unit { get; set; }
32 4314b3f3 gaqhf
        public string Template { get; set; }
33 88bac50c gaqhf
        public string SPPID_DrawingNumber { get; set; }
34
        public string SPPID_DrawingName { get; set; }
35 f947c634 gaqhf
36
        public void SetSPPIDInfo()
37
        {
38
            foreach (var item in SYMBOLS)
39
            {
40 39a2a688 gaqhf
                if (item.SPPID == null)
41
                    item.SPPID = new SPPIDSymbolInfo();
42 4b4dbca9 gaqhf
43
                foreach (var childSymbol in item.ChildSymbols)
44
                {
45
                    if (childSymbol.SPPID == null)
46
                        childSymbol.SPPID = new SPPIDSymbolInfo();
47
                    SetChildSymbolSPPIDInfo(childSymbol);
48
                }
49 39a2a688 gaqhf
            }
50
51
            foreach (var item in LINES)
52
            {
53
                if (item.SPPID == null)
54
                    item.SPPID = new SPPIDLineInfo();
55 1ba9c671 gaqhf
            }
56
57
            foreach (var item in Equipments)
58
            {
59
                if (item.SPPID == null)
60
                    item.SPPID = new SPPIDSymbolInfo();
61
            }
62
63
            foreach (var item in EndBreaks)
64
            {
65
                if (item.SPPID == null)
66
                    item.SPPID = new SPPIDSymbolInfo();
67
            }
68
69 53c81765 gaqhf
            foreach (var item in SpecBreaks)
70
            {
71
                if (item.SPPID == null)
72
                    item.SPPID = new SPPIDSymbolInfo();
73
            }
74
75 1ba9c671 gaqhf
            foreach (var item in LINENUMBERS)
76
            {
77
                if (item.SPPID == null)
78
                    item.SPPID = new SPPIDSymbolInfo();
79
            }
80
81
            foreach (var item in TEXTINFOS)
82
            {
83
                if (item.SPPID == null)
84
                    item.SPPID = new SPPIDSymbolInfo();
85
            }
86
87
            foreach (var item in NOTES)
88
            {
89
                if (item.SPPID == null)
90
                    item.SPPID = new SPPIDSymbolInfo();
91
            }
92
        }
93
94
        public void SetSPPIDLocation(double SPPIDDocumentX, double SPPIDDocumentY)
95
        {
96
            foreach (var item in SYMBOLS)
97
            {
98
                double x = double.NaN;
99
                double y = double.NaN;
100
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
101
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
102 06b40010 gaqhf
103 1ba9c671 gaqhf
                item.SPPID.ORIGINAL_X = x;
104
                item.SPPID.ORIGINAL_Y = y;
105
            }
106
107
            foreach (var item in LINES)
108
            {
109 a0e3dca4 gaqhf
                double startX = double.NaN;
110
                double startY = double.NaN;
111 39a2a688 gaqhf
112 a0e3dca4 gaqhf
                SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref startX, ref startY);
113
                SPPIDUtil.ConvertSPPIDPoint(ref startX, ref startY, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
114
                item.SPPID.START_X = startX;
115
                item.SPPID.START_Y = startY;
116 39a2a688 gaqhf
117 a0e3dca4 gaqhf
                double endX = double.NaN;
118
                double endY = double.NaN;
119
120
                SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref endX, ref endY);
121
                SPPIDUtil.ConvertSPPIDPoint(ref endX, ref endY, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
122
                item.SPPID.END_X = endX;
123
                item.SPPID.END_Y = endY;
124
125
                item.SlopeType = SPPIDUtil.CalcSlope(startX, startY, endX, endY);
126 39a2a688 gaqhf
            }
127 809a7640 gaqhf
128
            foreach (var item in Equipments)
129
            {
130
                double x = double.NaN;
131
                double y = double.NaN;
132
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
133 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
134 06b40010 gaqhf
135 809a7640 gaqhf
                item.SPPID.ORIGINAL_X = x;
136
                item.SPPID.ORIGINAL_Y = y;
137
            }
138 3165c259 gaqhf
139
            foreach (var item in EndBreaks)
140
            {
141
                double x = double.NaN;
142
                double y = double.NaN;
143
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
144 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
145 3165c259 gaqhf
                item.SPPID.ORIGINAL_X = x;
146
                item.SPPID.ORIGINAL_Y = y;
147
            }
148 10872260 gaqhf
149 53c81765 gaqhf
            foreach (var item in SpecBreaks)
150
            {
151
                double x = double.NaN;
152
                double y = double.NaN;
153
                SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y);
154
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
155
156
                item.SPPID.ORIGINAL_X = x;
157
                item.SPPID.ORIGINAL_Y = y;
158
            }
159
160 10872260 gaqhf
            foreach (var item in LINENUMBERS)
161
            {
162
                double x = double.NaN;
163
                double y = double.NaN;
164
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
165 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
166 10872260 gaqhf
                item.SPPID.ORIGINAL_X = x;
167
                item.SPPID.ORIGINAL_Y = y;
168 1a3a74a8 gaqhf
169
                item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
170
                double x1 = item.X1;
171
                double y1 = item.Y1;
172
                double x2 = item.X2;
173
                double y2 = item.Y2;
174 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
175
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
176 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
177
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
178
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
179
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
180 10872260 gaqhf
            }
181 6b298450 gaqhf
182
            foreach (var item in TEXTINFOS)
183
            {
184
                double x = double.NaN;
185
                double y = double.NaN;
186
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
187 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
188 6b298450 gaqhf
                item.SPPID.ORIGINAL_X = x;
189
                item.SPPID.ORIGINAL_Y = y;
190 1a3a74a8 gaqhf
191
                item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
192
                double x1 = item.X1;
193
                double y1 = item.Y1;
194
                double x2 = item.X2;
195
                double y2 = item.Y2;
196 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
197
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
198 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
199
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
200
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
201
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
202 6b298450 gaqhf
            }
203
204
            foreach (var item in NOTES)
205
            {
206
                double x = double.NaN;
207
                double y = double.NaN;
208
                SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y);
209 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
210 6b298450 gaqhf
                item.SPPID.ORIGINAL_X = x;
211
                item.SPPID.ORIGINAL_Y = y;
212 1a3a74a8 gaqhf
213
                item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
214
                double x1 = item.X1;
215
                double y1 = item.Y1;
216
                double x2 = item.X2;
217
                double y2 = item.Y2;
218 1ba9c671 gaqhf
                SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
219
                SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
220 1a3a74a8 gaqhf
                item.SPPIDLabelLocation.X1 = Math.Min(x1, x2);
221
                item.SPPIDLabelLocation.Y1 = Math.Min(y1, y2);
222
                item.SPPIDLabelLocation.X2 = Math.Max(x1, x2);
223
                item.SPPIDLabelLocation.Y2 = Math.Max(y1, y2);
224 6b298450 gaqhf
            }
225 39a2a688 gaqhf
        }
226 4b4dbca9 gaqhf
227 c01ce90b gaqhf
        /// <summary>
228
        /// 좌표 보정
229
        /// </summary>
230
        public void CoordinateCorrection()
231
        {
232
            foreach (Symbol symbol in SYMBOLS)
233
            {
234
                if (!symbol.SPPID.IsCorrectionX)
235
                {
236
                    List<object> group = new List<object>();
237
                    group.Add(symbol);
238
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.VERTICAL);
239
240
                    List<Symbol> groupSymbols = (from sym in @group
241
                                                 where sym.GetType() == typeof(Symbol)
242
                                                 select sym as Symbol).ToList();
243
244
                    // X 좌표만 보정
245
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionX);
246
                    double value = symbol.SPPID.ORIGINAL_X;
247
                    if (correctionSymbol == null)
248
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
249
                    else
250
                        value = correctionSymbol.SPPID.ORIGINAL_X;
251
252
                    foreach (var item in groupSymbols)
253
                    {
254
                        item.SPPID.IsCorrectionX = true;
255
                        item.SPPID.ORIGINAL_X = value;
256 d9794a6c gaqhf
                        item.SPPID.CorrectionX_GroupSymbols = groupSymbols;
257 c01ce90b gaqhf
                    }
258
                }
259
260
                if (!symbol.SPPID.IsCorrectionY)
261
                {
262
                    List<object> group = new List<object>();
263
                    group.Add(symbol);
264
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.HORIZONTAL);
265
266
                    List<Symbol> groupSymbols = (from sym in @group
267
                                                 where sym.GetType() == typeof(Symbol)
268
                                                 select sym as Symbol).ToList();
269
270
                    // Y 좌표만 보정
271
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionY);
272
                    double value = symbol.SPPID.ORIGINAL_Y;
273
                    if (correctionSymbol == null)
274
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
275
                    else
276
                        value = correctionSymbol.SPPID.ORIGINAL_Y;
277
278
                    foreach (var item in groupSymbols)
279
                    {
280
                        item.SPPID.IsCorrectionY = true;
281
                        item.SPPID.ORIGINAL_Y = value;
282 d9794a6c gaqhf
                        item.SPPID.CorrectionY_GroupSymbols = groupSymbols;
283 c01ce90b gaqhf
                    }
284
                }
285
            }
286 a0e3dca4 gaqhf
287
            foreach (Line line in LINES)
288
            {
289
                double tempX = line.SPPID.START_X;
290
                double tempY = line.SPPID.START_Y;
291
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
292
                line.SPPID.START_X = tempX;
293
                line.SPPID.START_Y = tempY;
294
295
                tempX = line.SPPID.END_X;
296
                tempY = line.SPPID.END_Y;
297
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
298
                line.SPPID.END_X = tempX;
299
                line.SPPID.END_Y = tempY;
300
301
                if (line.SlopeType == SlopeType.HORIZONTAL)
302
                    line.SPPID.END_Y = line.SPPID.START_Y;
303
                else if (line.SlopeType == SlopeType.VERTICAL)
304
                    line.SPPID.END_X = line.SPPID.START_X;
305
            }
306 c01ce90b gaqhf
        }
307
308
        private void FindGroupBySymbolAndSlopeType(Symbol symbol, List<object> group, SlopeType searchType)
309
        {
310
            foreach (var connector in symbol.CONNECTORS)
311
            {
312
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
313
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
314
                {
315
                    Symbol connSymbol = connectedItem as Symbol;
316
                    SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y);
317
                    if (slopeType == searchType)
318
                    {
319
                        if (!group.Contains(connSymbol))
320
                        {
321
                            group.Add(connSymbol);
322
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
323
                        }
324
                    }
325
                }
326
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
327
                {
328
                    Line connLine = connectedItem as Line;
329 02480ac1 gaqhf
330 1ed39474 gaqhf
                    Connector otherConnector = connLine.CONNECTORS.Find(x => x.CONNECTEDITEM != symbol.UID);
331 f1a7faf9 gaqhf
                    int connectorIndex = connLine.CONNECTORS.IndexOf(otherConnector);
332 02480ac1 gaqhf
                    double lineX = double.NaN;
333
                    double lineY = double.NaN;
334
                    // Symbol의 Connector ScenePoint
335 f1a7faf9 gaqhf
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? connLine.STARTPOINT : connLine.ENDPOINT, ref lineX, ref lineY);
336 02480ac1 gaqhf
                    double symbolX = double.NaN;
337
                    double symbolY = double.NaN;
338
                    SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref symbolX, ref symbolY);
339
340
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
341 c01ce90b gaqhf
                    if (slopeType == searchType)
342
                    {
343
                        if (!group.Contains(connLine))
344
                        {
345
                            group.Add(connLine);
346
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
347
                        }
348
                    }
349
                }
350
            }
351
        }
352
353 f1a7faf9 gaqhf
        private void FindGroupByLineAndSlopeType(Line line, List<object> group, SlopeType searchType)
354 c01ce90b gaqhf
        {
355 f1a7faf9 gaqhf
            foreach (var connector in line.CONNECTORS)
356 c01ce90b gaqhf
            {
357
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
358
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
359
                {
360
                    Symbol connSymbol = connectedItem as Symbol;
361 02480ac1 gaqhf
362 f1a7faf9 gaqhf
                    Connector otherConnector = line.CONNECTORS.Find(x => x.CONNECTEDITEM != connSymbol.UID);
363
                    int connectorIndex = line.CONNECTORS.IndexOf(otherConnector);
364 c01ce90b gaqhf
                    double lineX = double.NaN;
365
                    double lineY = double.NaN;
366 02480ac1 gaqhf
                    // Line의 Connector ScenePoint
367 f1a7faf9 gaqhf
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? line.STARTPOINT : line.ENDPOINT, ref lineX, ref lineY);
368 c01ce90b gaqhf
                    double symbolX = double.NaN;
369
                    double symbolY = double.NaN;
370
                    SPPIDUtil.ConvertPointBystring(connSymbol.ORIGINALPOINT, ref symbolX, ref symbolY);
371
372
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
373
                    if (slopeType == searchType)
374
                    {
375
                        if (!group.Contains(connSymbol))
376
                        {
377
                            group.Add(connSymbol);
378
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
379
                        }
380
                    }
381
                }
382
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
383
                {
384
                    Line connLine = connectedItem as Line;
385
                    SlopeType slopeType = SPPIDUtil.CalcSlope(connLine.SPPID.START_X, connLine.SPPID.START_Y, connLine.SPPID.END_X, connLine.SPPID.END_Y);
386
                    if (slopeType == searchType)
387
                    {
388
                        if (!group.Contains(connLine))
389
                        {
390
                            group.Add(connLine);
391
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
392
                        }
393
                    }
394
                }
395
            }
396
        }
397
398 4b4dbca9 gaqhf
        private void SetChildSymbolSPPIDInfo(ChildSymbol item)
399
        {
400
            foreach (var childSymbol in item.ChildSymbols)
401
            {
402
                if (childSymbol.SPPID == null)
403
                    childSymbol.SPPID = new SPPIDSymbolInfo();
404
                SetChildSymbolSPPIDInfo(childSymbol);
405
            }
406
        }
407
      
408 39a2a688 gaqhf
        public bool SetSPPIDMapping()
409
        {
410 68e9394a gaqhf
            bool result = true;
411
            StringBuilder sb = new StringBuilder();
412 39a2a688 gaqhf
            foreach (var item in SYMBOLS)
413
            {
414
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
415
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
416
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
417 68e9394a gaqhf
                {
418
                    result = false;
419
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
420
                }
421
                    
422 4b4dbca9 gaqhf
423
                foreach (var childSymbol in item.ChildSymbols)
424
                {
425
                    ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
426
                    childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
427
                    if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol))
428 68e9394a gaqhf
                    {
429
                        result = false;
430
                        sb.AppendLine("Need Mapping Symbol Name : " + childSymbol.NAME);
431
                    }
432 4b4dbca9 gaqhf
                }
433 39a2a688 gaqhf
            }
434
435
            foreach (var item in LINES)
436
            {
437
                LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID);
438
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
439
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
440 68e9394a gaqhf
                {
441
                    result = false;
442
                    sb.AppendLine("Need Mapping Line Type : " + item.TYPE);
443
                }
444 f947c634 gaqhf
            }
445
446 809a7640 gaqhf
            foreach (var item in Equipments)
447
            {
448
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
449
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
450
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
451 68e9394a gaqhf
                {
452
                    result = false;
453
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
454
                }
455 809a7640 gaqhf
            }
456
457 3165c259 gaqhf
            foreach (var item in EndBreaks)
458
            {
459
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
460
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
461
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
462 68e9394a gaqhf
                {
463
                    result = false;
464
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
465
                }
466 3165c259 gaqhf
            }
467
468 10872260 gaqhf
            foreach (var item in LINENUMBERS)
469
            {
470
                if (LineNumberMappings.Count > 0)
471
                    item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME;
472
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
473 68e9394a gaqhf
                {
474
                    result = false;
475
                    sb.AppendLine("Need Mapping LineNumber Mapping");
476
                }
477 10872260 gaqhf
            }
478
479 6b298450 gaqhf
            ETCSetting etc = ETCSetting.GetInstance();
480
            foreach (var item in NOTES)
481
            {
482
                item.SPPID.MAPPINGNAME = etc.NoteSymbolPath;
483
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
484 68e9394a gaqhf
                {
485
                    result = false;
486
                    sb.AppendLine("Need Mapping Note Mapping");
487
                }
488 6b298450 gaqhf
            }
489
490
            foreach (var item in TEXTINFOS)
491
            {
492
                item.SPPID.MAPPINGNAME = etc.TextSymbolPath;
493
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
494 68e9394a gaqhf
                {
495
                    result = false;
496
                    sb.AppendLine("Need Mapping Text Mapping");
497
                }
498 6b298450 gaqhf
            }
499 4b4dbca9 gaqhf
500 68e9394a gaqhf
            if (!result)
501
                ValidationMessage += sb.ToString();
502 5673a69f gaqhf
            else
503
                MappingValidation = true;
504 68e9394a gaqhf
505
            return result;
506 f947c634 gaqhf
        }
507 5dfb8a24 gaqhf
508 4b4dbca9 gaqhf
        private bool SetChildSymbolMapping(ChildSymbol item)
509
        {
510
            foreach (var childSymbol in item.ChildSymbols)
511
            {
512
                ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
513
                childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
514
                if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME))
515
                    return false;
516
                else
517
                    return SetChildSymbolMapping(childSymbol);
518
            }
519
520
            return true;
521
        }
522 30ba9ae0 gaqhf
523
        public void CheckModelingResult()
524
        {
525
            StringBuilder sb = new StringBuilder();
526
            sb.AppendLine("Modeling Result");
527
            foreach (var item in Equipments)
528
            {
529
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
530
                    sb.AppendLine("Fail Equipment Modeling UID : " + item.UID);
531
            }
532
            foreach (var item in SYMBOLS)
533
            {
534
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
535
                    sb.AppendLine("Fail Symbol Modeling UID : " + item.UID);
536
                foreach (var child in item.ChildSymbols)
537
                {
538
                    if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
539
                    {
540
                        sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
541
                        sb.AppendLine("Fail Child Symbol Name : " + child.NAME);
542
                    }
543
                    loop(child, item, sb);
544
                }
545
            }
546
            foreach (var item in LINES)
547
            {
548
                if (string.IsNullOrEmpty(item.SPPID.ModelItemId))
549
                    sb.AppendLine("Fail Line Modeling UID : " + item.UID);
550
            }
551
            foreach (var item in LINENUMBERS)
552
            {
553
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
554
                    sb.AppendLine("Fail Line Number Modeling UID : " + item.UID);
555
            }
556
            foreach (var item in NOTES)
557
            {
558
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
559
                    sb.AppendLine("Fail Note Text Modeling UID : " + item.UID);
560
            }
561
            foreach (var item in TEXTINFOS)
562
            {
563
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
564
                    sb.AppendLine("Fail Text Modeling UID : " + item.UID);
565
            }
566
            foreach (var item in EndBreaks)
567
            {
568
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
569
                    sb.AppendLine("Fail End Break Modeling UID : " + item.UID);
570
            }
571
            foreach (var item in SpecBreaks)
572
            {
573
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
574
                    sb.AppendLine("Fail SpecBreak Modeling UID : " + item.UID);
575
            }
576
            sb.AppendLine("End Modeling Result");
577
            Log.Write(sb.ToString());
578
        }
579
580
        private void loop(ChildSymbol childLoop, Symbol item, StringBuilder sb)
581
        {
582
            foreach (var childLoopLoop in childLoop.ChildSymbols)
583
            {
584
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
585
                {
586
                    sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
587
                    sb.AppendLine("Fail Child Symbol Name : " + childLoopLoop.NAME);
588
                }
589 3c8e40a5 gaqhf
                loop(childLoopLoop, item, sb);
590 30ba9ae0 gaqhf
            }
591
        }
592 bca86986 gaqhf
    }
593
}
클립보드 이미지 추가 (최대 크기: 500 MB)