프로젝트

일반

사용자정보

통계
| 개정판:

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

이력 | 보기 | 이력해설 | 다운로드 (25.8 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 4f0c0ed6 gaqhf
        public string BulkAttributeName { get; set; }
37 f947c634 gaqhf
        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 fb2d9638 gaqhf
227
            foreach (var item in VendorPackages)
228
            {
229
                double x = item.CenterPoint[0];
230
                double y = item.CenterPoint[1];
231
                SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY);
232
                item.SPPID.ORIGINAL_X = x;
233
                item.SPPID.ORIGINAL_Y = y;
234
            }
235 39a2a688 gaqhf
        }
236 4b4dbca9 gaqhf
237 c01ce90b gaqhf
        /// <summary>
238
        /// 좌표 보정
239
        /// </summary>
240
        public void CoordinateCorrection()
241
        {
242
            foreach (Symbol symbol in SYMBOLS)
243
            {
244
                if (!symbol.SPPID.IsCorrectionX)
245
                {
246
                    List<object> group = new List<object>();
247
                    group.Add(symbol);
248
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.VERTICAL);
249
250
                    List<Symbol> groupSymbols = (from sym in @group
251
                                                 where sym.GetType() == typeof(Symbol)
252
                                                 select sym as Symbol).ToList();
253
254
                    // X 좌표만 보정
255
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionX);
256
                    double value = symbol.SPPID.ORIGINAL_X;
257
                    if (correctionSymbol == null)
258
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
259
                    else
260
                        value = correctionSymbol.SPPID.ORIGINAL_X;
261
262
                    foreach (var item in groupSymbols)
263
                    {
264
                        item.SPPID.IsCorrectionX = true;
265
                        item.SPPID.ORIGINAL_X = value;
266 d9794a6c gaqhf
                        item.SPPID.CorrectionX_GroupSymbols = groupSymbols;
267 c01ce90b gaqhf
                    }
268
                }
269
270
                if (!symbol.SPPID.IsCorrectionY)
271
                {
272
                    List<object> group = new List<object>();
273
                    group.Add(symbol);
274
                    FindGroupBySymbolAndSlopeType(symbol, group, SlopeType.HORIZONTAL);
275
276
                    List<Symbol> groupSymbols = (from sym in @group
277
                                                 where sym.GetType() == typeof(Symbol)
278
                                                 select sym as Symbol).ToList();
279
280
                    // Y 좌표만 보정
281
                    Symbol correctionSymbol = groupSymbols.Find(x => x.SPPID.IsCorrectionY);
282
                    double value = symbol.SPPID.ORIGINAL_Y;
283
                    if (correctionSymbol == null)
284
                        SPPIDUtil.ConvertGridPointOnlyOnePoint(ref value);
285
                    else
286
                        value = correctionSymbol.SPPID.ORIGINAL_Y;
287
288
                    foreach (var item in groupSymbols)
289
                    {
290
                        item.SPPID.IsCorrectionY = true;
291
                        item.SPPID.ORIGINAL_Y = value;
292 d9794a6c gaqhf
                        item.SPPID.CorrectionY_GroupSymbols = groupSymbols;
293 c01ce90b gaqhf
                    }
294
                }
295
            }
296 a0e3dca4 gaqhf
297
            foreach (Line line in LINES)
298
            {
299
                double tempX = line.SPPID.START_X;
300
                double tempY = line.SPPID.START_Y;
301
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
302
                line.SPPID.START_X = tempX;
303
                line.SPPID.START_Y = tempY;
304
305
                tempX = line.SPPID.END_X;
306
                tempY = line.SPPID.END_Y;
307
                SPPIDUtil.ConvertGridPoint(ref tempX, ref tempY);
308
                line.SPPID.END_X = tempX;
309
                line.SPPID.END_Y = tempY;
310
311
                if (line.SlopeType == SlopeType.HORIZONTAL)
312
                    line.SPPID.END_Y = line.SPPID.START_Y;
313
                else if (line.SlopeType == SlopeType.VERTICAL)
314
                    line.SPPID.END_X = line.SPPID.START_X;
315
            }
316 c01ce90b gaqhf
        }
317
318
        private void FindGroupBySymbolAndSlopeType(Symbol symbol, List<object> group, SlopeType searchType)
