hytos / DTI_PID / SPPIDConverter / SPPIDModel / SPPID_Document.cs @ f28a350a
이력 | 보기 | 이력해설 | 다운로드 (24.3 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 |
|
228 |
/// <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 |
item.SPPID.CorrectionX_GroupSymbols = groupSymbols; |
258 |
} |
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 |
item.SPPID.CorrectionY_GroupSymbols = groupSymbols; |
284 |
} |
285 |
} |
286 |
} |
287 |
|
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 |
} |
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 |
|
331 |
Connector otherConnector = connLine.CONNECTORS.Find(x => x.CONNECTEDITEM != symbol.UID); |
332 |
int connectorIndex = connLine.CONNECTORS.IndexOf(otherConnector); |
333 |
double lineX = double.NaN; |
334 |
double lineY = double.NaN; |
335 |
// Symbol의 Connector ScenePoint |
336 |
SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? connLine.STARTPOINT : connLine.ENDPOINT, ref lineX, ref lineY); |
337 |
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 |
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 |
private void FindGroupByLineAndSlopeType(Line line, List<object> group, SlopeType searchType) |
355 |
{ |
356 |
foreach (var connector in line.CONNECTORS) |
357 |
{ |
358 |
object connectedItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
359 |
if (connectedItem != null && connectedItem.GetType() == typeof(Symbol)) |
360 |
{ |
361 |
Symbol connSymbol = connectedItem as Symbol; |
362 |
|
363 |
Connector otherConnector = line.CONNECTORS.Find(x => x.CONNECTEDITEM != connSymbol.UID); |
364 |
int connectorIndex = line.CONNECTORS.IndexOf(otherConnector); |
365 |
double lineX = double.NaN; |
366 |
double lineY = double.NaN; |
367 |
// Line의 Connector ScenePoint |
368 |
SPPIDUtil.ConvertPointBystring(connectorIndex == 0 ? line.STARTPOINT : line.ENDPOINT, ref lineX, ref lineY); |
369 |
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 |
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 |
public bool SetSPPIDMapping() |
410 |
{ |
411 |
bool result = true; |
412 |
StringBuilder sb = new StringBuilder(); |
413 |
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 |
{ |
419 |
result = false; |
420 |
sb.AppendLine("Need Mapping Symbol Name : " + item.NAME); |
421 |
} |
422 |
|
423 |
|
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 |
{ |
430 |
result = false; |
431 |
sb.AppendLine("Need Mapping Symbol Name : " + childSymbol.NAME); |
432 |
} |
433 |
} |
434 |
} |
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 |
{ |
442 |
result = false; |
443 |
sb.AppendLine("Need Mapping Line Type : " + item.TYPE); |
444 |
} |
445 |
} |
446 |
|
447 |
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 |
{ |
453 |
result = false; |
454 |
sb.AppendLine("Need Mapping Symbol Name : " + item.NAME); |
455 |
} |
456 |
} |
457 |
|
458 |
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 |
{ |
464 |
result = false; |
465 |
sb.AppendLine("Need Mapping Symbol Name : " + item.NAME); |
466 |
} |
467 |
} |
468 |
|
469 |
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 |
{ |
475 |
result = false; |
476 |
sb.AppendLine("Need Mapping LineNumber Mapping"); |
477 |
} |
478 |
} |
479 |
|
480 |
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 |
{ |
486 |
result = false; |
487 |
sb.AppendLine("Need Mapping Note Mapping"); |
488 |
} |
489 |
} |
490 |
|
491 |
foreach (var item in TEXTINFOS) |
492 |
{ |
493 |
item.SPPID.MAPPINGNAME = etc.TextSymbolPath; |
494 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
495 |
{ |
496 |
result = false; |
497 |
sb.AppendLine("Need Mapping Text Mapping"); |
498 |
} |
499 |
} |
500 |
|
501 |
if (!result) |
502 |
ValidationMessage += sb.ToString(); |
503 |
else |
504 |
MappingValidation = true; |
505 |
|
506 |
return result; |
507 |
} |
508 |
|
509 |
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 |
|
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 |
loop(childLoopLoop, item, sb); |
591 |
} |
592 |
} |
593 |
} |
594 |
} |