1
|
using System;
|
2
|
using System.Collections.Generic;
|
3
|
using System.Linq;
|
4
|
using System.Text;
|
5
|
using System.Threading.Tasks;
|
6
|
using System.IO;
|
7
|
using System.Xml.Linq;
|
8
|
using System.Windows.Forms;
|
9
|
using Converter.SPPID.Util;
|
10
|
using System.Data;
|
11
|
|
12
|
namespace Converter.BaseModel
|
13
|
{
|
14
|
public class Document
|
15
|
{
|
16
|
private string _DWGNAME;
|
17
|
private string _SIZE;
|
18
|
private double _SIZE_WIDTH;
|
19
|
private double _SIZE_HEIGHT;
|
20
|
private string _UID;
|
21
|
private List<Symbol> _SYMBOLS = new List<Symbol>();
|
22
|
private List<Text> _TEXTINFOS = new List<Text>();
|
23
|
private List<Note> _NOTES = new List<Note>();
|
24
|
private List<Line> _LINES = new List<Line>();
|
25
|
private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
|
26
|
private List<TrimLine> _TRIMLINES = new List<TrimLine>();
|
27
|
private List<EndBreak> _EndBreaks = new List<EndBreak>();
|
28
|
private List<SpecBreak> _SpecBreaks = new List<SpecBreak>();
|
29
|
private List<Equipment> _Equipments = new List<Equipment>();
|
30
|
private bool _Enable;
|
31
|
private bool _Validation;
|
32
|
private bool _MappingValidation;
|
33
|
private string _ValidationMessage = string.Empty;
|
34
|
bool validationResult = false;
|
35
|
private DataTable ID2SymbolTypeDT;
|
36
|
|
37
|
public string ValidationMessage { get => _ValidationMessage; set => _ValidationMessage = value; }
|
38
|
|
39
|
public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
|
40
|
public List<Text> TEXTINFOS { get => _TEXTINFOS; set => _TEXTINFOS = value; }
|
41
|
public List<Note> NOTES { get => _NOTES; set => _NOTES = value; }
|
42
|
public List<Line> LINES { get => _LINES; set => _LINES = value; }
|
43
|
public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
|
44
|
public List<EndBreak> EndBreaks { get => _EndBreaks; set => _EndBreaks = value; }
|
45
|
public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; }
|
46
|
public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; }
|
47
|
public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
|
48
|
public string SIZE
|
49
|
{
|
50
|
get
|
51
|
{
|
52
|
return _SIZE;
|
53
|
}
|
54
|
set
|
55
|
{
|
56
|
_SIZE = value;
|
57
|
string[] pointArr = _SIZE.Split(new char[] { ',' });
|
58
|
if (pointArr.Length == 2)
|
59
|
{
|
60
|
_SIZE_WIDTH = Convert.ToDouble(pointArr[0]);
|
61
|
_SIZE_HEIGHT = Convert.ToDouble(pointArr[1]);
|
62
|
}
|
63
|
}
|
64
|
}
|
65
|
public double SIZE_WIDTH { get => _SIZE_WIDTH; }
|
66
|
public double SIZE_HEIGHT { get => _SIZE_HEIGHT; }
|
67
|
public List<TrimLine> TRIMLINES { get => _TRIMLINES; set => _TRIMLINES = value; }
|
68
|
public string PATH { get; set; }
|
69
|
public bool Enable { get => _Enable; set => _Enable = value; }
|
70
|
public bool Validation { get => _Validation; set => _Validation = value; }
|
71
|
public bool MappingValidation { get => _MappingValidation; set => _MappingValidation = value; }
|
72
|
public string UID { get => _UID; set => _UID = value; }
|
73
|
|
74
|
StringBuilder validationStringBuilder = new StringBuilder();
|
75
|
|
76
|
public Document(string xmlPath, DataTable ID2SymbolTypeDT)
|
77
|
{
|
78
|
this.ID2SymbolTypeDT = ID2SymbolTypeDT;
|
79
|
validationStringBuilder.AppendLine("Document Path : " + xmlPath);
|
80
|
validationStringBuilder.AppendLine("");
|
81
|
try
|
82
|
{
|
83
|
if (xmlPath != null)
|
84
|
{
|
85
|
PATH = xmlPath;
|
86
|
XElement xml = XElement.Load(xmlPath);
|
87
|
DWGNAME = xml.Element("DWGNAME").Value;
|
88
|
SIZE = xml.Element("SIZE").Value;
|
89
|
|
90
|
validationStringBuilder.AppendLine("Drawing Name : " + DWGNAME);
|
91
|
validationStringBuilder.AppendLine("");
|
92
|
|
93
|
SetText(xml.Element("TEXTINFOS"));
|
94
|
SetNote(xml.Element("NOTES"));
|
95
|
SetSymbol(xml.Element("SYMBOLS"));
|
96
|
SetLine(xml.Element("LINEINFOS"));
|
97
|
SetLineNumber(xml.Element("LINENOS"));
|
98
|
SetTrimLine(xml.Element("TRIMLINENOS"));
|
99
|
|
100
|
SetAllConnectors();
|
101
|
Enable = true;
|
102
|
ValidationCheck();
|
103
|
}
|
104
|
}
|
105
|
catch (Exception ex)
|
106
|
{
|
107
|
Enable = false;
|
108
|
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
|
109
|
}
|
110
|
}
|
111
|
|
112
|
#region READ XML
|
113
|
private void SetSymbol(XElement node)
|
114
|
{
|
115
|
foreach (XElement item in node.Elements("SYMBOL"))
|
116
|
{
|
117
|
string sType = item.Element("TYPE").Value;
|
118
|
|
119
|
DataRow[] rows = ID2SymbolTypeDT.Select(string.Format("Type = '{0}'", sType.Replace("'", "''")));
|
120
|
string sCategory = rows[0]["Category"].ToString();
|
121
|
|
122
|
if (sType == "Segment Breaks")
|
123
|
{
|
124
|
SpecBreak specBreak = new SpecBreak()
|
125
|
{
|
126
|
UID = item.Element("UID").Value,
|
127
|
DBUID = item.Element("DBUID").Value,
|
128
|
NAME = item.Element("NAME").Value,
|
129
|
TYPE = item.Element("TYPE").Value,
|
130
|
OWNER = item.Element("OWNER").Value,
|
131
|
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
|
132
|
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
|
133
|
LOCATION = item.Element("LOCATION").Value,
|
134
|
SIZE = item.Element("SIZE").Value,
|
135
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
136
|
PARENT = item.Element("PARENT").Value,
|
137
|
CHILD = item.Element("CHILD").Value,
|
138
|
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
|
139
|
AREA = item.Element("AREA").Value,
|
140
|
FLIP = Convert.ToInt32(item.Element("FLIP").Value),
|
141
|
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
|
142
|
};
|
143
|
SetAssociations(item.Element("ASSOCIATIONS"), specBreak.ASSOCIATIONS);
|
144
|
SetSymbolConnectors(item.Element("CONNECTORS"), specBreak.CONNECTORS, specBreak.CONNECTIONPOINT);
|
145
|
SetProperties(item.Element("PROPERTIES"), specBreak.PROPERTIES);
|
146
|
SetAttributes(item.Element("SYMBOLATTRIBUTES"), specBreak.ATTRIBUTES);
|
147
|
SetSpecBreakAttribute(specBreak);
|
148
|
|
149
|
SpecBreaks.Add(specBreak);
|
150
|
}
|
151
|
else if (sType == "End Break")
|
152
|
{
|
153
|
EndBreak endBreak = new EndBreak()
|
154
|
{
|
155
|
UID = item.Element("UID").Value,
|
156
|
DBUID = item.Element("DBUID").Value,
|
157
|
NAME = item.Element("NAME").Value,
|
158
|
TYPE = item.Element("TYPE").Value,
|
159
|
OWNER = item.Element("OWNER").Value,
|
160
|
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
|
161
|
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
|
162
|
LOCATION = item.Element("LOCATION").Value,
|
163
|
SIZE = item.Element("SIZE").Value,
|
164
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
165
|
PARENT = item.Element("PARENT").Value,
|
166
|
CHILD = item.Element("CHILD").Value,
|
167
|
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
|
168
|
AREA = item.Element("AREA").Value,
|
169
|
FLIP = Convert.ToInt32(item.Element("FLIP").Value),
|
170
|
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
|
171
|
};
|
172
|
SetAssociations(item.Element("ASSOCIATIONS"), endBreak.ASSOCIATIONS);
|
173
|
SetSymbolConnectors(item.Element("CONNECTORS"), endBreak.CONNECTORS, endBreak.CONNECTIONPOINT);
|
174
|
SetProperties(item.Element("PROPERTIES"), endBreak.PROPERTIES);
|
175
|
SetAttributes(item.Element("SYMBOLATTRIBUTES"), endBreak.ATTRIBUTES);
|
176
|
|
177
|
EndBreaks.Add(endBreak);
|
178
|
}
|
179
|
else if (sCategory == "Equipment" ||
|
180
|
sCategory == "Equipment Components")
|
181
|
{
|
182
|
Equipment equipment = new Equipment()
|
183
|
{
|
184
|
UID = item.Element("UID").Value,
|
185
|
DBUID = item.Element("DBUID").Value,
|
186
|
NAME = item.Element("NAME").Value,
|
187
|
TYPE = item.Element("TYPE").Value,
|
188
|
OWNER = item.Element("OWNER").Value,
|
189
|
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
|
190
|
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
|
191
|
LOCATION = item.Element("LOCATION").Value,
|
192
|
SIZE = item.Element("SIZE").Value,
|
193
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
194
|
PARENT = item.Element("PARENT").Value,
|
195
|
CHILD = item.Element("CHILD").Value,
|
196
|
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
|
197
|
AREA = item.Element("AREA").Value,
|
198
|
FLIP = Convert.ToInt32(item.Element("FLIP").Value),
|
199
|
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
|
200
|
};
|
201
|
SetAssociations(item.Element("ASSOCIATIONS"), equipment.ASSOCIATIONS);
|
202
|
SetSymbolConnectors(item.Element("CONNECTORS"), equipment.CONNECTORS, equipment.CONNECTIONPOINT);
|
203
|
SetProperties(item.Element("PROPERTIES"), equipment.PROPERTIES);
|
204
|
SetAttributes(item.Element("SYMBOLATTRIBUTES"), equipment.ATTRIBUTES);
|
205
|
|
206
|
Equipments.Add(equipment);
|
207
|
}
|
208
|
else
|
209
|
{
|
210
|
Symbol symbol = new Symbol()
|
211
|
{
|
212
|
UID = item.Element("UID").Value,
|
213
|
DBUID = item.Element("DBUID").Value,
|
214
|
NAME = item.Element("NAME").Value,
|
215
|
TYPE = item.Element("TYPE").Value,
|
216
|
OWNER = item.Element("OWNER").Value,
|
217
|
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value,
|
218
|
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value,
|
219
|
LOCATION = item.Element("LOCATION").Value,
|
220
|
SIZE = item.Element("SIZE").Value,
|
221
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
222
|
PARENT = item.Element("PARENT").Value,
|
223
|
CHILD = item.Element("CHILD").Value,
|
224
|
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value,
|
225
|
AREA = item.Element("AREA").Value,
|
226
|
FLIP = Convert.ToInt32(item.Element("FLIP").Value),
|
227
|
CURRENTPOINTMODEINDEX = Convert.ToInt32(item.Element("CURRENTPOINTMODEINDEX").Value)
|
228
|
};
|
229
|
|
230
|
SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS);
|
231
|
SetSymbolConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS, symbol.CONNECTIONPOINT);
|
232
|
SetProperties(item.Element("PROPERTIES"), symbol.PROPERTIES);
|
233
|
SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES);
|
234
|
SetChildSymbol(symbol);
|
235
|
|
236
|
SYMBOLS.Add(symbol);
|
237
|
}
|
238
|
}
|
239
|
}
|
240
|
|
241
|
private void SetLine(XElement node)
|
242
|
{
|
243
|
foreach (XElement item in node.Elements("LINE"))
|
244
|
{
|
245
|
Line line = new Line()
|
246
|
{
|
247
|
OWNER = item.Attribute("OWNER").Value,
|
248
|
UID = item.Element("UID").Value,
|
249
|
STARTPOINT = item.Element("STARTPOINT").Value,
|
250
|
ENDPOINT = item.Element("ENDPOINT").Value,
|
251
|
TYPE = item.Element("TYPE").Value,
|
252
|
TYPEUID = item.Element("TYPE").Attribute("TYPEUID").Value,
|
253
|
AREA = item.Element("AREA").Value,
|
254
|
THICKNESS = item.Element("THICKNESS").Value,
|
255
|
};
|
256
|
int flowMarkPercent = 0;
|
257
|
if (int.TryParse(item.Element("FLOWMARK").Value, out flowMarkPercent))
|
258
|
{
|
259
|
line.FLOWMARK = true;
|
260
|
line.FLOWMARK_PERCENT = flowMarkPercent;
|
261
|
}
|
262
|
else
|
263
|
line.FLOWMARK = false;
|
264
|
|
265
|
SetAssociations(item.Element("ASSOCIATIONS"), line.ASSOCIATIONS);
|
266
|
SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS);
|
267
|
SetAttributes(item.Element("SYMBOLATTRIBUTES"), line.ATTRIBUTES);
|
268
|
LINES.Add(line);
|
269
|
}
|
270
|
}
|
271
|
|
272
|
private void SetLineNumber(XElement node)
|
273
|
{
|
274
|
foreach (XElement item in node.Elements("LINE_NO"))
|
275
|
{
|
276
|
LineNumber lineNumber = new LineNumber()
|
277
|
{
|
278
|
UID = item.Element("UID").Value,
|
279
|
TEXT = item.Element("TEXT").Value,
|
280
|
LOCATION = item.Element("LOCATION").Value,
|
281
|
WIDTH = item.Element("WIDTH").Value,
|
282
|
HEIGHT = item.Element("HEIGHT").Value,
|
283
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
284
|
AREA = item.Element("AREA").Value,
|
285
|
SCENE = item.Element("SCENE").Value
|
286
|
};
|
287
|
if (item.Element("CONNLINE") != null)
|
288
|
lineNumber.CONNLINE = item.Element("CONNLINE").Value;
|
289
|
else
|
290
|
{
|
291
|
validationStringBuilder.AppendLine("Not exist CONNLINE!" + "\r\nLineNumber UID : " + lineNumber.UID);
|
292
|
validationStringBuilder.AppendLine();
|
293
|
validationResult = true;
|
294
|
}
|
295
|
|
296
|
SetLineNumberRuns(item, lineNumber.RUNS);
|
297
|
SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES);
|
298
|
SetAttributes(item, lineNumber.ATTRIBUTES);
|
299
|
LINENUMBERS.Add(lineNumber);
|
300
|
}
|
301
|
}
|
302
|
|
303
|
private void SetText(XElement node)
|
304
|
{
|
305
|
foreach (XElement item in node.Elements("ATTRIBUTE"))
|
306
|
{
|
307
|
Text text = new Text()
|
308
|
{
|
309
|
UID = item.Element("UID").Value,
|
310
|
OWNER = item.Element("OWNER").Value,
|
311
|
ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
|
312
|
NAME = item.Element("NAME").Value,
|
313
|
LOCATION = item.Element("LOCATION").Value,
|
314
|
VALUE = item.Element("VALUE").Value,
|
315
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
316
|
WIDTH = item.Element("WIDTH").Value,
|
317
|
HEIGHT = item.Element("HEIGHT").Value,
|
318
|
AREA = item.Element("AREA").Value,
|
319
|
SCENE = item.Element("SCENE").Value
|
320
|
};
|
321
|
|
322
|
TEXTINFOS.Add(text);
|
323
|
}
|
324
|
}
|
325
|
|
326
|
private void SetNote(XElement node)
|
327
|
{
|
328
|
foreach (XElement item in node.Elements("ATTRIBUTE"))
|
329
|
{
|
330
|
Note note = new Note()
|
331
|
{
|
332
|
UID = item.Element("UID").Value,
|
333
|
ATTRIBUTEVALUE = item.Element("ATTRIBUTEVALUE").Value,
|
334
|
NAME = item.Element("NAME").Value,
|
335
|
LOCATION = item.Element("LOCATION").Value,
|
336
|
VALUE = item.Element("VALUE").Value,
|
337
|
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value),
|
338
|
WIDTH = item.Element("WIDTH").Value,
|
339
|
HEIGHT = item.Element("HEIGHT").Value,
|
340
|
AREA = item.Element("AREA").Value,
|
341
|
SCENE = item.Element("SCENE").Value,
|
342
|
OWNER = item.Element("OWNER").Value
|
343
|
};
|
344
|
|
345
|
NOTES.Add(note);
|
346
|
}
|
347
|
}
|
348
|
|
349
|
private void SetTrimLine(XElement node)
|
350
|
{
|
351
|
foreach (XElement item in node.Elements("TRIM_LINE_NO"))
|
352
|
{
|
353
|
TrimLine trimLine = new TrimLine()
|
354
|
{
|
355
|
UID = item.Element("UID").Value,
|
356
|
};
|
357
|
SetLineNumberRuns(item, trimLine.RUNS);
|
358
|
TRIMLINES.Add(trimLine);
|
359
|
}
|
360
|
}
|
361
|
|
362
|
private void SetAssociations(XElement node, List<Association> associations)
|
363
|
{
|
364
|
foreach (XElement item in node.Elements("ASSOCIATION"))
|
365
|
{
|
366
|
Association association = new Association()
|
367
|
{
|
368
|
TYPE = item.Attribute("TYPE").Value,
|
369
|
VALUE = item.Value
|
370
|
};
|
371
|
|
372
|
associations.Add(association);
|
373
|
}
|
374
|
}
|
375
|
|
376
|
private void SetConnectors(XElement node, List<Connector> connectors)
|
377
|
{
|
378
|
foreach (XElement item in node.Elements("CONNECTOR"))
|
379
|
{
|
380
|
connectors.Add(new Connector()
|
381
|
{
|
382
|
UID = item.Attribute("UID").Value,
|
383
|
CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
|
384
|
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
|
385
|
CONNECTPOINT = item.Element("CONNECTPOINT").Value,
|
386
|
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
|
387
|
});
|
388
|
}
|
389
|
}
|
390
|
|
391
|
private void SetSymbolConnectors(XElement node, List<Connector> connectors, string CONNECTIONPOINT)
|
392
|
{
|
393
|
foreach (XElement item in node.Elements("CONNECTOR"))
|
394
|
{
|
395
|
connectors.Add(new Connector()
|
396
|
{
|
397
|
UID = item.Attribute("UID").Value,
|
398
|
CONNECTED_AT = Convert.ToInt32(item.Attribute("CONNECTED_AT").Value),
|
399
|
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value,
|
400
|
CONNECTPOINT = item.Element("CONNECTPOINT").Value,
|
401
|
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value,
|
402
|
});
|
403
|
}
|
404
|
}
|
405
|
|
406
|
private void SetProperties(XElement node, List<Property> properties)
|
407
|
{
|
408
|
foreach (XElement item in node.Elements("PROPERTY"))
|
409
|
{
|
410
|
properties.Add(new Property()
|
411
|
{
|
412
|
UID = item.Attribute("UID").Value,
|
413
|
LENGTH = item.Attribute("Length").Value,
|
414
|
EXPRESSION = item.Attribute("Expression").Value,
|
415
|
DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
|
416
|
ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
|
417
|
ATTRIBUTE = item.Attribute("Attribute").Value,
|
418
|
VALUE = item.Value
|
419
|
});
|
420
|
}
|
421
|
}
|
422
|
|
423
|
private void SetAttributes(XElement node, List<Attribute> attributes)
|
424
|
{
|
425
|
foreach (XElement item in node.Elements("ATTRIBUTE"))
|
426
|
{
|
427
|
Attribute attribute = new Attribute()
|
428
|
{
|
429
|
UID = item.Attribute("UID").Value,
|
430
|
LENGTH = item.Attribute("Length").Value,
|
431
|
EXPRESSION = item.Attribute("Expression").Value,
|
432
|
DISPLAYATTRIBUTE = item.Attribute("DisplayAttribute").Value,
|
433
|
ATTRIBUTETYPE = item.Attribute("AttributeType").Value,
|
434
|
ATTRIBUTE = item.Attribute("Attribute").Value,
|
435
|
ATTRAT = item.Attribute("AttrAt").Value,
|
436
|
ASSOCITEM = item.Attribute("AssocItem").Value,
|
437
|
VALUE = item.Value
|
438
|
};
|
439
|
|
440
|
attributes.Add(attribute);
|
441
|
|
442
|
if (!string.IsNullOrEmpty(attribute.ASSOCITEM) && attribute.ASSOCITEM != "None")
|
443
|
{
|
444
|
Text text = _TEXTINFOS.Find(x => x.UID == attribute.ASSOCITEM);
|
445
|
if (text != null)
|
446
|
text.ASSOCIATION = true;
|
447
|
}
|
448
|
}
|
449
|
}
|
450
|
|
451
|
private void SetSpecBreakAttribute(SpecBreak specBreak)
|
452
|
{
|
453
|
string upStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "UpStream").VALUE;
|
454
|
string downStream = specBreak.ATTRIBUTES.Find(x => x.ATTRIBUTE == "DownStream").VALUE;
|
455
|
|
456
|
specBreak.UpStreamUID = upStream;
|
457
|
specBreak.DownStreamUID = downStream;
|
458
|
}
|
459
|
|
460
|
private void SetLineNumberRuns(XElement node, List<LineRun> lineNumberRuns)
|
461
|
{
|
462
|
foreach (XElement item in node.Elements("RUN"))
|
463
|
{
|
464
|
LineRun run = new LineRun()
|
465
|
{
|
466
|
TYPE = item.Attribute("TYPE").Value
|
467
|
};
|
468
|
|
469
|
foreach (XElement element in item.Elements())
|
470
|
{
|
471
|
if (element.Name == "SYMBOL")
|
472
|
{
|
473
|
Symbol symbol = GetSymbolByUID(element.Element("UID").Value);
|
474
|
if (symbol == null)
|
475
|
{
|
476
|
validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
|
477
|
validationStringBuilder.AppendLine();
|
478
|
validationResult = true;
|
479
|
}
|
480
|
run.RUNITEMS.Add(symbol);
|
481
|
}
|
482
|
else if (element.Name == "LINE")
|
483
|
{
|
484
|
Line line = GetLineByUID(element.Element("UID").Value);
|
485
|
if (line == null)
|
486
|
{
|
487
|
validationStringBuilder.AppendLine("Missing Item!" + "\r\nUID : " + element.Element("UID").Value);
|
488
|
validationStringBuilder.AppendLine();
|
489
|
validationResult = true;
|
490
|
}
|
491
|
run.RUNITEMS.Add(line);
|
492
|
}
|
493
|
}
|
494
|
lineNumberRuns.Add(run);
|
495
|
}
|
496
|
}
|
497
|
|
498
|
private void SetChildSymbol(Symbol symbol)
|
499
|
{
|
500
|
List<ChildSymbol> childList = new List<ChildSymbol>();
|
501
|
if (!string.IsNullOrEmpty(symbol.CHILD) && symbol.CHILD != "None")
|
502
|
{
|
503
|
string[] childArray = symbol.CHILD.Split(new char[] { '/' });
|
504
|
foreach (string sChild in childArray)
|
505
|
{
|
506
|
string[] sChildInfo = sChild.Split(new char[] { ',' });
|
507
|
childList.Add(new ChildSymbol()
|
508
|
{
|
509
|
ParentAt = Convert.ToInt32(sChildInfo[0]),
|
510
|
Direction = sChildInfo[1],
|
511
|
NAME = sChildInfo[2]
|
512
|
});
|
513
|
}
|
514
|
|
515
|
foreach (ChildSymbol child in childList)
|
516
|
{
|
517
|
if (child.ParentAt == 0)
|
518
|
symbol.ChildSymbols.Add(child);
|
519
|
else
|
520
|
childList[child.ParentAt - 1].ChildSymbols.Add(child);
|
521
|
}
|
522
|
}
|
523
|
if (!string.IsNullOrEmpty(symbol.CONNECTIONPOINT) && symbol.CONNECTIONPOINT != "None")
|
524
|
{
|
525
|
// 현재 부모 Symbol에 자식 Connector까지 들어가 있음
|
526
|
string[] connectionArray = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
|
527
|
string[] array = symbol.CONNECTIONPOINT.Split(new char[] { '/' });
|
528
|
for (int i = 0; i < array.Length; i++)
|
529
|
{
|
530
|
string[] arrConn = array[i].Split(new char[] { ',' });
|
531
|
int connIndex = Convert.ToInt32(arrConn[3]);
|
532
|
if (connIndex != 0)
|
533
|
{
|
534
|
childList[connIndex - 1].Connectors.Add(symbol.CONNECTORS[i]);
|
535
|
symbol.CONNECTORS[i].Index = connIndex;
|
536
|
}
|
537
|
}
|
538
|
}
|
539
|
}
|
540
|
#endregion
|
541
|
|
542
|
public Symbol GetSymbolByUID(string uid)
|
543
|
{
|
544
|
return SYMBOLS.Find(x => x.UID == uid);
|
545
|
}
|
546
|
|
547
|
public Line GetLineByUID(string uid)
|
548
|
{
|
549
|
return LINES.Find(x => x.UID == uid);
|
550
|
}
|
551
|
|
552
|
public void SetAllConnectors()
|
553
|
{
|
554
|
foreach (var item in SYMBOLS)
|
555
|
foreach (var connector in item.CONNECTORS)
|
556
|
connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
|
557
|
|
558
|
foreach (var item in LINES)
|
559
|
foreach (var connector in item.CONNECTORS)
|
560
|
connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
|
561
|
|
562
|
foreach (var item in Equipments)
|
563
|
foreach (var connector in item.CONNECTORS)
|
564
|
connector.ConnectedObject = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM);
|
565
|
}
|
566
|
|
567
|
|
568
|
|
569
|
public void ValidationCheck()
|
570
|
{
|
571
|
|
572
|
#region Connection Check / Symbol의 SceneConnectPoint Check
|
573
|
foreach (var item in _SYMBOLS)
|
574
|
{
|
575
|
foreach (var connector in item.CONNECTORS)
|
576
|
{
|
577
|
if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Line))
|
578
|
{
|
579
|
Line line = connector.ConnectedObject as Line;
|
580
|
if (line.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
|
581
|
{
|
582
|
validationStringBuilder.AppendLine("Check connection!");
|
583
|
validationStringBuilder.AppendLine("Symbol UID : " + item.UID);
|
584
|
validationStringBuilder.AppendLine("Line UID : " + line.UID);
|
585
|
validationStringBuilder.AppendLine();
|
586
|
validationResult = true;
|
587
|
}
|
588
|
}
|
589
|
|
590
|
if (connector.SCENECONNECTPOINT == connector.CONNECTPOINT)
|
591
|
{
|
592
|
validationStringBuilder.AppendLine("Check Symbol SceneConnectPoint!");
|
593
|
validationStringBuilder.AppendLine("Symbol UID : " + item.UID);
|
594
|
validationStringBuilder.AppendLine();
|
595
|
validationResult = true;
|
596
|
}
|
597
|
}
|
598
|
}
|
599
|
|
600
|
foreach (var item in _LINES)
|
601
|
{
|
602
|
foreach (var connector in item.CONNECTORS)
|
603
|
{
|
604
|
if (connector.ConnectedObject != null && connector.ConnectedObject.GetType() == typeof(Symbol))
|
605
|
{
|
606
|
Symbol symbol = connector.ConnectedObject as Symbol;
|
607
|
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
|
608
|
{
|
609
|
validationStringBuilder.AppendLine("Check connection!");
|
610
|
validationStringBuilder.AppendLine("Symbol UID : " + symbol.UID);
|
611
|
validationStringBuilder.AppendLine("Line UID : " + item.UID);
|
612
|
validationStringBuilder.AppendLine();
|
613
|
validationResult = true;
|
614
|
}
|
615
|
}
|
616
|
}
|
617
|
}
|
618
|
#endregion
|
619
|
|
620
|
#region Symbol Size Check
|
621
|
foreach (var item in _SYMBOLS)
|
622
|
{
|
623
|
if (item.SIZE == "0,0")
|
624
|
{
|
625
|
validationStringBuilder.AppendLine("Check symbol size!");
|
626
|
validationStringBuilder.AppendLine("Symbol UID : " + item.UID);
|
627
|
validationStringBuilder.AppendLine();
|
628
|
validationResult = true;
|
629
|
}
|
630
|
}
|
631
|
#endregion
|
632
|
|
633
|
#region SpecBreak, EndBreak Check
|
634
|
foreach (var item in SpecBreaks)
|
635
|
{
|
636
|
object obj1 = SPPIDUtil.FindObjectByUID(this, item.UpStreamUID);
|
637
|
object obj2 = SPPIDUtil.FindObjectByUID(this, item.DownStreamUID);
|
638
|
if (obj1 == null || obj2 == null)
|
639
|
{
|
640
|
validationStringBuilder.AppendLine("Check SpecBreak UpStream, DownStream!");
|
641
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
642
|
validationStringBuilder.AppendLine();
|
643
|
validationResult = true;
|
644
|
}
|
645
|
else
|
646
|
{
|
647
|
|
648
|
bool result = false;
|
649
|
if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Symbol))
|
650
|
{
|
651
|
Symbol symbol1 = obj1 as Symbol;
|
652
|
Symbol symbol2 = obj2 as Symbol;
|
653
|
if (symbol1.CONNECTORS.Find(x => x.ConnectedObject == symbol2) == null || symbol2.CONNECTORS.Find(x => x.ConnectedObject == symbol1) == null)
|
654
|
result = true;
|
655
|
}
|
656
|
else if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Line))
|
657
|
{
|
658
|
Symbol symbol = obj1 as Symbol;
|
659
|
Line line = obj2 as Line;
|
660
|
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
|
661
|
result = true;
|
662
|
}
|
663
|
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Symbol))
|
664
|
{
|
665
|
Symbol symbol = obj2 as Symbol;
|
666
|
Line line = obj1 as Line;
|
667
|
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
|
668
|
result = true;
|
669
|
}
|
670
|
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
|
671
|
{
|
672
|
Line line1 = obj2 as Line;
|
673
|
Line line2 = obj1 as Line;
|
674
|
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
|
675
|
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
|
676
|
if (connector1 == null && connector2 == null)
|
677
|
result = true;
|
678
|
}
|
679
|
|
680
|
if (result)
|
681
|
{
|
682
|
validationStringBuilder.AppendLine("Check SpecBreak UpStream, DownStream!");
|
683
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
684
|
validationStringBuilder.AppendLine();
|
685
|
validationResult = true;
|
686
|
}
|
687
|
|
688
|
// Rule
|
689
|
if (!result)
|
690
|
{
|
691
|
if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
|
692
|
{
|
693
|
Line line1 = obj1 as Line;
|
694
|
Line line2 = obj2 as Line;
|
695
|
|
696
|
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
|
697
|
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
|
698
|
|
699
|
if (connector1 != null && connector2 != null)
|
700
|
{
|
701
|
int connectorIndex = line1.CONNECTORS.IndexOf(connector1);
|
702
|
if (connectorIndex != 0 && !SPPIDUtil.IsBranchLine(line1))
|
703
|
result = true;
|
704
|
else if (connectorIndex != 0 && SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
|
705
|
result = true;
|
706
|
else if (connectorIndex == 0 && !SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
|
707
|
result = true;
|
708
|
}
|
709
|
else if (SPPIDUtil.IsBranchLine(line1, line2))
|
710
|
{
|
711
|
if (connector1 == null)
|
712
|
result = true;
|
713
|
}
|
714
|
|
715
|
if (result)
|
716
|
{
|
717
|
validationStringBuilder.AppendLine("Check Segment Rule!");
|
718
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
719
|
validationStringBuilder.AppendLine();
|
720
|
validationResult = true;
|
721
|
}
|
722
|
}
|
723
|
}
|
724
|
}
|
725
|
}
|
726
|
|
727
|
foreach (var item in EndBreaks)
|
728
|
{
|
729
|
object obj1 = SPPIDUtil.FindObjectByUID(this, item.OWNER);
|
730
|
object obj2 = SPPIDUtil.FindObjectByUID(this, item.PROPERTIES.Find(x => x.ATTRIBUTE == "Connected Item").VALUE);
|
731
|
if (obj1 == null || obj2 == null)
|
732
|
{
|
733
|
validationStringBuilder.AppendLine("Check EndBreak Owner, Connected Item!");
|
734
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
735
|
validationStringBuilder.AppendLine();
|
736
|
validationResult = true;
|
737
|
}
|
738
|
else
|
739
|
{
|
740
|
bool result = false;
|
741
|
if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Symbol))
|
742
|
{
|
743
|
Symbol symbol1 = obj1 as Symbol;
|
744
|
Symbol symbol2 = obj2 as Symbol;
|
745
|
if (symbol1.CONNECTORS.Find(x => x.ConnectedObject == symbol2) == null || symbol2.CONNECTORS.Find(x => x.ConnectedObject == symbol1) == null)
|
746
|
result = true;
|
747
|
}
|
748
|
else if (obj1.GetType() == typeof(Symbol) && obj2.GetType() == typeof(Line))
|
749
|
{
|
750
|
Symbol symbol = obj1 as Symbol;
|
751
|
Line line = obj2 as Line;
|
752
|
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
|
753
|
result = true;
|
754
|
}
|
755
|
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Symbol))
|
756
|
{
|
757
|
Symbol symbol = obj2 as Symbol;
|
758
|
Line line = obj1 as Line;
|
759
|
if (symbol.CONNECTORS.Find(x => x.ConnectedObject == line) == null || line.CONNECTORS.Find(x => x.ConnectedObject == symbol) == null)
|
760
|
result = true;
|
761
|
}
|
762
|
else if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
|
763
|
{
|
764
|
Line line1 = obj2 as Line;
|
765
|
Line line2 = obj1 as Line;
|
766
|
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
|
767
|
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
|
768
|
if (connector1 == null && connector2 == null)
|
769
|
result = true;
|
770
|
}
|
771
|
|
772
|
if (result)
|
773
|
{
|
774
|
validationStringBuilder.AppendLine("Check EndBreak Owner, Connected Item!");
|
775
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
776
|
validationStringBuilder.AppendLine();
|
777
|
validationResult = true;
|
778
|
}
|
779
|
|
780
|
// Rule
|
781
|
if (!result)
|
782
|
{
|
783
|
if (obj1.GetType() == typeof(Line) && obj2.GetType() == typeof(Line))
|
784
|
{
|
785
|
Line line1 = obj1 as Line;
|
786
|
Line line2 = obj2 as Line;
|
787
|
|
788
|
Connector connector1 = line1.CONNECTORS.Find(x => x.ConnectedObject == line2);
|
789
|
Connector connector2 = line2.CONNECTORS.Find(x => x.ConnectedObject == line1);
|
790
|
|
791
|
if (connector1 != null && connector2 != null)
|
792
|
{
|
793
|
int connectorIndex = line1.CONNECTORS.IndexOf(connector1);
|
794
|
if (connectorIndex != 0 && !SPPIDUtil.IsBranchLine(line1))
|
795
|
result = true;
|
796
|
else if (connectorIndex != 0 && SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
|
797
|
result = true;
|
798
|
else if (connectorIndex == 0 && !SPPIDUtil.IsBranchLine(line1) && SPPIDUtil.IsBranchLine(line2))
|
799
|
result = true;
|
800
|
}
|
801
|
else if (SPPIDUtil.IsBranchLine(line1, line2))
|
802
|
{
|
803
|
if (connector1 == null)
|
804
|
result = true;
|
805
|
}
|
806
|
|
807
|
if (result)
|
808
|
{
|
809
|
validationStringBuilder.AppendLine("Check Segment Rule!");
|
810
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
811
|
validationStringBuilder.AppendLine();
|
812
|
validationResult = true;
|
813
|
}
|
814
|
}
|
815
|
}
|
816
|
}
|
817
|
}
|
818
|
|
819
|
#endregion
|
820
|
|
821
|
#region Check Flow Direction
|
822
|
List<string[]> flowDirectionCheck = new List<string[]>();
|
823
|
foreach (var line in LINES)
|
824
|
{
|
825
|
foreach (var connector in line.CONNECTORS)
|
826
|
{
|
827
|
if (connector.ConnectedObject != null &&
|
828
|
connector.ConnectedObject.GetType() == typeof(Line) &&
|
829
|
!SPPIDUtil.IsBranchLine(line, connector.ConnectedObject as Line))
|
830
|
{
|
831
|
Line connLine = connector.ConnectedObject as Line;
|
832
|
int lineIndex1 = line.CONNECTORS.IndexOf(connector);
|
833
|
int lineIndex2 = connLine.CONNECTORS.IndexOf(connLine.CONNECTORS.Find(x => x.ConnectedObject == line));
|
834
|
if (lineIndex1 == lineIndex2 && flowDirectionCheck.Find(x => (x[0] == line.UID || x[1] == connLine.UID) || (x[1] == line.UID || x[0] == connLine.UID)) == null)
|
835
|
{
|
836
|
validationStringBuilder.AppendLine("Check line flow direction!");
|
837
|
validationStringBuilder.AppendLine("UID : " + line.UID);
|
838
|
validationStringBuilder.AppendLine("UID : " + connLine.UID);
|
839
|
validationStringBuilder.AppendLine();
|
840
|
validationResult = true;
|
841
|
flowDirectionCheck.Add(new string[] { line.UID, connLine.UID });
|
842
|
}
|
843
|
}
|
844
|
}
|
845
|
}
|
846
|
|
847
|
foreach (var item in SYMBOLS.FindAll(x => x.CONNECTORS.Count == 2 &&
|
848
|
x.CONNECTORS[0].ConnectedObject != null && x.CONNECTORS[0].ConnectedObject.GetType() == typeof(Line) &&
|
849
|
x.CONNECTORS[1].ConnectedObject != null && x.CONNECTORS[1].ConnectedObject.GetType() == typeof(Line)))
|
850
|
{
|
851
|
Line line1 = item.CONNECTORS[0].ConnectedObject as Line;
|
852
|
Line line2 = item.CONNECTORS[1].ConnectedObject as Line;
|
853
|
if (line1.TYPE == line2.TYPE)
|
854
|
{
|
855
|
int index1 = line1.CONNECTORS.IndexOf(line1.CONNECTORS.Find(x => x.ConnectedObject == item));
|
856
|
int index2 = line2.CONNECTORS.IndexOf(line2.CONNECTORS.Find(x => x.ConnectedObject == item));
|
857
|
if (index1 == index2)
|
858
|
{
|
859
|
validationStringBuilder.AppendLine("Check line flow direction!");
|
860
|
validationStringBuilder.AppendLine("UID : " + line1.UID);
|
861
|
validationStringBuilder.AppendLine("UID : " + line2.UID);
|
862
|
validationStringBuilder.AppendLine();
|
863
|
validationResult = true;
|
864
|
}
|
865
|
}
|
866
|
}
|
867
|
#endregion
|
868
|
|
869
|
#region Association Check
|
870
|
foreach (var item in TEXTINFOS)
|
871
|
{
|
872
|
if (item.ASSOCIATION)
|
873
|
{
|
874
|
object owner = SPPIDUtil.FindObjectByUID(this, item.OWNER);
|
875
|
if (owner == null)
|
876
|
{
|
877
|
validationStringBuilder.AppendLine("Check text owner!");
|
878
|
validationStringBuilder.AppendLine("Text UID : " + item.UID);
|
879
|
foreach (var associationItem in SYMBOLS.FindAll(x => x.ATTRIBUTES.Find(y => y.ASSOCITEM == item.UID) != null))
|
880
|
validationStringBuilder.AppendLine("Association UID : " + associationItem.UID);
|
881
|
|
882
|
validationStringBuilder.AppendLine();
|
883
|
validationResult = true;
|
884
|
}
|
885
|
}
|
886
|
}
|
887
|
#endregion
|
888
|
|
889
|
#region Line To Line Type Check
|
890
|
List<string[]> typeCheck = new List<string[]>();
|
891
|
foreach (var item in LINES)
|
892
|
{
|
893
|
foreach (var connector in item.CONNECTORS)
|
894
|
{
|
895
|
Line connLine = connector.ConnectedObject as Line;
|
896
|
if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) != null &&
|
897
|
connLine.TYPE != item.TYPE &&
|
898
|
typeCheck.Find(x => (x[0] == item.UID || x[1] == connLine.UID) || (x[1] == item.UID || x[0] == connLine.UID)) == null)
|
899
|
{
|
900
|
validationStringBuilder.AppendLine("Check line type!");
|
901
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
902
|
validationStringBuilder.AppendLine("UID : " + connLine.UID);
|
903
|
validationStringBuilder.AppendLine();
|
904
|
validationResult = true;
|
905
|
typeCheck.Add(new string[] { item.UID, connLine.UID });
|
906
|
}
|
907
|
}
|
908
|
}
|
909
|
#endregion
|
910
|
|
911
|
#region ConnenctionCheck
|
912
|
List<string[]> connectionCheck = new List<string[]>();
|
913
|
foreach (var item in _LINES)
|
914
|
{
|
915
|
List<string> connectedItem = new List<string>();
|
916
|
foreach (var connector in item.CONNECTORS)
|
917
|
{
|
918
|
if (connector.ConnectedObject != null)
|
919
|
{
|
920
|
Symbol connSymbol = connector.ConnectedObject as Symbol;
|
921
|
Line connLine = connector.ConnectedObject as Line;
|
922
|
string connUID = string.Empty;
|
923
|
bool result = false;
|
924
|
if (connSymbol != null && connSymbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
|
925
|
{
|
926
|
result = true;
|
927
|
connUID = connSymbol.UID;
|
928
|
}
|
929
|
else if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) == null && !SPPIDUtil.IsBranchLine(connLine, item))
|
930
|
{
|
931
|
result = true;
|
932
|
connUID = connLine.UID;
|
933
|
}
|
934
|
|
935
|
if (result && connectionCheck.Find(x => (x[0] == item.UID || x[1] == connUID) || (x[1] == item.UID || x[0] == connUID)) == null)
|
936
|
{
|
937
|
validationStringBuilder.AppendLine("Check connection!");
|
938
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
939
|
validationStringBuilder.AppendLine("UID : " + connUID);
|
940
|
validationStringBuilder.AppendLine();
|
941
|
validationResult = true;
|
942
|
connectionCheck.Add(new string[] { item.UID, connUID });
|
943
|
}
|
944
|
|
945
|
if (!connectedItem.Contains(connector.CONNECTEDITEM))
|
946
|
connectedItem.Add(connector.CONNECTEDITEM);
|
947
|
else
|
948
|
{
|
949
|
validationStringBuilder.AppendLine("Check connection!");
|
950
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
951
|
validationStringBuilder.AppendLine();
|
952
|
}
|
953
|
}
|
954
|
}
|
955
|
|
956
|
if (item.CONNECTORS.Find(x => x.CONNECTEDITEM == item.UID) != null)
|
957
|
{
|
958
|
validationStringBuilder.AppendLine("Check connection!");
|
959
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
960
|
validationStringBuilder.AppendLine();
|
961
|
validationResult = true;
|
962
|
}
|
963
|
}
|
964
|
foreach (var item in _SYMBOLS)
|
965
|
{
|
966
|
List<string> connectedItem = new List<string>();
|
967
|
foreach (var connector in item.CONNECTORS)
|
968
|
{
|
969
|
if (connector.ConnectedObject != null)
|
970
|
{
|
971
|
Symbol connSymbol = connector.ConnectedObject as Symbol;
|
972
|
Line connLine = connector.ConnectedObject as Line;
|
973
|
string connUID = string.Empty;
|
974
|
bool result = false;
|
975
|
if (connSymbol != null && connSymbol.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
|
976
|
{
|
977
|
result = true;
|
978
|
connUID = connSymbol.UID;
|
979
|
}
|
980
|
else if (connLine != null && connLine.CONNECTORS.Find(x => x.ConnectedObject == item) == null)
|
981
|
{
|
982
|
result = true;
|
983
|
connUID = connLine.UID;
|
984
|
}
|
985
|
|
986
|
if (result && connectionCheck.Find(x => (x[0] == item.UID || x[1] == connUID) || (x[1] == item.UID || x[0] == connUID)) == null)
|
987
|
{
|
988
|
validationStringBuilder.AppendLine("Check connection!");
|
989
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
990
|
validationStringBuilder.AppendLine("UID : " + connUID);
|
991
|
validationStringBuilder.AppendLine();
|
992
|
validationResult = true;
|
993
|
connectionCheck.Add(new string[] { item.UID, connUID });
|
994
|
}
|
995
|
|
996
|
if (!connectedItem.Contains(connector.CONNECTEDITEM))
|
997
|
connectedItem.Add(connector.CONNECTEDITEM);
|
998
|
else
|
999
|
{
|
1000
|
validationStringBuilder.AppendLine("Check connection!");
|
1001
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
1002
|
validationStringBuilder.AppendLine();
|
1003
|
}
|
1004
|
}
|
1005
|
}
|
1006
|
|
1007
|
if (item.CONNECTORS.Find(x => x.CONNECTEDITEM == item.UID) != null)
|
1008
|
{
|
1009
|
validationStringBuilder.AppendLine("Check connection!");
|
1010
|
validationStringBuilder.AppendLine("UID : " + item.UID);
|
1011
|
validationStringBuilder.AppendLine();
|
1012
|
validationResult = true;
|
1013
|
}
|
1014
|
}
|
1015
|
#endregion
|
1016
|
|
1017
|
if (validationResult)
|
1018
|
{
|
1019
|
Validation = false;
|
1020
|
Enable = false;
|
1021
|
_ValidationMessage += validationStringBuilder.ToString();
|
1022
|
}
|
1023
|
else
|
1024
|
{
|
1025
|
Validation = true;
|
1026
|
Enable = true;
|
1027
|
}
|
1028
|
}
|
1029
|
}
|
1030
|
}
|