319
        {
320
            foreach (var connector in symbol.CONNECTORS)
321
            {
322
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
323
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
324
                {
325
                    Symbol connSymbol = connectedItem as Symbol;
326
                    SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y, connSymbol.SPPID.ORIGINAL_X, connSymbol.SPPID.ORIGINAL_Y);
327
                    if (slopeType == searchType)
328
                    {
329
                        if (!group.Contains(connSymbol))
330
                        {
331
                            group.Add(connSymbol);
332
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
333
                        }
334
                    }
335
                }
336
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
337
                {
338
                    Line connLine = connectedItem as Line;
339 02480ac1 gaqhf
340 1ed39474 gaqhf
                    Connector otherConnector = connLine.CONNECTORS.Find(x => x.CONNECTEDITEM != symbol.UID);
341 f1a7faf9 gaqhf
                    int connectorIndex = connLine.CONNECTORS.IndexOf(otherConnector);
342 02480ac1 gaqhf
                    double lineX = double.NaN;
343
                    double lineY = double.NaN;
344
                    // Symbol의 Connector ScenePoint
345 f1a7faf9 gaqhf
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? connLine.STARTPOINT : connLine.ENDPOINT, ref lineX, ref lineY);
346 02480ac1 gaqhf
                    double symbolX = double.NaN;
347
                    double symbolY = double.NaN;
348
                    SPPIDUtil.ConvertPointBystring(symbol.ORIGINALPOINT, ref symbolX, ref symbolY);
349
350
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
351 c01ce90b gaqhf
                    if (slopeType == searchType)
352
                    {
353
                        if (!group.Contains(connLine))
354
                        {
355
                            group.Add(connLine);
356
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
357
                        }
358
                    }
359
                }
360
            }
361
        }
362
363 f1a7faf9 gaqhf
        private void FindGroupByLineAndSlopeType(Line line, List<object> group, SlopeType searchType)
364 c01ce90b gaqhf
        {
365 f1a7faf9 gaqhf
            foreach (var connector in line.CONNECTORS)
366 c01ce90b gaqhf
            {
367
                object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
368
                if (connectedItem != null && connectedItem.GetType() == typeof(Symbol))
369
                {
370
                    Symbol connSymbol = connectedItem as Symbol;
371 02480ac1 gaqhf
372 f1a7faf9 gaqhf
                    Connector otherConnector = line.CONNECTORS.Find(x => x.CONNECTEDITEM != connSymbol.UID);
373
                    int connectorIndex = line.CONNECTORS.IndexOf(otherConnector);
374 c01ce90b gaqhf
                    double lineX = double.NaN;
375
                    double lineY = double.NaN;
376 02480ac1 gaqhf
                    // Line의 Connector ScenePoint
377 f1a7faf9 gaqhf
                    SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? line.STARTPOINT : line.ENDPOINT, ref lineX, ref lineY);
378 c01ce90b gaqhf
                    double symbolX = double.NaN;
379
                    double symbolY = double.NaN;
380
                    SPPIDUtil.ConvertPointBystring(connSymbol.ORIGINALPOINT, ref symbolX, ref symbolY);
381
382
                    SlopeType slopeType = SPPIDUtil.CalcSlope(lineX, lineY, symbolX, symbolY);
383
                    if (slopeType == searchType)
384
                    {
385
                        if (!group.Contains(connSymbol))
386
                        {
387
                            group.Add(connSymbol);
388
                            FindGroupBySymbolAndSlopeType(connSymbol, group, searchType);
389
                        }
390
                    }
391
                }
392
                else if (connectedItem != null && connectedItem.GetType() == typeof(Line))
393
                {
394
                    Line connLine = connectedItem as Line;
395
                    SlopeType slopeType = SPPIDUtil.CalcSlope(connLine.SPPID.START_X, connLine.SPPID.START_Y, connLine.SPPID.END_X, connLine.SPPID.END_Y);
396
                    if (slopeType == searchType)
397
                    {
398
                        if (!group.Contains(connLine))
399
                        {
400
                            group.Add(connLine);
401
                            FindGroupByLineAndSlopeType(connLine, group, searchType);
402
                        }
403
                    }
404
                }
405
            }
406
        }
407
408 4b4dbca9 gaqhf
        private void SetChildSymbolSPPIDInfo(ChildSymbol item)
