hytos / DTI_PID / ID2PSN / DB.cs @ bfb338d6
이력 | 보기 | 이력해설 | 다운로드 (136 KB)
1 | 0dae5645 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | 6b9e7a56 | gaqhf | using System.Data; |
4 | 757ab2f2 | LJIYEON | using System.Data.Common; |
5 | 45529c16 | LJIYEON | using System.Data.SQLite; |
6 | using System.Linq; |
||
7 | using System.Text.RegularExpressions; |
||
8 | 0dae5645 | gaqhf | |
9 | namespace ID2PSN |
||
10 | { |
||
11 | 45529c16 | LJIYEON | public class DB |
12 | 0dae5645 | gaqhf | { |
13 | 6b9e7a56 | gaqhf | const string PSN_TOPOLOGY_RULE = "T_PSN_TOPOLOGY_RULE"; |
14 | const string PSN_HEADER_SETTING = "T_PSN_HEADER_SETTING"; |
||
15 | 36a45f13 | gaqhf | const string PSN_VENTDRAIN_SETTING = "T_PSN_VENTDRAIN_SETTING"; |
16 | 5dfc785c | LJIYEON | const string PSN_VIEW = "T_PSN_VIEW"; |
17 | ddc1c369 | LJIYEON | const string PSN_TRANSFORMKEYWORD_SETTING = "T_PSN_TRANSFORMKEYWORD_SETTING"; |
18 | 5dfc785c | LJIYEON | |
19 | 8f24b438 | gaqhf | const string PSN_PATHITEMS = "SPPIDPathItem"; |
20 | const string PSN_SEQUENCEDATA = "SPPIDSequenceData"; |
||
21 | const string PSN_PIPESYSTEMNETWORK = "SPPIDPipeSystemNetwork"; |
||
22 | const string PSN_EQUIPMENT = "SPPIDEquipment"; |
||
23 | const string PSN_NOZZLE = "SPPIDNozzle"; |
||
24 | const string PSN_FLUIDCODE = "SPPIDFluidCode"; |
||
25 | 67638be0 | LJIYEON | const string PSN_PIPINGMATLCLASS = "SPPIDPipingMatlClass"; |
26 | 36a45f13 | gaqhf | const string PSN_TOPOLOGYSET = "SPPIDTopologySet"; |
27 | a36541fb | LJIYEON | //2021.11.17 추가 |
28 | const string PSN_PIPELINE = "SPPIDPipeLine"; |
||
29 | 839708c6 | LJIYEON | //2021.11.26 추가 |
30 | const string PSN_INSULATIONPURPOSE = "SPPIDInsulationPurpose"; |
||
31 | 3210f690 | LJIYEON | //2021.12.01 추가 |
32 | const string PSN_REVISION_HISTORY = "T_PSN_REVISION_HISTORY"; |
||
33 | 1ae1a1c6 | LJIYEON | /// <summary> |
34 | /// ID2 Project.db 데이터를 가져온다. |
||
35 | /// DB 접속 정보 및 DBType (Sqlite, Mssql) 정보를 가져옴 |
||
36 | /// - JY |
||
37 | /// </summary> |
||
38 | /// <returns></returns> |
||
39 | public static DataTable GetProject() |
||
40 | 757ab2f2 | LJIYEON | { |
41 | 1ae1a1c6 | LJIYEON | DataTable dt = new DataTable(); |
42 | ID2Info id2Info = ID2Info.GetInstance(); |
||
43 | try |
||
44 | { |
||
45 | using (SQLiteConnection connection = new SQLiteConnection(@"Data Source = C:\ProgramData\Digital PID\Project.db", true)) |
||
46 | { |
||
47 | connection.Open(); |
||
48 | if (connection.State.Equals(ConnectionState.Open)) |
||
49 | { |
||
50 | using (SQLiteCommand cmd = connection.CreateCommand()) |
||
51 | { |
||
52 | cmd.CommandText = "SELECT p.[Id], p.Name, p.Path, s.DBTypes_UID, s.Host, s.[User], s.[Password], s.FilePath FROM DBSettings s, Projects p WHERE s.Projects_UID = p.[Id]"; |
||
53 | using (SQLiteDataReader dr = cmd.ExecuteReader()) |
||
54 | dt.Load(dr); |
||
55 | } |
||
56 | |||
57 | } |
||
58 | connection.Close(); |
||
59 | } |
||
60 | } |
||
61 | catch (Exception ex) |
||
62 | { |
||
63 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
64 | } |
||
65 | |||
66 | dt.AcceptChanges(); |
||
67 | dt.DefaultView.Sort = "Name"; |
||
68 | dt = dt.DefaultView.ToTable(); |
||
69 | 757ab2f2 | LJIYEON | |
70 | 1ae1a1c6 | LJIYEON | return dt; |
71 | } |
||
72 | 757ab2f2 | LJIYEON | |
73 | 1ae1a1c6 | LJIYEON | /// <summary> |
74 | c4a35107 | humkyung | /// SQLite에 초기 DB 생성 |
75 | 1ae1a1c6 | LJIYEON | /// - JY |
76 | /// </summary> |
||
77 | /// <returns></returns> |
||
78 | 6b9e7a56 | gaqhf | public static bool ConnTestAndCreateTable() |
79 | { |
||
80 | bool result = false; |
||
81 | ID2Info id2Info = ID2Info.GetInstance(); |
||
82 | 1ae1a1c6 | LJIYEON | |
83 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
84 | 6b9e7a56 | gaqhf | { |
85 | 0fe04b33 | LJIYEON | try |
86 | 6b9e7a56 | gaqhf | { |
87 | 23a96301 | humkyung | var names = connection.GetTableNames(); |
88 | var matched = names.FirstOrDefault(param => param == PSN_HEADER_SETTING); |
||
89 | 0ff2a9f1 | LJIYEON | Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
90 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
91 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
92 | dicColCheck.Add("INDEX", "INTEGER"); |
||
93 | dicColCheck.Add("NAME", "TEXT"); |
||
94 | |||
95 | 23a96301 | humkyung | if (matched == null) |
96 | 6b9e7a56 | gaqhf | { |
97 | 23a96301 | humkyung | var query = $"CREATE TABLE {PSN_HEADER_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
98 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
99 | 6b9e7a56 | gaqhf | { |
100 | 23a96301 | humkyung | cmd.ExecuteNonQuery(); |
101 | } |
||
102 | } |
||
103 | 0ff2a9f1 | LJIYEON | else |
104 | { |
||
105 | AddColumn(PSN_HEADER_SETTING, dicColCheck); |
||
106 | } |
||
107 | 757ab2f2 | LJIYEON | |
108 | 23a96301 | humkyung | matched = names.FirstOrDefault(param => param == PSN_VENTDRAIN_SETTING); |
109 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
110 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
111 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
112 | dicColCheck.Add("INDEX", "INTEGER"); |
||
113 | dicColCheck.Add("NAME", "TEXT"); |
||
114 | 23a96301 | humkyung | if (matched == null) |
115 | { |
||
116 | var query = $"CREATE TABLE {PSN_VENTDRAIN_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
||
117 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
118 | { |
||
119 | cmd.ExecuteNonQuery(); |
||
120 | } |
||
121 | } |
||
122 | 0ff2a9f1 | LJIYEON | else |
123 | { |
||
124 | AddColumn(PSN_VENTDRAIN_SETTING, dicColCheck); |
||
125 | } |
||
126 | 757ab2f2 | LJIYEON | |
127 | 23a96301 | humkyung | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGY_RULE); |
128 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
129 | dicColCheck.Add("UID", "TEXT"); |
||
130 | 23a96301 | humkyung | if (matched == null) |
131 | { |
||
132 | var query = $"CREATE TABLE {PSN_TOPOLOGY_RULE} (UID TEXT)"; |
||
133 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
134 | { |
||
135 | cmd.ExecuteNonQuery(); |
||
136 | } |
||
137 | 757ab2f2 | LJIYEON | |
138 | 23a96301 | humkyung | DataTable topologyRule = new DataTable(); |
139 | topologyRule.Columns.Add("NAME", typeof(string)); |
||
140 | 757ab2f2 | LJIYEON | |
141 | 23a96301 | humkyung | topologyRule.Rows.Add("FluidCode"); |
142 | topologyRule.Rows.Add("-"); |
||
143 | topologyRule.Rows.Add("PipingMaterialsClass"); |
||
144 | topologyRule.Rows.Add("-"); |
||
145 | topologyRule.Rows.Add("Tag Seq No"); |
||
146 | |||
147 | SaveTopologyRule(topologyRule); |
||
148 | } |
||
149 | 0ff2a9f1 | LJIYEON | //else |
150 | //{ |
||
151 | // AddColumn(PSN_TOPOLOGY_RULE, dicColCheck); |
||
152 | //} |
||
153 | 72775f2e | LJIYEON | |
154 | matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEMNETWORK); |
||
155 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
156 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
157 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
158 | dicColCheck.Add("OrderNumber", "NVARCHAR(255)"); |
||
159 | dicColCheck.Add("Pipeline_OID", "NVARCHAR(255)"); |
||
160 | dicColCheck.Add("From_Data", "NVARCHAR(255)"); |
||
161 | dicColCheck.Add("To_Data", "NVARCHAR(255)"); |
||
162 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(125)"); |
||
163 | dicColCheck.Add("PSNRevisionNumber", "NVARCHAR(255)"); |
||
164 | dicColCheck.Add("IsValid", "INT"); |
||
165 | dicColCheck.Add("Status", "NVARCHAR(255)"); |
||
166 | dicColCheck.Add("PBS", "NVARCHAR(255)"); |
||
167 | dicColCheck.Add("Drawings", "NVARCHAR(255)"); |
||
168 | dicColCheck.Add("IncludingVirtualData", "NVARCHAR(10)"); |
||
169 | dicColCheck.Add("PSNAccuracy", "REAL"); |
||
170 | |||
171 | 23a96301 | humkyung | if (matched == null) |
172 | { |
||
173 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_PIPESYSTEMNETWORK} (OID NVARCHAR(255), Type NVARCHAR(255), OrderNumber NVARCHAR(255), Pipeline_OID NVARCHAR(255), From_Data NVARCHAR(255), " + |
174 | "To_Data NVARCHAR(255), TopologySet_OID_Key NVARCHAR(125), PSNRevisionNumber NVARCHAR(255), IsValid INTEGER, Status NVARCHAR(255), PBS NVARCHAR(255), Drawings NVARCHAR(255), " + |
||
175 | 72775f2e | LJIYEON | "IncludingVirtualData NVARCHAR(10), PSNAccuracy REAL)"; |
176 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
177 | { |
||
178 | cmd.ExecuteNonQuery(); |
||
179 | 757ab2f2 | LJIYEON | } |
180 | } |
||
181 | 0ff2a9f1 | LJIYEON | else |
182 | { |
||
183 | AddColumn(PSN_PIPESYSTEMNETWORK, dicColCheck); |
||
184 | } |
||
185 | 23a96301 | humkyung | |
186 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_EQUIPMENT); |
187 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
188 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
189 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
190 | dicColCheck.Add("Xcoords", "REAL"); |
||
191 | dicColCheck.Add("Ycoords", "REAL"); |
||
192 | 23a96301 | humkyung | if (matched == null) |
193 | { |
||
194 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_EQUIPMENT} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL)"; |
195 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
196 | { |
||
197 | cmd.ExecuteNonQuery(); |
||
198 | } |
||
199 | } |
||
200 | 0ff2a9f1 | LJIYEON | else |
201 | { |
||
202 | AddColumn(PSN_EQUIPMENT, dicColCheck); |
||
203 | } |
||
204 | |||
205 | dicColCheck.Clear(); |
||
206 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
207 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
208 | dicColCheck.Add("Xcoords", "REAL"); |
||
209 | dicColCheck.Add("Ycoords", "REAL"); |
||
210 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
211 | dicColCheck.Add("Fluid", "NVARCHAR(255)"); |
||
212 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
213 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
214 | dicColCheck.Add("Rotation", "REAL"); |
||
215 | dicColCheck.Add("FlowDirection", "NVARCHAR(255)"); |
||
216 | 23a96301 | humkyung | |
217 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_NOZZLE); |
218 | 23a96301 | humkyung | if (matched == null) |
219 | { |
||
220 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_NOZZLE} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL, Equipment_OID NVARCHAR(255), " + |
221 | 33cee849 | LJIYEON | "Fluid NVARCHAR(255), NPD NVARCHAR(255), PMC NVARCHAR(255), Rotation REAL, FlowDirection NVARCHAR(255))"; |
222 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
223 | { |
||
224 | cmd.ExecuteNonQuery(); |
||
225 | } |
||
226 | } |
||
227 | 0ff2a9f1 | LJIYEON | else |
228 | { |
||
229 | AddColumn(PSN_NOZZLE, dicColCheck); |
||
230 | } |
||
231 | 23a96301 | humkyung | |
232 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_FLUIDCODE); |
233 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
234 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
235 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
236 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
237 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
238 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
239 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
240 | 23a96301 | humkyung | if (matched == null) |
241 | { |
||
242 | 72775f2e | LJIYEON | var query = $"CREATE TABLE {PSN_FLUIDCODE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Condition NVARCHAR(255), Remarks NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
243 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
244 | { |
||
245 | cmd.ExecuteNonQuery(); |
||
246 | } |
||
247 | } |
||
248 | 0ff2a9f1 | LJIYEON | else |
249 | { |
||
250 | AddColumn(PSN_FLUIDCODE, dicColCheck); |
||
251 | } |
||
252 | 72775f2e | LJIYEON | |
253 | matched = names.FirstOrDefault(param => param == PSN_PIPINGMATLCLASS); |
||
254 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
255 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
256 | dicColCheck.Add("Priority", "INTEGER"); |
||
257 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
258 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
259 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
260 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
261 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
262 | 23a96301 | humkyung | if (matched == null) |
263 | { |
||
264 | 72775f2e | LJIYEON | var query = $"CREATE TABLE {PSN_PIPINGMATLCLASS} (UID NVARCHAR(50), Priority INTEGER, Code NVARCHAR(255), Description NVARCHAR(255), Condition NVARCHAR(255), Remarks NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
265 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
266 | { |
||
267 | cmd.ExecuteNonQuery(); |
||
268 | } |
||
269 | } |
||
270 | 0ff2a9f1 | LJIYEON | else |
271 | { |
||
272 | AddColumn(PSN_PIPINGMATLCLASS, dicColCheck); |
||
273 | } |
||
274 | 23a96301 | humkyung | |
275 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_SEQUENCEDATA); |
276 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
277 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
278 | dicColCheck.Add("SERIALNUMBER", "NVARCHAR(255)"); |
||
279 | dicColCheck.Add("PathItem_OID", "NVARCHAR(255)"); |
||
280 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(255)"); |
||
281 | 23a96301 | humkyung | if (matched == null) |
282 | { |
||
283 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_SEQUENCEDATA} (OID NVARCHAR(255), SERIALNUMBER NVARCHAR(255), PathItem_OID NVARCHAR(255), TopologySet_OID_Key NVARCHAR(255))"; |
284 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
285 | { |
||
286 | cmd.ExecuteNonQuery(); |
||
287 | } |
||
288 | } |
||
289 | 0ff2a9f1 | LJIYEON | else |
290 | { |
||
291 | AddColumn(PSN_SEQUENCEDATA, dicColCheck); |
||
292 | } |
||
293 | 23a96301 | humkyung | |
294 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_PATHITEMS); |
295 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
296 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
297 | dicColCheck.Add("SequenceData_OID", "NVARCHAR(255)"); |
||
298 | dicColCheck.Add("TopologySet_OID", "NVARCHAR(255)"); |
||
299 | dicColCheck.Add("BranchTopologySet_OID", "NVARCHAR(255)"); |
||
300 | dicColCheck.Add("PipeLine_OID", "NVARCHAR(255)"); |
||
301 | dicColCheck.Add("ItemName", "NVARCHAR(255)"); |
||
302 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
303 | dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)"); |
||
304 | dicColCheck.Add("CLASS", "NVARCHAR(255)"); |
||
305 | dicColCheck.Add("SUBCLASS", "NVARCHAR(255)"); |
||
306 | dicColCheck.Add("TYPE", "NVARCHAR(255)"); |
||
307 | dicColCheck.Add("PIDNAME", "NVARCHAR(255)"); |
||
308 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
309 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
310 | dicColCheck.Add("PipeSystemNetwork_OID", "NVARCHAR(255)"); |
||
311 | dicColCheck.Add("PipeRun_OID", "NVARCHAR(255)"); |
||
312 | dicColCheck.Add("ViewPipeSystemNetwork_OID", "NVARCHAR(255)"); |
||
313 | 23a96301 | humkyung | if (matched == null) |
314 | { |
||
315 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_PATHITEMS} (OID NVARCHAR(255), SequenceData_OID NVARCHAR(255), " + |
316 | "TopologySet_OID NVARCHAR(255), BranchTopologySet_OID NVARCHAR(255), PipeLine_OID NVARCHAR(255), ItemName NVARCHAR(255), ItemTag NVARCHAR(255), DESCRIPTION NVARCHAR(255), " + |
||
317 | "CLASS NVARCHAR(255), SUBCLASS NVARCHAR(255), TYPE NVARCHAR(255), PIDNAME NVARCHAR(255), Equipment_OID NVARCHAR(255), NPD NVARCHAR(255), PipeSystemNetwork_OID NVARCHAR(255), PipeRun_OID NVARCHAR(255), " + |
||
318 | 72775f2e | LJIYEON | "ViewPipeSystemNetwork_OID NVARCHAR(255))"; |
319 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
320 | { |
||
321 | cmd.ExecuteNonQuery(); |
||
322 | } |
||
323 | } |
||
324 | 0ff2a9f1 | LJIYEON | else |
325 | { |
||
326 | AddColumn(PSN_PATHITEMS, dicColCheck); |
||
327 | } |
||
328 | |||
329 | 23a96301 | humkyung | matched = names.FirstOrDefault(param => param == PSN_VIEW); |
330 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
331 | dicColCheck.Add("OID", "TEXT"); |
||
332 | 23a96301 | humkyung | if (matched == null) |
333 | { |
||
334 | var query = $"CREATE TABLE {PSN_VIEW} (OID TEXT)"; |
||
335 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
336 | { |
||
337 | cmd.ExecuteNonQuery(); |
||
338 | } |
||
339 | } |
||
340 | |||
341 | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGYSET); |
||
342 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
343 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
344 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
345 | dicColCheck.Add("SubType", "NVARCHAR(255)"); |
||
346 | dicColCheck.Add("HeadItemTag", "NVARCHAR(255)"); |
||
347 | dicColCheck.Add("TailItemTag", "NVARCHAR(255)"); |
||
348 | dicColCheck.Add("HeadItemSPID", "NVARCHAR(255)"); |
||
349 | dicColCheck.Add("TailItemSPID", "NVARCHAR(255)"); |
||
350 | |||
351 | 23a96301 | humkyung | if (matched == null) |
352 | { |
||
353 | f9f2787b | LJIYEON | var query = $"CREATE TABLE { PSN_TOPOLOGYSET} (OID NVARCHAR(255), Type NVARCHAR(255), SubType NVARCHAR(255), HeadItemTag NVARCHAR(255), TailItemTag NVARCHAR(255), HeadItemSPID NVARCHAR(255), TailItemSPID NVARCHAR(255))"; |
354 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
355 | { |
||
356 | cmd.ExecuteNonQuery(); |
||
357 | } |
||
358 | } |
||
359 | 0ff2a9f1 | LJIYEON | else |
360 | { |
||
361 | AddColumn(PSN_TOPOLOGYSET, dicColCheck); |
||
362 | } |
||
363 | |||
364 | ddc1c369 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_TRANSFORMKEYWORD_SETTING); |
365 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
366 | dicColCheck.Add("[INDEX]", "INTEGER"); |
||
367 | dicColCheck.Add("[NAME]", "TEXT"); |
||
368 | dicColCheck.Add("[KEYWORD]", "TEXT"); |
||
369 | ddc1c369 | LJIYEON | if (matched == null) |
370 | { |
||
371 | d4b1ab29 | LJIYEON | var query = $"CREATE TABLE {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX] INTEGER, [NAME] TEXT, [KEYWORD] TEXT)"; |
372 | ddc1c369 | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
373 | { |
||
374 | cmd.ExecuteNonQuery(); |
||
375 | } |
||
376 | } |
||
377 | 0ff2a9f1 | LJIYEON | else |
378 | { |
||
379 | AddColumn(PSN_TRANSFORMKEYWORD_SETTING, dicColCheck); |
||
380 | } |
||
381 | ddc1c369 | LJIYEON | |
382 | a36541fb | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_PIPELINE); |
383 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
384 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
385 | dicColCheck.Add("PipeSystem_OID", "NVARCHAR(255)"); |
||
386 | dicColCheck.Add("FLUID", "NVARCHAR(255)"); |
||
387 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
388 | dicColCheck.Add("SEQNUMBER", "NVARCHAR(255)"); |
||
389 | dicColCheck.Add("INSULATION", "NVARCHAR(255)"); |
||
390 | dicColCheck.Add("FROM_DATA", "NVARCHAR(255)"); |
||
391 | dicColCheck.Add("TO_DATA", "NVARCHAR(255)"); |
||
392 | dicColCheck.Add("Unit", "NVARCHAR(100)"); |
||
393 | a36541fb | LJIYEON | if (matched == null) |
394 | { |
||
395 | var query = $"CREATE TABLE {PSN_PIPELINE} (OID NVARCHAR(255), PipeSystem_OID NVARCHAR(255), FLUID NVARCHAR(255), PMC NVARCHAR(255), SEQNUMBER NVARCHAR(255), INSULATION NVARCHAR(255), " + |
||
396 | $"FROM_DATA NVARCHAR(255), TO_DATA NVARCHAR(255), Unit NVARCHAR(100))"; |
||
397 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
398 | { |
||
399 | cmd.ExecuteNonQuery(); |
||
400 | } |
||
401 | } |
||
402 | 0ff2a9f1 | LJIYEON | else |
403 | { |
||
404 | AddColumn(PSN_PIPELINE, dicColCheck); |
||
405 | } |
||
406 | a36541fb | LJIYEON | |
407 | 839708c6 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_INSULATIONPURPOSE); |
408 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
409 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
410 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
411 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
412 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
413 | 839708c6 | LJIYEON | if (matched == null) |
414 | { |
||
415 | var query = $"CREATE TABLE {PSN_INSULATIONPURPOSE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Remarks NVARCHAR(255))"; |
||
416 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
417 | { |
||
418 | cmd.ExecuteNonQuery(); |
||
419 | } |
||
420 | } |
||
421 | 0ff2a9f1 | LJIYEON | else |
422 | { |
||
423 | AddColumn(PSN_INSULATIONPURPOSE, dicColCheck); |
||
424 | } |
||
425 | |||
426 | void AddColumn(string TableName, Dictionary<string, string> dicCol) |
||
427 | { |
||
428 | var colnames = connection.GetColumnNames(TableName); |
||
429 | bool check = false; |
||
430 | if (colnames != null) |
||
431 | { |
||
432 | foreach (KeyValuePair<string, string> col in dicCol) |
||
433 | { |
||
434 | check = false; |
||
435 | foreach (string c in colnames) |
||
436 | { |
||
437 | if (col.Key.Contains(c)) |
||
438 | { |
||
439 | check = true; |
||
440 | break; |
||
441 | } |
||
442 | } |
||
443 | |||
444 | if (!check) //없으면 추가 |
||
445 | { |
||
446 | string i = string.Empty; |
||
447 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
448 | i = "DEFAULT 0"; |
||
449 | |||
450 | var query = $"ALTER TABLE " + TableName + " ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
||
451 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
452 | { |
||
453 | cmd.ExecuteNonQuery(); |
||
454 | } |
||
455 | } |
||
456 | } |
||
457 | } |
||
458 | } |
||
459 | 839708c6 | LJIYEON | |
460 | 23a96301 | humkyung | result = true; |
461 | 0fe04b33 | LJIYEON | } |
462 | catch (Exception ex) |
||
463 | { |
||
464 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
465 | } |
||
466 | 6b9e7a56 | gaqhf | } |
467 | 45529c16 | LJIYEON | |
468 | 6b9e7a56 | gaqhf | return result; |
469 | } |
||
470 | |||
471 | 1ae1a1c6 | LJIYEON | // ID2 DB 데이터 |
472 | c4a35107 | humkyung | /// <summary> |
473 | /// ID2 데이타베이스에서 OPC 데이터를 조회 |
||
474 | /// </summary> |
||
475 | /// <returns></returns> |
||
476 | 1ae1a1c6 | LJIYEON | public static DataTable SelectOPCRelations() |
477 | 6b9e7a56 | gaqhf | { |
478 | 23a96301 | humkyung | DataTable dt = null; |
479 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
480 | 0fe04b33 | LJIYEON | |
481 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
482 | 6b9e7a56 | gaqhf | { |
483 | 0fe04b33 | LJIYEON | try |
484 | 6b9e7a56 | gaqhf | { |
485 | 23a96301 | humkyung | var query = "SELECT * FROM OPCRelations;"; |
486 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
487 | 757ab2f2 | LJIYEON | { |
488 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
489 | 6b9e7a56 | gaqhf | } |
490 | } |
||
491 | 0fe04b33 | LJIYEON | catch (Exception ex) |
492 | 36a45f13 | gaqhf | { |
493 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
494 | } |
||
495 | 36a45f13 | gaqhf | } |
496 | 1ae1a1c6 | LJIYEON | |
497 | 36a45f13 | gaqhf | return dt; |
498 | } |
||
499 | 6b9e7a56 | gaqhf | |
500 | c4a35107 | humkyung | /// <summary> |
501 | /// ID2 데이타베이스에서 도면 데이터를 조회 |
||
502 | /// </summary> |
||
503 | /// <returns></returns> |
||
504 | 1ae1a1c6 | LJIYEON | public static DataTable SelectDrawings() |
505 | 6b9e7a56 | gaqhf | { |
506 | 23a96301 | humkyung | DataTable dt = null; |
507 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
508 | 0fe04b33 | LJIYEON | |
509 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
510 | 6b9e7a56 | gaqhf | { |
511 | 0fe04b33 | LJIYEON | try |
512 | 6b9e7a56 | gaqhf | { |
513 | 23a96301 | humkyung | var query = "SELECT * FROM Drawings"; |
514 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
515 | 1ae1a1c6 | LJIYEON | { |
516 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
517 | 6b9e7a56 | gaqhf | } |
518 | } |
||
519 | 0fe04b33 | LJIYEON | catch (Exception ex) |
520 | 36a45f13 | gaqhf | { |
521 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
522 | } |
||
523 | 36a45f13 | gaqhf | } |
524 | 1ae1a1c6 | LJIYEON | |
525 | return dt; |
||
526 | 36a45f13 | gaqhf | } |
527 | abee404a | LJIYEON | |
528 | 1ae1a1c6 | LJIYEON | public static DataTable SelectLineProperties() |
529 | 6b9e7a56 | gaqhf | { |
530 | 23a96301 | humkyung | DataTable dt = null; |
531 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
532 | 23a96301 | humkyung | |
533 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
534 | 6b9e7a56 | gaqhf | { |
535 | 0fe04b33 | LJIYEON | try |
536 | 6b9e7a56 | gaqhf | { |
537 | 23a96301 | humkyung | var query = "SELECT * FROM LineProperties"; |
538 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
539 | 1ae1a1c6 | LJIYEON | { |
540 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
541 | 6b9e7a56 | gaqhf | } |
542 | } |
||
543 | 0fe04b33 | LJIYEON | catch (Exception ex) |
544 | 6b9e7a56 | gaqhf | { |
545 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
546 | } |
||
547 | 6b9e7a56 | gaqhf | } |
548 | 0fe04b33 | LJIYEON | |
549 | 6b9e7a56 | gaqhf | return dt; |
550 | } |
||
551 | 45529c16 | LJIYEON | |
552 | 1ae1a1c6 | LJIYEON | public static DataTable SelectFluidCode() |
553 | 6b9e7a56 | gaqhf | { |
554 | 23a96301 | humkyung | DataTable dt = null; |
555 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
556 | 0fe04b33 | LJIYEON | |
557 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
558 | 6b9e7a56 | gaqhf | { |
559 | 0fe04b33 | LJIYEON | try |
560 | 6b9e7a56 | gaqhf | { |
561 | 23a96301 | humkyung | var query = "SELECT * FROM FluidCode"; |
562 | 45529c16 | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
563 | 1ae1a1c6 | LJIYEON | { |
564 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
565 | 6b9e7a56 | gaqhf | } |
566 | } |
||
567 | 0fe04b33 | LJIYEON | catch (Exception ex) |
568 | 6b9e7a56 | gaqhf | { |
569 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
570 | } |
||
571 | 1ae1a1c6 | LJIYEON | } |
572 | |||
573 | return dt; |
||
574 | } |
||
575 | |||
576 | public static DataTable SelectPipingMaterialsClass() |
||
577 | { |
||
578 | 23a96301 | humkyung | DataTable dt = null; |
579 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
580 | 0fe04b33 | LJIYEON | |
581 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
582 | 1ae1a1c6 | LJIYEON | { |
583 | 0fe04b33 | LJIYEON | try |
584 | 6b9e7a56 | gaqhf | { |
585 | 23a96301 | humkyung | var query = "SELECT * FROM PipingMaterialsClass"; |
586 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
587 | 1ae1a1c6 | LJIYEON | { |
588 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
589 | 1ae1a1c6 | LJIYEON | } |
590 | } |
||
591 | 0fe04b33 | LJIYEON | catch (Exception ex) |
592 | 1ae1a1c6 | LJIYEON | { |
593 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
594 | } |
||
595 | 6b9e7a56 | gaqhf | } |
596 | 1ae1a1c6 | LJIYEON | |
597 | 6b9e7a56 | gaqhf | return dt; |
598 | } |
||
599 | |||
600 | 1ae1a1c6 | LJIYEON | public static DataTable SelectPSNPIPINGMATLCLASS() |
601 | 6b9e7a56 | gaqhf | { |
602 | 23a96301 | humkyung | DataTable dt = null; |
603 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
604 | 0fe04b33 | LJIYEON | |
605 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
606 | 1ae1a1c6 | LJIYEON | { |
607 | 0fe04b33 | LJIYEON | try |
608 | { |
||
609 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_PIPINGMATLCLASS}"; |
610 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
611 | 1ae1a1c6 | LJIYEON | { |
612 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
613 | 1ae1a1c6 | LJIYEON | } |
614 | 0fe04b33 | LJIYEON | } |
615 | catch (Exception ex) |
||
616 | { |
||
617 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
618 | } |
||
619 | 1ae1a1c6 | LJIYEON | } |
620 | |||
621 | return dt; |
||
622 | } |
||
623 | 3210f690 | LJIYEON | |
624 | 839708c6 | LJIYEON | public static DataTable SelectInsulationPurpose() |
625 | { |
||
626 | DataTable dt = null; |
||
627 | ID2Info id2Info = ID2Info.GetInstance(); |
||
628 | |||
629 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
630 | { |
||
631 | try |
||
632 | { |
||
633 | var query = "SELECT * FROM InsulationPurpose"; |
||
634 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
635 | { |
||
636 | dt = ds.Tables[0].Copy(); |
||
637 | } |
||
638 | } |
||
639 | catch (Exception ex) |
||
640 | { |
||
641 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
642 | } |
||
643 | } |
||
644 | |||
645 | return dt; |
||
646 | } |
||
647 | |||
648 | public static DataTable SelectPSNINSULATIONPURPOSE() |
||
649 | { |
||
650 | DataTable dt = null; |
||
651 | ID2Info id2Info = ID2Info.GetInstance(); |
||
652 | |||
653 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
654 | 839708c6 | LJIYEON | { |
655 | try |
||
656 | { |
||
657 | var query = $"SELECT * FROM {PSN_INSULATIONPURPOSE}"; |
||
658 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
659 | { |
||
660 | dt = ds.Tables[0].Copy(); |
||
661 | } |
||
662 | } |
||
663 | catch (Exception ex) |
||
664 | { |
||
665 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
666 | } |
||
667 | } |
||
668 | |||
669 | return dt; |
||
670 | } |
||
671 | |||
672 | 1ae1a1c6 | LJIYEON | public static DataTable SelectNominalDiameter() |
673 | { |
||
674 | 23a96301 | humkyung | DataTable dt = null; |
675 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
676 | 0fe04b33 | LJIYEON | |
677 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
678 | 1ae1a1c6 | LJIYEON | { |
679 | 0fe04b33 | LJIYEON | try |
680 | 6b9e7a56 | gaqhf | { |
681 | 23a96301 | humkyung | var query = "SELECT * FROM NominalDiameter ORDER BY Metric DESC"; |
682 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
683 | 1ae1a1c6 | LJIYEON | { |
684 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
685 | 1ae1a1c6 | LJIYEON | } |
686 | 6b9e7a56 | gaqhf | } |
687 | 0fe04b33 | LJIYEON | catch (Exception ex) |
688 | 1ae1a1c6 | LJIYEON | { |
689 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
690 | } |
||
691 | 1ae1a1c6 | LJIYEON | } |
692 | |||
693 | c4a35107 | humkyung | ///TODO: need to check below code |
694 | 1ae1a1c6 | LJIYEON | dt.Rows.RemoveAt(0); |
695 | dt.Rows.RemoveAt(0); |
||
696 | dt.Rows.RemoveAt(0); |
||
697 | dt.Rows.RemoveAt(0); |
||
698 | |||
699 | 6b9e7a56 | gaqhf | return dt; |
700 | } |
||
701 | abee404a | LJIYEON | |
702 | 1ae1a1c6 | LJIYEON | public static DataTable SelectSymbolAttribute() |
703 | 6b9e7a56 | gaqhf | { |
704 | 23b86f8b | LJIYEON | DataTable dt = null; |
705 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
706 | 0fe04b33 | LJIYEON | |
707 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
708 | 6b9e7a56 | gaqhf | { |
709 | 0fe04b33 | LJIYEON | try |
710 | 6b9e7a56 | gaqhf | { |
711 | 23b86f8b | LJIYEON | // var query = "SELECT DISTINCT Attribute, DisplayAttribute FROM SymbolAttribute;"; |
712 | 502d1d50 | LJIYEON | var query = "SELECT DISTINCT Attribute FROM SymbolAttribute;"; |
713 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
714 | 1ae1a1c6 | LJIYEON | { |
715 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
716 | 1ae1a1c6 | LJIYEON | } |
717 | } |
||
718 | 0fe04b33 | LJIYEON | catch (Exception ex) |
719 | 1ae1a1c6 | LJIYEON | { |
720 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
721 | } |
||
722 | 1ae1a1c6 | LJIYEON | } |
723 | 0fe04b33 | LJIYEON | |
724 | 1ae1a1c6 | LJIYEON | return dt; |
725 | } |
||
726 | |||
727 | public static DataTable SelectSymbolName() |
||
728 | { |
||
729 | 23a96301 | humkyung | DataTable dt = null; |
730 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
731 | 0fe04b33 | LJIYEON | |
732 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
733 | 1ae1a1c6 | LJIYEON | { |
734 | 0fe04b33 | LJIYEON | try |
735 | 1ae1a1c6 | LJIYEON | { |
736 | 23a96301 | humkyung | var query = "SELECT * FROM SymbolName;"; |
737 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
738 | 1ae1a1c6 | LJIYEON | { |
739 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
740 | 1ae1a1c6 | LJIYEON | } |
741 | } |
||
742 | 0fe04b33 | LJIYEON | catch (Exception ex) |
743 | 1ae1a1c6 | LJIYEON | { |
744 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
745 | } |
||
746 | 1ae1a1c6 | LJIYEON | } |
747 | 0fe04b33 | LJIYEON | |
748 | 1ae1a1c6 | LJIYEON | return dt; |
749 | 45529c16 | LJIYEON | } |
750 | 1ae1a1c6 | LJIYEON | |
751 | public static double[] GetDrawingSize() |
||
752 | { |
||
753 | double[] result = null; |
||
754 | |||
755 | ID2Info id2Info = ID2Info.GetInstance(); |
||
756 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
757 | 1ae1a1c6 | LJIYEON | { |
758 | 0fe04b33 | LJIYEON | try |
759 | 1ae1a1c6 | LJIYEON | { |
760 | d36e2fe0 | esham21 | var query = "SELECT value FROM Configuration WHERE Section = 'Area' AND [Key] = 'Drawing';"; |
761 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
762 | 1ae1a1c6 | LJIYEON | { |
763 | 23a96301 | humkyung | if (ds.Tables[0].Rows.Count == 1) |
764 | 0fe04b33 | LJIYEON | { |
765 | 23a96301 | humkyung | string value = ds.Tables[0].Rows[0][0].ToString(); |
766 | 0fe04b33 | LJIYEON | string[] split = value.Split(new char[] { ',' }); |
767 | result = new double[] { |
||
768 | 45529c16 | LJIYEON | Convert.ToDouble(Regex.Replace(split[0], @"[^0-9]", string.Empty)), |
769 | Convert.ToDouble(Regex.Replace(split[1], @"[^0-9]", string.Empty)), |
||
770 | Convert.ToDouble(Regex.Replace(split[2], @"[^0-9]", string.Empty)), |
||
771 | Convert.ToDouble(Regex.Replace(split[3], @"[^0-9]", string.Empty)) |
||
772 | 1ae1a1c6 | LJIYEON | }; |
773 | 0fe04b33 | LJIYEON | result = new double[] { |
774 | 1ae1a1c6 | LJIYEON | Math.Min(result[0], result[2]), |
775 | Math.Min(result[1], result[3]), |
||
776 | Math.Max(result[0], result[2]), |
||
777 | Math.Max(result[1], result[3]) |
||
778 | }; |
||
779 | } |
||
780 | } |
||
781 | } |
||
782 | 0fe04b33 | LJIYEON | catch (Exception ex) |
783 | 1ae1a1c6 | LJIYEON | { |
784 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
785 | } |
||
786 | 1ae1a1c6 | LJIYEON | } |
787 | |||
788 | return result; |
||
789 | } |
||
790 | |||
791 | public static DataTable GetEquipmentType() |
||
792 | { |
||
793 | 23a96301 | humkyung | DataTable dt = null; |
794 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
795 | 0fe04b33 | LJIYEON | |
796 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
797 | 1ae1a1c6 | LJIYEON | { |
798 | 0fe04b33 | LJIYEON | try |
799 | 1ae1a1c6 | LJIYEON | { |
800 | 23a96301 | humkyung | var query = "SELECT Type FROM SymbolType WHERE Category = 'Equipment';"; |
801 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
802 | 1ae1a1c6 | LJIYEON | { |
803 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
804 | 1ae1a1c6 | LJIYEON | } |
805 | } |
||
806 | 0fe04b33 | LJIYEON | catch (Exception ex) |
807 | 1ae1a1c6 | LJIYEON | { |
808 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
809 | } |
||
810 | 6b9e7a56 | gaqhf | } |
811 | 0fe04b33 | LJIYEON | |
812 | 6b9e7a56 | gaqhf | return dt; |
813 | } |
||
814 | abee404a | LJIYEON | |
815 | 1ae1a1c6 | LJIYEON | /// <summary> |
816 | /// Zoom 을 위하여 저장 T_PSN_VIEW 데이터로 PSN 데이터지만 Msqql 과 Sqlite 둘다 저장되어 있음 |
||
817 | /// => ID2 가 DB 타입에 따라서 바라보는 DB가 mssql이냐 sqlite냐로 지정되기 때문에 zoom 기능을 그대로 사용하려면 해당 데이터는 psn도 id2 dbtype에 맞춰서 저장 및 로드해야함 |
||
818 | c4a35107 | humkyung | /// => 더 이상 사용하지 않음 |
819 | 1ae1a1c6 | LJIYEON | /// </summary> |
820 | /// <param name="values"></param> |
||
821 | /// <returns></returns> |
||
822 | public static bool SaveView(List<string> values) |
||
823 | 6b9e7a56 | gaqhf | { |
824 | ID2Info id2Info = ID2Info.GetInstance(); |
||
825 | 1ae1a1c6 | LJIYEON | |
826 | bool result = true; |
||
827 | |||
828 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
829 | { |
||
830 | try |
||
831 | 6b9e7a56 | gaqhf | { |
832 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
833 | 6b9e7a56 | gaqhf | { |
834 | 23a96301 | humkyung | try |
835 | 6b9e7a56 | gaqhf | { |
836 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_VIEW}"; |
837 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
838 | |||
839 | foreach (string value in values) |
||
840 | 1ae1a1c6 | LJIYEON | { |
841 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_VIEW} (OID) VALUES (@OID)"; |
842 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
843 | AddWithValue(cmd, "@OID", value); |
||
844 | connection.ExecuteNonQuery(cmd, txn); |
||
845 | 1ae1a1c6 | LJIYEON | } |
846 | 23a96301 | humkyung | txn.Commit(); |
847 | } |
||
848 | catch (Exception ex) |
||
849 | { |
||
850 | txn.Rollback(); |
||
851 | result = false; |
||
852 | 6b9e7a56 | gaqhf | } |
853 | 1ae1a1c6 | LJIYEON | } |
854 | 6b9e7a56 | gaqhf | } |
855 | 23a96301 | humkyung | catch (Exception ex) |
856 | { |
||
857 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
858 | result = false; |
||
859 | } |
||
860 | } |
||
861 | |||
862 | 1ae1a1c6 | LJIYEON | return result; |
863 | 6b9e7a56 | gaqhf | } |
864 | |||
865 | 1ae1a1c6 | LJIYEON | public static bool DeleteView() |
866 | 6b9e7a56 | gaqhf | { |
867 | ID2Info id2Info = ID2Info.GetInstance(); |
||
868 | 1ae1a1c6 | LJIYEON | |
869 | bool result = true; |
||
870 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
871 | { |
||
872 | try |
||
873 | 6b9e7a56 | gaqhf | { |
874 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
875 | 6b9e7a56 | gaqhf | { |
876 | 23a96301 | humkyung | try |
877 | 1ae1a1c6 | LJIYEON | { |
878 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_VIEW}"; |
879 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
880 | txn.Commit(); |
||
881 | } |
||
882 | catch (Exception ex) |
||
883 | { |
||
884 | txn.Rollback(); |
||
885 | result = false; |
||
886 | 1ae1a1c6 | LJIYEON | } |
887 | 6b9e7a56 | gaqhf | } |
888 | } |
||
889 | 23a96301 | humkyung | catch (Exception ex) |
890 | { |
||
891 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
892 | result = false; |
||
893 | } |
||
894 | } |
||
895 | 1ae1a1c6 | LJIYEON | |
896 | return result; |
||
897 | 6b9e7a56 | gaqhf | } |
898 | abee404a | LJIYEON | |
899 | 1ae1a1c6 | LJIYEON | //PSN Sqlite |
900 | public static DataTable SelectHeaderSetting() |
||
901 | 6b9e7a56 | gaqhf | { |
902 | 23a96301 | humkyung | DataTable dt = null; |
903 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
904 | 1ae1a1c6 | LJIYEON | |
905 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
906 | 6b9e7a56 | gaqhf | { |
907 | try |
||
908 | { |
||
909 | 23a96301 | humkyung | var query = $@"SELECT GROUP_ID, DESCRIPTION, [INDEX], NAME FROM {PSN_HEADER_SETTING};"; |
910 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
911 | 6b9e7a56 | gaqhf | { |
912 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
913 | 6b9e7a56 | gaqhf | } |
914 | } |
||
915 | catch (Exception ex) |
||
916 | { |
||
917 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
918 | } |
||
919 | } |
||
920 | 1ae1a1c6 | LJIYEON | |
921 | 6b9e7a56 | gaqhf | return dt; |
922 | } |
||
923 | |||
924 | 1ae1a1c6 | LJIYEON | public static DataTable SelectVentDrainSetting() |
925 | 6b9e7a56 | gaqhf | { |
926 | 23a96301 | humkyung | DataTable dt = null; |
927 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
928 | 23a96301 | humkyung | |
929 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
930 | 6b9e7a56 | gaqhf | { |
931 | try |
||
932 | { |
||
933 | 23a96301 | humkyung | var query = $@"SELECT GROUP_ID, DESCRIPTION, [INDEX], NAME FROM {PSN_VENTDRAIN_SETTING};"; |
934 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
935 | 6b9e7a56 | gaqhf | { |
936 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
937 | 6b9e7a56 | gaqhf | } |
938 | } |
||
939 | catch (Exception ex) |
||
940 | { |
||
941 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
942 | } |
||
943 | } |
||
944 | 23a96301 | humkyung | |
945 | 6b9e7a56 | gaqhf | return dt; |
946 | } |
||
947 | abee404a | LJIYEON | |
948 | ddc1c369 | LJIYEON | public static DataTable SelectKeywordsSetting() |
949 | { |
||
950 | DataTable dt = null; |
||
951 | ID2Info id2Info = ID2Info.GetInstance(); |
||
952 | |||
953 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
954 | ddc1c369 | LJIYEON | { |
955 | try |
||
956 | { |
||
957 | d4b1ab29 | LJIYEON | var query = $@"SELECT [KEYWORD], [INDEX], [NAME] FROM {PSN_TRANSFORMKEYWORD_SETTING};"; |
958 | ddc1c369 | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
959 | { |
||
960 | dt = ds.Tables[0].Copy(); |
||
961 | } |
||
962 | } |
||
963 | catch (Exception ex) |
||
964 | { |
||
965 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
966 | } |
||
967 | } |
||
968 | |||
969 | return dt; |
||
970 | } |
||
971 | |||
972 | 1ae1a1c6 | LJIYEON | public static bool SaveHeaderSetting(List<HeaderInfo> headerInfos) |
973 | 6b9e7a56 | gaqhf | { |
974 | ID2Info id2Info = ID2Info.GetInstance(); |
||
975 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
976 | 6b9e7a56 | gaqhf | { |
977 | try |
||
978 | { |
||
979 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
980 | 6b9e7a56 | gaqhf | { |
981 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_HEADER_SETTING}"; |
982 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
983 | 1ae1a1c6 | LJIYEON | |
984 | foreach (HeaderInfo headerInfo in headerInfos) |
||
985 | { |
||
986 | foreach (HeaderItem item in headerInfo.HeaderItems) |
||
987 | { |
||
988 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_HEADER_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
989 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
990 | AddWithValue(cmd, "@GROUP_ID", headerInfo.UID); |
||
991 | AddWithValue(cmd, "@DESCRIPTION", headerInfo.Description); |
||
992 | AddWithValue(cmd, "@INDEX", item.Index); |
||
993 | AddWithValue(cmd, "@NAME", item.Name); |
||
994 | connection.ExecuteNonQuery(cmd, txn); |
||
995 | 1ae1a1c6 | LJIYEON | } |
996 | } |
||
997 | 81bdaeed | LJIYEON | txn.Commit(); |
998 | 6b9e7a56 | gaqhf | } |
999 | 81bdaeed | LJIYEON | |
1000 | 6b9e7a56 | gaqhf | } |
1001 | catch (Exception ex) |
||
1002 | { |
||
1003 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1004 | 1ae1a1c6 | LJIYEON | return false; |
1005 | 6b9e7a56 | gaqhf | } |
1006 | } |
||
1007 | 1ae1a1c6 | LJIYEON | return true; |
1008 | 6b9e7a56 | gaqhf | } |
1009 | abee404a | LJIYEON | |
1010 | 1ae1a1c6 | LJIYEON | public static bool SaveVentDrainSetting(List<VentDrainInfo> ventDrainInfos) |
1011 | 6b9e7a56 | gaqhf | { |
1012 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1013 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1014 | 6b9e7a56 | gaqhf | { |
1015 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1016 | 6b9e7a56 | gaqhf | { |
1017 | 23a96301 | humkyung | try |
1018 | 6b9e7a56 | gaqhf | { |
1019 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_VENTDRAIN_SETTING}"; |
1020 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1021 | 1ae1a1c6 | LJIYEON | |
1022 | foreach (VentDrainInfo ventDrainInfo in ventDrainInfos) |
||
1023 | { |
||
1024 | foreach (VentDrainItem item in ventDrainInfo.VentDrainItems) |
||
1025 | { |
||
1026 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_VENTDRAIN_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
1027 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1028 | AddWithValue(cmd, "@GROUP_ID", ventDrainInfo.UID); |
||
1029 | AddWithValue(cmd, "@DESCRIPTION", ventDrainInfo.Description); |
||
1030 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1031 | AddWithValue(cmd, "@NAME", item.Name); |
||
1032 | connection.ExecuteNonQuery(cmd, txn); |
||
1033 | 1ae1a1c6 | LJIYEON | } |
1034 | } |
||
1035 | 81bdaeed | LJIYEON | |
1036 | txn.Commit(); |
||
1037 | 6b9e7a56 | gaqhf | } |
1038 | 23a96301 | humkyung | catch (Exception ex) |
1039 | { |
||
1040 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1041 | return false; |
||
1042 | } |
||
1043 | 6b9e7a56 | gaqhf | } |
1044 | } |
||
1045 | 23a96301 | humkyung | |
1046 | 1ae1a1c6 | LJIYEON | return true; |
1047 | 6b9e7a56 | gaqhf | } |
1048 | abee404a | LJIYEON | |
1049 | 8ab98ea3 | LJIYEON | public static bool SaveKeywordsSetting(List<KeywordItem> keywordItems) |
1050 | ddc1c369 | LJIYEON | { |
1051 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1052 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1053 | ddc1c369 | LJIYEON | { |
1054 | using (var txn = connection.BeginTransaction()) |
||
1055 | { |
||
1056 | try |
||
1057 | { |
||
1058 | 81bdaeed | LJIYEON | var query = $"DELETE FROM {PSN_TRANSFORMKEYWORD_SETTING}"; |
1059 | ddc1c369 | LJIYEON | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
1060 | 8ab98ea3 | LJIYEON | |
1061 | foreach (KeywordItem item in keywordItems) |
||
1062 | ddc1c369 | LJIYEON | { |
1063 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX], NAME, KEYWORD) VALUES (@INDEX, @NAME, @KEYWORD)"; |
1064 | 8ab98ea3 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1065 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1066 | AddWithValue(cmd, "@NAME", item.Name); |
||
1067 | AddWithValue(cmd, "@KEYWORD", item.Keyword); |
||
1068 | connection.ExecuteNonQuery(cmd, txn); |
||
1069 | ddc1c369 | LJIYEON | } |
1070 | 8ab98ea3 | LJIYEON | |
1071 | 81bdaeed | LJIYEON | txn.Commit(); |
1072 | ddc1c369 | LJIYEON | } |
1073 | catch (Exception ex) |
||
1074 | { |
||
1075 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1076 | return false; |
||
1077 | } |
||
1078 | } |
||
1079 | } |
||
1080 | |||
1081 | return true; |
||
1082 | } |
||
1083 | |||
1084 | 1ae1a1c6 | LJIYEON | public static bool SaveTopologyRule(DataTable dt) |
1085 | c6503eaa | gaqhf | { |
1086 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1087 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1088 | c6503eaa | gaqhf | { |
1089 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1090 | c6503eaa | gaqhf | { |
1091 | 23a96301 | humkyung | try |
1092 | c6503eaa | gaqhf | { |
1093 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_TOPOLOGY_RULE}"; |
1094 | var cmd = connection.GetSqlStringCommand(query); |
||
1095 | 0ff2a9f1 | LJIYEON | //connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
1096 | connection.ExecuteNonQuery(cmd, txn); |
||
1097 | 1ae1a1c6 | LJIYEON | |
1098 | foreach (DataRow row in dt.Rows) |
||
1099 | { |
||
1100 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_TOPOLOGY_RULE} (UID) VALUES (@UID)"; |
1101 | 23a96301 | humkyung | cmd = connection.GetSqlStringCommand(query); |
1102 | AddWithValue(cmd, "@UID", row["NAME"].ToString()); |
||
1103 | connection.ExecuteNonQuery(cmd, txn); |
||
1104 | 1ae1a1c6 | LJIYEON | } |
1105 | 23a96301 | humkyung | |
1106 | txn.Commit(); |
||
1107 | } |
||
1108 | catch (Exception ex) |
||
1109 | { |
||
1110 | txn.Rollback(); |
||
1111 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1112 | return false; |
||
1113 | c6503eaa | gaqhf | } |
1114 | } |
||
1115 | } |
||
1116 | 23a96301 | humkyung | |
1117 | 1ae1a1c6 | LJIYEON | return true; |
1118 | c6503eaa | gaqhf | } |
1119 | abee404a | LJIYEON | |
1120 | 1ae1a1c6 | LJIYEON | public static DataTable SelectTopologyRule() |
1121 | 7881ec8f | gaqhf | { |
1122 | 23a96301 | humkyung | DataTable dt = null; |
1123 | |||
1124 | 7881ec8f | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1125 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1126 | 7881ec8f | gaqhf | { |
1127 | try |
||
1128 | { |
||
1129 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_TOPOLOGY_RULE}"; |
1130 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1131 | 7881ec8f | gaqhf | { |
1132 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1133 | 7881ec8f | gaqhf | } |
1134 | } |
||
1135 | catch (Exception ex) |
||
1136 | { |
||
1137 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1138 | } |
||
1139 | } |
||
1140 | 23a96301 | humkyung | |
1141 | 7881ec8f | gaqhf | return dt; |
1142 | } |
||
1143 | 45529c16 | LJIYEON | |
1144 | 23a96301 | humkyung | private static void AddWithValue(DbCommand cmd, string PropName, object Value) |
1145 | { |
||
1146 | var param = cmd.CreateParameter(); |
||
1147 | param.ParameterName = PropName; |
||
1148 | param.Value = Value; |
||
1149 | cmd.Parameters.Add(param); |
||
1150 | } |
||
1151 | 3d842083 | LJIYEON | |
1152 | 5c248ee3 | gaqhf | public static bool SavePSNData(PSN item) |
1153 | 6b9e7a56 | gaqhf | { |
1154 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1155 | |||
1156 | bool result = true; |
||
1157 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1158 | 6b9e7a56 | gaqhf | { |
1159 | try |
||
1160 | { |
||
1161 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1162 | 6b9e7a56 | gaqhf | { |
1163 | try |
||
1164 | { |
||
1165 | 23a96301 | humkyung | // Path Items |
1166 | var query = $"DELETE FROM {PSN_PATHITEMS}"; |
||
1167 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1168 | 9c151350 | gaqhf | for (int i = 0; i < item.PathItems.Rows.Count; i++) |
1169 | 6b9e7a56 | gaqhf | { |
1170 | 9c151350 | gaqhf | DataRow row = item.PathItems.Rows[i]; |
1171 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_PATHITEMS} " + |
1172 | $"(OID, SequenceData_OID, TopologySet_OID, BranchTopologySet_OID, PipeLine_OID, ItemName, ItemTag, DESCRIPTION, CLASS, SUBCLASS, TYPE, " + |
||
1173 | $"PIDNAME, Equipment_OID, NPD, PipeSystemNetwork_OID, PipeRun_OID, ViewPipeSystemNetwork_OID) VALUES " + |
||
1174 | $"(@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @DESCRIPTION, @Class, @SubClass, @TYPE, @PIDNAME, @Equipment_OID, @NPD, @PipeSystemNetwork_OID,@PipeRun_OID, @ViewPipeSystemNetwork_OID)"; |
||
1175 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1176 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1177 | AddWithValue(cmd, "@SequenceData_OID", string.IsNullOrEmpty(row["SequenceData_OID"].ToString()) ? "" : row["SequenceData_OID"].ToString()); |
||
1178 | AddWithValue(cmd, "@TopologySet_OID", string.IsNullOrEmpty(row["TopologySet_OID"].ToString()) ? "" : row["TopologySet_OID"].ToString()); |
||
1179 | AddWithValue(cmd, "@BranchTopologySet_OID", string.IsNullOrEmpty(row["BranchTopologySet_OID"].ToString()) ? "" : row["BranchTopologySet_OID"].ToString()); |
||
1180 | AddWithValue(cmd, "@PipeLine_OID", string.IsNullOrEmpty(row["PipeLine_OID"].ToString()) ? "" : row["PipeLine_OID"].ToString()); |
||
1181 | AddWithValue(cmd, "@ITEMNAME", string.IsNullOrEmpty(row["ITEMNAME"].ToString()) ? "" : row["ITEMNAME"].ToString()); |
||
1182 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
1183 | AddWithValue(cmd, "@DESCRIPTION", string.IsNullOrEmpty(row["DESCRIPTION"].ToString()) ? "" : row["DESCRIPTION"].ToString()); |
||
1184 | AddWithValue(cmd, "@Class", string.IsNullOrEmpty(row["Class"].ToString()) ? "" : row["Class"].ToString()); |
||
1185 | AddWithValue(cmd, "@SubClass", string.IsNullOrEmpty(row["SubClass"].ToString()) ? "" : row["SubClass"].ToString()); |
||
1186 | AddWithValue(cmd, "@TYPE", string.IsNullOrEmpty(row["TYPE"].ToString()) ? "" : row["TYPE"].ToString()); |
||
1187 | AddWithValue(cmd, "@PIDNAME", string.IsNullOrEmpty(row["PIDNAME"].ToString()) ? "" : row["PIDNAME"].ToString()); |
||
1188 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
1189 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
1190 | AddWithValue(cmd, "@PipeSystemNetwork_OID", string.IsNullOrEmpty(row["PipeSystemNetwork_OID"].ToString()) ? "" : row["PipeSystemNetwork_OID"].ToString()); |
||
1191 | AddWithValue(cmd, "@ViewPipeSystemNetwork_OID", string.IsNullOrEmpty(row["ViewPipeSystemNetwork_OID"].ToString()) ? "" : row["ViewPipeSystemNetwork_OID"].ToString()); |
||
1192 | AddWithValue(cmd, "@PipeRun_OID", string.IsNullOrEmpty(row["PipeRun_OID"].ToString()) ? "" : row["PipeRun_OID"].ToString()); |
||
1193 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1194 | } |
||
1195 | 6b9e7a56 | gaqhf | |
1196 | 23a96301 | humkyung | // Sequence |
1197 | query = $"DELETE FROM {PSN_SEQUENCEDATA}"; |
||
1198 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1199 | foreach (DataRow row in item.SequenceData.Rows) |
||
1200 | { |
||
1201 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_SEQUENCEDATA} (OID, SERIALNUMBER, PathItem_OID, TopologySet_OID_Key) VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)"; |
1202 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1203 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1204 | AddWithValue(cmd, "@SERIALNUMBER", string.IsNullOrEmpty(row["SERIALNUMBER"].ToString()) ? "" : row["SERIALNUMBER"].ToString()); |
||
1205 | AddWithValue(cmd, "@PathItem_OID", string.IsNullOrEmpty(row["PathItem_OID"].ToString()) ? "" : row["PathItem_OID"].ToString()); |
||
1206 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
1207 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1208 | } |
||
1209 | 5c248ee3 | gaqhf | |
1210 | 23a96301 | humkyung | // Nozzle |
1211 | query = $"DELETE FROM {PSN_NOZZLE}"; |
||
1212 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1213 | foreach (DataRow row in item.Nozzle.Rows) |
||
1214 | { |
||
1215 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_NOZZLE} (OID, ItemTag, Xcoords, Ycoords, Equipment_OID, Fluid, NPD, PMC, Rotation, FlowDirection) VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS, @Equipment_OID, @FLUID, @NPD, @PMC, @ROTATION, @FlowDirection)"; |
1216 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1217 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1218 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
1219 | |||
1220 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
1221 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
1222 | else |
||
1223 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
1224 | |||
1225 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
1226 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
1227 | else |
||
1228 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
1229 | |||
1230 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
1231 | AddWithValue(cmd, "@FLUID", string.IsNullOrEmpty(row["FLUID"].ToString()) ? "" : row["FLUID"].ToString()); |
||
1232 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
1233 | 33cee849 | LJIYEON | AddWithValue(cmd, "@PMC", string.IsNullOrEmpty(row["PMC"].ToString()) ? "" : row["PMC"].ToString()); |
1234 | f9f2787b | LJIYEON | |
1235 | if (string.IsNullOrEmpty(row["ROTATION"].ToString())) |
||
1236 | AddWithValue(cmd, "@ROTATION", DBNull.Value); |
||
1237 | else |
||
1238 | AddWithValue(cmd, "@ROTATION", row["ROTATION"].ToString()); |
||
1239 | |||
1240 | AddWithValue(cmd, "@FlowDirection", string.IsNullOrEmpty(row["FlowDirection"].ToString()) ? "" : row["FlowDirection"].ToString()); |
||
1241 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1242 | } |
||
1243 | 5c248ee3 | gaqhf | |
1244 | 23a96301 | humkyung | //Equipment |
1245 | query = $"DELETE FROM {PSN_EQUIPMENT}"; |
||
1246 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1247 | foreach (DataRow row in item.Equipment.Rows) |
||
1248 | { |
||
1249 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_EQUIPMENT} (OID, ItemTag, Xcoords, Ycoords) VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)"; |
1250 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1251 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1252 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
1253 | |||
1254 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
1255 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
1256 | else |
||
1257 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
1258 | |||
1259 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
1260 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
1261 | else |
||
1262 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
1263 | |||
1264 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1265 | } |
||
1266 | 5c248ee3 | gaqhf | |
1267 | 23a96301 | humkyung | // TopologySet |
1268 | query = $"DELETE FROM {PSN_TOPOLOGYSET}"; |
||
1269 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1270 | foreach (DataRow row in item.TopologySet.Rows) |
||
1271 | { |
||
1272 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_TOPOLOGYSET} (OID, Type, SubType, HeadItemTag, TailItemTag, HeadItemSPID, TailItemSPID) VALUES (@OID, @Type, @SubType, @HeadItemTag, @TailItemTag, @HeadItemSPID, @TailItemSPID)"; |
1273 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1274 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1275 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
1276 | AddWithValue(cmd, "@SubType", string.IsNullOrEmpty(row["SubType"].ToString()) ? "" : row["SubType"].ToString()); |
||
1277 | AddWithValue(cmd, "@HeadItemTag", string.IsNullOrEmpty(row["HeadItemTag"].ToString()) ? "" : row["HeadItemTag"].ToString()); |
||
1278 | AddWithValue(cmd, "@TailItemTag", string.IsNullOrEmpty(row["TailItemTag"].ToString()) ? "" : row["TailItemTag"].ToString()); |
||
1279 | AddWithValue(cmd, "@HeadItemSPID", string.IsNullOrEmpty(row["HeadItemSPID"].ToString()) ? "" : row["HeadItemSPID"].ToString()); |
||
1280 | AddWithValue(cmd, "@TailItemSPID", string.IsNullOrEmpty(row["TailItemSPID"].ToString()) ? "" : row["TailItemSPID"].ToString()); |
||
1281 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1282 | } |
||
1283 | 36a45f13 | gaqhf | |
1284 | 23a96301 | humkyung | // PSN |
1285 | query = $"DELETE FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", item.Revision)}'"; |
||
1286 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1287 | foreach (DataRow row in item.PipeSystemNetwork.Rows) |
||
1288 | { |
||
1289 | eb44d82c | LJIYEON | query = $"INSERT INTO {PSN_PIPESYSTEMNETWORK} " + |
1290 | $"(OID, Type, OrderNumber, Pipeline_OID, FROM_DATA, TO_DATA, TopologySet_OID_Key, PSNRevisionNumber, PBS, Drawings, IsValid, Status, IncludingVirtualData, PSNAccuracy) VALUES " + |
||
1291 | $"(@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber, @PBS, @Drawings, @IsValid, @Status, @IncludingVirtualData, @PSNAccuracy)"; |
||
1292 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1293 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1294 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
1295 | AddWithValue(cmd, "@OrderNumber", string.IsNullOrEmpty(row["OrderNumber"].ToString()) ? "" : row["OrderNumber"].ToString()); |
||
1296 | AddWithValue(cmd, "@Pipeline_OID", string.IsNullOrEmpty(row["Pipeline_OID"].ToString()) ? "" : row["Pipeline_OID"].ToString()); |
||
1297 | AddWithValue(cmd, "@FROM_DATA", string.IsNullOrEmpty(row["FROM_DATA"].ToString()) ? "" : row["FROM_DATA"].ToString()); |
||
1298 | AddWithValue(cmd, "@TO_DATA", string.IsNullOrEmpty(row["TO_DATA"].ToString()) ? "" : row["TO_DATA"].ToString()); |
||
1299 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
1300 | AddWithValue(cmd, "@PSNRevisionNumber", string.IsNullOrEmpty(row["PSNRevisionNumber"].ToString()) ? "" : row["PSNRevisionNumber"].ToString()); |
||
1301 | eb44d82c | LJIYEON | |
1302 | 72775f2e | LJIYEON | int IsValid = 0; |
1303 | eb44d82c | LJIYEON | if (row["IsValid"].ToString() == string.Empty || row["IsValid"].ToString() == "OK") |
1304 | 72775f2e | LJIYEON | IsValid = 0; |
1305 | else if (row["IsValid"].ToString() == "InValid") |
||
1306 | IsValid = 1; |
||
1307 | else if (row["IsValid"].ToString() == "Error") |
||
1308 | IsValid = -1; |
||
1309 | f9f2787b | LJIYEON | |
1310 | 72775f2e | LJIYEON | AddWithValue(cmd, "@IsValid", IsValid); |
1311 | f9f2787b | LJIYEON | AddWithValue(cmd, "@Status", string.IsNullOrEmpty(row["Status"].ToString()) ? "" : row["Status"].ToString()); |
1312 | |||
1313 | AddWithValue(cmd, "@PBS", string.IsNullOrEmpty(row["PBS"].ToString()) ? "" : row["PBS"].ToString()); |
||
1314 | AddWithValue(cmd, "@Drawings", string.IsNullOrEmpty(row["Drawings"].ToString()) ? "" : row["Drawings"].ToString()); |
||
1315 | |||
1316 | AddWithValue(cmd, "@IncludingVirtualData", string.IsNullOrEmpty(row["IncludingVirtualData"].ToString()) ? "" : row["IncludingVirtualData"].ToString()); |
||
1317 | if (string.IsNullOrEmpty(row["PSNAccuracy"].ToString())) |
||
1318 | AddWithValue(cmd, "@PSNAccuracy", DBNull.Value); |
||
1319 | else |
||
1320 | AddWithValue(cmd, "@PSNAccuracy", row["PSNAccuracy"].ToString()); |
||
1321 | eb44d82c | LJIYEON | |
1322 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1323 | 6b9e7a56 | gaqhf | } |
1324 | 23a96301 | humkyung | |
1325 | f9f2787b | LJIYEON | //Pipeline |
1326 | query = $"DELETE FROM {PSN_PIPELINE}"; |
||
1327 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1328 | foreach (DataRow row in item.PipeLine.Rows) |
||
1329 | { |
||
1330 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_PIPELINE} (OID, PipeSystem_OID, FLUID, PMC, SEQNUMBER, INSULATION, FROM_DATA, TO_DATA, Unit) VALUES (@OID, @PipeSystem_OID, @FLUID, @PMC, @SEQNUMBER, @INSULATION, @FROM_DATA, @TO_DATA, @Unit)"; |
1331 | f9f2787b | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1332 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
1333 | AddWithValue(cmd, "@PipeSystem_OID", row["PipeSystem_OID"].ToString()); |
||
1334 | AddWithValue(cmd, "@FLUID", row["FLUID"].ToString()); |
||
1335 | AddWithValue(cmd, "@PMC", row["PMC"].ToString()); |
||
1336 | AddWithValue(cmd, "@SEQNUMBER", row["SEQNUMBER"].ToString()); |
||
1337 | AddWithValue(cmd, "@INSULATION", row["INSULATION"].ToString()); |
||
1338 | AddWithValue(cmd, "@FROM_DATA", row["FROM_DATA"].ToString()); |
||
1339 | AddWithValue(cmd, "@TO_DATA", row["TO_DATA"].ToString()); |
||
1340 | AddWithValue(cmd, "@Unit", row["Unit"].ToString()); |
||
1341 | connection.ExecuteNonQuery(cmd, txn); |
||
1342 | } |
||
1343 | a36541fb | LJIYEON | |
1344 | 23a96301 | humkyung | txn.Commit(); |
1345 | 6b9e7a56 | gaqhf | } |
1346 | catch (Exception ex) |
||
1347 | { |
||
1348 | 23a96301 | humkyung | txn.Rollback(); |
1349 | 6b9e7a56 | gaqhf | result = false; |
1350 | } |
||
1351 | } |
||
1352 | } |
||
1353 | catch (Exception ex) |
||
1354 | { |
||
1355 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1356 | result = false; |
||
1357 | } |
||
1358 | } |
||
1359 | |||
1360 | return result; |
||
1361 | } |
||
1362 | |||
1363 | 5c248ee3 | gaqhf | public static bool SavePSNFluidCode(DataTable dt) |
1364 | 6b9e7a56 | gaqhf | { |
1365 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1366 | |||
1367 | bool result = true; |
||
1368 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1369 | 6b9e7a56 | gaqhf | { |
1370 | 1ae1a1c6 | LJIYEON | try |
1371 | 6b9e7a56 | gaqhf | { |
1372 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1373 | 1ae1a1c6 | LJIYEON | { |
1374 | try |
||
1375 | 757ab2f2 | LJIYEON | { |
1376 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_FLUIDCODE}"; |
1377 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1378 | |||
1379 | foreach (DataRow row in dt.Rows) |
||
1380 | 757ab2f2 | LJIYEON | { |
1381 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_FLUIDCODE} (UID, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
1382 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1383 | cmd.Parameters.Clear(); |
||
1384 | |||
1385 | { |
||
1386 | var param = cmd.CreateParameter(); |
||
1387 | param.ParameterName = "@UID"; |
||
1388 | param.Value = row["UID"].ToString(); |
||
1389 | cmd.Parameters.Add(param); |
||
1390 | } |
||
1391 | |||
1392 | { |
||
1393 | var param = cmd.CreateParameter(); |
||
1394 | param.ParameterName = "@Code"; |
||
1395 | param.Value = row["Code"].ToString(); |
||
1396 | cmd.Parameters.Add(param); |
||
1397 | } |
||
1398 | |||
1399 | { |
||
1400 | var param = cmd.CreateParameter(); |
||
1401 | param.ParameterName = "@Description"; |
||
1402 | param.Value = row["Description"].ToString(); |
||
1403 | cmd.Parameters.Add(param); |
||
1404 | } |
||
1405 | |||
1406 | { |
||
1407 | var param = cmd.CreateParameter(); |
||
1408 | param.ParameterName = "@Condition"; |
||
1409 | param.Value = row["Condition"].ToString(); |
||
1410 | cmd.Parameters.Add(param); |
||
1411 | } |
||
1412 | |||
1413 | { |
||
1414 | var param = cmd.CreateParameter(); |
||
1415 | param.ParameterName = "@Remarks"; |
||
1416 | param.Value = row["Remarks"].ToString(); |
||
1417 | cmd.Parameters.Add(param); |
||
1418 | } |
||
1419 | 1ae1a1c6 | LJIYEON | |
1420 | 757ab2f2 | LJIYEON | { |
1421 | 23a96301 | humkyung | var param = cmd.CreateParameter(); |
1422 | param.ParameterName = "@GroundLevel"; |
||
1423 | param.Value = row["GroundLevel"].ToString(); |
||
1424 | cmd.Parameters.Add(param); |
||
1425 | 757ab2f2 | LJIYEON | } |
1426 | 23a96301 | humkyung | |
1427 | connection.ExecuteNonQuery(cmd, txn); |
||
1428 | 757ab2f2 | LJIYEON | } |
1429 | 23a96301 | humkyung | txn.Commit(); |
1430 | 757ab2f2 | LJIYEON | } |
1431 | 1ae1a1c6 | LJIYEON | catch (Exception ex) |
1432 | 6b9e7a56 | gaqhf | { |
1433 | 23a96301 | humkyung | txn.Rollback(); |
1434 | 1ae1a1c6 | LJIYEON | result = false; |
1435 | 6b9e7a56 | gaqhf | } |
1436 | } |
||
1437 | 1ae1a1c6 | LJIYEON | } |
1438 | catch (Exception ex) |
||
1439 | { |
||
1440 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1441 | result = false; |
||
1442 | } |
||
1443 | 6b9e7a56 | gaqhf | } |
1444 | |||
1445 | return result; |
||
1446 | } |
||
1447 | |||
1448 | 1ae1a1c6 | LJIYEON | public static DataTable SelectPSNFluidCode() |
1449 | 31d37d58 | LJIYEON | { |
1450 | 23a96301 | humkyung | DataTable dt = null; |
1451 | 31d37d58 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
1452 | 1ae1a1c6 | LJIYEON | |
1453 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1454 | 31d37d58 | LJIYEON | { |
1455 | 1ae1a1c6 | LJIYEON | try |
1456 | 31d37d58 | LJIYEON | { |
1457 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_FLUIDCODE}"; |
1458 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1459 | 31d37d58 | LJIYEON | { |
1460 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1461 | 31d37d58 | LJIYEON | } |
1462 | } |
||
1463 | 1ae1a1c6 | LJIYEON | catch (Exception ex) |
1464 | { |
||
1465 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1466 | } |
||
1467 | 31d37d58 | LJIYEON | } |
1468 | 23a96301 | humkyung | |
1469 | 1ae1a1c6 | LJIYEON | return dt; |
1470 | } |
||
1471 | |||
1472 | public static bool SavePSNPMC(DataTable dt) |
||
1473 | { |
||
1474 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1475 | |||
1476 | bool result = true; |
||
1477 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1478 | 31d37d58 | LJIYEON | { |
1479 | 1ae1a1c6 | LJIYEON | try |
1480 | { |
||
1481 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1482 | 1ae1a1c6 | LJIYEON | { |
1483 | try |
||
1484 | { |
||
1485 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_PIPINGMATLCLASS}"; |
1486 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1487 | |||
1488 | foreach (DataRow row in dt.Rows) |
||
1489 | 1ae1a1c6 | LJIYEON | { |
1490 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_PIPINGMATLCLASS} ( UID, Priority, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
1491 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1492 | cmd.Parameters.Clear(); |
||
1493 | |||
1494 | { |
||
1495 | var param = cmd.CreateParameter(); |
||
1496 | param.ParameterName = "@UID"; |
||
1497 | param.Value = row["UID"].ToString(); |
||
1498 | cmd.Parameters.Add(param); |
||
1499 | } |
||
1500 | |||
1501 | { |
||
1502 | var param = cmd.CreateParameter(); |
||
1503 | param.ParameterName = "@Priority"; |
||
1504 | param.Value = row["Priority"].ToString(); |
||
1505 | cmd.Parameters.Add(param); |
||
1506 | } |
||
1507 | |||
1508 | { |
||
1509 | var param = cmd.CreateParameter(); |
||
1510 | param.ParameterName = "@Code"; |
||
1511 | param.Value = row["Code"].ToString(); |
||
1512 | cmd.Parameters.Add(param); |
||
1513 | } |
||
1514 | |||
1515 | { |
||
1516 | var param = cmd.CreateParameter(); |
||
1517 | param.ParameterName = "@Description"; |
||
1518 | param.Value = row["Description"].ToString(); |
||
1519 | cmd.Parameters.Add(param); |
||
1520 | } |
||
1521 | 31d37d58 | LJIYEON | |
1522 | 1ae1a1c6 | LJIYEON | { |
1523 | 23a96301 | humkyung | var param = cmd.CreateParameter(); |
1524 | param.ParameterName = "@Condition"; |
||
1525 | param.Value = row["Condition"].ToString(); |
||
1526 | cmd.Parameters.Add(param); |
||
1527 | 1ae1a1c6 | LJIYEON | } |
1528 | 23a96301 | humkyung | |
1529 | { |
||
1530 | var param = cmd.CreateParameter(); |
||
1531 | param.ParameterName = "@Remarks"; |
||
1532 | param.Value = row["Remarks"].ToString(); |
||
1533 | cmd.Parameters.Add(param); |
||
1534 | } |
||
1535 | |||
1536 | { |
||
1537 | var param = cmd.CreateParameter(); |
||
1538 | param.ParameterName = "@GroundLevel"; |
||
1539 | param.Value = row["GroundLevel"].ToString(); |
||
1540 | cmd.Parameters.Add(param); |
||
1541 | } |
||
1542 | |||
1543 | connection.ExecuteNonQuery(cmd, txn); |
||
1544 | 1ae1a1c6 | LJIYEON | } |
1545 | 23a96301 | humkyung | |
1546 | txn.Commit(); |
||
1547 | 1ae1a1c6 | LJIYEON | } |
1548 | catch (Exception ex) |
||
1549 | { |
||
1550 | 23a96301 | humkyung | txn.Rollback(); |
1551 | 1ae1a1c6 | LJIYEON | result = false; |
1552 | } |
||
1553 | } |
||
1554 | } |
||
1555 | catch (Exception ex) |
||
1556 | { |
||
1557 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1558 | result = false; |
||
1559 | } |
||
1560 | } |
||
1561 | 31d37d58 | LJIYEON | |
1562 | 1ae1a1c6 | LJIYEON | return result; |
1563 | 31d37d58 | LJIYEON | } |
1564 | |||
1565 | 33cee849 | LJIYEON | public static bool SavePSNInsulation(DataTable dt) |
1566 | { |
||
1567 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1568 | |||
1569 | bool result = true; |
||
1570 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1571 | 33cee849 | LJIYEON | { |
1572 | try |
||
1573 | { |
||
1574 | using (var txn = connection.BeginTransaction()) |
||
1575 | { |
||
1576 | try |
||
1577 | { |
||
1578 | var query = $"DELETE FROM {PSN_INSULATIONPURPOSE}"; |
||
1579 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1580 | |||
1581 | foreach (DataRow row in dt.Rows) |
||
1582 | { |
||
1583 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_INSULATIONPURPOSE} (UID, Code, Description, Remarks) VALUES (@UID, @Code, @Description, @Remarks)"; |
1584 | 33cee849 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1585 | cmd.Parameters.Clear(); |
||
1586 | |||
1587 | { |
||
1588 | var param = cmd.CreateParameter(); |
||
1589 | param.ParameterName = "@UID"; |
||
1590 | param.Value = row["UID"].ToString(); |
||
1591 | cmd.Parameters.Add(param); |
||
1592 | } |
||
1593 | |||
1594 | { |
||
1595 | var param = cmd.CreateParameter(); |
||
1596 | param.ParameterName = "@Code"; |
||
1597 | param.Value = row["Code"].ToString(); |
||
1598 | cmd.Parameters.Add(param); |
||
1599 | } |
||
1600 | |||
1601 | { |
||
1602 | var param = cmd.CreateParameter(); |
||
1603 | param.ParameterName = "@Description"; |
||
1604 | param.Value = row["Description"].ToString(); |
||
1605 | cmd.Parameters.Add(param); |
||
1606 | } |
||
1607 | |||
1608 | { |
||
1609 | var param = cmd.CreateParameter(); |
||
1610 | param.ParameterName = "@Remarks"; |
||
1611 | param.Value = row["Remarks"].ToString(); |
||
1612 | cmd.Parameters.Add(param); |
||
1613 | } |
||
1614 | |||
1615 | connection.ExecuteNonQuery(cmd, txn); |
||
1616 | } |
||
1617 | |||
1618 | txn.Commit(); |
||
1619 | } |
||
1620 | catch (Exception ex) |
||
1621 | { |
||
1622 | txn.Rollback(); |
||
1623 | result = false; |
||
1624 | } |
||
1625 | } |
||
1626 | } |
||
1627 | catch (Exception ex) |
||
1628 | { |
||
1629 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1630 | result = false; |
||
1631 | } |
||
1632 | } |
||
1633 | |||
1634 | return result; |
||
1635 | } |
||
1636 | 3210f690 | LJIYEON | |
1637 | 5c248ee3 | gaqhf | public static PSN GetDBPSN() |
1638 | 6b9e7a56 | gaqhf | { |
1639 | 5c248ee3 | gaqhf | PSN result = new PSN(); |
1640 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1641 | |||
1642 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1643 | 6b9e7a56 | gaqhf | { |
1644 | try |
||
1645 | { |
||
1646 | 3210f690 | LJIYEON | //query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK}"; |
1647 | eb44d82c | LJIYEON | //using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
1648 | //{ |
||
1649 | 3210f690 | LJIYEON | // result.PipeSystemNetwork = ds.Tables[0].Copy(); |
1650 | eb44d82c | LJIYEON | //} |
1651 | |||
1652 | 3210f690 | LJIYEON | var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'"; |
1653 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1654 | { |
||
1655 | result.PipeSystemNetwork = ds.Tables[0].Clone(); |
||
1656 | result.PipeSystemNetwork.Columns["IsValid"].DataType = typeof(string); |
||
1657 | |||
1658 | foreach (DataRow row in ds.Tables[0].Rows) |
||
1659 | { |
||
1660 | DataRow newRow = result.PipeSystemNetwork.NewRow(); |
||
1661 | newRow["OID"] = row["OID"].ToString(); |
||
1662 | newRow["Type"] = row["Type"].ToString(); |
||
1663 | newRow["OrderNumber"] = row["OrderNumber"].ToString(); |
||
1664 | newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString(); |
||
1665 | newRow["FROM_DATA"] = row["FROM_DATA"].ToString(); |
||
1666 | newRow["TO_DATA"] = row["TO_DATA"].ToString(); |
||
1667 | newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString(); |
||
1668 | newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString(); |
||
1669 | |||
1670 | string IsValid = string.Empty; |
||
1671 | |||
1672 | if (Convert.ToInt32(row["IsValid"].ToString()) == 0) |
||
1673 | IsValid = string.Empty;//"OK"; |
||
1674 | else if (Convert.ToInt32(row["IsValid"].ToString()) == 1) |
||
1675 | IsValid = "InValid"; |
||
1676 | else if (Convert.ToInt32(row["IsValid"].ToString()) == -1) |
||
1677 | IsValid = "Error"; |
||
1678 | |||
1679 | newRow["IsValid"] = IsValid; |
||
1680 | |||
1681 | newRow["Status"] = row["Status"].ToString(); |
||
1682 | newRow["PBS"] = row["PBS"].ToString(); |
||
1683 | newRow["Drawings"] = row["Drawings"].ToString(); |
||
1684 | |||
1685 | newRow["IncludingVirtualData"] = row["IncludingVirtualData"].ToString(); |
||
1686 | newRow["PSNAccuracy"] = row["PSNAccuracy"].ToString(); |
||
1687 | |||
1688 | result.PipeSystemNetwork.Rows.Add(newRow); |
||
1689 | } |
||
1690 | } |
||
1691 | |||
1692 | query = $"SELECT * FROM {PSN_EQUIPMENT}"; |
||
1693 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
1694 | 6b9e7a56 | gaqhf | { |
1695 | 23a96301 | humkyung | result.Equipment = ds.Tables[0].Copy(); |
1696 | } |
||
1697 | |||
1698 | query = $"SELECT * FROM {PSN_NOZZLE}"; |
||
1699 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1700 | { |
||
1701 | result.Nozzle = ds.Tables[0].Copy(); |
||
1702 | 6b9e7a56 | gaqhf | } |
1703 | 23a96301 | humkyung | |
1704 | query = $"SELECT * FROM {PSN_PATHITEMS}"; |
||
1705 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1706 | { |
||
1707 | result.PathItems = ds.Tables[0].Copy(); |
||
1708 | } |
||
1709 | |||
1710 | query = $"SELECT * FROM {PSN_SEQUENCEDATA}"; |
||
1711 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1712 | { |
||
1713 | result.SequenceData = ds.Tables[0].Copy(); |
||
1714 | } |
||
1715 | |||
1716 | aadd8450 | LJIYEON | query = $"SELECT * FROM {PSN_TOPOLOGYSET}"; |
1717 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1718 | { |
||
1719 | result.TopologySet = ds.Tables[0].Copy(); |
||
1720 | } |
||
1721 | |||
1722 | 3210f690 | LJIYEON | |
1723 | |||
1724 | a36541fb | LJIYEON | query = $"SELECT * FROM {PSN_PIPELINE}"; |
1725 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1726 | { |
||
1727 | result.PipeLine = ds.Tables[0].Copy(); |
||
1728 | } |
||
1729 | |||
1730 | 23a96301 | humkyung | result.Revision = GetRevision(); |
1731 | 6b9e7a56 | gaqhf | } |
1732 | catch (Exception ex) |
||
1733 | { |
||
1734 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1735 | 5c248ee3 | gaqhf | result = null; |
1736 | 6b9e7a56 | gaqhf | } |
1737 | } |
||
1738 | 23a96301 | humkyung | |
1739 | 6b9e7a56 | gaqhf | return result; |
1740 | } |
||
1741 | 8f24b438 | gaqhf | |
1742 | public static int GetRevision() |
||
1743 | { |
||
1744 | int result = 0; |
||
1745 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1746 | 23a96301 | humkyung | |
1747 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1748 | 8f24b438 | gaqhf | { |
1749 | try |
||
1750 | { |
||
1751 | 23a96301 | humkyung | var query = $"SELECT DISTINCT PSNRevisionNumber FROM {PSN_PIPESYSTEMNETWORK};"; |
1752 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1753 | 8f24b438 | gaqhf | { |
1754 | 23a96301 | humkyung | foreach (DataRow row in ds.Tables[0].Rows) |
1755 | 8f24b438 | gaqhf | { |
1756 | d5637426 | gaqhf | string value = row["PSNRevisionNumber"].ToString(); |
1757 | 36a45f13 | gaqhf | if (value.StartsWith("V")) |
1758 | d5637426 | gaqhf | value = value.Remove(0, 1); |
1759 | int revisionNumber = Convert.ToInt32(value); |
||
1760 | 8f24b438 | gaqhf | if (result < revisionNumber) |
1761 | result = revisionNumber; |
||
1762 | } |
||
1763 | } |
||
1764 | } |
||
1765 | catch (Exception ex) |
||
1766 | { |
||
1767 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1768 | result = -1; |
||
1769 | } |
||
1770 | } |
||
1771 | |||
1772 | return result; |
||
1773 | } |
||
1774 | |||
1775 | 5c248ee3 | gaqhf | public static DataTable GetPathItem() |
1776 | { |
||
1777 | 23a96301 | humkyung | DataTable dt = null; |
1778 | |||
1779 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1780 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1781 | 5c248ee3 | gaqhf | { |
1782 | try |
||
1783 | { |
||
1784 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_PATHITEMS}"; |
1785 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1786 | 5c248ee3 | gaqhf | { |
1787 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1788 | 5c248ee3 | gaqhf | } |
1789 | } |
||
1790 | catch (Exception ex) |
||
1791 | { |
||
1792 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1793 | } |
||
1794 | } |
||
1795 | 23a96301 | humkyung | |
1796 | 5c248ee3 | gaqhf | return dt; |
1797 | } |
||
1798 | 757ab2f2 | LJIYEON | |
1799 | 36a45f13 | gaqhf | public static DataTable GetTopologySet() |
1800 | 5c248ee3 | gaqhf | { |
1801 | 23a96301 | humkyung | DataTable dt = null; |
1802 | |||
1803 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1804 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1805 | 5c248ee3 | gaqhf | { |
1806 | try |
||
1807 | { |
||
1808 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_TOPOLOGYSET}"; |
1809 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1810 | 5c248ee3 | gaqhf | { |
1811 | aadd8450 | LJIYEON | dt = ds.Tables[0].Clone(); |
1812 | foreach (DataRow row in ds.Tables[0].Rows) |
||
1813 | { |
||
1814 | DataRow newRow = dt.NewRow(); |
||
1815 | newRow["OID"] = row["OID"].ToString(); |
||
1816 | newRow["Type"] = row["Type"].ToString(); |
||
1817 | newRow["SubType"] = row["SubType"].ToString(); |
||
1818 | newRow["HeadItemTag"] = row["HeadItemTag"].ToString(); |
||
1819 | newRow["TailItemTag"] = row["TailItemTag"].ToString(); |
||
1820 | 72775f2e | LJIYEON | newRow["HeadItemSPID"] = row["HeadItemSPID"].ToString(); |
1821 | newRow["TailItemSPID"] = row["TailItemSPID"].ToString(); |
||
1822 | aadd8450 | LJIYEON | dt.Rows.Add(newRow); |
1823 | } |
||
1824 | 5c248ee3 | gaqhf | } |
1825 | } |
||
1826 | catch (Exception ex) |
||
1827 | { |
||
1828 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1829 | } |
||
1830 | } |
||
1831 | 23a96301 | humkyung | |
1832 | 5c248ee3 | gaqhf | return dt; |
1833 | } |
||
1834 | 757ab2f2 | LJIYEON | |
1835 | 5c248ee3 | gaqhf | public static DataTable GetPipeSystemNetwork() |
1836 | { |
||
1837 | 23a96301 | humkyung | DataTable dt = null; |
1838 | |||
1839 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1840 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1841 | 5c248ee3 | gaqhf | { |
1842 | try |
||
1843 | { |
||
1844 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'"; |
1845 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1846 | 5c248ee3 | gaqhf | { |
1847 | 45529c16 | LJIYEON | dt = ds.Tables[0].Clone(); |
1848 | 72775f2e | LJIYEON | dt.Columns["IsValid"].DataType = typeof(string); |
1849 | 45529c16 | LJIYEON | foreach (DataRow row in ds.Tables[0].Rows) |
1850 | { |
||
1851 | DataRow newRow = dt.NewRow(); |
||
1852 | newRow["OID"] = row["OID"].ToString(); |
||
1853 | newRow["Type"] = row["Type"].ToString(); |
||
1854 | newRow["OrderNumber"] = row["OrderNumber"].ToString(); |
||
1855 | newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString(); |
||
1856 | newRow["FROM_DATA"] = row["FROM_DATA"].ToString(); |
||
1857 | newRow["TO_DATA"] = row["TO_DATA"].ToString(); |
||
1858 | newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString(); |
||
1859 | newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString(); |
||
1860 | eb44d82c | LJIYEON | |
1861 | 72775f2e | LJIYEON | string IsValid = string.Empty; |
1862 | 45529c16 | LJIYEON | |
1863 | 72775f2e | LJIYEON | if (Convert.ToInt32(row["IsValid"].ToString()) == 0) |
1864 | IsValid = string.Empty;//"OK"; |
||
1865 | else if (Convert.ToInt32(row["IsValid"].ToString()) == 1) |
||
1866 | IsValid = "InValid"; |
||
1867 | else if (Convert.ToInt32(row["IsValid"].ToString()) == -1) |
||
1868 | IsValid = "Error"; |
||
1869 | 45529c16 | LJIYEON | |
1870 | 72775f2e | LJIYEON | newRow["IsValid"] = IsValid; |
1871 | 45529c16 | LJIYEON | newRow["Status"] = row["Status"].ToString(); |
1872 | eb44d82c | LJIYEON | |
1873 | newRow["PBS"] = row["PBS"].ToString(); |
||
1874 | newRow["Drawings"] = row["Drawings"].ToString(); |
||
1875 | |||
1876 | ddc1c369 | LJIYEON | newRow["IncludingVirtualData"] = row["IncludingVirtualData"].ToString(); |
1877 | eb44d82c | LJIYEON | newRow["PSNAccuracy"] = row["PSNAccuracy"].ToString(); |
1878 | |||
1879 | 45529c16 | LJIYEON | dt.Rows.Add(newRow); |
1880 | } |
||
1881 | 5c248ee3 | gaqhf | } |
1882 | } |
||
1883 | catch (Exception ex) |
||
1884 | { |
||
1885 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1886 | } |
||
1887 | } |
||
1888 | 23a96301 | humkyung | |
1889 | 5c248ee3 | gaqhf | return dt; |
1890 | } |
||
1891 | 757ab2f2 | LJIYEON | |
1892 | 5c248ee3 | gaqhf | public static DataTable GetSequenceData() |
1893 | { |
||
1894 | 23a96301 | humkyung | DataTable dt = null; |
1895 | |||
1896 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1897 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1898 | 5c248ee3 | gaqhf | { |
1899 | try |
||
1900 | { |
||
1901 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_SEQUENCEDATA}"; |
1902 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1903 | 5c248ee3 | gaqhf | { |
1904 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1905 | 5c248ee3 | gaqhf | } |
1906 | } |
||
1907 | catch (Exception ex) |
||
1908 | { |
||
1909 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1910 | } |
||
1911 | } |
||
1912 | 23a96301 | humkyung | |
1913 | 5c248ee3 | gaqhf | return dt; |
1914 | } |
||
1915 | 3d842083 | LJIYEON | |
1916 | //Anohter DB |
||
1917 | public static bool ConnTestAndCreateAnotherTable() |
||
1918 | { |
||
1919 | bool result = false; |
||
1920 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
1921 | |||
1922 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1923 | { |
||
1924 | try |
||
1925 | { |
||
1926 | var names = connection.GetTableNames(); |
||
1927 | var matched = names.FirstOrDefault(param => param == PSN_HEADER_SETTING); |
||
1928 | Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
||
1929 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
1930 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
1931 | dicColCheck.Add("INDEX", "INTEGER"); |
||
1932 | dicColCheck.Add("NAME", "TEXT"); |
||
1933 | |||
1934 | if (matched == null) |
||
1935 | { |
||
1936 | var query = $"CREATE TABLE {PSN_HEADER_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
||
1937 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
1938 | { |
||
1939 | cmd.ExecuteNonQuery(); |
||
1940 | } |
||
1941 | } |
||
1942 | else |
||
1943 | { |
||
1944 | AddColumn(PSN_HEADER_SETTING, dicColCheck); |
||
1945 | } |
||
1946 | |||
1947 | matched = names.FirstOrDefault(param => param == PSN_VENTDRAIN_SETTING); |
||
1948 | dicColCheck.Clear(); |
||
1949 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
1950 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
1951 | dicColCheck.Add("INDEX", "INTEGER"); |
||
1952 | dicColCheck.Add("NAME", "TEXT"); |
||
1953 | if (matched == null) |
||
1954 | { |
||
1955 | var query = $"CREATE TABLE {PSN_VENTDRAIN_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
||
1956 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
1957 | { |
||
1958 | cmd.ExecuteNonQuery(); |
||
1959 | } |
||
1960 | } |
||
1961 | else |
||
1962 | { |
||
1963 | AddColumn(PSN_VENTDRAIN_SETTING, dicColCheck); |
||
1964 | } |
||
1965 | |||
1966 | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGY_RULE); |
||
1967 | dicColCheck.Clear(); |
||
1968 | dicColCheck.Add("UID", "TEXT"); |
||
1969 | if (matched == null) |
||
1970 | { |
||
1971 | var query = $"CREATE TABLE {PSN_TOPOLOGY_RULE} (UID TEXT)"; |
||
1972 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
1973 | { |
||
1974 | cmd.ExecuteNonQuery(); |
||
1975 | } |
||
1976 | |||
1977 | DataTable topologyRule = new DataTable(); |
||
1978 | topologyRule.Columns.Add("NAME", typeof(string)); |
||
1979 | |||
1980 | topologyRule.Rows.Add("FluidCode"); |
||
1981 | topologyRule.Rows.Add("-"); |
||
1982 | topologyRule.Rows.Add("PipingMaterialsClass"); |
||
1983 | topologyRule.Rows.Add("-"); |
||
1984 | topologyRule.Rows.Add("Tag Seq No"); |
||
1985 | |||
1986 | SaveTopologyRule(topologyRule); |
||
1987 | } |
||
1988 | //else |
||
1989 | //{ |
||
1990 | // AddColumn(PSN_TOPOLOGY_RULE, dicColCheck); |
||
1991 | //} |
||
1992 | |||
1993 | matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEMNETWORK); |
||
1994 | dicColCheck.Clear(); |
||
1995 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
1996 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
1997 | dicColCheck.Add("OrderNumber", "NVARCHAR(255)"); |
||
1998 | dicColCheck.Add("Pipeline_OID", "NVARCHAR(255)"); |
||
1999 | dicColCheck.Add("From_Data", "NVARCHAR(255)"); |
||
2000 | dicColCheck.Add("To_Data", "NVARCHAR(255)"); |
||
2001 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(125)"); |
||
2002 | dicColCheck.Add("PSNRevisionNumber", "NVARCHAR(255)"); |
||
2003 | dicColCheck.Add("IsValid", "INT"); |
||
2004 | dicColCheck.Add("Status", "NVARCHAR(255)"); |
||
2005 | dicColCheck.Add("PBS", "NVARCHAR(255)"); |
||
2006 | dicColCheck.Add("Drawings", "NVARCHAR(255)"); |
||
2007 | dicColCheck.Add("IncludingVirtualData", "NVARCHAR(10)"); |
||
2008 | dicColCheck.Add("PSNAccuracy", "REAL"); |
||
2009 | |||
2010 | if (matched == null) |
||
2011 | { |
||
2012 | var query = $"CREATE TABLE {PSN_PIPESYSTEMNETWORK} (OID NVARCHAR(255), Type NVARCHAR(255), OrderNumber NVARCHAR(255), Pipeline_OID NVARCHAR(255), From_Data NVARCHAR(255), " + |
||
2013 | "To_Data NVARCHAR(255), TopologySet_OID_Key NVARCHAR(125), PSNRevisionNumber NVARCHAR(255), IsValid INTEGER, Status NVARCHAR(255), PBS NVARCHAR(255), Drawings NVARCHAR(255), " + |
||
2014 | "IncludingVirtualData NVARCHAR(10), PSNAccuracy REAL)"; |
||
2015 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2016 | { |
||
2017 | cmd.ExecuteNonQuery(); |
||
2018 | } |
||
2019 | } |
||
2020 | else |
||
2021 | { |
||
2022 | AddColumn(PSN_PIPESYSTEMNETWORK, dicColCheck); |
||
2023 | } |
||
2024 | |||
2025 | matched = names.FirstOrDefault(param => param == PSN_EQUIPMENT); |
||
2026 | dicColCheck.Clear(); |
||
2027 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2028 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
2029 | dicColCheck.Add("Xcoords", "REAL"); |
||
2030 | dicColCheck.Add("Ycoords", "REAL"); |
||
2031 | if (matched == null) |
||
2032 | { |
||
2033 | var query = $"CREATE TABLE {PSN_EQUIPMENT} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL)"; |
||
2034 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2035 | { |
||
2036 | cmd.ExecuteNonQuery(); |
||
2037 | } |
||
2038 | } |
||
2039 | else |
||
2040 | { |
||
2041 | AddColumn(PSN_EQUIPMENT, dicColCheck); |
||
2042 | } |
||
2043 | |||
2044 | dicColCheck.Clear(); |
||
2045 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2046 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
2047 | dicColCheck.Add("Xcoords", "REAL"); |
||
2048 | dicColCheck.Add("Ycoords", "REAL"); |
||
2049 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
2050 | dicColCheck.Add("Fluid", "NVARCHAR(255)"); |
||
2051 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
2052 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
2053 | dicColCheck.Add("Rotation", "REAL"); |
||
2054 | dicColCheck.Add("FlowDirection", "NVARCHAR(255)"); |
||
2055 | |||
2056 | matched = names.FirstOrDefault(param => param == PSN_NOZZLE); |
||
2057 | if (matched == null) |
||
2058 | { |
||
2059 | var query = $"CREATE TABLE {PSN_NOZZLE} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL, Equipment_OID NVARCHAR(255), " + |
||
2060 | "Fluid NVARCHAR(255), NPD NVARCHAR(255), PMC NVARCHAR(255), Rotation REAL, FlowDirection NVARCHAR(255))"; |
||
2061 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2062 | { |
||
2063 | cmd.ExecuteNonQuery(); |
||
2064 | } |
||
2065 | } |
||
2066 | else |
||
2067 | { |
||
2068 | AddColumn(PSN_NOZZLE, dicColCheck); |
||
2069 | } |
||
2070 | |||
2071 | matched = names.FirstOrDefault(param => param == PSN_FLUIDCODE); |
||
2072 | dicColCheck.Clear(); |
||
2073 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
2074 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
2075 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
2076 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
2077 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
2078 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
2079 | if (matched == null) |
||
2080 | { |
||
2081 | var query = $"CREATE TABLE {PSN_FLUIDCODE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Condition NVARCHAR(255), Remarks NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
||
2082 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2083 | { |
||
2084 | cmd.ExecuteNonQuery(); |
||
2085 | } |
||
2086 | } |
||
2087 | else |
||
2088 | { |
||
2089 | AddColumn(PSN_FLUIDCODE, dicColCheck); |
||
2090 | } |
||
2091 | |||
2092 | matched = names.FirstOrDefault(param => param == PSN_PIPINGMATLCLASS); |
||
2093 | dicColCheck.Clear(); |
||
2094 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
2095 | dicColCheck.Add("Priority", "INTEGER"); |
||
2096 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
2097 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
2098 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
2099 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
2100 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
2101 | if (matched == null) |
||
2102 | { |
||
2103 | var query = $"CREATE TABLE {PSN_PIPINGMATLCLASS} (UID NVARCHAR(50), Priority INTEGER, Code NVARCHAR(255), Description NVARCHAR(255), Condition NVARCHAR(255), Remarks NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
||
2104 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2105 | { |
||
2106 | cmd.ExecuteNonQuery(); |
||
2107 | } |
||
2108 | } |
||
2109 | else |
||
2110 | { |
||
2111 | AddColumn(PSN_PIPINGMATLCLASS, dicColCheck); |
||
2112 | } |
||
2113 | |||
2114 | matched = names.FirstOrDefault(param => param == PSN_SEQUENCEDATA); |
||
2115 | dicColCheck.Clear(); |
||
2116 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2117 | dicColCheck.Add("SERIALNUMBER", "NVARCHAR(255)"); |
||
2118 | dicColCheck.Add("PathItem_OID", "NVARCHAR(255)"); |
||
2119 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(255)"); |
||
2120 | if (matched == null) |
||
2121 | { |
||
2122 | var query = $"CREATE TABLE {PSN_SEQUENCEDATA} (OID NVARCHAR(255), SERIALNUMBER NVARCHAR(255), PathItem_OID NVARCHAR(255), TopologySet_OID_Key NVARCHAR(255))"; |
||
2123 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2124 | { |
||
2125 | cmd.ExecuteNonQuery(); |
||
2126 | } |
||
2127 | } |
||
2128 | else |
||
2129 | { |
||
2130 | AddColumn(PSN_SEQUENCEDATA, dicColCheck); |
||
2131 | } |
||
2132 | |||
2133 | matched = names.FirstOrDefault(param => param == PSN_PATHITEMS); |
||
2134 | dicColCheck.Clear(); |
||
2135 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2136 | dicColCheck.Add("SequenceData_OID", "NVARCHAR(255)"); |
||
2137 | dicColCheck.Add("TopologySet_OID", "NVARCHAR(255)"); |
||
2138 | dicColCheck.Add("BranchTopologySet_OID", "NVARCHAR(255)"); |
||
2139 | dicColCheck.Add("PipeLine_OID", "NVARCHAR(255)"); |
||
2140 | dicColCheck.Add("ItemName", "NVARCHAR(255)"); |
||
2141 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
2142 | dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)"); |
||
2143 | dicColCheck.Add("CLASS", "NVARCHAR(255)"); |
||
2144 | dicColCheck.Add("SUBCLASS", "NVARCHAR(255)"); |
||
2145 | dicColCheck.Add("TYPE", "NVARCHAR(255)"); |
||
2146 | dicColCheck.Add("PIDNAME", "NVARCHAR(255)"); |
||
2147 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
2148 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
2149 | dicColCheck.Add("PipeSystemNetwork_OID", "NVARCHAR(255)"); |
||
2150 | dicColCheck.Add("PipeRun_OID", "NVARCHAR(255)"); |
||
2151 | dicColCheck.Add("ViewPipeSystemNetwork_OID", "NVARCHAR(255)"); |
||
2152 | if (matched == null) |
||
2153 | { |
||
2154 | var query = $"CREATE TABLE {PSN_PATHITEMS} (OID NVARCHAR(255), SequenceData_OID NVARCHAR(255), " + |
||
2155 | "TopologySet_OID NVARCHAR(255), BranchTopologySet_OID NVARCHAR(255), PipeLine_OID NVARCHAR(255), ItemName NVARCHAR(255), ItemTag NVARCHAR(255), DESCRIPTION NVARCHAR(255), " + |
||
2156 | "CLASS NVARCHAR(255), SUBCLASS NVARCHAR(255), TYPE NVARCHAR(255), PIDNAME NVARCHAR(255), Equipment_OID NVARCHAR(255), NPD NVARCHAR(255), PipeSystemNetwork_OID NVARCHAR(255), PipeRun_OID NVARCHAR(255), " + |
||
2157 | "ViewPipeSystemNetwork_OID NVARCHAR(255))"; |
||
2158 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2159 | { |
||
2160 | cmd.ExecuteNonQuery(); |
||
2161 | } |
||
2162 | } |
||
2163 | else |
||
2164 | { |
||
2165 | AddColumn(PSN_PATHITEMS, dicColCheck); |
||
2166 | } |
||
2167 | |||
2168 | matched = names.FirstOrDefault(param => param == PSN_VIEW); |
||
2169 | dicColCheck.Clear(); |
||
2170 | dicColCheck.Add("OID", "TEXT"); |
||
2171 | if (matched == null) |
||
2172 | { |
||
2173 | var query = $"CREATE TABLE {PSN_VIEW} (OID TEXT)"; |
||
2174 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2175 | { |
||
2176 | cmd.ExecuteNonQuery(); |
||
2177 | } |
||
2178 | } |
||
2179 | |||
2180 | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGYSET); |
||
2181 | dicColCheck.Clear(); |
||
2182 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2183 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
2184 | dicColCheck.Add("SubType", "NVARCHAR(255)"); |
||
2185 | dicColCheck.Add("HeadItemTag", "NVARCHAR(255)"); |
||
2186 | dicColCheck.Add("TailItemTag", "NVARCHAR(255)"); |
||
2187 | dicColCheck.Add("HeadItemSPID", "NVARCHAR(255)"); |
||
2188 | dicColCheck.Add("TailItemSPID", "NVARCHAR(255)"); |
||
2189 | |||
2190 | if (matched == null) |
||
2191 | { |
||
2192 | var query = $"CREATE TABLE { PSN_TOPOLOGYSET} (OID NVARCHAR(255), Type NVARCHAR(255), SubType NVARCHAR(255), HeadItemTag NVARCHAR(255), TailItemTag NVARCHAR(255), HeadItemSPID NVARCHAR(255), TailItemSPID NVARCHAR(255))"; |
||
2193 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2194 | { |
||
2195 | cmd.ExecuteNonQuery(); |
||
2196 | } |
||
2197 | } |
||
2198 | else |
||
2199 | { |
||
2200 | AddColumn(PSN_TOPOLOGYSET, dicColCheck); |
||
2201 | } |
||
2202 | |||
2203 | matched = names.FirstOrDefault(param => param == PSN_TRANSFORMKEYWORD_SETTING); |
||
2204 | dicColCheck.Clear(); |
||
2205 | dicColCheck.Add("[INDEX]", "INTEGER"); |
||
2206 | dicColCheck.Add("[NAME]", "TEXT"); |
||
2207 | dicColCheck.Add("[KEYWORD]", "TEXT"); |
||
2208 | if (matched == null) |
||
2209 | { |
||
2210 | var query = $"CREATE TABLE {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX] INTEGER, [NAME] TEXT, [KEYWORD] TEXT)"; |
||
2211 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2212 | { |
||
2213 | cmd.ExecuteNonQuery(); |
||
2214 | } |
||
2215 | } |
||
2216 | else |
||
2217 | { |
||
2218 | AddColumn(PSN_TRANSFORMKEYWORD_SETTING, dicColCheck); |
||
2219 | } |
||
2220 | |||
2221 | matched = names.FirstOrDefault(param => param == PSN_PIPELINE); |
||
2222 | dicColCheck.Clear(); |
||
2223 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2224 | dicColCheck.Add("PipeSystem_OID", "NVARCHAR(255)"); |
||
2225 | dicColCheck.Add("FLUID", "NVARCHAR(255)"); |
||
2226 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
2227 | dicColCheck.Add("SEQNUMBER", "NVARCHAR(255)"); |
||
2228 | dicColCheck.Add("INSULATION", "NVARCHAR(255)"); |
||
2229 | dicColCheck.Add("FROM_DATA", "NVARCHAR(255)"); |
||
2230 | dicColCheck.Add("TO_DATA", "NVARCHAR(255)"); |
||
2231 | dicColCheck.Add("Unit", "NVARCHAR(100)"); |
||
2232 | if (matched == null) |
||
2233 | { |
||
2234 | var query = $"CREATE TABLE {PSN_PIPELINE} (OID NVARCHAR(255), PipeSystem_OID NVARCHAR(255), FLUID NVARCHAR(255), PMC NVARCHAR(255), SEQNUMBER NVARCHAR(255), INSULATION NVARCHAR(255), " + |
||
2235 | $"FROM_DATA NVARCHAR(255), TO_DATA NVARCHAR(255), Unit NVARCHAR(100))"; |
||
2236 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2237 | { |
||
2238 | cmd.ExecuteNonQuery(); |
||
2239 | } |
||
2240 | } |
||
2241 | else |
||
2242 | { |
||
2243 | AddColumn(PSN_PIPELINE, dicColCheck); |
||
2244 | } |
||
2245 | |||
2246 | matched = names.FirstOrDefault(param => param == PSN_INSULATIONPURPOSE); |
||
2247 | dicColCheck.Clear(); |
||
2248 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
2249 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
2250 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
2251 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
2252 | if (matched == null) |
||
2253 | { |
||
2254 | var query = $"CREATE TABLE {PSN_INSULATIONPURPOSE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Remarks NVARCHAR(255))"; |
||
2255 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2256 | { |
||
2257 | cmd.ExecuteNonQuery(); |
||
2258 | } |
||
2259 | } |
||
2260 | else |
||
2261 | { |
||
2262 | AddColumn(PSN_INSULATIONPURPOSE, dicColCheck); |
||
2263 | } |
||
2264 | |||
2265 | void AddColumn(string TableName, Dictionary<string, string> dicCol) |
||
2266 | { |
||
2267 | var colnames = connection.GetColumnNames(TableName); |
||
2268 | bool check = false; |
||
2269 | if (colnames != null) |
||
2270 | { |
||
2271 | foreach (KeyValuePair<string, string> col in dicCol) |
||
2272 | { |
||
2273 | check = false; |
||
2274 | foreach (string c in colnames) |
||
2275 | { |
||
2276 | if (col.Key.Contains(c)) |
||
2277 | { |
||
2278 | check = true; |
||
2279 | break; |
||
2280 | } |
||
2281 | } |
||
2282 | |||
2283 | if (!check) //없으면 추가 |
||
2284 | { |
||
2285 | string i = string.Empty; |
||
2286 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
2287 | i = "DEFAULT 0"; |
||
2288 | |||
2289 | var query = $"ALTER TABLE " + TableName + " ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
||
2290 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2291 | { |
||
2292 | cmd.ExecuteNonQuery(); |
||
2293 | } |
||
2294 | } |
||
2295 | } |
||
2296 | } |
||
2297 | } |
||
2298 | |||
2299 | result = true; |
||
2300 | } |
||
2301 | catch (Exception ex) |
||
2302 | { |
||
2303 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2304 | } |
||
2305 | } |
||
2306 | |||
2307 | return result; |
||
2308 | } |
||
2309 | |||
2310 | public static bool SaveAnotherPSNData(PSN item, List<HeaderInfo> headerInfos, List<VentDrainInfo> ventDrainInfos, |
||
2311 | List<KeywordItem> keywordItems, DataTable dtTopologyRule, DataTable dtFluidCode, DataTable dtPMC, DataTable dtInsulation) |
||
2312 | { |
||
2313 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
2314 | |||
2315 | bool result = true; |
||
2316 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
2317 | { |
||
2318 | try |
||
2319 | { |
||
2320 | using (var txn = connection.BeginTransaction()) |
||
2321 | { |
||
2322 | try |
||
2323 | { |
||
2324 | // Path Items |
||
2325 | var query = $"DELETE FROM {PSN_PATHITEMS}"; |
||
2326 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2327 | for (int i = 0; i < item.PathItems.Rows.Count; i++) |
||
2328 | { |
||
2329 | DataRow row = item.PathItems.Rows[i]; |
||
2330 | query = $"INSERT INTO {PSN_PATHITEMS} " + |
||
2331 | $"(OID, SequenceData_OID, TopologySet_OID, BranchTopologySet_OID, PipeLine_OID, ItemName, ItemTag, DESCRIPTION, CLASS, SUBCLASS, TYPE, " + |
||
2332 | $"PIDNAME, Equipment_OID, NPD, PipeSystemNetwork_OID, PipeRun_OID, ViewPipeSystemNetwork_OID) VALUES " + |
||
2333 | $"(@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @DESCRIPTION, @Class, @SubClass, @TYPE, @PIDNAME, @Equipment_OID, @NPD, @PipeSystemNetwork_OID,@PipeRun_OID, @ViewPipeSystemNetwork_OID)"; |
||
2334 | var cmd = connection.GetSqlStringCommand(query); |
||
2335 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
2336 | AddWithValue(cmd, "@SequenceData_OID", string.IsNullOrEmpty(row["SequenceData_OID"].ToString()) ? "" : row["SequenceData_OID"].ToString()); |
||
2337 | AddWithValue(cmd, "@TopologySet_OID", string.IsNullOrEmpty(row["TopologySet_OID"].ToString()) ? "" : row["TopologySet_OID"].ToString()); |
||
2338 | AddWithValue(cmd, "@BranchTopologySet_OID", string.IsNullOrEmpty(row["BranchTopologySet_OID"].ToString()) ? "" : row["BranchTopologySet_OID"].ToString()); |
||
2339 | AddWithValue(cmd, "@PipeLine_OID", string.IsNullOrEmpty(row["PipeLine_OID"].ToString()) ? "" : row["PipeLine_OID"].ToString()); |
||
2340 | AddWithValue(cmd, "@ITEMNAME", string.IsNullOrEmpty(row["ITEMNAME"].ToString()) ? "" : row["ITEMNAME"].ToString()); |
||
2341 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
2342 | AddWithValue(cmd, "@DESCRIPTION", string.IsNullOrEmpty(row["DESCRIPTION"].ToString()) ? "" : row["DESCRIPTION"].ToString()); |
||
2343 | AddWithValue(cmd, "@Class", string.IsNullOrEmpty(row["Class"].ToString()) ? "" : row["Class"].ToString()); |
||
2344 | AddWithValue(cmd, "@SubClass", string.IsNullOrEmpty(row["SubClass"].ToString()) ? "" : row["SubClass"].ToString()); |
||
2345 | AddWithValue(cmd, "@TYPE", string.IsNullOrEmpty(row["TYPE"].ToString()) ? "" : row["TYPE"].ToString()); |
||
2346 | AddWithValue(cmd, "@PIDNAME", string.IsNullOrEmpty(row["PIDNAME"].ToString()) ? "" : row["PIDNAME"].ToString()); |
||
2347 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
2348 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
2349 | AddWithValue(cmd, "@PipeSystemNetwork_OID", string.IsNullOrEmpty(row["PipeSystemNetwork_OID"].ToString()) ? "" : row["PipeSystemNetwork_OID"].ToString()); |
||
2350 | AddWithValue(cmd, "@ViewPipeSystemNetwork_OID", string.IsNullOrEmpty(row["ViewPipeSystemNetwork_OID"].ToString()) ? "" : row["ViewPipeSystemNetwork_OID"].ToString()); |
||
2351 | AddWithValue(cmd, "@PipeRun_OID", string.IsNullOrEmpty(row["PipeRun_OID"].ToString()) ? "" : row["PipeRun_OID"].ToString()); |
||
2352 | connection.ExecuteNonQuery(cmd, txn); |
||
2353 | } |
||
2354 | |||
2355 | // Sequence |
||
2356 | query = $"DELETE FROM {PSN_SEQUENCEDATA}"; |
||
2357 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2358 | foreach (DataRow row in item.SequenceData.Rows) |
||
2359 | { |
||
2360 | query = $"INSERT INTO {PSN_SEQUENCEDATA} (OID, SERIALNUMBER, PathItem_OID, TopologySet_OID_Key) VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)"; |
||
2361 | var cmd = connection.GetSqlStringCommand(query); |
||
2362 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
2363 | AddWithValue(cmd, "@SERIALNUMBER", string.IsNullOrEmpty(row["SERIALNUMBER"].ToString()) ? "" : row["SERIALNUMBER"].ToString()); |
||
2364 | AddWithValue(cmd, "@PathItem_OID", string.IsNullOrEmpty(row["PathItem_OID"].ToString()) ? "" : row["PathItem_OID"].ToString()); |
||
2365 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
2366 | connection.ExecuteNonQuery(cmd, txn); |
||
2367 | } |
||
2368 | |||
2369 | // Nozzle |
||
2370 | query = $"DELETE FROM {PSN_NOZZLE}"; |
||
2371 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2372 | foreach (DataRow row in item.Nozzle.Rows) |
||
2373 | { |
||
2374 | query = $"INSERT INTO {PSN_NOZZLE} (OID, ItemTag, Xcoords, Ycoords, Equipment_OID, Fluid, NPD, PMC, Rotation, FlowDirection) VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS, @Equipment_OID, @FLUID, @NPD, @PMC, @ROTATION, @FlowDirection)"; |
||
2375 | var cmd = connection.GetSqlStringCommand(query); |
||
2376 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
2377 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
2378 | |||
2379 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
2380 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
2381 | else |
||
2382 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
2383 | |||
2384 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
2385 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
2386 | else |
||
2387 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
2388 | |||
2389 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
2390 | AddWithValue(cmd, "@FLUID", string.IsNullOrEmpty(row["FLUID"].ToString()) ? "" : row["FLUID"].ToString()); |
||
2391 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
2392 | AddWithValue(cmd, "@PMC", string.IsNullOrEmpty(row["PMC"].ToString()) ? "" : row["PMC"].ToString()); |
||
2393 | |||
2394 | if (string.IsNullOrEmpty(row["ROTATION"].ToString())) |
||
2395 | AddWithValue(cmd, "@ROTATION", DBNull.Value); |
||
2396 | else |
||
2397 | AddWithValue(cmd, "@ROTATION", row["ROTATION"].ToString()); |
||
2398 | |||
2399 | AddWithValue(cmd, "@FlowDirection", string.IsNullOrEmpty(row["FlowDirection"].ToString()) ? "" : row["FlowDirection"].ToString()); |
||
2400 | connection.ExecuteNonQuery(cmd, txn); |
||
2401 | } |
||
2402 | |||
2403 | //Equipment |
||
2404 | query = $"DELETE FROM {PSN_EQUIPMENT}"; |
||
2405 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2406 | foreach (DataRow row in item.Equipment.Rows) |
||
2407 | { |
||
2408 | query = $"INSERT INTO {PSN_EQUIPMENT} (OID, ItemTag, Xcoords, Ycoords) VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)"; |
||
2409 | var cmd = connection.GetSqlStringCommand(query); |
||
2410 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
2411 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
2412 | |||
2413 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
2414 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
2415 | else |
||
2416 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
2417 | |||
2418 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
2419 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
2420 | else |
||
2421 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
2422 | |||
2423 | connection.ExecuteNonQuery(cmd, txn); |
||
2424 | } |
||
2425 | |||
2426 | // TopologySet |
||
2427 | query = $"DELETE FROM {PSN_TOPOLOGYSET}"; |
||
2428 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2429 | foreach (DataRow row in item.TopologySet.Rows) |
||
2430 | { |
||
2431 | query = $"INSERT INTO {PSN_TOPOLOGYSET} (OID, Type, SubType, HeadItemTag, TailItemTag, HeadItemSPID, TailItemSPID) VALUES (@OID, @Type, @SubType, @HeadItemTag, @TailItemTag, @HeadItemSPID, @TailItemSPID)"; |
||
2432 | var cmd = connection.GetSqlStringCommand(query); |
||
2433 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
2434 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
2435 | AddWithValue(cmd, "@SubType", string.IsNullOrEmpty(row["SubType"].ToString()) ? "" : row["SubType"].ToString()); |
||
2436 | AddWithValue(cmd, "@HeadItemTag", string.IsNullOrEmpty(row["HeadItemTag"].ToString()) ? "" : row["HeadItemTag"].ToString()); |
||
2437 | AddWithValue(cmd, "@TailItemTag", string.IsNullOrEmpty(row["TailItemTag"].ToString()) ? "" : row["TailItemTag"].ToString()); |
||
2438 | AddWithValue(cmd, "@HeadItemSPID", string.IsNullOrEmpty(row["HeadItemSPID"].ToString()) ? "" : row["HeadItemSPID"].ToString()); |
||
2439 | AddWithValue(cmd, "@TailItemSPID", string.IsNullOrEmpty(row["TailItemSPID"].ToString()) ? "" : row["TailItemSPID"].ToString()); |
||
2440 | connection.ExecuteNonQuery(cmd, txn); |
||
2441 | } |
||
2442 | |||
2443 | // PSN |
||
2444 | query = $"DELETE FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", item.Revision)}'"; |
||
2445 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2446 | foreach (DataRow row in item.PipeSystemNetwork.Rows) |
||
2447 | { |
||
2448 | query = $"INSERT INTO {PSN_PIPESYSTEMNETWORK} " + |
||
2449 | $"(OID, Type, OrderNumber, Pipeline_OID, FROM_DATA, TO_DATA, TopologySet_OID_Key, PSNRevisionNumber, PBS, Drawings, IsValid, Status, IncludingVirtualData, PSNAccuracy) VALUES " + |
||
2450 | $"(@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber, @PBS, @Drawings, @IsValid, @Status, @IncludingVirtualData, @PSNAccuracy)"; |
||
2451 | var cmd = connection.GetSqlStringCommand(query); |
||
2452 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
2453 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
2454 | AddWithValue(cmd, "@OrderNumber", string.IsNullOrEmpty(row["OrderNumber"].ToString()) ? "" : row["OrderNumber"].ToString()); |
||
2455 | AddWithValue(cmd, "@Pipeline_OID", string.IsNullOrEmpty(row["Pipeline_OID"].ToString()) ? "" : row["Pipeline_OID"].ToString()); |
||
2456 | AddWithValue(cmd, "@FROM_DATA", string.IsNullOrEmpty(row["FROM_DATA"].ToString()) ? "" : row["FROM_DATA"].ToString()); |
||
2457 | AddWithValue(cmd, "@TO_DATA", string.IsNullOrEmpty(row["TO_DATA"].ToString()) ? "" : row["TO_DATA"].ToString()); |
||
2458 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
2459 | AddWithValue(cmd, "@PSNRevisionNumber", string.IsNullOrEmpty(row["PSNRevisionNumber"].ToString()) ? "" : row["PSNRevisionNumber"].ToString()); |
||
2460 | |||
2461 | int IsValid = 0; |
||
2462 | if (row["IsValid"].ToString() == string.Empty || row["IsValid"].ToString() == "OK") |
||
2463 | IsValid = 0; |
||
2464 | else if (row["IsValid"].ToString() == "InValid") |
||
2465 | IsValid = 1; |
||
2466 | else if (row["IsValid"].ToString() == "Error") |
||
2467 | IsValid = -1; |
||
2468 | |||
2469 | AddWithValue(cmd, "@IsValid", IsValid); |
||
2470 | AddWithValue(cmd, "@Status", string.IsNullOrEmpty(row["Status"].ToString()) ? "" : row["Status"].ToString()); |
||
2471 | |||
2472 | AddWithValue(cmd, "@PBS", string.IsNullOrEmpty(row["PBS"].ToString()) ? "" : row["PBS"].ToString()); |
||
2473 | AddWithValue(cmd, "@Drawings", string.IsNullOrEmpty(row["Drawings"].ToString()) ? "" : row["Drawings"].ToString()); |
||
2474 | |||
2475 | AddWithValue(cmd, "@IncludingVirtualData", string.IsNullOrEmpty(row["IncludingVirtualData"].ToString()) ? "" : row["IncludingVirtualData"].ToString()); |
||
2476 | if (string.IsNullOrEmpty(row["PSNAccuracy"].ToString())) |
||
2477 | AddWithValue(cmd, "@PSNAccuracy", DBNull.Value); |
||
2478 | else |
||
2479 | AddWithValue(cmd, "@PSNAccuracy", row["PSNAccuracy"].ToString()); |
||
2480 | |||
2481 | connection.ExecuteNonQuery(cmd, txn); |
||
2482 | } |
||
2483 | |||
2484 | //Pipeline |
||
2485 | query = $"DELETE FROM {PSN_PIPELINE}"; |
||
2486 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2487 | foreach (DataRow row in item.PipeLine.Rows) |
||
2488 | { |
||
2489 | query = $"INSERT INTO {PSN_PIPELINE} (OID, PipeSystem_OID, FLUID, PMC, SEQNUMBER, INSULATION, FROM_DATA, TO_DATA, Unit) VALUES (@OID, @PipeSystem_OID, @FLUID, @PMC, @SEQNUMBER, @INSULATION, @FROM_DATA, @TO_DATA, @Unit)"; |
||
2490 | var cmd = connection.GetSqlStringCommand(query); |
||
2491 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
2492 | AddWithValue(cmd, "@PipeSystem_OID", row["PipeSystem_OID"].ToString()); |
||
2493 | AddWithValue(cmd, "@FLUID", row["FLUID"].ToString()); |
||
2494 | AddWithValue(cmd, "@PMC", row["PMC"].ToString()); |
||
2495 | AddWithValue(cmd, "@SEQNUMBER", row["SEQNUMBER"].ToString()); |
||
2496 | AddWithValue(cmd, "@INSULATION", row["INSULATION"].ToString()); |
||
2497 | AddWithValue(cmd, "@FROM_DATA", row["FROM_DATA"].ToString()); |
||
2498 | AddWithValue(cmd, "@TO_DATA", row["TO_DATA"].ToString()); |
||
2499 | AddWithValue(cmd, "@Unit", row["Unit"].ToString()); |
||
2500 | connection.ExecuteNonQuery(cmd, txn); |
||
2501 | } |
||
2502 | |||
2503 | //Header Setting |
||
2504 | query = $"DELETE FROM {PSN_HEADER_SETTING}"; |
||
2505 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2506 | |||
2507 | foreach (HeaderInfo headerInfo in headerInfos) |
||
2508 | { |
||
2509 | foreach (HeaderItem itemheader in headerInfo.HeaderItems) |
||
2510 | { |
||
2511 | query = $"INSERT INTO {PSN_HEADER_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
||
2512 | var cmd = connection.GetSqlStringCommand(query); |
||
2513 | AddWithValue(cmd, "@GROUP_ID", headerInfo.UID); |
||
2514 | AddWithValue(cmd, "@DESCRIPTION", headerInfo.Description); |
||
2515 | AddWithValue(cmd, "@INDEX", itemheader.Index); |
||
2516 | AddWithValue(cmd, "@NAME", itemheader.Name); |
||
2517 | connection.ExecuteNonQuery(cmd, txn); |
||
2518 | } |
||
2519 | } |
||
2520 | |||
2521 | //Vent/Drain Setting |
||
2522 | query = $"DELETE FROM {PSN_VENTDRAIN_SETTING}"; |
||
2523 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2524 | |||
2525 | foreach (VentDrainInfo ventDrainInfo in ventDrainInfos) |
||
2526 | { |
||
2527 | foreach (VentDrainItem itemventdrain in ventDrainInfo.VentDrainItems) |
||
2528 | { |
||
2529 | query = $"INSERT INTO {PSN_VENTDRAIN_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
||
2530 | var cmd = connection.GetSqlStringCommand(query); |
||
2531 | AddWithValue(cmd, "@GROUP_ID", ventDrainInfo.UID); |
||
2532 | AddWithValue(cmd, "@DESCRIPTION", ventDrainInfo.Description); |
||
2533 | AddWithValue(cmd, "@INDEX", itemventdrain.Index); |
||
2534 | AddWithValue(cmd, "@NAME", itemventdrain.Name); |
||
2535 | connection.ExecuteNonQuery(cmd, txn); |
||
2536 | } |
||
2537 | } |
||
2538 | |||
2539 | //Keyword Setting |
||
2540 | query = $"DELETE FROM {PSN_TRANSFORMKEYWORD_SETTING}"; |
||
2541 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2542 | |||
2543 | foreach (KeywordItem itemKeyword in keywordItems) |
||
2544 | { |
||
2545 | query = $"INSERT INTO {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX], NAME, KEYWORD) VALUES (@INDEX, @NAME, @KEYWORD)"; |
||
2546 | var cmd = connection.GetSqlStringCommand(query); |
||
2547 | AddWithValue(cmd, "@INDEX", itemKeyword.Index); |
||
2548 | AddWithValue(cmd, "@NAME", itemKeyword.Name); |
||
2549 | AddWithValue(cmd, "@KEYWORD", itemKeyword.Keyword); |
||
2550 | connection.ExecuteNonQuery(cmd, txn); |
||
2551 | } |
||
2552 | |||
2553 | //FulidCode |
||
2554 | query = $"DELETE FROM {PSN_FLUIDCODE}"; |
||
2555 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2556 | |||
2557 | foreach (DataRow row in dtFluidCode.Rows) |
||
2558 | { |
||
2559 | query = $"INSERT INTO {PSN_FLUIDCODE} (UID, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
||
2560 | var cmd = connection.GetSqlStringCommand(query); |
||
2561 | cmd.Parameters.Clear(); |
||
2562 | |||
2563 | { |
||
2564 | var param = cmd.CreateParameter(); |
||
2565 | param.ParameterName = "@UID"; |
||
2566 | param.Value = row["UID"].ToString(); |
||
2567 | cmd.Parameters.Add(param); |
||
2568 | } |
||
2569 | |||
2570 | { |
||
2571 | var param = cmd.CreateParameter(); |
||
2572 | param.ParameterName = "@Code"; |
||
2573 | param.Value = row["Code"].ToString(); |
||
2574 | cmd.Parameters.Add(param); |
||
2575 | } |
||
2576 | |||
2577 | { |
||
2578 | var param = cmd.CreateParameter(); |
||
2579 | param.ParameterName = "@Description"; |
||
2580 | param.Value = row["Description"].ToString(); |
||
2581 | cmd.Parameters.Add(param); |
||
2582 | } |
||
2583 | |||
2584 | { |
||
2585 | var param = cmd.CreateParameter(); |
||
2586 | param.ParameterName = "@Condition"; |
||
2587 | param.Value = row["Condition"].ToString(); |
||
2588 | cmd.Parameters.Add(param); |
||
2589 | } |
||
2590 | |||
2591 | { |
||
2592 | var param = cmd.CreateParameter(); |
||
2593 | param.ParameterName = "@Remarks"; |
||
2594 | param.Value = row["Remarks"].ToString(); |
||
2595 | cmd.Parameters.Add(param); |
||
2596 | } |
||
2597 | |||
2598 | { |
||
2599 | var param = cmd.CreateParameter(); |
||
2600 | param.ParameterName = "@GroundLevel"; |
||
2601 | param.Value = row["GroundLevel"].ToString(); |
||
2602 | cmd.Parameters.Add(param); |
||
2603 | } |
||
2604 | |||
2605 | connection.ExecuteNonQuery(cmd, txn); |
||
2606 | } |
||
2607 | |||
2608 | //PMC |
||
2609 | query = $"DELETE FROM {PSN_PIPINGMATLCLASS}"; |
||
2610 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2611 | |||
2612 | foreach (DataRow row in dtPMC.Rows) |
||
2613 | { |
||
2614 | query = $"INSERT INTO {PSN_PIPINGMATLCLASS} ( UID, Priority, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
||
2615 | var cmd = connection.GetSqlStringCommand(query); |
||
2616 | cmd.Parameters.Clear(); |
||
2617 | |||
2618 | { |
||
2619 | var param = cmd.CreateParameter(); |
||
2620 | param.ParameterName = "@UID"; |
||
2621 | param.Value = row["UID"].ToString(); |
||
2622 | cmd.Parameters.Add(param); |
||
2623 | } |
||
2624 | |||
2625 | { |
||
2626 | var param = cmd.CreateParameter(); |
||
2627 | param.ParameterName = "@Priority"; |
||
2628 | param.Value = row["Priority"].ToString(); |
||
2629 | cmd.Parameters.Add(param); |
||
2630 | } |
||
2631 | |||
2632 | { |
||
2633 | var param = cmd.CreateParameter(); |
||
2634 | param.ParameterName = "@Code"; |
||
2635 | param.Value = row["Code"].ToString(); |
||
2636 | cmd.Parameters.Add(param); |
||
2637 | } |
||
2638 | |||
2639 | { |
||
2640 | var param = cmd.CreateParameter(); |
||
2641 | param.ParameterName = "@Description"; |
||
2642 | param.Value = row["Description"].ToString(); |
||
2643 | cmd.Parameters.Add(param); |
||
2644 | } |
||
2645 | |||
2646 | { |
||
2647 | var param = cmd.CreateParameter(); |
||
2648 | param.ParameterName = "@Condition"; |
||
2649 | param.Value = row["Condition"].ToString(); |
||
2650 | cmd.Parameters.Add(param); |
||
2651 | } |
||
2652 | |||
2653 | { |
||
2654 | var param = cmd.CreateParameter(); |
||
2655 | param.ParameterName = "@Remarks"; |
||
2656 | param.Value = row["Remarks"].ToString(); |
||
2657 | cmd.Parameters.Add(param); |
||
2658 | } |
||
2659 | |||
2660 | { |
||
2661 | var param = cmd.CreateParameter(); |
||
2662 | param.ParameterName = "@GroundLevel"; |
||
2663 | param.Value = row["GroundLevel"].ToString(); |
||
2664 | cmd.Parameters.Add(param); |
||
2665 | } |
||
2666 | |||
2667 | connection.ExecuteNonQuery(cmd, txn); |
||
2668 | } |
||
2669 | |||
2670 | //Insulation |
||
2671 | query = $"DELETE FROM {PSN_INSULATIONPURPOSE}"; |
||
2672 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2673 | |||
2674 | foreach (DataRow row in dtInsulation.Rows) |
||
2675 | { |
||
2676 | query = $"INSERT INTO {PSN_INSULATIONPURPOSE} (UID, Code, Description, Remarks) VALUES (@UID, @Code, @Description, @Remarks)"; |
||
2677 | var cmd = connection.GetSqlStringCommand(query); |
||
2678 | cmd.Parameters.Clear(); |
||
2679 | |||
2680 | { |
||
2681 | var param = cmd.CreateParameter(); |
||
2682 | param.ParameterName = "@UID"; |
||
2683 | param.Value = row["UID"].ToString(); |
||
2684 | cmd.Parameters.Add(param); |
||
2685 | } |
||
2686 | |||
2687 | { |
||
2688 | var param = cmd.CreateParameter(); |
||
2689 | param.ParameterName = "@Code"; |
||
2690 | param.Value = row["Code"].ToString(); |
||
2691 | cmd.Parameters.Add(param); |
||
2692 | } |
||
2693 | |||
2694 | { |
||
2695 | var param = cmd.CreateParameter(); |
||
2696 | param.ParameterName = "@Description"; |
||
2697 | param.Value = row["Description"].ToString(); |
||
2698 | cmd.Parameters.Add(param); |
||
2699 | } |
||
2700 | |||
2701 | { |
||
2702 | var param = cmd.CreateParameter(); |
||
2703 | param.ParameterName = "@Remarks"; |
||
2704 | param.Value = row["Remarks"].ToString(); |
||
2705 | cmd.Parameters.Add(param); |
||
2706 | } |
||
2707 | |||
2708 | connection.ExecuteNonQuery(cmd, txn); |
||
2709 | } |
||
2710 | |||
2711 | //Topology Rule |
||
2712 | query = $"DELETE FROM {PSN_TOPOLOGY_RULE}"; |
||
2713 | var cmdtopology = connection.GetSqlStringCommand(query); |
||
2714 | //connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2715 | connection.ExecuteNonQuery(cmdtopology, txn); |
||
2716 | |||
2717 | foreach (DataRow row in dtTopologyRule.Rows) |
||
2718 | { |
||
2719 | query = $"INSERT INTO {PSN_TOPOLOGY_RULE} (UID) VALUES (@UID)"; |
||
2720 | cmdtopology = connection.GetSqlStringCommand(query); |
||
2721 | AddWithValue(cmdtopology, "@UID", row["UID"].ToString()); |
||
2722 | connection.ExecuteNonQuery(cmdtopology, txn); |
||
2723 | } |
||
2724 | |||
2725 | txn.Commit(); |
||
2726 | } |
||
2727 | catch (Exception ex) |
||
2728 | { |
||
2729 | txn.Rollback(); |
||
2730 | result = false; |
||
2731 | } |
||
2732 | } |
||
2733 | } |
||
2734 | catch (Exception ex) |
||
2735 | { |
||
2736 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
2737 | result = false; |
||
2738 | } |
||
2739 | } |
||
2740 | |||
2741 | return result; |
||
2742 | } |
||
2743 | 0dae5645 | gaqhf | } |
2744 | } |