프로젝트

일반

사용자정보

통계
| 개정판:

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

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