409
        {
410
            foreach (var childSymbol in item.ChildSymbols)
411
            {
412
                if (childSymbol.SPPID == null)
413
                    childSymbol.SPPID = new SPPIDSymbolInfo();
414
                SetChildSymbolSPPIDInfo(childSymbol);
415
            }
416
        }
417
      
418 39a2a688 gaqhf
        public bool SetSPPIDMapping()
419
        {
420 68e9394a gaqhf
            bool result = true;
421
            StringBuilder sb = new StringBuilder();
422 39a2a688 gaqhf
            foreach (var item in SYMBOLS)
423
            {
424
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
425
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
426
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
427 68e9394a gaqhf
                {
428
                    result = false;
429
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
430
                }
431
                    
432 4b4dbca9 gaqhf
433
                foreach (var childSymbol in item.ChildSymbols)
434
                {
435
                    ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
436
                    childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
437
                    if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol))
438 68e9394a gaqhf
                    {
439
                        result = false;
440
                        sb.AppendLine("Need Mapping Symbol Name : " + childSymbol.NAME);
441
                    }
442 4b4dbca9 gaqhf
                }
443 39a2a688 gaqhf
            }
444
445
            foreach (var item in LINES)
446
            {
447
                LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID);
448
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
449
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
450 68e9394a gaqhf
                {
451
                    result = false;
452
                    sb.AppendLine("Need Mapping Line Type : " + item.TYPE);
453
                }
454 f947c634 gaqhf
            }
455
456 809a7640 gaqhf
            foreach (var item in Equipments)
457
            {
458
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
459
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
460
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
461 68e9394a gaqhf
                {
462
                    result = false;
463
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
464
                }
465 809a7640 gaqhf
            }
466
467 3165c259 gaqhf
            foreach (var item in EndBreaks)
468
            {
469
                SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID);
470
                item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null;
471
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
472 68e9394a gaqhf
                {
473
                    result = false;
474
                    sb.AppendLine("Need Mapping Symbol Name : " + item.NAME);
475
                }
476 3165c259 gaqhf
            }
477
478 10872260 gaqhf
            foreach (var item in LINENUMBERS)
479
            {
480
                if (LineNumberMappings.Count > 0)
481
                    item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME;
482
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
483 68e9394a gaqhf
                {
484
                    result = false;
485
                    sb.AppendLine("Need Mapping LineNumber Mapping");
486
                }
487 10872260 gaqhf
            }
488
489 6b298450 gaqhf
            ETCSetting etc = ETCSetting.GetInstance();
490
            foreach (var item in NOTES)
491
            {
492
                item.SPPID.MAPPINGNAME = etc.NoteSymbolPath;
493
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
494 68e9394a gaqhf
                {
495
                    result = false;
496
                    sb.AppendLine("Need Mapping Note Mapping");
497
                }
498 6b298450 gaqhf
            }
499
500
            foreach (var item in TEXTINFOS)
501
            {
502
                item.SPPID.MAPPINGNAME = etc.TextSymbolPath;
503
                if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME))
504 68e9394a gaqhf
                {
505
                    result = false;
506
                    sb.AppendLine("Need Mapping Text Mapping");
507
                }
508 6b298450 gaqhf
            }
509 4b4dbca9 gaqhf
510 68e9394a gaqhf
            if (!result)
511
                ValidationMessage += sb.ToString();
512 5673a69f gaqhf
            else
513
                MappingValidation = true;
514 68e9394a gaqhf
515
            return result;
516 f947c634 gaqhf
        }
517 5dfb8a24 gaqhf
518 4b4dbca9 gaqhf
        private bool SetChildSymbolMapping(ChildSymbol item)
519
        {
520
            foreach (var childSymbol in item.ChildSymbols)
521
            {
522
                ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME);
523
                childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null;
524
                if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME))
525
                    return false;
526
                else
527
                    return SetChildSymbolMapping(childSymbol);
528
            }
529
530
            return true;
531
        }
532 30ba9ae0 gaqhf
533
        public void CheckModelingResult()
