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