hytos / DTI_PID / SPPIDConverter / Model / SPPID_Document.cs @ 310aeb31
이력 | 보기 | 이력해설 | 다운로드 (8.68 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.Data; |
7 |
using Converter.BaseModel; |
8 |
using Converter.SPPID.Util; |
9 |
|
10 |
namespace Converter.SPPID.Model |
11 |
{ |
12 |
public class SPPID_Document : Document |
13 |
{ |
14 |
public SPPID_Document(string xmlPath) : base(xmlPath) |
15 |
{ |
16 |
|
17 |
} |
18 |
|
19 |
private double testX = 0.855; |
20 |
private double testY = 0.55; |
21 |
|
22 |
public List<SymbolMapping> SymbolMappings; |
23 |
public List<ChildSymbolMapping> ChildSymbolMappings; |
24 |
public List<LineMapping> LineMappings; |
25 |
public List<LineNumberMapping> LineNumberMappings; |
26 |
public List<AttributeMapping> AttributeMappings; |
27 |
public ETCSetting ETCSetting; |
28 |
|
29 |
public List<Group> GROUPS = new List<Group>(); |
30 |
|
31 |
public string DrawingName { get; set; } |
32 |
public string DrawingNumber { get; set; } |
33 |
public string Unit { get; set; } |
34 |
public string Template { get; set; } |
35 |
|
36 |
|
37 |
public void SetSPPIDInfo() |
38 |
{ |
39 |
foreach (var item in SYMBOLS) |
40 |
{ |
41 |
if (item.SPPID == null) |
42 |
item.SPPID = new SPPIDSymbolInfo(); |
43 |
double x = double.NaN; |
44 |
double y = double.NaN; |
45 |
SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
46 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
47 |
item.SPPID.ORIGINAL_X = x; |
48 |
item.SPPID.ORIGINAL_Y = y; |
49 |
|
50 |
foreach (var childSymbol in item.ChildSymbols) |
51 |
{ |
52 |
if (childSymbol.SPPID == null) |
53 |
childSymbol.SPPID = new SPPIDSymbolInfo(); |
54 |
SetChildSymbolSPPIDInfo(childSymbol); |
55 |
} |
56 |
} |
57 |
|
58 |
foreach (var item in LINES) |
59 |
{ |
60 |
if (item.SPPID == null) |
61 |
item.SPPID = new SPPIDLineInfo(); |
62 |
double x = double.NaN; |
63 |
double y = double.NaN; |
64 |
|
65 |
SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref x, ref y); |
66 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
67 |
item.SPPID.START_X = x; |
68 |
item.SPPID.START_Y = y; |
69 |
|
70 |
SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref x, ref y); |
71 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
72 |
item.SPPID.END_X = x; |
73 |
item.SPPID.END_Y = y; |
74 |
} |
75 |
|
76 |
foreach (var item in Equipments) |
77 |
{ |
78 |
if (item.SPPID == null) |
79 |
item.SPPID = new SPPIDSymbolInfo(); |
80 |
double x = double.NaN; |
81 |
double y = double.NaN; |
82 |
SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
83 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
84 |
item.SPPID.ORIGINAL_X = x; |
85 |
item.SPPID.ORIGINAL_Y = y; |
86 |
} |
87 |
|
88 |
foreach (var item in EndBreaks) |
89 |
{ |
90 |
if (item.SPPID == null) |
91 |
item.SPPID = new SPPIDSymbolInfo(); |
92 |
double x = double.NaN; |
93 |
double y = double.NaN; |
94 |
SPPIDUtil.ConvertPointBystring(item.ORIGINALPOINT, ref x, ref y); |
95 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
96 |
item.SPPID.ORIGINAL_X = x; |
97 |
item.SPPID.ORIGINAL_Y = y; |
98 |
} |
99 |
|
100 |
foreach (var item in LINENUMBERS) |
101 |
{ |
102 |
if (item.SPPID == null) |
103 |
item.SPPID = new SPPIDSymbolInfo(); |
104 |
double x = double.NaN; |
105 |
double y = double.NaN; |
106 |
SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
107 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
108 |
item.SPPID.ORIGINAL_X = x; |
109 |
item.SPPID.ORIGINAL_Y = y; |
110 |
} |
111 |
|
112 |
foreach (var item in TEXTINFOS) |
113 |
{ |
114 |
if (item.SPPID == null) |
115 |
item.SPPID = new SPPIDSymbolInfo(); |
116 |
double x = double.NaN; |
117 |
double y = double.NaN; |
118 |
SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
119 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
120 |
item.SPPID.ORIGINAL_X = x; |
121 |
item.SPPID.ORIGINAL_Y = y; |
122 |
} |
123 |
|
124 |
foreach (var item in NOTES) |
125 |
{ |
126 |
if (item.SPPID == null) |
127 |
item.SPPID = new SPPIDSymbolInfo(); |
128 |
double x = double.NaN; |
129 |
double y = double.NaN; |
130 |
SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
131 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
132 |
item.SPPID.ORIGINAL_X = x; |
133 |
item.SPPID.ORIGINAL_Y = y; |
134 |
} |
135 |
} |
136 |
|
137 |
private void SetChildSymbolSPPIDInfo(ChildSymbol item) |
138 |
{ |
139 |
foreach (var childSymbol in item.ChildSymbols) |
140 |
{ |
141 |
if (childSymbol.SPPID == null) |
142 |
childSymbol.SPPID = new SPPIDSymbolInfo(); |
143 |
SetChildSymbolSPPIDInfo(childSymbol); |
144 |
} |
145 |
} |
146 |
|
147 |
public bool SetSPPIDMapping() |
148 |
{ |
149 |
foreach (var item in SYMBOLS) |
150 |
{ |
151 |
SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
152 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
153 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
154 |
return false; |
155 |
|
156 |
foreach (var childSymbol in item.ChildSymbols) |
157 |
{ |
158 |
ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME); |
159 |
childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null; |
160 |
if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol)) |
161 |
return false; |
162 |
} |
163 |
} |
164 |
|
165 |
foreach (var item in LINES) |
166 |
{ |
167 |
LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID); |
168 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
169 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
170 |
return false; |
171 |
} |
172 |
|
173 |
foreach (var item in Equipments) |
174 |
{ |
175 |
SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
176 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
177 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
178 |
return false; |
179 |
} |
180 |
|
181 |
foreach (var item in EndBreaks) |
182 |
{ |
183 |
SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
184 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
185 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
186 |
return false; |
187 |
} |
188 |
|
189 |
foreach (var item in LINENUMBERS) |
190 |
{ |
191 |
if (LineNumberMappings.Count > 0) |
192 |
item.SPPID.MAPPINGNAME = LineNumberMappings[0].SPPIDSYMBOLNAME; |
193 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
194 |
return false; |
195 |
} |
196 |
|
197 |
ETCSetting etc = ETCSetting.GetInstance(); |
198 |
foreach (var item in NOTES) |
199 |
{ |
200 |
item.SPPID.MAPPINGNAME = etc.NoteSymbolPath; |
201 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
202 |
return false; |
203 |
} |
204 |
|
205 |
foreach (var item in TEXTINFOS) |
206 |
{ |
207 |
item.SPPID.MAPPINGNAME = etc.TextSymbolPath; |
208 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
209 |
return false; |
210 |
} |
211 |
|
212 |
return true; |
213 |
} |
214 |
|
215 |
private bool SetChildSymbolMapping(ChildSymbol item) |
216 |
{ |
217 |
foreach (var childSymbol in item.ChildSymbols) |
218 |
{ |
219 |
ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME); |
220 |
childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null; |
221 |
if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME)) |
222 |
return false; |
223 |
else |
224 |
return SetChildSymbolMapping(childSymbol); |
225 |
} |
226 |
|
227 |
return true; |
228 |
} |
229 |
} |
230 |
} |