프로젝트

일반

사용자정보

통계
| 개정판:

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

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