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