534
        {
535
            StringBuilder sb = new StringBuilder();
536
            sb.AppendLine("Modeling Result");
537 c24d977b gaqhf
            int failSymbolCnt = 0;
538
            int failLineCnt = 0;
539 8fbc78be gaqhf
            int failTextCnt = 0;
540 30ba9ae0 gaqhf
            foreach (var item in Equipments)
541
            {
542
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
543 c24d977b gaqhf
                {
544 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Equipment Modeling UID : " + item.UID);
545 c24d977b gaqhf
                    failSymbolCnt++;
546
                }
547 30ba9ae0 gaqhf
            }
548
            foreach (var item in SYMBOLS)
549
            {
550
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
551 c24d977b gaqhf
                {
552 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Symbol Modeling UID : " + item.UID);
553 c24d977b gaqhf
                    failSymbolCnt++;
554
                }
555 30ba9ae0 gaqhf
                foreach (var child in item.ChildSymbols)
556
                {
557
                    if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
558
                    {
559
                        sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
560
                        sb.AppendLine("Fail Child Symbol Name : " + child.NAME);
561
                    }
562
                    loop(child, item, sb);
563
                }
564
            }
565
            foreach (var item in LINES)
566
            {
567
                if (string.IsNullOrEmpty(item.SPPID.ModelItemId))
568 c24d977b gaqhf
                {
569 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Line Modeling UID : " + item.UID);
570 c24d977b gaqhf
                    failLineCnt++;
571
                }
572 30ba9ae0 gaqhf
            }
573
            foreach (var item in LINENUMBERS)
574
            {
575
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
576
                    sb.AppendLine("Fail Line Number Modeling UID : " + item.UID);
577
            }
578
            foreach (var item in NOTES)
579
            {
580
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
581 8fbc78be gaqhf
                {
582 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Note Text Modeling UID : " + item.UID);
583 8fbc78be gaqhf
                    failTextCnt++;
584
                }
585 30ba9ae0 gaqhf
            }
586
            foreach (var item in TEXTINFOS)
587
            {
588
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
589 8fbc78be gaqhf
                {
590 30ba9ae0 gaqhf
                    sb.AppendLine("Fail Text Modeling UID : " + item.UID);
591 8fbc78be gaqhf
                    failTextCnt++;
592
                }
593 30ba9ae0 gaqhf
            }
594
            foreach (var item in EndBreaks)
595
            {
596
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
597 c24d977b gaqhf
                {
598 30ba9ae0 gaqhf
                    sb.AppendLine("Fail End Break Modeling UID : " + item.UID);
599 c24d977b gaqhf
                    failSymbolCnt++;
600
                }
601 30ba9ae0 gaqhf
            }
602
            foreach (var item in SpecBreaks)
603
            {
604
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
605 c24d977b gaqhf
                {
606 30ba9ae0 gaqhf
                    sb.AppendLine("Fail SpecBreak Modeling UID : " + item.UID);
607 c24d977b gaqhf
                    failSymbolCnt++;
608
                }
609 30ba9ae0 gaqhf
            }
610
            sb.AppendLine("End Modeling Result");
611 fa24d104 gaqhf
            Log.Write(sb.ToString());
612 c24d977b gaqhf
613
            int allSymbol = Equipments.Count + SYMBOLS.Count + EndBreaks.Count + SpecBreaks.Count;
614 97a6ee26 gaqhf
615
            Log.Write("Success Symbol Modeling : " + (allSymbol - failSymbolCnt));
616
            Log.Write("Fail Symbol Modeling : " + failSymbolCnt);
617
            Log.Write("Success Line Modeling : " + (LINES.Count - failLineCnt));
618
            Log.Write("Fail Line Modeling : " + failLineCnt);
619 8fbc78be gaqhf
            Log.Write("Success Text/Note Modeling : " + (TEXTINFOS.Count + NOTES.Count - failTextCnt));
620
            Log.Write("Fail Text/Note Modeling : " + failTextCnt);
621 30ba9ae0 gaqhf
        }
622
623
        private void loop(ChildSymbol childLoop, Symbol item, StringBuilder sb)
624
        {
625
            foreach (var childLoopLoop in childLoop.ChildSymbols)
626
            {
627
                if (string.IsNullOrEmpty(item.SPPID.RepresentationId))
628
                {
629
                    sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID);
630
                    sb.AppendLine("Fail Child Symbol Name : " + childLoopLoop.NAME);
631
                }
632 3c8e40a5 gaqhf
                loop(childLoopLoop, item, sb);
633 30ba9ae0 gaqhf
            }
634
        }
635 bca86986 gaqhf
    }
636
}
클립보드 이미지 추가 (최대 크기: 500 MB)