hytos / DTI_PID / SPPIDConverter / SPPIDModel / SPPID_Document.cs @ acb80620
이력 | 보기 | 이력해설 | 다운로드 (25.4 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Data; |
7 |
using Converter.BaseModel; |
8 |
using Converter.SPPID.Util; |
9 |
|
10 |
namespace Converter.SPPID.Model |
11 |
{ |
12 |
public class SPPID_Document : Document |
13 |
{ |
14 |
public SPPID_Document(string xmlPath, DataTable ID2SymbolTypeDT) : base(xmlPath, ID2SymbolTypeDT) |
15 |
{ |
16 |
|
17 |
} |
18 |
|
19 |
public List<SymbolMapping> SymbolMappings; |
20 |
public List<ChildSymbolMapping> ChildSymbolMappings; |
21 |
public List<LineMapping> LineMappings; |
22 |
public List<LineNumberMapping> LineNumberMappings; |
23 |
public List<AttributeMapping> AttributeMappings; |
24 |
public ETCSetting ETCSetting; |
25 |
|
26 |
public DataTable SymbolTable { get; set; } |
27 |
|
28 |
public List<Group> GROUPS = new List<Group>(); |
29 |
|
30 |
public string DrawingName { get; set; } |
31 |
public string DrawingNumber { get; set; } |
32 |
public string Unit { get; set; } |
33 |
public string Template { get; set; } |
34 |
public string SPPID_DrawingNumber { get; set; } |
35 |
public string SPPID_DrawingName { get; set; } |
36 |
|
37 |
public void SetSPPIDInfo() |
38 |
{ |
39 |
foreach (var item in SYMBOLS) |
40 |
{ |
41 |
if (item.SPPID == null) |
42 |
item.SPPID = new SPPIDSymbolInfo(); |
43 |
|
44 |
foreach (var childSymbol in item.ChildSymbols) |
45 |
{ |
46 |
if (childSymbol.SPPID == null) |
47 |
childSymbol.SPPID = new SPPIDSymbolInfo(); |
48 |
SetChildSymbolSPPIDInfo(childSymbol); |
49 |
} |
50 |
} |
51 |
|
52 |
foreach (var item in LINES) |
53 |
{ |
54 |
if (item.SPPID == null) |
55 |
item.SPPID = new SPPIDLineInfo(); |
56 |
} |
57 |
|
58 |
foreach (var item in Equipments) |
59 |
{ |
60 |
if (item.SPPID == null) |
61 |
item.SPPID = new SPPIDSymbolInfo(); |
62 |
} |
63 |
|
64 |
foreach (var item in EndBreaks) |
65 |
{ |
66 |
if (item.SPPID == null) |
67 |
item.SPPID = new SPPIDSymbolInfo(); |
68 |
} |
69 |
|
70 |
foreach (var item in SpecBreaks) |
71 |
{ |
72 |
if (item.SPPID == null) |
73 |
item.SPPID = new SPPIDSymbolInfo(); |
74 |
} |
75 |
|
76 |
foreach (var item in LINENUMBERS) |
77 |
{ |
78 |
if (item.SPPID == null) |
79 |
item.SPPID = new SPPIDSymbolInfo(); |
80 |
} |
81 |
|
82 |
foreach (var item in TEXTINFOS) |
83 |
{ |
84 |
if (item.SPPID == null) |
85 |
item.SPPID = new SPPIDSymbolInfo(); |
86 |
} |
87 |
|
88 |
foreach (var item in NOTES) |
89 |
{ |
90 |
if (item.SPPID == null) |
91 |
item.SPPID = new SPPIDSymbolInfo(); |
92 |
} |
93 |
} |
94 |
|
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 |
|
104 |
item.SPPID.ORIGINAL_X = x; |
105 |
item.SPPID.ORIGINAL_Y = y; |
106 |
} |
107 |
|
108 |
foreach (var item in LINES) |
109 |
{ |
110 |
double startX = double.NaN; |
111 |
double startY = double.NaN; |
112 |
|
113 |
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 |
|
118 |
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 |
} |
128 |
|
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 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
135 |
|
136 |
item.SPPID.ORIGINAL_X = x; |
137 |
item.SPPID.ORIGINAL_Y = y; |
138 |
} |
139 |
|
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 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
146 |
item.SPPID.ORIGINAL_X = x; |
147 |
item.SPPID.ORIGINAL_Y = y; |
148 |
} |
149 |
|
150 |
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 |
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 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
167 |
item.SPPID.ORIGINAL_X = x; |
168 |
item.SPPID.ORIGINAL_Y = y; |
169 |
|
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 |
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 |
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 |
} |
182 |
|
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 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
189 |
item.SPPID.ORIGINAL_X = x; |
190 |
item.SPPID.ORIGINAL_Y = y; |
191 |
|
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 |
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 |
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 |
} |
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 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
211 |
item.SPPID.ORIGINAL_X = x; |
212 |
item.SPPID.ORIGINAL_Y = y; |
213 |
|
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 |
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 |
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 |
} |
226 |
|
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 |
} |
236 |
|
237 |
/// <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 |
item.SPPID.CorrectionX_GroupSymbols = groupSymbols; |
267 |
} |
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 |
item.SPPID.CorrectionY_GroupSymbols = groupSymbols; |
293 |
} |
294 |
} |
295 |
} |
296 |
|
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 |
} |
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 |
|
340 |
Connector otherConnector = connLine.CONNECTORS.Find(x => x.CONNECTEDITEM != symbol.UID); |
341 |
int connectorIndex = connLine.CONNECTORS.IndexOf(otherConnector); |
342 |
double lineX = double.NaN; |
343 |
double lineY = double.NaN; |
344 |
// Symbol의 Connector ScenePoint |
345 |
SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? connLine.STARTPOINT : connLine.ENDPOINT, ref lineX, ref lineY); |
346 |
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 |
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 |
private void FindGroupByLineAndSlopeType(Line line, List<object> group, SlopeType searchType) |
364 |
{ |
365 |
foreach (var connector in line.CONNECTORS) |
366 |
{ |
367 |
object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
368 |
if (connectedItem != null && connectedItem.GetType() == typeof(Symbol)) |
369 |
{ |
370 |
Symbol connSymbol = connectedItem as Symbol; |
371 |
|
372 |
Connector otherConnector = line.CONNECTORS.Find(x => x.CONNECTEDITEM != connSymbol.UID); |
373 |
int connectorIndex = line.CONNECTORS.IndexOf(otherConnector); |
374 |
double lineX = double.NaN; |
375 |
double lineY = double.NaN; |
376 |
// Line의 Connector ScenePoint |
377 |
SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? line.STARTPOINT : line.ENDPOINT, ref lineX, ref lineY); |
378 |
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 |
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 |
public bool SetSPPIDMapping() |
419 |
{ |
420 |
bool result = true; |
421 |
StringBuilder sb = new StringBuilder(); |
422 |
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 |
{ |
428 |
result = false; |
429 |
sb.AppendLine("Need Mapping Symbol Name : " + item.NAME); |
430 |
} |
431 |
|
432 |
|
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 |
{ |
439 |
result = false; |
440 |
sb.AppendLine("Need Mapping Symbol Name : " + childSymbol.NAME); |
441 |
} |
442 |
} |
443 |
} |
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 |
{ |
451 |
result = false; |
452 |
sb.AppendLine("Need Mapping Line Type : " + item.TYPE); |
453 |
} |
454 |
} |
455 |
|
456 |
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 |
{ |
462 |
result = false; |
463 |
sb.AppendLine("Need Mapping Symbol Name : " + item.NAME); |
464 |
} |
465 |
} |
466 |
|
467 |
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 |
{ |
473 |
result = false; |
474 |
sb.AppendLine("Need Mapping Symbol Name : " + item.NAME); |
475 |
} |
476 |
} |
477 |
|
478 |
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 |
{ |
484 |
result = false; |
485 |
sb.AppendLine("Need Mapping LineNumber Mapping"); |
486 |
} |
487 |
} |
488 |
|
489 |
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 |
{ |
495 |
result = false; |
496 |
sb.AppendLine("Need Mapping Note Mapping"); |
497 |
} |
498 |
} |
499 |
|
500 |
foreach (var item in TEXTINFOS) |
501 |
{ |
502 |
item.SPPID.MAPPINGNAME = etc.TextSymbolPath; |
503 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
504 |
{ |
505 |
result = false; |
506 |
sb.AppendLine("Need Mapping Text Mapping"); |
507 |
} |
508 |
} |
509 |
|
510 |
if (!result) |
511 |
ValidationMessage += sb.ToString(); |
512 |
else |
513 |
MappingValidation = true; |
514 |
|
515 |
return result; |
516 |
} |
517 |
|
518 |
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 |
|
533 |
public void CheckModelingResult() |
534 |
{ |
535 |
StringBuilder sb = new StringBuilder(); |
536 |
sb.AppendLine("Modeling Result"); |
537 |
int failSymbolCnt = 0; |
538 |
int failLineCnt = 0; |
539 |
foreach (var item in Equipments) |
540 |
{ |
541 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
542 |
{ |
543 |
sb.AppendLine("Fail Equipment Modeling UID : " + item.UID); |
544 |
failSymbolCnt++; |
545 |
} |
546 |
} |
547 |
foreach (var item in SYMBOLS) |
548 |
{ |
549 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
550 |
{ |
551 |
sb.AppendLine("Fail Symbol Modeling UID : " + item.UID); |
552 |
failSymbolCnt++; |
553 |
} |
554 |
foreach (var child in item.ChildSymbols) |
555 |
{ |
556 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
557 |
{ |
558 |
sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID); |
559 |
sb.AppendLine("Fail Child Symbol Name : " + child.NAME); |
560 |
} |
561 |
loop(child, item, sb); |
562 |
} |
563 |
} |
564 |
foreach (var item in LINES) |
565 |
{ |
566 |
if (string.IsNullOrEmpty(item.SPPID.ModelItemId)) |
567 |
{ |
568 |
sb.AppendLine("Fail Line Modeling UID : " + item.UID); |
569 |
failLineCnt++; |
570 |
} |
571 |
} |
572 |
foreach (var item in LINENUMBERS) |
573 |
{ |
574 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
575 |
sb.AppendLine("Fail Line Number Modeling UID : " + item.UID); |
576 |
} |
577 |
foreach (var item in NOTES) |
578 |
{ |
579 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
580 |
sb.AppendLine("Fail Note Text Modeling UID : " + item.UID); |
581 |
} |
582 |
foreach (var item in TEXTINFOS) |
583 |
{ |
584 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
585 |
sb.AppendLine("Fail Text Modeling UID : " + item.UID); |
586 |
} |
587 |
foreach (var item in EndBreaks) |
588 |
{ |
589 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
590 |
{ |
591 |
sb.AppendLine("Fail End Break Modeling UID : " + item.UID); |
592 |
failSymbolCnt++; |
593 |
} |
594 |
} |
595 |
foreach (var item in SpecBreaks) |
596 |
{ |
597 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
598 |
{ |
599 |
sb.AppendLine("Fail SpecBreak Modeling UID : " + item.UID); |
600 |
failSymbolCnt++; |
601 |
} |
602 |
} |
603 |
sb.AppendLine("End Modeling Result"); |
604 |
Log.Write(sb.ToString()); |
605 |
|
606 |
int allSymbol = Equipments.Count + SYMBOLS.Count + EndBreaks.Count + SpecBreaks.Count; |
607 |
|
608 |
Log.Write("Success Symbol Modeling : " + (allSymbol - failSymbolCnt)); |
609 |
Log.Write("Fail Symbol Modeling : " + failSymbolCnt); |
610 |
Log.Write("Success Line Modeling : " + (LINES.Count - failLineCnt)); |
611 |
Log.Write("Fail Line Modeling : " + failLineCnt); |
612 |
} |
613 |
|
614 |
private void loop(ChildSymbol childLoop, Symbol item, StringBuilder sb) |
615 |
{ |
616 |
foreach (var childLoopLoop in childLoop.ChildSymbols) |
617 |
{ |
618 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
619 |
{ |
620 |
sb.AppendLine("Fail Child Symbol Modeling UID : " + item.UID); |
621 |
sb.AppendLine("Fail Child Symbol Name : " + childLoopLoop.NAME); |
622 |
} |
623 |
loop(childLoopLoop, item, sb); |
624 |
} |
625 |
} |
626 |
} |
627 |
} |