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