hytos / DTI_PID / ID2PSN / DB.cs @ 284fa2c9
이력 | 보기 | 이력해설 | 다운로드 (190 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 | 1d46fca7 | LJIYEON | using System.Data.SqlClient; |
6 | 45529c16 | LJIYEON | using System.Data.SQLite; |
7 | using System.Linq; |
||
8 | using System.Text.RegularExpressions; |
||
9 | 0dae5645 | gaqhf | |
10 | namespace ID2PSN |
||
11 | { |
||
12 | 45529c16 | LJIYEON | public class DB |
13 | 0dae5645 | gaqhf | { |
14 | 6b9e7a56 | gaqhf | const string PSN_TOPOLOGY_RULE = "T_PSN_TOPOLOGY_RULE"; |
15 | const string PSN_HEADER_SETTING = "T_PSN_HEADER_SETTING"; |
||
16 | 36a45f13 | gaqhf | const string PSN_VENTDRAIN_SETTING = "T_PSN_VENTDRAIN_SETTING"; |
17 | 5dfc785c | LJIYEON | const string PSN_VIEW = "T_PSN_VIEW"; |
18 | 3610fd3f | LJIYEON | const string PSN_TRANSFORMKEYWORD_SETTING = "T_PSN_TRANSFORMKEYWORD_SETTING"; |
19 | const string PSN_VALVEGROUP_SETTING = "SPPIDValveGroup"; |
||
20 | 5dfc785c | LJIYEON | |
21 | 8f24b438 | gaqhf | const string PSN_PATHITEMS = "SPPIDPathItem"; |
22 | const string PSN_SEQUENCEDATA = "SPPIDSequenceData"; |
||
23 | const string PSN_PIPESYSTEMNETWORK = "SPPIDPipeSystemNetwork"; |
||
24 | const string PSN_EQUIPMENT = "SPPIDEquipment"; |
||
25 | const string PSN_NOZZLE = "SPPIDNozzle"; |
||
26 | const string PSN_FLUIDCODE = "SPPIDFluidCode"; |
||
27 | 67638be0 | LJIYEON | const string PSN_PIPINGMATLCLASS = "SPPIDPipingMatlClass"; |
28 | 36a45f13 | gaqhf | const string PSN_TOPOLOGYSET = "SPPIDTopologySet"; |
29 | a36541fb | LJIYEON | //2021.11.17 추가 |
30 | const string PSN_PIPELINE = "SPPIDPipeLine"; |
||
31 | 839708c6 | LJIYEON | //2021.11.26 추가 |
32 | const string PSN_INSULATIONPURPOSE = "SPPIDInsulationPurpose"; |
||
33 | 3610fd3f | LJIYEON | //2022.01.12 추가 //ARS_COMMON DB |
34 | const string PSN_REVISION = "PSNRevision"; |
||
35 | const string PSN_COMMON = "ARS_COMMON"; |
||
36 | 531fb158 | LJIYEON | //2022.01.19 추가 |
37 | const string PSN_PIPESYSTEM = "SPPIDPipeSystem"; |
||
38 | 88c1965b | gaqhf | |
39 | //2022.02.03 추가 |
||
40 | const string PSN_NOPOCKETSETTING = "T_PSN_NOPOCKET_SETTING"; |
||
41 | f2a63376 | 이지연 | const string PSN_AIRFINCOOLERSETTING = "T_PSN_AIRFINCOOLER_SETTING"; |
42 | 1ae1a1c6 | LJIYEON | /// <summary> |
43 | /// ID2 Project.db 데이터를 가져온다. |
||
44 | /// DB 접속 정보 및 DBType (Sqlite, Mssql) 정보를 가져옴 |
||
45 | /// - JY |
||
46 | /// </summary> |
||
47 | /// <returns></returns> |
||
48 | public static DataTable GetProject() |
||
49 | 757ab2f2 | LJIYEON | { |
50 | 1ae1a1c6 | LJIYEON | DataTable dt = new DataTable(); |
51 | ID2Info id2Info = ID2Info.GetInstance(); |
||
52 | try |
||
53 | { |
||
54 | using (SQLiteConnection connection = new SQLiteConnection(@"Data Source = C:\ProgramData\Digital PID\Project.db", true)) |
||
55 | { |
||
56 | connection.Open(); |
||
57 | if (connection.State.Equals(ConnectionState.Open)) |
||
58 | { |
||
59 | using (SQLiteCommand cmd = connection.CreateCommand()) |
||
60 | { |
||
61 | 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]"; |
||
62 | using (SQLiteDataReader dr = cmd.ExecuteReader()) |
||
63 | dt.Load(dr); |
||
64 | } |
||
65 | |||
66 | } |
||
67 | connection.Close(); |
||
68 | } |
||
69 | } |
||
70 | catch (Exception ex) |
||
71 | { |
||
72 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
73 | } |
||
74 | |||
75 | dt.AcceptChanges(); |
||
76 | dt.DefaultView.Sort = "Name"; |
||
77 | dt = dt.DefaultView.ToTable(); |
||
78 | 757ab2f2 | LJIYEON | |
79 | 1ae1a1c6 | LJIYEON | return dt; |
80 | } |
||
81 | 757ab2f2 | LJIYEON | |
82 | 1ae1a1c6 | LJIYEON | /// <summary> |
83 | c4a35107 | humkyung | /// SQLite에 초기 DB 생성 |
84 | 1ae1a1c6 | LJIYEON | /// - JY |
85 | /// </summary> |
||
86 | /// <returns></returns> |
||
87 | 6b9e7a56 | gaqhf | public static bool ConnTestAndCreateTable() |
88 | { |
||
89 | bool result = false; |
||
90 | ID2Info id2Info = ID2Info.GetInstance(); |
||
91 | 1ae1a1c6 | LJIYEON | |
92 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
93 | 6b9e7a56 | gaqhf | { |
94 | 0fe04b33 | LJIYEON | try |
95 | 6b9e7a56 | gaqhf | { |
96 | 23a96301 | humkyung | var names = connection.GetTableNames(); |
97 | var matched = names.FirstOrDefault(param => param == PSN_HEADER_SETTING); |
||
98 | 0ff2a9f1 | LJIYEON | Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
99 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
100 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
101 | dicColCheck.Add("INDEX", "INTEGER"); |
||
102 | dicColCheck.Add("NAME", "TEXT"); |
||
103 | |||
104 | 23a96301 | humkyung | if (matched == null) |
105 | 6b9e7a56 | gaqhf | { |
106 | 23a96301 | humkyung | var query = $"CREATE TABLE {PSN_HEADER_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
107 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
108 | 6b9e7a56 | gaqhf | { |
109 | 23a96301 | humkyung | cmd.ExecuteNonQuery(); |
110 | } |
||
111 | } |
||
112 | 0ff2a9f1 | LJIYEON | else |
113 | { |
||
114 | AddColumn(PSN_HEADER_SETTING, dicColCheck); |
||
115 | } |
||
116 | 757ab2f2 | LJIYEON | |
117 | 23a96301 | humkyung | matched = names.FirstOrDefault(param => param == PSN_VENTDRAIN_SETTING); |
118 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
119 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
120 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
121 | dicColCheck.Add("INDEX", "INTEGER"); |
||
122 | dicColCheck.Add("NAME", "TEXT"); |
||
123 | 23a96301 | humkyung | if (matched == null) |
124 | { |
||
125 | var query = $"CREATE TABLE {PSN_VENTDRAIN_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
||
126 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
127 | { |
||
128 | cmd.ExecuteNonQuery(); |
||
129 | } |
||
130 | } |
||
131 | 0ff2a9f1 | LJIYEON | else |
132 | { |
||
133 | AddColumn(PSN_VENTDRAIN_SETTING, dicColCheck); |
||
134 | } |
||
135 | 757ab2f2 | LJIYEON | |
136 | 23a96301 | humkyung | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGY_RULE); |
137 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
138 | dicColCheck.Add("UID", "TEXT"); |
||
139 | 23a96301 | humkyung | if (matched == null) |
140 | { |
||
141 | var query = $"CREATE TABLE {PSN_TOPOLOGY_RULE} (UID TEXT)"; |
||
142 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
143 | { |
||
144 | cmd.ExecuteNonQuery(); |
||
145 | } |
||
146 | 757ab2f2 | LJIYEON | |
147 | 23a96301 | humkyung | DataTable topologyRule = new DataTable(); |
148 | topologyRule.Columns.Add("NAME", typeof(string)); |
||
149 | 757ab2f2 | LJIYEON | |
150 | 23a96301 | humkyung | topologyRule.Rows.Add("FluidCode"); |
151 | topologyRule.Rows.Add("-"); |
||
152 | topologyRule.Rows.Add("PipingMaterialsClass"); |
||
153 | topologyRule.Rows.Add("-"); |
||
154 | topologyRule.Rows.Add("Tag Seq No"); |
||
155 | |||
156 | SaveTopologyRule(topologyRule); |
||
157 | } |
||
158 | 0ff2a9f1 | LJIYEON | //else |
159 | //{ |
||
160 | // AddColumn(PSN_TOPOLOGY_RULE, dicColCheck); |
||
161 | //} |
||
162 | 72775f2e | LJIYEON | |
163 | matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEMNETWORK); |
||
164 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
165 | d1afd412 | 이지연 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
166 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
167 | dicColCheck.Add("OrderNumber", "NVARCHAR(255)"); |
||
168 | dicColCheck.Add("Pipeline_OID", "NVARCHAR(255)"); |
||
169 | dicColCheck.Add("From_Data", "NVARCHAR(255)"); |
||
170 | 0ff2a9f1 | LJIYEON | dicColCheck.Add("To_Data", "NVARCHAR(255)"); |
171 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(125)"); |
||
172 | dicColCheck.Add("PSNRevisionNumber", "NVARCHAR(255)"); |
||
173 | dicColCheck.Add("IsValid", "INT"); |
||
174 | dicColCheck.Add("Status", "NVARCHAR(255)"); |
||
175 | dicColCheck.Add("PBS", "NVARCHAR(255)"); |
||
176 | dicColCheck.Add("Drawings", "NVARCHAR(255)"); |
||
177 | dicColCheck.Add("IncludingVirtualData", "NVARCHAR(10)"); |
||
178 | 08b33e44 | gaqhf | dicColCheck.Add("PSNAccuracy", "REAL"); |
179 | dicColCheck.Add("Pocket", "NVARCHAR(10)"); |
||
180 | d1afd412 | 이지연 | dicColCheck.Add("EGTag", "NVARCHAR(255)"); |
181 | dicColCheck.Add("HasMLTags", "NVARCHAR(50)"); |
||
182 | |||
183 | 23a96301 | humkyung | if (matched == null) |
184 | { |
||
185 | 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), " + |
186 | "To_Data NVARCHAR(255), TopologySet_OID_Key NVARCHAR(125), PSNRevisionNumber NVARCHAR(255), IsValid INTEGER, Status NVARCHAR(255), PBS NVARCHAR(255), Drawings NVARCHAR(255), " + |
||
187 | d1afd412 | 이지연 | "IncludingVirtualData NVARCHAR(10), PSNAccuracy REAL, Pocket NVARCHAR(10), EGTag NVARCHAR(255), HasMLTags NVARCHAR(50))"; |
188 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
189 | { |
||
190 | cmd.ExecuteNonQuery(); |
||
191 | 757ab2f2 | LJIYEON | } |
192 | } |
||
193 | 0ff2a9f1 | LJIYEON | else |
194 | { |
||
195 | AddColumn(PSN_PIPESYSTEMNETWORK, dicColCheck); |
||
196 | } |
||
197 | 23a96301 | humkyung | |
198 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_EQUIPMENT); |
199 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
200 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
201 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
202 | dicColCheck.Add("Xcoords", "REAL"); |
||
203 | dicColCheck.Add("Ycoords", "REAL"); |
||
204 | 23a96301 | humkyung | if (matched == null) |
205 | { |
||
206 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_EQUIPMENT} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL)"; |
207 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
208 | { |
||
209 | cmd.ExecuteNonQuery(); |
||
210 | } |
||
211 | } |
||
212 | 0ff2a9f1 | LJIYEON | else |
213 | { |
||
214 | AddColumn(PSN_EQUIPMENT, dicColCheck); |
||
215 | } |
||
216 | |||
217 | dicColCheck.Clear(); |
||
218 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
219 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
220 | dicColCheck.Add("Xcoords", "REAL"); |
||
221 | dicColCheck.Add("Ycoords", "REAL"); |
||
222 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
223 | dicColCheck.Add("Fluid", "NVARCHAR(255)"); |
||
224 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
225 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
226 | dicColCheck.Add("Rotation", "REAL"); |
||
227 | dicColCheck.Add("FlowDirection", "NVARCHAR(255)"); |
||
228 | 23a96301 | humkyung | |
229 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_NOZZLE); |
230 | 23a96301 | humkyung | if (matched == null) |
231 | { |
||
232 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_NOZZLE} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL, Equipment_OID NVARCHAR(255), " + |
233 | 33cee849 | LJIYEON | "Fluid NVARCHAR(255), NPD NVARCHAR(255), PMC NVARCHAR(255), Rotation REAL, FlowDirection NVARCHAR(255))"; |
234 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
235 | { |
||
236 | cmd.ExecuteNonQuery(); |
||
237 | } |
||
238 | } |
||
239 | 0ff2a9f1 | LJIYEON | else |
240 | { |
||
241 | AddColumn(PSN_NOZZLE, dicColCheck); |
||
242 | } |
||
243 | 23a96301 | humkyung | |
244 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_FLUIDCODE); |
245 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
246 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
247 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
248 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
249 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
250 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
251 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
252 | 23a96301 | humkyung | if (matched == null) |
253 | { |
||
254 | 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))"; |
255 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
256 | { |
||
257 | cmd.ExecuteNonQuery(); |
||
258 | } |
||
259 | } |
||
260 | 0ff2a9f1 | LJIYEON | else |
261 | { |
||
262 | AddColumn(PSN_FLUIDCODE, dicColCheck); |
||
263 | } |
||
264 | 72775f2e | LJIYEON | |
265 | matched = names.FirstOrDefault(param => param == PSN_PIPINGMATLCLASS); |
||
266 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
267 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
268 | dicColCheck.Add("Priority", "INTEGER"); |
||
269 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
270 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
271 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
272 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
273 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
274 | 23a96301 | humkyung | if (matched == null) |
275 | { |
||
276 | 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))"; |
277 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
278 | { |
||
279 | cmd.ExecuteNonQuery(); |
||
280 | } |
||
281 | } |
||
282 | 0ff2a9f1 | LJIYEON | else |
283 | { |
||
284 | AddColumn(PSN_PIPINGMATLCLASS, dicColCheck); |
||
285 | } |
||
286 | 23a96301 | humkyung | |
287 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_SEQUENCEDATA); |
288 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
289 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
290 | dicColCheck.Add("SERIALNUMBER", "NVARCHAR(255)"); |
||
291 | dicColCheck.Add("PathItem_OID", "NVARCHAR(255)"); |
||
292 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(255)"); |
||
293 | 23a96301 | humkyung | if (matched == null) |
294 | { |
||
295 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_SEQUENCEDATA} (OID NVARCHAR(255), SERIALNUMBER NVARCHAR(255), PathItem_OID NVARCHAR(255), TopologySet_OID_Key NVARCHAR(255))"; |
296 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
297 | { |
||
298 | cmd.ExecuteNonQuery(); |
||
299 | } |
||
300 | } |
||
301 | 0ff2a9f1 | LJIYEON | else |
302 | { |
||
303 | AddColumn(PSN_SEQUENCEDATA, dicColCheck); |
||
304 | } |
||
305 | 23a96301 | humkyung | |
306 | 72775f2e | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_PATHITEMS); |
307 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
308 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
309 | dicColCheck.Add("SequenceData_OID", "NVARCHAR(255)"); |
||
310 | dicColCheck.Add("TopologySet_OID", "NVARCHAR(255)"); |
||
311 | dicColCheck.Add("BranchTopologySet_OID", "NVARCHAR(255)"); |
||
312 | dicColCheck.Add("PipeLine_OID", "NVARCHAR(255)"); |
||
313 | dicColCheck.Add("ItemName", "NVARCHAR(255)"); |
||
314 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
315 | dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)"); |
||
316 | dicColCheck.Add("CLASS", "NVARCHAR(255)"); |
||
317 | dicColCheck.Add("SUBCLASS", "NVARCHAR(255)"); |
||
318 | dicColCheck.Add("TYPE", "NVARCHAR(255)"); |
||
319 | dicColCheck.Add("PIDNAME", "NVARCHAR(255)"); |
||
320 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
321 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
322 | 811d7949 | LJIYEON | dicColCheck.Add("GROUPTAG", "NVARCHAR(255)"); |
323 | 0ff2a9f1 | LJIYEON | dicColCheck.Add("PipeSystemNetwork_OID", "NVARCHAR(255)"); |
324 | dicColCheck.Add("PipeRun_OID", "NVARCHAR(255)"); |
||
325 | dicColCheck.Add("ViewPipeSystemNetwork_OID", "NVARCHAR(255)"); |
||
326 | 7106e181 | LJIYEON | |
327 | bf9e8432 | 이지연 | dicColCheck.Add("EqpGroupTag", "NVARCHAR(255)"); |
328 | dicColCheck.Add("MainLineTag", "NVARCHAR(255)"); |
||
329 | |||
330 | dicColCheck.Add("EGTConnectedPoint", "INT"); |
||
331 | dicColCheck.Add("EGFlowDirection", "NVARCHAR(10)"); |
||
332 | |||
333 | 23a96301 | humkyung | if (matched == null) |
334 | { |
||
335 | f9f2787b | LJIYEON | var query = $"CREATE TABLE {PSN_PATHITEMS} (OID NVARCHAR(255), SequenceData_OID NVARCHAR(255), " + |
336 | "TopologySet_OID NVARCHAR(255), BranchTopologySet_OID NVARCHAR(255), PipeLine_OID NVARCHAR(255), ItemName NVARCHAR(255), ItemTag NVARCHAR(255), DESCRIPTION NVARCHAR(255), " + |
||
337 | 811d7949 | LJIYEON | "CLASS NVARCHAR(255), SUBCLASS NVARCHAR(255), TYPE NVARCHAR(255), PIDNAME NVARCHAR(255), Equipment_OID NVARCHAR(255), NPD NVARCHAR(255), GROUPTAG NVARCHAR(255), PipeSystemNetwork_OID NVARCHAR(255), PipeRun_OID NVARCHAR(255), " + |
338 | bf9e8432 | 이지연 | "ViewPipeSystemNetwork_OID NVARCHAR(255), EqpGroupTag NVARCHAR(255), MainLineTag NVARCHAR(255), EGTConnectedPoint INT, EGFlowDirection NVARCHAR(10))"; |
339 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
340 | { |
||
341 | cmd.ExecuteNonQuery(); |
||
342 | } |
||
343 | } |
||
344 | 0ff2a9f1 | LJIYEON | else |
345 | { |
||
346 | AddColumn(PSN_PATHITEMS, dicColCheck); |
||
347 | } |
||
348 | |||
349 | 23a96301 | humkyung | matched = names.FirstOrDefault(param => param == PSN_VIEW); |
350 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
351 | dicColCheck.Add("OID", "TEXT"); |
||
352 | 23a96301 | humkyung | if (matched == null) |
353 | { |
||
354 | var query = $"CREATE TABLE {PSN_VIEW} (OID TEXT)"; |
||
355 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
356 | { |
||
357 | cmd.ExecuteNonQuery(); |
||
358 | } |
||
359 | } |
||
360 | |||
361 | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGYSET); |
||
362 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
363 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
364 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
365 | dicColCheck.Add("SubType", "NVARCHAR(255)"); |
||
366 | dicColCheck.Add("HeadItemTag", "NVARCHAR(255)"); |
||
367 | dicColCheck.Add("TailItemTag", "NVARCHAR(255)"); |
||
368 | dicColCheck.Add("HeadItemSPID", "NVARCHAR(255)"); |
||
369 | dicColCheck.Add("TailItemSPID", "NVARCHAR(255)"); |
||
370 | |||
371 | 23a96301 | humkyung | if (matched == null) |
372 | { |
||
373 | 88c1965b | gaqhf | 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))"; |
374 | 23a96301 | humkyung | using (var cmd = connection.GetSqlStringCommand(query)) |
375 | { |
||
376 | cmd.ExecuteNonQuery(); |
||
377 | } |
||
378 | } |
||
379 | 0ff2a9f1 | LJIYEON | else |
380 | { |
||
381 | AddColumn(PSN_TOPOLOGYSET, dicColCheck); |
||
382 | } |
||
383 | |||
384 | ddc1c369 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_TRANSFORMKEYWORD_SETTING); |
385 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
386 | 284fa2c9 | 이지연 | dicColCheck.Add("INDEX", "INTEGER"); |
387 | dicColCheck.Add("NAME", "TEXT"); |
||
388 | dicColCheck.Add("KEYWORD", "TEXT"); |
||
389 | ddc1c369 | LJIYEON | if (matched == null) |
390 | { |
||
391 | d4b1ab29 | LJIYEON | var query = $"CREATE TABLE {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX] INTEGER, [NAME] TEXT, [KEYWORD] TEXT)"; |
392 | ddc1c369 | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
393 | { |
||
394 | cmd.ExecuteNonQuery(); |
||
395 | } |
||
396 | } |
||
397 | 0ff2a9f1 | LJIYEON | else |
398 | { |
||
399 | AddColumn(PSN_TRANSFORMKEYWORD_SETTING, dicColCheck); |
||
400 | } |
||
401 | ddc1c369 | LJIYEON | |
402 | a36541fb | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_PIPELINE); |
403 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
404 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
405 | dicColCheck.Add("PipeSystem_OID", "NVARCHAR(255)"); |
||
406 | dicColCheck.Add("FLUID", "NVARCHAR(255)"); |
||
407 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
408 | dicColCheck.Add("SEQNUMBER", "NVARCHAR(255)"); |
||
409 | dicColCheck.Add("INSULATION", "NVARCHAR(255)"); |
||
410 | dicColCheck.Add("FROM_DATA", "NVARCHAR(255)"); |
||
411 | dicColCheck.Add("TO_DATA", "NVARCHAR(255)"); |
||
412 | dicColCheck.Add("Unit", "NVARCHAR(100)"); |
||
413 | a36541fb | LJIYEON | if (matched == null) |
414 | { |
||
415 | 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), " + |
||
416 | $"FROM_DATA NVARCHAR(255), TO_DATA NVARCHAR(255), Unit NVARCHAR(100))"; |
||
417 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
418 | { |
||
419 | cmd.ExecuteNonQuery(); |
||
420 | } |
||
421 | } |
||
422 | 0ff2a9f1 | LJIYEON | else |
423 | { |
||
424 | AddColumn(PSN_PIPELINE, dicColCheck); |
||
425 | } |
||
426 | a36541fb | LJIYEON | |
427 | 839708c6 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_INSULATIONPURPOSE); |
428 | 0ff2a9f1 | LJIYEON | dicColCheck.Clear(); |
429 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
430 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
431 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
432 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
433 | 839708c6 | LJIYEON | if (matched == null) |
434 | { |
||
435 | var query = $"CREATE TABLE {PSN_INSULATIONPURPOSE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Remarks NVARCHAR(255))"; |
||
436 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
437 | { |
||
438 | cmd.ExecuteNonQuery(); |
||
439 | } |
||
440 | } |
||
441 | 0ff2a9f1 | LJIYEON | else |
442 | { |
||
443 | AddColumn(PSN_INSULATIONPURPOSE, dicColCheck); |
||
444 | } |
||
445 | |||
446 | 3610fd3f | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_VALVEGROUP_SETTING); |
447 | dicColCheck.Clear(); |
||
448 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
449 | dicColCheck.Add("GroupType", "NVARCHAR(255)"); |
||
450 | dicColCheck.Add("TagIdentifier", "NVARCHAR(50)"); |
||
451 | dicColCheck.Add("AttributeName", "NVARCHAR(255)"); |
||
452 | dicColCheck.Add("SppidSymbolName", "NVARCHAR(255)"); |
||
453 | if (matched == null) |
||
454 | { |
||
455 | 531fb158 | LJIYEON | var query = $"CREATE TABLE {PSN_VALVEGROUP_SETTING} (OID NVARCHAR(255), GroupType NVARCHAR(255), TagIdentifier NVARCHAR(50), AttributeName NVARCHAR(255), SppidSymbolName NVARCHAR(255))"; |
456 | 3610fd3f | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
457 | { |
||
458 | cmd.ExecuteNonQuery(); |
||
459 | } |
||
460 | } |
||
461 | else |
||
462 | { |
||
463 | AddColumn(PSN_VALVEGROUP_SETTING, dicColCheck); |
||
464 | } |
||
465 | |||
466 | 531fb158 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEM); |
467 | dicColCheck.Clear(); |
||
468 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
469 | dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)"); |
||
470 | dicColCheck.Add("FLUID", "NVARCHAR(255)"); |
||
471 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
472 | dicColCheck.Add("PipeLineQty", "NVARCHAR(255)"); |
||
473 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
474 | if (matched == null) |
||
475 | { |
||
476 | var query = $"CREATE TABLE {PSN_PIPESYSTEM} (OID NVARCHAR(255), DESCRIPTION NVARCHAR(255), FLUID NVARCHAR(255), PMC NVARCHAR(255), PipeLineQty NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
||
477 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
478 | { |
||
479 | cmd.ExecuteNonQuery(); |
||
480 | } |
||
481 | } |
||
482 | else |
||
483 | { |
||
484 | AddColumn(PSN_PIPESYSTEM, dicColCheck); |
||
485 | } |
||
486 | 88c1965b | gaqhf | |
487 | matched = names.FirstOrDefault(param => param == PSN_NOPOCKETSETTING); |
||
488 | dicColCheck.Clear(); |
||
489 | 284fa2c9 | 이지연 | dicColCheck.Add("INDEX", "INTEGER"); |
490 | dicColCheck.Add("TYPE", "TEXT"); |
||
491 | dicColCheck.Add("NAME", "TEXT"); |
||
492 | 88c1965b | gaqhf | if (matched == null) |
493 | { |
||
494 | var query = $"CREATE TABLE {PSN_NOPOCKETSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [NAME] TEXT)"; |
||
495 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
496 | { |
||
497 | cmd.ExecuteNonQuery(); |
||
498 | } |
||
499 | } |
||
500 | else |
||
501 | { |
||
502 | AddColumn(PSN_NOPOCKETSETTING, dicColCheck); |
||
503 | } |
||
504 | |||
505 | f2a63376 | 이지연 | matched = names.FirstOrDefault(param => param == PSN_AIRFINCOOLERSETTING); |
506 | 284fa2c9 | 이지연 | |
507 | f2a63376 | 이지연 | dicColCheck.Clear(); |
508 | 284fa2c9 | 이지연 | dicColCheck.Add("INDEX", "INTEGER"); |
509 | dicColCheck.Add("TYPE", "TEXT"); |
||
510 | dicColCheck.Add("TagIdentifier", "TEXT"); |
||
511 | dicColCheck.Add("AttributeName", "TEXT"); |
||
512 | dicColCheck.Add("NAME", "TEXT"); |
||
513 | |||
514 | f2a63376 | 이지연 | if (matched == null) |
515 | { |
||
516 | 284fa2c9 | 이지연 | var query = $"CREATE TABLE {PSN_AIRFINCOOLERSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [TagIdentifier] TEXT, [AttributeName] TEXT, [NAME] TEXT)"; |
517 | f2a63376 | 이지연 | using (var cmd = connection.GetSqlStringCommand(query)) |
518 | { |
||
519 | cmd.ExecuteNonQuery(); |
||
520 | } |
||
521 | } |
||
522 | else |
||
523 | { |
||
524 | AddColumn(PSN_AIRFINCOOLERSETTING, dicColCheck); |
||
525 | } |
||
526 | |||
527 | 3610fd3f | LJIYEON | |
528 | 0ff2a9f1 | LJIYEON | void AddColumn(string TableName, Dictionary<string, string> dicCol) |
529 | { |
||
530 | var colnames = connection.GetColumnNames(TableName); |
||
531 | bool check = false; |
||
532 | if (colnames != null) |
||
533 | { |
||
534 | foreach (KeyValuePair<string, string> col in dicCol) |
||
535 | { |
||
536 | check = false; |
||
537 | foreach (string c in colnames) |
||
538 | { |
||
539 | if (col.Key.Contains(c)) |
||
540 | { |
||
541 | check = true; |
||
542 | break; |
||
543 | } |
||
544 | } |
||
545 | |||
546 | if (!check) //없으면 추가 |
||
547 | { |
||
548 | string i = string.Empty; |
||
549 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
550 | i = "DEFAULT 0"; |
||
551 | |||
552 | var query = $"ALTER TABLE " + TableName + " ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
||
553 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
554 | { |
||
555 | cmd.ExecuteNonQuery(); |
||
556 | } |
||
557 | } |
||
558 | } |
||
559 | } |
||
560 | } |
||
561 | 839708c6 | LJIYEON | |
562 | 23a96301 | humkyung | result = true; |
563 | 0fe04b33 | LJIYEON | } |
564 | catch (Exception ex) |
||
565 | { |
||
566 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
567 | } |
||
568 | 6b9e7a56 | gaqhf | } |
569 | 45529c16 | LJIYEON | |
570 | 6b9e7a56 | gaqhf | return result; |
571 | } |
||
572 | |||
573 | 1ae1a1c6 | LJIYEON | // ID2 DB 데이터 |
574 | c4a35107 | humkyung | /// <summary> |
575 | /// ID2 데이타베이스에서 OPC 데이터를 조회 |
||
576 | /// </summary> |
||
577 | /// <returns></returns> |
||
578 | 1ae1a1c6 | LJIYEON | public static DataTable SelectOPCRelations() |
579 | 6b9e7a56 | gaqhf | { |
580 | 23a96301 | humkyung | DataTable dt = null; |
581 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
582 | 0fe04b33 | LJIYEON | |
583 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
584 | 6b9e7a56 | gaqhf | { |
585 | 0fe04b33 | LJIYEON | try |
586 | 6b9e7a56 | gaqhf | { |
587 | 23a96301 | humkyung | var query = "SELECT * FROM OPCRelations;"; |
588 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
589 | 757ab2f2 | LJIYEON | { |
590 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
591 | 6b9e7a56 | gaqhf | } |
592 | } |
||
593 | 0fe04b33 | LJIYEON | catch (Exception ex) |
594 | 36a45f13 | gaqhf | { |
595 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
596 | } |
||
597 | 36a45f13 | gaqhf | } |
598 | 1ae1a1c6 | LJIYEON | |
599 | 36a45f13 | gaqhf | return dt; |
600 | } |
||
601 | 6b9e7a56 | gaqhf | |
602 | c4a35107 | humkyung | /// <summary> |
603 | /// ID2 데이타베이스에서 도면 데이터를 조회 |
||
604 | /// </summary> |
||
605 | /// <returns></returns> |
||
606 | 1ae1a1c6 | LJIYEON | public static DataTable SelectDrawings() |
607 | 6b9e7a56 | gaqhf | { |
608 | 23a96301 | humkyung | DataTable dt = null; |
609 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
610 | 0fe04b33 | LJIYEON | |
611 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
612 | 6b9e7a56 | gaqhf | { |
613 | 0fe04b33 | LJIYEON | try |
614 | 6b9e7a56 | gaqhf | { |
615 | c3b48db0 | esham21 | var query = "SELECT DISTINCT NAME FROM [Drawings] order by Name"; |
616 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
617 | 1ae1a1c6 | LJIYEON | { |
618 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
619 | 6b9e7a56 | gaqhf | } |
620 | } |
||
621 | 0fe04b33 | LJIYEON | catch (Exception ex) |
622 | 36a45f13 | gaqhf | { |
623 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
624 | } |
||
625 | 36a45f13 | gaqhf | } |
626 | 1ae1a1c6 | LJIYEON | |
627 | return dt; |
||
628 | 36a45f13 | gaqhf | } |
629 | abee404a | LJIYEON | |
630 | ec1cc293 | LJIYEON | public static DataTable AllDrawings() |
631 | { |
||
632 | DataTable dt = null; |
||
633 | ID2Info id2Info = ID2Info.GetInstance(); |
||
634 | |||
635 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
636 | { |
||
637 | try |
||
638 | { |
||
639 | var query = "SELECT * FROM [Drawings]"; |
||
640 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
641 | { |
||
642 | dt = ds.Tables[0].Copy(); |
||
643 | } |
||
644 | } |
||
645 | catch (Exception ex) |
||
646 | { |
||
647 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
648 | } |
||
649 | } |
||
650 | |||
651 | return dt; |
||
652 | } |
||
653 | |||
654 | 1ae1a1c6 | LJIYEON | public static DataTable SelectLineProperties() |
655 | 6b9e7a56 | gaqhf | { |
656 | 23a96301 | humkyung | DataTable dt = null; |
657 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
658 | 23a96301 | humkyung | |
659 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
660 | 6b9e7a56 | gaqhf | { |
661 | 0fe04b33 | LJIYEON | try |
662 | 6b9e7a56 | gaqhf | { |
663 | 23a96301 | humkyung | var query = "SELECT * FROM LineProperties"; |
664 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
665 | 1ae1a1c6 | LJIYEON | { |
666 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
667 | 6b9e7a56 | gaqhf | } |
668 | } |
||
669 | 0fe04b33 | LJIYEON | catch (Exception ex) |
670 | 6b9e7a56 | gaqhf | { |
671 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
672 | } |
||
673 | 6b9e7a56 | gaqhf | } |
674 | 0fe04b33 | LJIYEON | |
675 | 6b9e7a56 | gaqhf | return dt; |
676 | } |
||
677 | 45529c16 | LJIYEON | |
678 | 1ae1a1c6 | LJIYEON | public static DataTable SelectFluidCode() |
679 | 6b9e7a56 | gaqhf | { |
680 | 23a96301 | humkyung | DataTable dt = null; |
681 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
682 | 0fe04b33 | LJIYEON | |
683 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
684 | 6b9e7a56 | gaqhf | { |
685 | 0fe04b33 | LJIYEON | try |
686 | 6b9e7a56 | gaqhf | { |
687 | 23a96301 | humkyung | var query = "SELECT * FROM FluidCode"; |
688 | 45529c16 | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
689 | 1ae1a1c6 | LJIYEON | { |
690 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
691 | 6b9e7a56 | gaqhf | } |
692 | } |
||
693 | 0fe04b33 | LJIYEON | catch (Exception ex) |
694 | 6b9e7a56 | gaqhf | { |
695 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
696 | } |
||
697 | 1ae1a1c6 | LJIYEON | } |
698 | |||
699 | return dt; |
||
700 | } |
||
701 | |||
702 | public static DataTable SelectPipingMaterialsClass() |
||
703 | { |
||
704 | 23a96301 | humkyung | DataTable dt = null; |
705 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
706 | 0fe04b33 | LJIYEON | |
707 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
708 | 1ae1a1c6 | LJIYEON | { |
709 | 0fe04b33 | LJIYEON | try |
710 | 6b9e7a56 | gaqhf | { |
711 | 23a96301 | humkyung | var query = "SELECT * FROM PipingMaterialsClass"; |
712 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
713 | 1ae1a1c6 | LJIYEON | { |
714 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
715 | 1ae1a1c6 | LJIYEON | } |
716 | } |
||
717 | 0fe04b33 | LJIYEON | catch (Exception ex) |
718 | 1ae1a1c6 | LJIYEON | { |
719 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
720 | } |
||
721 | 6b9e7a56 | gaqhf | } |
722 | 1ae1a1c6 | LJIYEON | |
723 | 6b9e7a56 | gaqhf | return dt; |
724 | } |
||
725 | |||
726 | 1ae1a1c6 | LJIYEON | public static DataTable SelectPSNPIPINGMATLCLASS() |
727 | 6b9e7a56 | gaqhf | { |
728 | 23a96301 | humkyung | DataTable dt = null; |
729 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
730 | 0fe04b33 | LJIYEON | |
731 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
732 | 1ae1a1c6 | LJIYEON | { |
733 | 0fe04b33 | LJIYEON | try |
734 | { |
||
735 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_PIPINGMATLCLASS}"; |
736 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
737 | 1ae1a1c6 | LJIYEON | { |
738 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
739 | 1ae1a1c6 | LJIYEON | } |
740 | 0fe04b33 | LJIYEON | } |
741 | catch (Exception ex) |
||
742 | { |
||
743 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
744 | } |
||
745 | 1ae1a1c6 | LJIYEON | } |
746 | |||
747 | return dt; |
||
748 | } |
||
749 | d1afd412 | 이지연 | |
750 | 839708c6 | LJIYEON | public static DataTable SelectInsulationPurpose() |
751 | { |
||
752 | DataTable dt = null; |
||
753 | ID2Info id2Info = ID2Info.GetInstance(); |
||
754 | |||
755 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
756 | { |
||
757 | try |
||
758 | { |
||
759 | var query = "SELECT * FROM InsulationPurpose"; |
||
760 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
761 | { |
||
762 | dt = ds.Tables[0].Copy(); |
||
763 | } |
||
764 | } |
||
765 | catch (Exception ex) |
||
766 | { |
||
767 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
768 | } |
||
769 | } |
||
770 | |||
771 | return dt; |
||
772 | } |
||
773 | |||
774 | public static DataTable SelectPSNINSULATIONPURPOSE() |
||
775 | { |
||
776 | DataTable dt = null; |
||
777 | ID2Info id2Info = ID2Info.GetInstance(); |
||
778 | |||
779 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
780 | 839708c6 | LJIYEON | { |
781 | try |
||
782 | { |
||
783 | var query = $"SELECT * FROM {PSN_INSULATIONPURPOSE}"; |
||
784 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
785 | { |
||
786 | dt = ds.Tables[0].Copy(); |
||
787 | } |
||
788 | } |
||
789 | catch (Exception ex) |
||
790 | { |
||
791 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
792 | } |
||
793 | } |
||
794 | |||
795 | return dt; |
||
796 | } |
||
797 | |||
798 | 1ae1a1c6 | LJIYEON | public static DataTable SelectNominalDiameter() |
799 | { |
||
800 | 23a96301 | humkyung | DataTable dt = null; |
801 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
802 | 0fe04b33 | LJIYEON | |
803 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
804 | 1ae1a1c6 | LJIYEON | { |
805 | 0fe04b33 | LJIYEON | try |
806 | 6b9e7a56 | gaqhf | { |
807 | 23a96301 | humkyung | var query = "SELECT * FROM NominalDiameter ORDER BY Metric DESC"; |
808 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
809 | 1ae1a1c6 | LJIYEON | { |
810 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
811 | 1ae1a1c6 | LJIYEON | } |
812 | 6b9e7a56 | gaqhf | } |
813 | 0fe04b33 | LJIYEON | catch (Exception ex) |
814 | 1ae1a1c6 | LJIYEON | { |
815 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
816 | } |
||
817 | 1ae1a1c6 | LJIYEON | } |
818 | |||
819 | c4a35107 | humkyung | ///TODO: need to check below code |
820 | 1ae1a1c6 | LJIYEON | dt.Rows.RemoveAt(0); |
821 | dt.Rows.RemoveAt(0); |
||
822 | dt.Rows.RemoveAt(0); |
||
823 | dt.Rows.RemoveAt(0); |
||
824 | |||
825 | 6b9e7a56 | gaqhf | return dt; |
826 | } |
||
827 | abee404a | LJIYEON | |
828 | b267209c | LJIYEON | public static DataTable SelectAllSymbolAttribute() |
829 | { |
||
830 | DataTable dt = null; |
||
831 | ID2Info id2Info = ID2Info.GetInstance(); |
||
832 | |||
833 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
834 | { |
||
835 | try |
||
836 | { |
||
837 | 353c2919 | LJIYEON | var query = "SELECT B.Name AS SymbolName, Attribute AS SymbolAttribute, A.SymbolType_UID ,Attribute ,DisplayAttribute ,AttributeType, Expression FROM SymbolAttribute A INNER JOIN Symbol B ON A.SymbolType_UID = B.SymbolType_UID; "; |
838 | b267209c | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
839 | { |
||
840 | dt = ds.Tables[0].Copy(); |
||
841 | } |
||
842 | } |
||
843 | catch (Exception ex) |
||
844 | { |
||
845 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
846 | } |
||
847 | } |
||
848 | |||
849 | return dt; |
||
850 | } |
||
851 | |||
852 | 1ae1a1c6 | LJIYEON | public static DataTable SelectSymbolAttribute() |
853 | 6b9e7a56 | gaqhf | { |
854 | 23b86f8b | LJIYEON | DataTable dt = null; |
855 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
856 | 0fe04b33 | LJIYEON | |
857 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
858 | 6b9e7a56 | gaqhf | { |
859 | 0fe04b33 | LJIYEON | try |
860 | 6b9e7a56 | gaqhf | { |
861 | d1afd412 | 이지연 | // var query = "SELECT DISTINCT Attribute, DisplayAttribute FROM SymbolAttribute;"; |
862 | 502d1d50 | LJIYEON | var query = "SELECT DISTINCT Attribute FROM SymbolAttribute;"; |
863 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
864 | 1ae1a1c6 | LJIYEON | { |
865 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
866 | 1ae1a1c6 | LJIYEON | } |
867 | } |
||
868 | 0fe04b33 | LJIYEON | catch (Exception ex) |
869 | 1ae1a1c6 | LJIYEON | { |
870 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
871 | } |
||
872 | 1ae1a1c6 | LJIYEON | } |
873 | 0fe04b33 | LJIYEON | |
874 | 1ae1a1c6 | LJIYEON | return dt; |
875 | } |
||
876 | |||
877 | public static DataTable SelectSymbolName() |
||
878 | { |
||
879 | 23a96301 | humkyung | DataTable dt = null; |
880 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
881 | 0fe04b33 | LJIYEON | |
882 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
883 | 1ae1a1c6 | LJIYEON | { |
884 | 0fe04b33 | LJIYEON | try |
885 | 1ae1a1c6 | LJIYEON | { |
886 | 23a96301 | humkyung | var query = "SELECT * FROM SymbolName;"; |
887 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
888 | 1ae1a1c6 | LJIYEON | { |
889 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
890 | 1ae1a1c6 | LJIYEON | } |
891 | } |
||
892 | 0fe04b33 | LJIYEON | catch (Exception ex) |
893 | 1ae1a1c6 | LJIYEON | { |
894 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
895 | } |
||
896 | 1ae1a1c6 | LJIYEON | } |
897 | 0fe04b33 | LJIYEON | |
898 | 1ae1a1c6 | LJIYEON | return dt; |
899 | 45529c16 | LJIYEON | } |
900 | 1ae1a1c6 | LJIYEON | |
901 | public static double[] GetDrawingSize() |
||
902 | { |
||
903 | double[] result = null; |
||
904 | |||
905 | ID2Info id2Info = ID2Info.GetInstance(); |
||
906 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
907 | 1ae1a1c6 | LJIYEON | { |
908 | 0fe04b33 | LJIYEON | try |
909 | 1ae1a1c6 | LJIYEON | { |
910 | d36e2fe0 | esham21 | var query = "SELECT value FROM Configuration WHERE Section = 'Area' AND [Key] = 'Drawing';"; |
911 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
912 | 1ae1a1c6 | LJIYEON | { |
913 | 23a96301 | humkyung | if (ds.Tables[0].Rows.Count == 1) |
914 | 0fe04b33 | LJIYEON | { |
915 | 23a96301 | humkyung | string value = ds.Tables[0].Rows[0][0].ToString(); |
916 | 0fe04b33 | LJIYEON | string[] split = value.Split(new char[] { ',' }); |
917 | result = new double[] { |
||
918 | 45529c16 | LJIYEON | Convert.ToDouble(Regex.Replace(split[0], @"[^0-9]", string.Empty)), |
919 | Convert.ToDouble(Regex.Replace(split[1], @"[^0-9]", string.Empty)), |
||
920 | Convert.ToDouble(Regex.Replace(split[2], @"[^0-9]", string.Empty)), |
||
921 | Convert.ToDouble(Regex.Replace(split[3], @"[^0-9]", string.Empty)) |
||
922 | 1ae1a1c6 | LJIYEON | }; |
923 | 0fe04b33 | LJIYEON | result = new double[] { |
924 | 1ae1a1c6 | LJIYEON | Math.Min(result[0], result[2]), |
925 | Math.Min(result[1], result[3]), |
||
926 | Math.Max(result[0], result[2]), |
||
927 | Math.Max(result[1], result[3]) |
||
928 | }; |
||
929 | } |
||
930 | } |
||
931 | } |
||
932 | 0fe04b33 | LJIYEON | catch (Exception ex) |
933 | 1ae1a1c6 | LJIYEON | { |
934 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
935 | } |
||
936 | 1ae1a1c6 | LJIYEON | } |
937 | |||
938 | return result; |
||
939 | } |
||
940 | |||
941 | public static DataTable GetEquipmentType() |
||
942 | { |
||
943 | 23a96301 | humkyung | DataTable dt = null; |
944 | 1ae1a1c6 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
945 | 0fe04b33 | LJIYEON | |
946 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
947 | 1ae1a1c6 | LJIYEON | { |
948 | 0fe04b33 | LJIYEON | try |
949 | 1ae1a1c6 | LJIYEON | { |
950 | 23a96301 | humkyung | var query = "SELECT Type FROM SymbolType WHERE Category = 'Equipment';"; |
951 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
952 | 1ae1a1c6 | LJIYEON | { |
953 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
954 | 1ae1a1c6 | LJIYEON | } |
955 | } |
||
956 | 0fe04b33 | LJIYEON | catch (Exception ex) |
957 | 1ae1a1c6 | LJIYEON | { |
958 | 0fe04b33 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
959 | } |
||
960 | 6b9e7a56 | gaqhf | } |
961 | 0fe04b33 | LJIYEON | |
962 | 6b9e7a56 | gaqhf | return dt; |
963 | } |
||
964 | abee404a | LJIYEON | |
965 | 1ae1a1c6 | LJIYEON | /// <summary> |
966 | /// Zoom 을 위하여 저장 T_PSN_VIEW 데이터로 PSN 데이터지만 Msqql 과 Sqlite 둘다 저장되어 있음 |
||
967 | /// => ID2 가 DB 타입에 따라서 바라보는 DB가 mssql이냐 sqlite냐로 지정되기 때문에 zoom 기능을 그대로 사용하려면 해당 데이터는 psn도 id2 dbtype에 맞춰서 저장 및 로드해야함 |
||
968 | c4a35107 | humkyung | /// => 더 이상 사용하지 않음 |
969 | 1ae1a1c6 | LJIYEON | /// </summary> |
970 | /// <param name="values"></param> |
||
971 | /// <returns></returns> |
||
972 | public static bool SaveView(List<string> values) |
||
973 | 6b9e7a56 | gaqhf | { |
974 | ID2Info id2Info = ID2Info.GetInstance(); |
||
975 | 1ae1a1c6 | LJIYEON | |
976 | bool result = true; |
||
977 | |||
978 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
979 | { |
||
980 | try |
||
981 | 6b9e7a56 | gaqhf | { |
982 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
983 | 6b9e7a56 | gaqhf | { |
984 | 23a96301 | humkyung | try |
985 | 6b9e7a56 | gaqhf | { |
986 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_VIEW}"; |
987 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
988 | |||
989 | foreach (string value in values) |
||
990 | 1ae1a1c6 | LJIYEON | { |
991 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_VIEW} (OID) VALUES (@OID)"; |
992 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
993 | AddWithValue(cmd, "@OID", value); |
||
994 | connection.ExecuteNonQuery(cmd, txn); |
||
995 | 1ae1a1c6 | LJIYEON | } |
996 | 23a96301 | humkyung | txn.Commit(); |
997 | } |
||
998 | catch (Exception ex) |
||
999 | { |
||
1000 | txn.Rollback(); |
||
1001 | result = false; |
||
1002 | 6b9e7a56 | gaqhf | } |
1003 | 1ae1a1c6 | LJIYEON | } |
1004 | 6b9e7a56 | gaqhf | } |
1005 | 23a96301 | humkyung | catch (Exception ex) |
1006 | { |
||
1007 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1008 | result = false; |
||
1009 | } |
||
1010 | } |
||
1011 | |||
1012 | 1ae1a1c6 | LJIYEON | return result; |
1013 | 6b9e7a56 | gaqhf | } |
1014 | |||
1015 | 1ae1a1c6 | LJIYEON | public static bool DeleteView() |
1016 | 6b9e7a56 | gaqhf | { |
1017 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1018 | 1ae1a1c6 | LJIYEON | |
1019 | bool result = true; |
||
1020 | 23a96301 | humkyung | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1021 | { |
||
1022 | try |
||
1023 | 6b9e7a56 | gaqhf | { |
1024 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1025 | 6b9e7a56 | gaqhf | { |
1026 | 23a96301 | humkyung | try |
1027 | 1ae1a1c6 | LJIYEON | { |
1028 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_VIEW}"; |
1029 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1030 | txn.Commit(); |
||
1031 | } |
||
1032 | catch (Exception ex) |
||
1033 | { |
||
1034 | txn.Rollback(); |
||
1035 | result = false; |
||
1036 | 1ae1a1c6 | LJIYEON | } |
1037 | 6b9e7a56 | gaqhf | } |
1038 | } |
||
1039 | 23a96301 | humkyung | catch (Exception ex) |
1040 | { |
||
1041 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1042 | result = false; |
||
1043 | } |
||
1044 | } |
||
1045 | 1ae1a1c6 | LJIYEON | |
1046 | return result; |
||
1047 | 6b9e7a56 | gaqhf | } |
1048 | abee404a | LJIYEON | |
1049 | 1ae1a1c6 | LJIYEON | //PSN Sqlite |
1050 | public static DataTable SelectHeaderSetting() |
||
1051 | 6b9e7a56 | gaqhf | { |
1052 | 23a96301 | humkyung | DataTable dt = null; |
1053 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1054 | 1ae1a1c6 | LJIYEON | |
1055 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1056 | 6b9e7a56 | gaqhf | { |
1057 | try |
||
1058 | { |
||
1059 | 23a96301 | humkyung | var query = $@"SELECT GROUP_ID, DESCRIPTION, [INDEX], NAME FROM {PSN_HEADER_SETTING};"; |
1060 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1061 | 6b9e7a56 | gaqhf | { |
1062 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1063 | 6b9e7a56 | gaqhf | } |
1064 | } |
||
1065 | catch (Exception ex) |
||
1066 | { |
||
1067 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1068 | } |
||
1069 | } |
||
1070 | 1ae1a1c6 | LJIYEON | |
1071 | 6b9e7a56 | gaqhf | return dt; |
1072 | } |
||
1073 | |||
1074 | 1ae1a1c6 | LJIYEON | public static DataTable SelectVentDrainSetting() |
1075 | 6b9e7a56 | gaqhf | { |
1076 | 23a96301 | humkyung | DataTable dt = null; |
1077 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1078 | 23a96301 | humkyung | |
1079 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1080 | 6b9e7a56 | gaqhf | { |
1081 | try |
||
1082 | { |
||
1083 | 23a96301 | humkyung | var query = $@"SELECT GROUP_ID, DESCRIPTION, [INDEX], NAME FROM {PSN_VENTDRAIN_SETTING};"; |
1084 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1085 | 6b9e7a56 | gaqhf | { |
1086 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1087 | 6b9e7a56 | gaqhf | } |
1088 | } |
||
1089 | catch (Exception ex) |
||
1090 | { |
||
1091 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1092 | } |
||
1093 | } |
||
1094 | 23a96301 | humkyung | |
1095 | 6b9e7a56 | gaqhf | return dt; |
1096 | } |
||
1097 | abee404a | LJIYEON | |
1098 | ddc1c369 | LJIYEON | public static DataTable SelectKeywordsSetting() |
1099 | { |
||
1100 | DataTable dt = null; |
||
1101 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1102 | |||
1103 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1104 | ddc1c369 | LJIYEON | { |
1105 | try |
||
1106 | { |
||
1107 | d4b1ab29 | LJIYEON | var query = $@"SELECT [KEYWORD], [INDEX], [NAME] FROM {PSN_TRANSFORMKEYWORD_SETTING};"; |
1108 | ddc1c369 | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
1109 | { |
||
1110 | dt = ds.Tables[0].Copy(); |
||
1111 | } |
||
1112 | } |
||
1113 | catch (Exception ex) |
||
1114 | { |
||
1115 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1116 | } |
||
1117 | } |
||
1118 | |||
1119 | return dt; |
||
1120 | } |
||
1121 | |||
1122 | 3610fd3f | LJIYEON | public static DataTable SelectValveGroupItemsSetting() |
1123 | { |
||
1124 | DataTable dt = null; |
||
1125 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1126 | |||
1127 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1128 | { |
||
1129 | try |
||
1130 | { |
||
1131 | var query = $@"SELECT OID, GroupType, TagIdentifier, AttributeName, SppidSymbolName FROM {PSN_VALVEGROUP_SETTING};"; |
||
1132 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1133 | { |
||
1134 | dt = ds.Tables[0].Copy(); |
||
1135 | } |
||
1136 | } |
||
1137 | catch (Exception ex) |
||
1138 | { |
||
1139 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1140 | } |
||
1141 | } |
||
1142 | |||
1143 | return dt; |
||
1144 | } |
||
1145 | |||
1146 | d1afd412 | 이지연 | |
1147 | 88c1965b | gaqhf | public static DataTable SelectEquipmentNoPocketSetting() |
1148 | { |
||
1149 | DataTable dt = null; |
||
1150 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1151 | |||
1152 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1153 | { |
||
1154 | try |
||
1155 | { |
||
1156 | var query = $@"SELECT [INDEX], [TYPE], [NAME] FROM {PSN_NOPOCKETSETTING};"; |
||
1157 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1158 | { |
||
1159 | dt = ds.Tables[0].Copy(); |
||
1160 | } |
||
1161 | } |
||
1162 | catch (Exception ex) |
||
1163 | { |
||
1164 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1165 | } |
||
1166 | } |
||
1167 | |||
1168 | return dt; |
||
1169 | } |
||
1170 | |||
1171 | f2a63376 | 이지연 | public static DataTable SelectAirFinCoolerSetting() |
1172 | { |
||
1173 | DataTable dt = null; |
||
1174 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1175 | |||
1176 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1177 | { |
||
1178 | try |
||
1179 | { |
||
1180 | 284fa2c9 | 이지연 | var query = $@"SELECT [INDEX], [TYPE], [TagIdentifier], [AttributeName], [NAME] FROM {PSN_AIRFINCOOLERSETTING};"; |
1181 | f2a63376 | 이지연 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
1182 | { |
||
1183 | dt = ds.Tables[0].Copy(); |
||
1184 | } |
||
1185 | } |
||
1186 | catch (Exception ex) |
||
1187 | { |
||
1188 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1189 | } |
||
1190 | } |
||
1191 | |||
1192 | d1afd412 | 이지연 | return dt; |
1193 | f2a63376 | 이지연 | } |
1194 | |||
1195 | 1ae1a1c6 | LJIYEON | public static bool SaveHeaderSetting(List<HeaderInfo> headerInfos) |
1196 | 6b9e7a56 | gaqhf | { |
1197 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1198 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1199 | 6b9e7a56 | gaqhf | { |
1200 | try |
||
1201 | { |
||
1202 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1203 | 6b9e7a56 | gaqhf | { |
1204 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_HEADER_SETTING}"; |
1205 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1206 | 1ae1a1c6 | LJIYEON | |
1207 | foreach (HeaderInfo headerInfo in headerInfos) |
||
1208 | { |
||
1209 | foreach (HeaderItem item in headerInfo.HeaderItems) |
||
1210 | { |
||
1211 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_HEADER_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
1212 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1213 | AddWithValue(cmd, "@GROUP_ID", headerInfo.UID); |
||
1214 | AddWithValue(cmd, "@DESCRIPTION", headerInfo.Description); |
||
1215 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1216 | AddWithValue(cmd, "@NAME", item.Name); |
||
1217 | connection.ExecuteNonQuery(cmd, txn); |
||
1218 | 1ae1a1c6 | LJIYEON | } |
1219 | } |
||
1220 | 81bdaeed | LJIYEON | txn.Commit(); |
1221 | 6b9e7a56 | gaqhf | } |
1222 | d1afd412 | 이지연 | |
1223 | 6b9e7a56 | gaqhf | } |
1224 | catch (Exception ex) |
||
1225 | { |
||
1226 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1227 | 1ae1a1c6 | LJIYEON | return false; |
1228 | 6b9e7a56 | gaqhf | } |
1229 | } |
||
1230 | 1ae1a1c6 | LJIYEON | return true; |
1231 | 6b9e7a56 | gaqhf | } |
1232 | abee404a | LJIYEON | |
1233 | 1ae1a1c6 | LJIYEON | public static bool SaveVentDrainSetting(List<VentDrainInfo> ventDrainInfos) |
1234 | 6b9e7a56 | gaqhf | { |
1235 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1236 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1237 | 6b9e7a56 | gaqhf | { |
1238 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1239 | 6b9e7a56 | gaqhf | { |
1240 | 23a96301 | humkyung | try |
1241 | 6b9e7a56 | gaqhf | { |
1242 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_VENTDRAIN_SETTING}"; |
1243 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1244 | 1ae1a1c6 | LJIYEON | |
1245 | foreach (VentDrainInfo ventDrainInfo in ventDrainInfos) |
||
1246 | { |
||
1247 | foreach (VentDrainItem item in ventDrainInfo.VentDrainItems) |
||
1248 | { |
||
1249 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_VENTDRAIN_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
1250 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1251 | AddWithValue(cmd, "@GROUP_ID", ventDrainInfo.UID); |
||
1252 | AddWithValue(cmd, "@DESCRIPTION", ventDrainInfo.Description); |
||
1253 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1254 | AddWithValue(cmd, "@NAME", item.Name); |
||
1255 | connection.ExecuteNonQuery(cmd, txn); |
||
1256 | 1ae1a1c6 | LJIYEON | } |
1257 | } |
||
1258 | 81bdaeed | LJIYEON | |
1259 | txn.Commit(); |
||
1260 | 6b9e7a56 | gaqhf | } |
1261 | 23a96301 | humkyung | catch (Exception ex) |
1262 | { |
||
1263 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1264 | return false; |
||
1265 | } |
||
1266 | 6b9e7a56 | gaqhf | } |
1267 | } |
||
1268 | 23a96301 | humkyung | |
1269 | 1ae1a1c6 | LJIYEON | return true; |
1270 | 6b9e7a56 | gaqhf | } |
1271 | abee404a | LJIYEON | |
1272 | 3610fd3f | LJIYEON | public static bool SaveValveGroupItemsSetting(List<ValveGroupItem> valveGroupItems) |
1273 | { |
||
1274 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1275 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1276 | { |
||
1277 | using (var txn = connection.BeginTransaction()) |
||
1278 | { |
||
1279 | try |
||
1280 | { |
||
1281 | var query = $"DELETE FROM {PSN_VALVEGROUP_SETTING}"; |
||
1282 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1283 | |||
1284 | foreach (ValveGroupItem item in valveGroupItems) |
||
1285 | { |
||
1286 | query = $"INSERT INTO {PSN_VALVEGROUP_SETTING} (OID, GroupType, TagIdentifier, AttributeName, SppidSymbolName) " + |
||
1287 | $"VALUES (@OID, @GroupType, @TagIdentifier, @AttributeName, @SppidSymbolName)"; |
||
1288 | var cmd = connection.GetSqlStringCommand(query); |
||
1289 | AddWithValue(cmd, "@OID", item.OID); |
||
1290 | AddWithValue(cmd, "@GroupType", item.GroupType); |
||
1291 | AddWithValue(cmd, "@TagIdentifier", item.TagIdentifier); |
||
1292 | AddWithValue(cmd, "@AttributeName", item.AttributeName); |
||
1293 | AddWithValue(cmd, "@SppidSymbolName", item.SppidSymbolName); |
||
1294 | connection.ExecuteNonQuery(cmd, txn); |
||
1295 | } |
||
1296 | |||
1297 | txn.Commit(); |
||
1298 | } |
||
1299 | catch (Exception ex) |
||
1300 | { |
||
1301 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1302 | return false; |
||
1303 | } |
||
1304 | } |
||
1305 | } |
||
1306 | |||
1307 | return true; |
||
1308 | } |
||
1309 | |||
1310 | 8ab98ea3 | LJIYEON | public static bool SaveKeywordsSetting(List<KeywordItem> keywordItems) |
1311 | ddc1c369 | LJIYEON | { |
1312 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1313 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1314 | ddc1c369 | LJIYEON | { |
1315 | using (var txn = connection.BeginTransaction()) |
||
1316 | { |
||
1317 | try |
||
1318 | { |
||
1319 | 81bdaeed | LJIYEON | var query = $"DELETE FROM {PSN_TRANSFORMKEYWORD_SETTING}"; |
1320 | ddc1c369 | LJIYEON | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
1321 | d1afd412 | 이지연 | |
1322 | 8ab98ea3 | LJIYEON | foreach (KeywordItem item in keywordItems) |
1323 | ddc1c369 | LJIYEON | { |
1324 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX], NAME, KEYWORD) VALUES (@INDEX, @NAME, @KEYWORD)"; |
1325 | 8ab98ea3 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1326 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1327 | AddWithValue(cmd, "@NAME", item.Name); |
||
1328 | d1afd412 | 이지연 | AddWithValue(cmd, "@KEYWORD", item.Keyword); |
1329 | 8ab98ea3 | LJIYEON | connection.ExecuteNonQuery(cmd, txn); |
1330 | ddc1c369 | LJIYEON | } |
1331 | d1afd412 | 이지연 | |
1332 | 81bdaeed | LJIYEON | txn.Commit(); |
1333 | ddc1c369 | LJIYEON | } |
1334 | catch (Exception ex) |
||
1335 | { |
||
1336 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1337 | return false; |
||
1338 | } |
||
1339 | } |
||
1340 | } |
||
1341 | |||
1342 | return true; |
||
1343 | } |
||
1344 | |||
1345 | 88c1965b | gaqhf | public static bool SaveEquipmentNopocketSetting(List<EquipmentNoPocketItem> keywordItems) |
1346 | { |
||
1347 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1348 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1349 | { |
||
1350 | using (var txn = connection.BeginTransaction()) |
||
1351 | { |
||
1352 | try |
||
1353 | { |
||
1354 | var query = $"DELETE FROM {PSN_NOPOCKETSETTING}"; |
||
1355 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1356 | |||
1357 | foreach (EquipmentNoPocketItem item in keywordItems) |
||
1358 | { |
||
1359 | query = $"INSERT INTO {PSN_NOPOCKETSETTING} ([INDEX], [TYPE], [NAME]) VALUES (@INDEX, @TYPE, @NAME)"; |
||
1360 | var cmd = connection.GetSqlStringCommand(query); |
||
1361 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1362 | AddWithValue(cmd, "@TYPE", item.Type); |
||
1363 | AddWithValue(cmd, "@NAME", item.Name); |
||
1364 | connection.ExecuteNonQuery(cmd, txn); |
||
1365 | } |
||
1366 | |||
1367 | txn.Commit(); |
||
1368 | } |
||
1369 | catch (Exception ex) |
||
1370 | { |
||
1371 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1372 | return false; |
||
1373 | } |
||
1374 | } |
||
1375 | } |
||
1376 | |||
1377 | return true; |
||
1378 | } |
||
1379 | |||
1380 | f2a63376 | 이지연 | public static bool SaveAirFinCoolerSetting(List<EquipmentAirFinCoolerItem> keywordItems) |
1381 | { |
||
1382 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1383 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1384 | { |
||
1385 | using (var txn = connection.BeginTransaction()) |
||
1386 | { |
||
1387 | try |
||
1388 | { |
||
1389 | var query = $"DELETE FROM {PSN_AIRFINCOOLERSETTING}"; |
||
1390 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1391 | |||
1392 | foreach (EquipmentAirFinCoolerItem item in keywordItems) |
||
1393 | { |
||
1394 | 284fa2c9 | 이지연 | query = $"INSERT INTO {PSN_AIRFINCOOLERSETTING} ([INDEX], [TYPE], [TagIdentifier], [AttributeName], [NAME]) VALUES (@INDEX, @TYPE, @TagIdentifier, @AttributeName, @NAME)"; |
1395 | f2a63376 | 이지연 | var cmd = connection.GetSqlStringCommand(query); |
1396 | AddWithValue(cmd, "@INDEX", item.Index); |
||
1397 | AddWithValue(cmd, "@TYPE", item.Type); |
||
1398 | 284fa2c9 | 이지연 | AddWithValue(cmd, "@TagIdentifier", item.TagIdentifier); |
1399 | AddWithValue(cmd, "@AttributeName", item.AttributeName); |
||
1400 | f2a63376 | 이지연 | AddWithValue(cmd, "@NAME", item.Name); |
1401 | connection.ExecuteNonQuery(cmd, txn); |
||
1402 | 284fa2c9 | 이지연 | |
1403 | f2a63376 | 이지연 | } |
1404 | |||
1405 | txn.Commit(); |
||
1406 | } |
||
1407 | catch (Exception ex) |
||
1408 | { |
||
1409 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1410 | return false; |
||
1411 | } |
||
1412 | } |
||
1413 | } |
||
1414 | |||
1415 | return true; |
||
1416 | } |
||
1417 | |||
1418 | 1ae1a1c6 | LJIYEON | public static bool SaveTopologyRule(DataTable dt) |
1419 | c6503eaa | gaqhf | { |
1420 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1421 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1422 | c6503eaa | gaqhf | { |
1423 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1424 | c6503eaa | gaqhf | { |
1425 | 23a96301 | humkyung | try |
1426 | c6503eaa | gaqhf | { |
1427 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_TOPOLOGY_RULE}"; |
1428 | var cmd = connection.GetSqlStringCommand(query); |
||
1429 | 0ff2a9f1 | LJIYEON | //connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
1430 | connection.ExecuteNonQuery(cmd, txn); |
||
1431 | 1ae1a1c6 | LJIYEON | |
1432 | foreach (DataRow row in dt.Rows) |
||
1433 | { |
||
1434 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_TOPOLOGY_RULE} (UID) VALUES (@UID)"; |
1435 | 23a96301 | humkyung | cmd = connection.GetSqlStringCommand(query); |
1436 | AddWithValue(cmd, "@UID", row["NAME"].ToString()); |
||
1437 | connection.ExecuteNonQuery(cmd, txn); |
||
1438 | 1ae1a1c6 | LJIYEON | } |
1439 | 23a96301 | humkyung | |
1440 | txn.Commit(); |
||
1441 | } |
||
1442 | catch (Exception ex) |
||
1443 | { |
||
1444 | txn.Rollback(); |
||
1445 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1446 | return false; |
||
1447 | c6503eaa | gaqhf | } |
1448 | } |
||
1449 | } |
||
1450 | 23a96301 | humkyung | |
1451 | 1ae1a1c6 | LJIYEON | return true; |
1452 | c6503eaa | gaqhf | } |
1453 | abee404a | LJIYEON | |
1454 | 1ae1a1c6 | LJIYEON | public static DataTable SelectTopologyRule() |
1455 | 7881ec8f | gaqhf | { |
1456 | 23a96301 | humkyung | DataTable dt = null; |
1457 | |||
1458 | 7881ec8f | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
1459 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1460 | 7881ec8f | gaqhf | { |
1461 | try |
||
1462 | { |
||
1463 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_TOPOLOGY_RULE}"; |
1464 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1465 | 7881ec8f | gaqhf | { |
1466 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
1467 | 7881ec8f | gaqhf | } |
1468 | } |
||
1469 | catch (Exception ex) |
||
1470 | { |
||
1471 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1472 | } |
||
1473 | } |
||
1474 | 23a96301 | humkyung | |
1475 | 7881ec8f | gaqhf | return dt; |
1476 | } |
||
1477 | 45529c16 | LJIYEON | |
1478 | 23a96301 | humkyung | private static void AddWithValue(DbCommand cmd, string PropName, object Value) |
1479 | { |
||
1480 | var param = cmd.CreateParameter(); |
||
1481 | param.ParameterName = PropName; |
||
1482 | param.Value = Value; |
||
1483 | cmd.Parameters.Add(param); |
||
1484 | } |
||
1485 | 3610fd3f | LJIYEON | |
1486 | 1d46fca7 | LJIYEON | public static DataTable SelectRevisionTable() |
1487 | 3610fd3f | LJIYEON | { |
1488 | 1d46fca7 | LJIYEON | DataTable dt = null; |
1489 | 3610fd3f | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
1490 | 1d46fca7 | LJIYEON | |
1491 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1492 | 3610fd3f | LJIYEON | { |
1493 | try |
||
1494 | { |
||
1495 | 7106e181 | LJIYEON | var query = $"SELECT T.name AS table_name, C.name AS column_name FROM ARS_COMMON.sys.tables AS T INNER JOIN ARS_COMMON.sys.columns AS C ON T.object_id = C.object_id WHERE T.name = 'PSNREVISION'"; |
1496 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
1497 | { |
||
1498 | dt = ds.Tables[0].Copy(); |
||
1499 | } |
||
1500 | } |
||
1501 | catch (Exception ex) |
||
1502 | { |
||
1503 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1504 | } |
||
1505 | } |
||
1506 | |||
1507 | return dt; |
||
1508 | } |
||
1509 | |||
1510 | public static DataTable SelectRevision() |
||
1511 | { |
||
1512 | DataTable dt = null; |
||
1513 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1514 | |||
1515 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1516 | { |
||
1517 | try |
||
1518 | { |
||
1519 | var query = $"SELECT * FROM ARS_COMMON.dbo.PSNREVISION"; |
||
1520 | |||
1521 | 1d46fca7 | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
1522 | 3610fd3f | LJIYEON | { |
1523 | 1d46fca7 | LJIYEON | dt = ds.Tables[0].Copy(); |
1524 | } |
||
1525 | } |
||
1526 | catch (Exception ex) |
||
1527 | { |
||
1528 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
1529 | } |
||
1530 | } |
||
1531 | 3610fd3f | LJIYEON | |
1532 | 1d46fca7 | LJIYEON | return dt; |
1533 | } |
||
1534 | 54b6df95 | LJIYEON | |
1535 | 1d46fca7 | LJIYEON | public static bool ConnCreateRevisionTable(Dictionary<string, string> dicColCheck, List<string> names) |
1536 | { |
||
1537 | bool result = false; |
||
1538 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1539 | |||
1540 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1541 | { |
||
1542 | try |
||
1543 | { |
||
1544 | if (names.Count == 0) |
||
1545 | { |
||
1546 | d1afd412 | 이지연 | |
1547 | 1d46fca7 | LJIYEON | var query = $"CREATE TABLE ARS_COMMON.dbo.PSNRevision ([OID] [uniqueidentifier] ,[Project_OID] [uniqueidentifier] ," + |
1548 | $"[ProjectCode] nvarchar(255), [RevNumber] int ,[UserName] nvarchar(255) ,[TimeData] nvarchar(255) ," + |
||
1549 | $"[PSNDatabasePath] nvarchar(255) , [PsnByPBSFilter] varchar(20) ,[PsnByNPDFilter] varchar(20) ,[PidDrawings] int , " + |
||
1550 | $"[PipeSystems] int ,[PipeLines] int ,[Topologies] int ,[PipeSystemNetworks] int ,[InValidPSNs] int ,[E2E] int ," + |
||
1551 | 91c75c0b | 이지연 | $"[E2B] int ,[B2E] int ,[HDE] int ,[HD2] int ,[HDB] int ,[B2B] int, [LastModificationdate] nvarchar(255), [ID2_PSN] nvarchar(10))"; |
1552 | 1d46fca7 | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
1553 | 3610fd3f | LJIYEON | { |
1554 | 1d46fca7 | LJIYEON | cmd.ExecuteNonQuery(); |
1555 | 3610fd3f | LJIYEON | } |
1556 | 1d46fca7 | LJIYEON | } |
1557 | else |
||
1558 | { |
||
1559 | AddColumn(PSN_REVISION, dicColCheck, names); |
||
1560 | 3610fd3f | LJIYEON | } |
1561 | |||
1562 | 1d46fca7 | LJIYEON | void AddColumn(string TableName, Dictionary<string, string> dicCol, List<string> colnames) |
1563 | 3610fd3f | LJIYEON | { |
1564 | bool check = false; |
||
1565 | if (colnames != null) |
||
1566 | { |
||
1567 | foreach (KeyValuePair<string, string> col in dicCol) |
||
1568 | { |
||
1569 | check = false; |
||
1570 | foreach (string c in colnames) |
||
1571 | { |
||
1572 | if (col.Key.Contains(c)) |
||
1573 | { |
||
1574 | check = true; |
||
1575 | break; |
||
1576 | } |
||
1577 | } |
||
1578 | |||
1579 | if (!check) //없으면 추가 |
||
1580 | { |
||
1581 | string i = string.Empty; |
||
1582 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
1583 | i = "DEFAULT 0"; |
||
1584 | |||
1585 | 1d46fca7 | LJIYEON | var queryalter = $"ALTER TABLE ARS_COMMON.dbo.PSNRevision ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
1586 | using (var cmd = connection.GetSqlStringCommand(queryalter)) |
||
1587 | 3610fd3f | LJIYEON | { |
1588 | cmd.ExecuteNonQuery(); |
||
1589 | } |
||
1590 | } |
||
1591 | } |
||
1592 | } |
||
1593 | } |
||
1594 | 1d46fca7 | LJIYEON | |
1595 | result = true; |
||
1596 | 3610fd3f | LJIYEON | } |
1597 | catch (Exception ex) |
||
1598 | { |
||
1599 | 1d46fca7 | LJIYEON | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
1600 | 3610fd3f | LJIYEON | } |
1601 | } |
||
1602 | 1d46fca7 | LJIYEON | |
1603 | return result; |
||
1604 | 3610fd3f | LJIYEON | } |
1605 | 1d46fca7 | LJIYEON | |
1606 | 7106e181 | LJIYEON | public static bool UpdateRevision(string TimeData, string ProjectCode, int RevNumber, string UserName, string PSNDatabasePath, string PsnByPBSFilter, string PsnByNPDFilter, |
1607 | int PidDrawings, int PipeSystems, int PipeLines, int Topologies, int PipeSystemNetworks, int InValidPSNs, int E2E, int E2B, int B2E, int HDE, int HD2, int HDB, int B2B) |
||
1608 | { |
||
1609 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1610 | bool result = true; |
||
1611 | |||
1612 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1613 | { |
||
1614 | try |
||
1615 | { |
||
1616 | using (var txn = connection.BeginTransaction()) |
||
1617 | { |
||
1618 | try |
||
1619 | { |
||
1620 | string where = string.Format("DELETE FROM ARS_COMMON.dbo.PSNRevision WHERE ProjectCode = '{0}' AND PSNDatabasePath = '{1}' AND RevNumber = {2}", ProjectCode, PSNDatabasePath, RevNumber); |
||
1621 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(where), txn); |
||
1622 | var query = $"INSERT INTO ARS_COMMON.dbo.PSNRevision (OID, Project_OID, ProjectCode, RevNumber, UserName, TimeData, PSNDatabasePath, " + |
||
1623 | $"PsnByPBSFilter, PsnByNPDFilter, PidDrawings, PipeSystems, PipeLines, Topologies, PipeSystemNetworks, InValidPSNs, E2E, E2B, B2E, HDE, " + |
||
1624 | 91c75c0b | 이지연 | $"HD2, HDB, B2B, LastModificationdate, ID2_PSN) VALUES (NEWID(), NEWID(), @ProjectCode, @RevNumber, @UserName, @TimeData, @PSNDatabasePath" + |
1625 | 7106e181 | LJIYEON | $", @PsnByPBSFilter, @PsnByNPDFilter, @PidDrawings, @PipeSystems, @PipeLines, @Topologies, @PipeSystemNetworks, @InValidPSNs, " + |
1626 | 91c75c0b | 이지연 | $"@E2E, @E2B, @B2E, @HDE, @HD2, @HDB, @B2B, @LastModificationdate, @ID2_PSN)"; |
1627 | 7106e181 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1628 | d1afd412 | 이지연 | |
1629 | 7106e181 | LJIYEON | AddWithValue(cmd, "@ProjectCode", ProjectCode); |
1630 | AddWithValue(cmd, "@RevNumber", RevNumber); |
||
1631 | AddWithValue(cmd, "@UserName", UserName); |
||
1632 | AddWithValue(cmd, "@TimeData", TimeData); //String.Format("{0:G}", dt) // DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") |
||
1633 | |||
1634 | AddWithValue(cmd, "@PSNDatabasePath", PSNDatabasePath); |
||
1635 | |||
1636 | AddWithValue(cmd, "@PsnByPBSFilter", PsnByPBSFilter); |
||
1637 | AddWithValue(cmd, "@PsnByNPDFilter", PsnByNPDFilter); |
||
1638 | AddWithValue(cmd, "@PidDrawings", PidDrawings); |
||
1639 | AddWithValue(cmd, "@PipeSystems", PipeSystems); |
||
1640 | AddWithValue(cmd, "@PipeLines", PipeLines); |
||
1641 | |||
1642 | AddWithValue(cmd, "@Topologies", Topologies); |
||
1643 | AddWithValue(cmd, "@PipeSystemNetworks", PipeSystemNetworks); |
||
1644 | AddWithValue(cmd, "@InValidPSNs", InValidPSNs); |
||
1645 | AddWithValue(cmd, "@E2E", E2E); |
||
1646 | AddWithValue(cmd, "@E2B", E2B); |
||
1647 | AddWithValue(cmd, "@B2E", B2E); |
||
1648 | AddWithValue(cmd, "@HDE", HDE); |
||
1649 | AddWithValue(cmd, "@HD2", HD2); |
||
1650 | AddWithValue(cmd, "@HDB", HDB); |
||
1651 | AddWithValue(cmd, "@B2B", B2B); |
||
1652 | System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US"); |
||
1653 | DateTime oDateTime = DateTime.Now; |
||
1654 | AddWithValue(cmd, "@LastModificationdate", oDateTime.ToString(ci)); |
||
1655 | 91c75c0b | 이지연 | AddWithValue(cmd, "@ID2_PSN", "Y"); |
1656 | 7106e181 | LJIYEON | connection.ExecuteNonQuery(cmd, txn); |
1657 | |||
1658 | txn.Commit(); |
||
1659 | } |
||
1660 | catch (Exception ex) |
||
1661 | { |
||
1662 | txn.Rollback(); |
||
1663 | result = false; |
||
1664 | } |
||
1665 | } |
||
1666 | } |
||
1667 | catch (Exception ex) |
||
1668 | { |
||
1669 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1670 | result = false; |
||
1671 | } |
||
1672 | } |
||
1673 | |||
1674 | return result; |
||
1675 | } |
||
1676 | |||
1677 | |||
1678 | 1621e1e9 | LJIYEON | public static bool SaveRevision(string ProjectCode, int RevNumber, string UserName, string PSNDatabasePath, string PsnByPBSFilter, string PsnByNPDFilter, |
1679 | int PidDrawings, int PipeSystems, int PipeLines, int Topologies, int PipeSystemNetworks, int InValidPSNs, int E2E, int E2B, int B2E, int HDE, int HD2, int HDB, int B2B) |
||
1680 | { |
||
1681 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1682 | |||
1683 | bool result = true; |
||
1684 | |||
1685 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
1686 | { |
||
1687 | try |
||
1688 | { |
||
1689 | using (var txn = connection.BeginTransaction()) |
||
1690 | { |
||
1691 | try |
||
1692 | d1afd412 | 이지연 | { |
1693 | |||
1694 | 1621e1e9 | LJIYEON | var query = $"INSERT INTO ARS_COMMON.dbo.PSNRevision (OID, Project_OID, ProjectCode, RevNumber, UserName, TimeData, PSNDatabasePath, " + |
1695 | $"PsnByPBSFilter, PsnByNPDFilter, PidDrawings, PipeSystems, PipeLines, Topologies, PipeSystemNetworks, InValidPSNs, E2E, E2B, B2E, HDE, " + |
||
1696 | 91c75c0b | 이지연 | $"HD2, HDB, B2B, LastModificationdate, ID2_PSN) VALUES (NEWID(), NEWID(), @ProjectCode, @RevNumber, @UserName, @TimeData, @PSNDatabasePath" + |
1697 | 1621e1e9 | LJIYEON | $", @PsnByPBSFilter, @PsnByNPDFilter, @PidDrawings, @PipeSystems, @PipeLines, @Topologies, @PipeSystemNetworks, @InValidPSNs, " + |
1698 | 91c75c0b | 이지연 | $"@E2E, @E2B, @B2E, @HDE, @HD2, @HDB, @B2B, @LastModificationdate, @ID2_PSN)"; |
1699 | 1621e1e9 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1700 | AddWithValue(cmd, "@OID", Guid.NewGuid().ToString()); |
||
1701 | AddWithValue(cmd, "@Project_OID", Guid.NewGuid().ToString()); |
||
1702 | AddWithValue(cmd, "@ProjectCode", ProjectCode); |
||
1703 | AddWithValue(cmd, "@RevNumber", RevNumber); |
||
1704 | AddWithValue(cmd, "@UserName", UserName); |
||
1705 | 54b6df95 | LJIYEON | |
1706 | System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US"); |
||
1707 | DateTime oDateTime = DateTime.Now; |
||
1708 | |||
1709 | AddWithValue(cmd, "@TimeData", oDateTime.ToString(ci)); //String.Format("{0:G}", dt) // DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") |
||
1710 | |||
1711 | 1621e1e9 | LJIYEON | AddWithValue(cmd, "@PSNDatabasePath", PSNDatabasePath); |
1712 | |||
1713 | AddWithValue(cmd, "@PsnByPBSFilter", PsnByPBSFilter); |
||
1714 | AddWithValue(cmd, "@PsnByNPDFilter", PsnByNPDFilter); |
||
1715 | AddWithValue(cmd, "@PidDrawings", PidDrawings); |
||
1716 | AddWithValue(cmd, "@PipeSystems", PipeSystems); |
||
1717 | AddWithValue(cmd, "@PipeLines", PipeLines); |
||
1718 | |||
1719 | AddWithValue(cmd, "@Topologies", Topologies); |
||
1720 | AddWithValue(cmd, "@PipeSystemNetworks", PipeSystemNetworks); |
||
1721 | AddWithValue(cmd, "@InValidPSNs", InValidPSNs); |
||
1722 | AddWithValue(cmd, "@E2E", E2E); |
||
1723 | AddWithValue(cmd, "@E2B", E2B); |
||
1724 | AddWithValue(cmd, "@B2E", B2E); |
||
1725 | AddWithValue(cmd, "@HDE", HDE); |
||
1726 | AddWithValue(cmd, "@HD2", HD2); |
||
1727 | AddWithValue(cmd, "@HDB", HDB); |
||
1728 | AddWithValue(cmd, "@B2B", B2B); |
||
1729 | 3b253d62 | gaqhf | // AddWithValue(cmd, "@LastModificationdate", oDateTime.ToString(ci)); |
1730 | AddWithValue(cmd, "@LastModificationdate", ""); |
||
1731 | 91c75c0b | 이지연 | AddWithValue(cmd, "@ID2_PSN", "Y"); |
1732 | d1afd412 | 이지연 | |
1733 | 1621e1e9 | LJIYEON | connection.ExecuteNonQuery(cmd, txn); |
1734 | d1afd412 | 이지연 | |
1735 | 1621e1e9 | LJIYEON | txn.Commit(); |
1736 | } |
||
1737 | catch (Exception ex) |
||
1738 | { |
||
1739 | txn.Rollback(); |
||
1740 | result = false; |
||
1741 | } |
||
1742 | } |
||
1743 | } |
||
1744 | catch (Exception ex) |
||
1745 | { |
||
1746 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
1747 | result = false; |
||
1748 | } |
||
1749 | } |
||
1750 | |||
1751 | return result; |
||
1752 | } |
||
1753 | |||
1754 | 5c248ee3 | gaqhf | public static bool SavePSNData(PSN item) |
1755 | 6b9e7a56 | gaqhf | { |
1756 | ID2Info id2Info = ID2Info.GetInstance(); |
||
1757 | |||
1758 | d1afd412 | 이지연 | bool result = true; |
1759 | 3610fd3f | LJIYEON | |
1760 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
1761 | 6b9e7a56 | gaqhf | { |
1762 | try |
||
1763 | { |
||
1764 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
1765 | 6b9e7a56 | gaqhf | { |
1766 | try |
||
1767 | { |
||
1768 | 23a96301 | humkyung | // Path Items |
1769 | var query = $"DELETE FROM {PSN_PATHITEMS}"; |
||
1770 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1771 | 9c151350 | gaqhf | for (int i = 0; i < item.PathItems.Rows.Count; i++) |
1772 | 6b9e7a56 | gaqhf | { |
1773 | 9c151350 | gaqhf | DataRow row = item.PathItems.Rows[i]; |
1774 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_PATHITEMS} " + |
1775 | $"(OID, SequenceData_OID, TopologySet_OID, BranchTopologySet_OID, PipeLine_OID, ItemName, ItemTag, DESCRIPTION, CLASS, SUBCLASS, TYPE, " + |
||
1776 | bf9e8432 | 이지연 | $"PIDNAME, Equipment_OID, NPD, GROUPTAG, PipeSystemNetwork_OID, PipeRun_OID, ViewPipeSystemNetwork_OID, EqpGroupTag, MainLineTag, EGTConnectedPoint, EGFlowDirection) VALUES " + |
1777 | 811d7949 | LJIYEON | $"(@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @DESCRIPTION, @Class, @SubClass, @TYPE, @PIDNAME, " + |
1778 | bf9e8432 | 이지연 | $"@Equipment_OID, @NPD, @GROUPTAG, @PipeSystemNetwork_OID,@PipeRun_OID, @ViewPipeSystemNetwork_OID, @EqpGroupTag , @MainLineTag, @EGTConnectedPoint, @EGFlowDirection)"; |
1779 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1780 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1781 | AddWithValue(cmd, "@SequenceData_OID", string.IsNullOrEmpty(row["SequenceData_OID"].ToString()) ? "" : row["SequenceData_OID"].ToString()); |
||
1782 | AddWithValue(cmd, "@TopologySet_OID", string.IsNullOrEmpty(row["TopologySet_OID"].ToString()) ? "" : row["TopologySet_OID"].ToString()); |
||
1783 | AddWithValue(cmd, "@BranchTopologySet_OID", string.IsNullOrEmpty(row["BranchTopologySet_OID"].ToString()) ? "" : row["BranchTopologySet_OID"].ToString()); |
||
1784 | AddWithValue(cmd, "@PipeLine_OID", string.IsNullOrEmpty(row["PipeLine_OID"].ToString()) ? "" : row["PipeLine_OID"].ToString()); |
||
1785 | AddWithValue(cmd, "@ITEMNAME", string.IsNullOrEmpty(row["ITEMNAME"].ToString()) ? "" : row["ITEMNAME"].ToString()); |
||
1786 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
1787 | 3610fd3f | LJIYEON | AddWithValue(cmd, "@DESCRIPTION", string.IsNullOrEmpty(row["DESCRIPTION"].ToString()) ? "" : row["DESCRIPTION"].ToString()); |
1788 | f9f2787b | LJIYEON | AddWithValue(cmd, "@Class", string.IsNullOrEmpty(row["Class"].ToString()) ? "" : row["Class"].ToString()); |
1789 | AddWithValue(cmd, "@SubClass", string.IsNullOrEmpty(row["SubClass"].ToString()) ? "" : row["SubClass"].ToString()); |
||
1790 | AddWithValue(cmd, "@TYPE", string.IsNullOrEmpty(row["TYPE"].ToString()) ? "" : row["TYPE"].ToString()); |
||
1791 | AddWithValue(cmd, "@PIDNAME", string.IsNullOrEmpty(row["PIDNAME"].ToString()) ? "" : row["PIDNAME"].ToString()); |
||
1792 | 3610fd3f | LJIYEON | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
1793 | f9f2787b | LJIYEON | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
1794 | 811d7949 | LJIYEON | AddWithValue(cmd, "@GROUPTAG", string.IsNullOrEmpty(row["GROUPTAG"].ToString()) ? "" : row["GROUPTAG"].ToString()); |
1795 | f9f2787b | LJIYEON | AddWithValue(cmd, "@PipeSystemNetwork_OID", string.IsNullOrEmpty(row["PipeSystemNetwork_OID"].ToString()) ? "" : row["PipeSystemNetwork_OID"].ToString()); |
1796 | AddWithValue(cmd, "@ViewPipeSystemNetwork_OID", string.IsNullOrEmpty(row["ViewPipeSystemNetwork_OID"].ToString()) ? "" : row["ViewPipeSystemNetwork_OID"].ToString()); |
||
1797 | AddWithValue(cmd, "@PipeRun_OID", string.IsNullOrEmpty(row["PipeRun_OID"].ToString()) ? "" : row["PipeRun_OID"].ToString()); |
||
1798 | bf9e8432 | 이지연 | AddWithValue(cmd, "@EqpGroupTag", string.IsNullOrEmpty(row["EqpGroupTag"].ToString()) ? "" : row["EqpGroupTag"].ToString()); |
1799 | AddWithValue(cmd, "@MainLineTag", string.IsNullOrEmpty(row["MainLineTag"].ToString()) ? "" : row["MainLineTag"].ToString()); |
||
1800 | |||
1801 | AddWithValue(cmd, "@EGTConnectedPoint", string.IsNullOrEmpty(row["EGTConnectedPoint"].ToString()) ? "0" : row["EGTConnectedPoint"].ToString()); |
||
1802 | AddWithValue(cmd, "@EGFlowDirection", string.IsNullOrEmpty(row["EGFlowDirection"].ToString()) ? "" : row["EGFlowDirection"].ToString()); |
||
1803 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1804 | } |
||
1805 | 6b9e7a56 | gaqhf | |
1806 | 23a96301 | humkyung | // Sequence |
1807 | query = $"DELETE FROM {PSN_SEQUENCEDATA}"; |
||
1808 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1809 | foreach (DataRow row in item.SequenceData.Rows) |
||
1810 | { |
||
1811 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_SEQUENCEDATA} (OID, SERIALNUMBER, PathItem_OID, TopologySet_OID_Key) VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)"; |
1812 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1813 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1814 | AddWithValue(cmd, "@SERIALNUMBER", string.IsNullOrEmpty(row["SERIALNUMBER"].ToString()) ? "" : row["SERIALNUMBER"].ToString()); |
||
1815 | AddWithValue(cmd, "@PathItem_OID", string.IsNullOrEmpty(row["PathItem_OID"].ToString()) ? "" : row["PathItem_OID"].ToString()); |
||
1816 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
1817 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1818 | } |
||
1819 | 5c248ee3 | gaqhf | |
1820 | 23a96301 | humkyung | // Nozzle |
1821 | query = $"DELETE FROM {PSN_NOZZLE}"; |
||
1822 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1823 | foreach (DataRow row in item.Nozzle.Rows) |
||
1824 | { |
||
1825 | 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)"; |
1826 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1827 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1828 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
1829 | |||
1830 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
1831 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
1832 | else |
||
1833 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
1834 | |||
1835 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
1836 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
1837 | else |
||
1838 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
1839 | |||
1840 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
1841 | AddWithValue(cmd, "@FLUID", string.IsNullOrEmpty(row["FLUID"].ToString()) ? "" : row["FLUID"].ToString()); |
||
1842 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
1843 | 33cee849 | LJIYEON | AddWithValue(cmd, "@PMC", string.IsNullOrEmpty(row["PMC"].ToString()) ? "" : row["PMC"].ToString()); |
1844 | f9f2787b | LJIYEON | |
1845 | if (string.IsNullOrEmpty(row["ROTATION"].ToString())) |
||
1846 | AddWithValue(cmd, "@ROTATION", DBNull.Value); |
||
1847 | else |
||
1848 | AddWithValue(cmd, "@ROTATION", row["ROTATION"].ToString()); |
||
1849 | 3610fd3f | LJIYEON | |
1850 | f9f2787b | LJIYEON | AddWithValue(cmd, "@FlowDirection", string.IsNullOrEmpty(row["FlowDirection"].ToString()) ? "" : row["FlowDirection"].ToString()); |
1851 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1852 | } |
||
1853 | 5c248ee3 | gaqhf | |
1854 | 23a96301 | humkyung | //Equipment |
1855 | query = $"DELETE FROM {PSN_EQUIPMENT}"; |
||
1856 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1857 | foreach (DataRow row in item.Equipment.Rows) |
||
1858 | { |
||
1859 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_EQUIPMENT} (OID, ItemTag, Xcoords, Ycoords) VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)"; |
1860 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1861 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1862 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
1863 | |||
1864 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
1865 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
1866 | else |
||
1867 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
1868 | |||
1869 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
1870 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
1871 | else |
||
1872 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
1873 | |||
1874 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1875 | } |
||
1876 | 5c248ee3 | gaqhf | |
1877 | 23a96301 | humkyung | // TopologySet |
1878 | query = $"DELETE FROM {PSN_TOPOLOGYSET}"; |
||
1879 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1880 | foreach (DataRow row in item.TopologySet.Rows) |
||
1881 | { |
||
1882 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_TOPOLOGYSET} (OID, Type, SubType, HeadItemTag, TailItemTag, HeadItemSPID, TailItemSPID) VALUES (@OID, @Type, @SubType, @HeadItemTag, @TailItemTag, @HeadItemSPID, @TailItemSPID)"; |
1883 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1884 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1885 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
1886 | AddWithValue(cmd, "@SubType", string.IsNullOrEmpty(row["SubType"].ToString()) ? "" : row["SubType"].ToString()); |
||
1887 | AddWithValue(cmd, "@HeadItemTag", string.IsNullOrEmpty(row["HeadItemTag"].ToString()) ? "" : row["HeadItemTag"].ToString()); |
||
1888 | AddWithValue(cmd, "@TailItemTag", string.IsNullOrEmpty(row["TailItemTag"].ToString()) ? "" : row["TailItemTag"].ToString()); |
||
1889 | AddWithValue(cmd, "@HeadItemSPID", string.IsNullOrEmpty(row["HeadItemSPID"].ToString()) ? "" : row["HeadItemSPID"].ToString()); |
||
1890 | AddWithValue(cmd, "@TailItemSPID", string.IsNullOrEmpty(row["TailItemSPID"].ToString()) ? "" : row["TailItemSPID"].ToString()); |
||
1891 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1892 | } |
||
1893 | 36a45f13 | gaqhf | |
1894 | 23a96301 | humkyung | // PSN |
1895 | query = $"DELETE FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", item.Revision)}'"; |
||
1896 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1897 | foreach (DataRow row in item.PipeSystemNetwork.Rows) |
||
1898 | { |
||
1899 | eb44d82c | LJIYEON | query = $"INSERT INTO {PSN_PIPESYSTEMNETWORK} " + |
1900 | d1afd412 | 이지연 | $"(OID, Type, OrderNumber, Pipeline_OID, FROM_DATA, TO_DATA, TopologySet_OID_Key, PSNRevisionNumber, PBS, Drawings, IsValid, Status, IncludingVirtualData, PSNAccuracy, Pocket, EGTag, HasMLTags) VALUES " + |
1901 | $"(@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber, @PBS, @Drawings, @IsValid, @Status, @IncludingVirtualData, @PSNAccuracy, @Pocket, @EGTag, @HasMLTags)"; |
||
1902 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
1903 | f9f2787b | LJIYEON | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
1904 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
1905 | AddWithValue(cmd, "@OrderNumber", string.IsNullOrEmpty(row["OrderNumber"].ToString()) ? "" : row["OrderNumber"].ToString()); |
||
1906 | AddWithValue(cmd, "@Pipeline_OID", string.IsNullOrEmpty(row["Pipeline_OID"].ToString()) ? "" : row["Pipeline_OID"].ToString()); |
||
1907 | AddWithValue(cmd, "@FROM_DATA", string.IsNullOrEmpty(row["FROM_DATA"].ToString()) ? "" : row["FROM_DATA"].ToString()); |
||
1908 | AddWithValue(cmd, "@TO_DATA", string.IsNullOrEmpty(row["TO_DATA"].ToString()) ? "" : row["TO_DATA"].ToString()); |
||
1909 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
1910 | AddWithValue(cmd, "@PSNRevisionNumber", string.IsNullOrEmpty(row["PSNRevisionNumber"].ToString()) ? "" : row["PSNRevisionNumber"].ToString()); |
||
1911 | eb44d82c | LJIYEON | |
1912 | 72775f2e | LJIYEON | int IsValid = 0; |
1913 | eb44d82c | LJIYEON | if (row["IsValid"].ToString() == string.Empty || row["IsValid"].ToString() == "OK") |
1914 | 72775f2e | LJIYEON | IsValid = 0; |
1915 | else if (row["IsValid"].ToString() == "InValid") |
||
1916 | IsValid = 1; |
||
1917 | else if (row["IsValid"].ToString() == "Error") |
||
1918 | IsValid = -1; |
||
1919 | f9f2787b | LJIYEON | |
1920 | 72775f2e | LJIYEON | AddWithValue(cmd, "@IsValid", IsValid); |
1921 | f9f2787b | LJIYEON | AddWithValue(cmd, "@Status", string.IsNullOrEmpty(row["Status"].ToString()) ? "" : row["Status"].ToString()); |
1922 | |||
1923 | AddWithValue(cmd, "@PBS", string.IsNullOrEmpty(row["PBS"].ToString()) ? "" : row["PBS"].ToString()); |
||
1924 | AddWithValue(cmd, "@Drawings", string.IsNullOrEmpty(row["Drawings"].ToString()) ? "" : row["Drawings"].ToString()); |
||
1925 | |||
1926 | AddWithValue(cmd, "@IncludingVirtualData", string.IsNullOrEmpty(row["IncludingVirtualData"].ToString()) ? "" : row["IncludingVirtualData"].ToString()); |
||
1927 | if (string.IsNullOrEmpty(row["PSNAccuracy"].ToString())) |
||
1928 | AddWithValue(cmd, "@PSNAccuracy", DBNull.Value); |
||
1929 | else |
||
1930 | d3fbf0c0 | gaqhf | AddWithValue(cmd, "@PSNAccuracy", row["PSNAccuracy"].ToString().Replace("%", "")); |
1931 | eb44d82c | LJIYEON | |
1932 | 08b33e44 | gaqhf | AddWithValue(cmd, "@Pocket", string.IsNullOrEmpty(row["Pocket"].ToString()) ? "Yes" : row["Pocket"].ToString()); |
1933 | |||
1934 | d1afd412 | 이지연 | AddWithValue(cmd, "@EGTag", string.IsNullOrEmpty(row["EGTag"].ToString()) ? "" : row["EGTag"].ToString()); |
1935 | AddWithValue(cmd, "@HasMLTags", string.IsNullOrEmpty(row["HasMLTags"].ToString()) ? "False" : row["HasMLTags"].ToString()); |
||
1936 | 23a96301 | humkyung | connection.ExecuteNonQuery(cmd, txn); |
1937 | 6b9e7a56 | gaqhf | } |
1938 | 23a96301 | humkyung | |
1939 | f9f2787b | LJIYEON | //Pipeline |
1940 | query = $"DELETE FROM {PSN_PIPELINE}"; |
||
1941 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1942 | foreach (DataRow row in item.PipeLine.Rows) |
||
1943 | { |
||
1944 | 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)"; |
1945 | f9f2787b | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
1946 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
1947 | AddWithValue(cmd, "@PipeSystem_OID", row["PipeSystem_OID"].ToString()); |
||
1948 | AddWithValue(cmd, "@FLUID", row["FLUID"].ToString()); |
||
1949 | AddWithValue(cmd, "@PMC", row["PMC"].ToString()); |
||
1950 | AddWithValue(cmd, "@SEQNUMBER", row["SEQNUMBER"].ToString()); |
||
1951 | AddWithValue(cmd, "@INSULATION", row["INSULATION"].ToString()); |
||
1952 | AddWithValue(cmd, "@FROM_DATA", row["FROM_DATA"].ToString()); |
||
1953 | AddWithValue(cmd, "@TO_DATA", row["TO_DATA"].ToString()); |
||
1954 | AddWithValue(cmd, "@Unit", row["Unit"].ToString()); |
||
1955 | connection.ExecuteNonQuery(cmd, txn); |
||
1956 | } |
||
1957 | a36541fb | LJIYEON | |
1958 | 531fb158 | LJIYEON | //PipeSystem |
1959 | query = $"DELETE FROM {PSN_PIPESYSTEM}"; |
||
1960 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1961 | foreach (DataRow row in item.PipeSystem.Rows) |
||
1962 | { |
||
1963 | query = $"INSERT INTO {PSN_PIPESYSTEM} (OID, DESCRIPTION, FLUID, PMC, PipeLineQty, GroundLevel) VALUES (@OID, @DESCRIPTION, @FLUID, @PMC, @PipeLineQty, @GroundLevel)"; |
||
1964 | var cmd = connection.GetSqlStringCommand(query); |
||
1965 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
1966 | AddWithValue(cmd, "@DESCRIPTION", row["DESCRIPTION"].ToString()); |
||
1967 | AddWithValue(cmd, "@FLUID", row["FLUID"].ToString()); |
||
1968 | AddWithValue(cmd, "@PMC", row["PMC"].ToString()); |
||
1969 | AddWithValue(cmd, "@PipeLineQty", row["PipeLineQty"].ToString()); |
||
1970 | AddWithValue(cmd, "@GroundLevel", row["GroundLevel"].ToString()); |
||
1971 | connection.ExecuteNonQuery(cmd, txn); |
||
1972 | } |
||
1973 | |||
1974 | d1afd412 | 이지연 | if (id2Info.ID2DBType == ID2DB_Type.MSSQL) |
1975 | ad39d1ee | LJIYEON | { |
1976 | query = $"If(db_id(N'" + PSN_COMMON + "') IS NULL) CREATE DATABASE [" + PSN_COMMON + "]"; |
||
1977 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
1978 | } |
||
1979 | d1afd412 | 이지연 | |
1980 | 3610fd3f | LJIYEON | |
1981 | 23a96301 | humkyung | txn.Commit(); |
1982 | 6b9e7a56 | gaqhf | } |
1983 | catch (Exception ex) |
||
1984 | { |
||
1985 | 23a96301 | humkyung | txn.Rollback(); |
1986 | 6b9e7a56 | gaqhf | result = false; |
1987 | } |
||
1988 | 1d46fca7 | LJIYEON | |
1989 | } |
||
1990 | void AddColumn(string TableName, Dictionary<string, string> dicCol, List<string> colnames) |
||
1991 | d1afd412 | 이지연 | { |
1992 | 1d46fca7 | LJIYEON | bool check = false; |
1993 | if (colnames != null) |
||
1994 | { |
||
1995 | foreach (KeyValuePair<string, string> col in dicCol) |
||
1996 | { |
||
1997 | check = false; |
||
1998 | foreach (string c in colnames) |
||
1999 | { |
||
2000 | if (col.Key.Contains(c)) |
||
2001 | { |
||
2002 | check = true; |
||
2003 | break; |
||
2004 | } |
||
2005 | } |
||
2006 | |||
2007 | if (!check) //없으면 추가 |
||
2008 | { |
||
2009 | string i = string.Empty; |
||
2010 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
2011 | i = "DEFAULT 0"; |
||
2012 | |||
2013 | var queryalter = $"ALTER TABLE " + TableName + " ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
||
2014 | using (var cmd = connection.GetSqlStringCommand(queryalter)) |
||
2015 | { |
||
2016 | cmd.ExecuteNonQuery(); |
||
2017 | } |
||
2018 | } |
||
2019 | } |
||
2020 | } |
||
2021 | 6b9e7a56 | gaqhf | } |
2022 | } |
||
2023 | catch (Exception ex) |
||
2024 | { |
||
2025 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
2026 | result = false; |
||
2027 | } |
||
2028 | } |
||
2029 | |||
2030 | return result; |
||
2031 | } |
||
2032 | |||
2033 | 5c248ee3 | gaqhf | public static bool SavePSNFluidCode(DataTable dt) |
2034 | 6b9e7a56 | gaqhf | { |
2035 | ID2Info id2Info = ID2Info.GetInstance(); |
||
2036 | |||
2037 | bool result = true; |
||
2038 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2039 | 6b9e7a56 | gaqhf | { |
2040 | 1ae1a1c6 | LJIYEON | try |
2041 | 6b9e7a56 | gaqhf | { |
2042 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
2043 | 1ae1a1c6 | LJIYEON | { |
2044 | try |
||
2045 | 757ab2f2 | LJIYEON | { |
2046 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_FLUIDCODE}"; |
2047 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2048 | |||
2049 | foreach (DataRow row in dt.Rows) |
||
2050 | 757ab2f2 | LJIYEON | { |
2051 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_FLUIDCODE} (UID, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
2052 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
2053 | cmd.Parameters.Clear(); |
||
2054 | |||
2055 | { |
||
2056 | var param = cmd.CreateParameter(); |
||
2057 | param.ParameterName = "@UID"; |
||
2058 | param.Value = row["UID"].ToString(); |
||
2059 | cmd.Parameters.Add(param); |
||
2060 | } |
||
2061 | |||
2062 | { |
||
2063 | var param = cmd.CreateParameter(); |
||
2064 | param.ParameterName = "@Code"; |
||
2065 | param.Value = row["Code"].ToString(); |
||
2066 | cmd.Parameters.Add(param); |
||
2067 | } |
||
2068 | |||
2069 | { |
||
2070 | var param = cmd.CreateParameter(); |
||
2071 | param.ParameterName = "@Description"; |
||
2072 | param.Value = row["Description"].ToString(); |
||
2073 | cmd.Parameters.Add(param); |
||
2074 | } |
||
2075 | |||
2076 | { |
||
2077 | var param = cmd.CreateParameter(); |
||
2078 | param.ParameterName = "@Condition"; |
||
2079 | param.Value = row["Condition"].ToString(); |
||
2080 | cmd.Parameters.Add(param); |
||
2081 | } |
||
2082 | |||
2083 | { |
||
2084 | var param = cmd.CreateParameter(); |
||
2085 | param.ParameterName = "@Remarks"; |
||
2086 | param.Value = row["Remarks"].ToString(); |
||
2087 | cmd.Parameters.Add(param); |
||
2088 | } |
||
2089 | 1ae1a1c6 | LJIYEON | |
2090 | 757ab2f2 | LJIYEON | { |
2091 | 23a96301 | humkyung | var param = cmd.CreateParameter(); |
2092 | param.ParameterName = "@GroundLevel"; |
||
2093 | param.Value = row["GroundLevel"].ToString(); |
||
2094 | cmd.Parameters.Add(param); |
||
2095 | 757ab2f2 | LJIYEON | } |
2096 | 23a96301 | humkyung | |
2097 | connection.ExecuteNonQuery(cmd, txn); |
||
2098 | 757ab2f2 | LJIYEON | } |
2099 | 23a96301 | humkyung | txn.Commit(); |
2100 | 757ab2f2 | LJIYEON | } |
2101 | 1ae1a1c6 | LJIYEON | catch (Exception ex) |
2102 | 6b9e7a56 | gaqhf | { |
2103 | 23a96301 | humkyung | txn.Rollback(); |
2104 | 1ae1a1c6 | LJIYEON | result = false; |
2105 | 6b9e7a56 | gaqhf | } |
2106 | } |
||
2107 | 1ae1a1c6 | LJIYEON | } |
2108 | catch (Exception ex) |
||
2109 | { |
||
2110 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
2111 | result = false; |
||
2112 | } |
||
2113 | 6b9e7a56 | gaqhf | } |
2114 | |||
2115 | return result; |
||
2116 | } |
||
2117 | |||
2118 | 1ae1a1c6 | LJIYEON | public static DataTable SelectPSNFluidCode() |
2119 | 31d37d58 | LJIYEON | { |
2120 | 23a96301 | humkyung | DataTable dt = null; |
2121 | 31d37d58 | LJIYEON | ID2Info id2Info = ID2Info.GetInstance(); |
2122 | 1ae1a1c6 | LJIYEON | |
2123 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2124 | 31d37d58 | LJIYEON | { |
2125 | 1ae1a1c6 | LJIYEON | try |
2126 | 31d37d58 | LJIYEON | { |
2127 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_FLUIDCODE}"; |
2128 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2129 | 31d37d58 | LJIYEON | { |
2130 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
2131 | 31d37d58 | LJIYEON | } |
2132 | } |
||
2133 | 1ae1a1c6 | LJIYEON | catch (Exception ex) |
2134 | { |
||
2135 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2136 | } |
||
2137 | 31d37d58 | LJIYEON | } |
2138 | 23a96301 | humkyung | |
2139 | 1ae1a1c6 | LJIYEON | return dt; |
2140 | } |
||
2141 | |||
2142 | public static bool SavePSNPMC(DataTable dt) |
||
2143 | { |
||
2144 | ID2Info id2Info = ID2Info.GetInstance(); |
||
2145 | |||
2146 | bool result = true; |
||
2147 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2148 | 31d37d58 | LJIYEON | { |
2149 | 1ae1a1c6 | LJIYEON | try |
2150 | { |
||
2151 | 23a96301 | humkyung | using (var txn = connection.BeginTransaction()) |
2152 | 1ae1a1c6 | LJIYEON | { |
2153 | try |
||
2154 | { |
||
2155 | 23a96301 | humkyung | var query = $"DELETE FROM {PSN_PIPINGMATLCLASS}"; |
2156 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2157 | |||
2158 | foreach (DataRow row in dt.Rows) |
||
2159 | 1ae1a1c6 | LJIYEON | { |
2160 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_PIPINGMATLCLASS} ( UID, Priority, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
2161 | 23a96301 | humkyung | var cmd = connection.GetSqlStringCommand(query); |
2162 | cmd.Parameters.Clear(); |
||
2163 | |||
2164 | { |
||
2165 | var param = cmd.CreateParameter(); |
||
2166 | param.ParameterName = "@UID"; |
||
2167 | param.Value = row["UID"].ToString(); |
||
2168 | cmd.Parameters.Add(param); |
||
2169 | } |
||
2170 | |||
2171 | { |
||
2172 | var param = cmd.CreateParameter(); |
||
2173 | param.ParameterName = "@Priority"; |
||
2174 | param.Value = row["Priority"].ToString(); |
||
2175 | cmd.Parameters.Add(param); |
||
2176 | } |
||
2177 | |||
2178 | { |
||
2179 | var param = cmd.CreateParameter(); |
||
2180 | param.ParameterName = "@Code"; |
||
2181 | param.Value = row["Code"].ToString(); |
||
2182 | cmd.Parameters.Add(param); |
||
2183 | } |
||
2184 | |||
2185 | { |
||
2186 | var param = cmd.CreateParameter(); |
||
2187 | param.ParameterName = "@Description"; |
||
2188 | param.Value = row["Description"].ToString(); |
||
2189 | cmd.Parameters.Add(param); |
||
2190 | } |
||
2191 | 31d37d58 | LJIYEON | |
2192 | 1ae1a1c6 | LJIYEON | { |
2193 | 23a96301 | humkyung | var param = cmd.CreateParameter(); |
2194 | param.ParameterName = "@Condition"; |
||
2195 | param.Value = row["Condition"].ToString(); |
||
2196 | cmd.Parameters.Add(param); |
||
2197 | 1ae1a1c6 | LJIYEON | } |
2198 | 23a96301 | humkyung | |
2199 | { |
||
2200 | var param = cmd.CreateParameter(); |
||
2201 | param.ParameterName = "@Remarks"; |
||
2202 | param.Value = row["Remarks"].ToString(); |
||
2203 | cmd.Parameters.Add(param); |
||
2204 | } |
||
2205 | |||
2206 | { |
||
2207 | var param = cmd.CreateParameter(); |
||
2208 | param.ParameterName = "@GroundLevel"; |
||
2209 | param.Value = row["GroundLevel"].ToString(); |
||
2210 | cmd.Parameters.Add(param); |
||
2211 | } |
||
2212 | |||
2213 | connection.ExecuteNonQuery(cmd, txn); |
||
2214 | 1ae1a1c6 | LJIYEON | } |
2215 | 23a96301 | humkyung | |
2216 | txn.Commit(); |
||
2217 | 1ae1a1c6 | LJIYEON | } |
2218 | catch (Exception ex) |
||
2219 | { |
||
2220 | 23a96301 | humkyung | txn.Rollback(); |
2221 | 1ae1a1c6 | LJIYEON | result = false; |
2222 | } |
||
2223 | } |
||
2224 | } |
||
2225 | catch (Exception ex) |
||
2226 | { |
||
2227 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
2228 | result = false; |
||
2229 | } |
||
2230 | } |
||
2231 | 31d37d58 | LJIYEON | |
2232 | 1ae1a1c6 | LJIYEON | return result; |
2233 | 31d37d58 | LJIYEON | } |
2234 | |||
2235 | 33cee849 | LJIYEON | public static bool SavePSNInsulation(DataTable dt) |
2236 | { |
||
2237 | ID2Info id2Info = ID2Info.GetInstance(); |
||
2238 | |||
2239 | bool result = true; |
||
2240 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2241 | 33cee849 | LJIYEON | { |
2242 | try |
||
2243 | { |
||
2244 | using (var txn = connection.BeginTransaction()) |
||
2245 | { |
||
2246 | try |
||
2247 | { |
||
2248 | var query = $"DELETE FROM {PSN_INSULATIONPURPOSE}"; |
||
2249 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
2250 | |||
2251 | foreach (DataRow row in dt.Rows) |
||
2252 | { |
||
2253 | 0ff2a9f1 | LJIYEON | query = $"INSERT INTO {PSN_INSULATIONPURPOSE} (UID, Code, Description, Remarks) VALUES (@UID, @Code, @Description, @Remarks)"; |
2254 | 33cee849 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
2255 | cmd.Parameters.Clear(); |
||
2256 | |||
2257 | { |
||
2258 | var param = cmd.CreateParameter(); |
||
2259 | param.ParameterName = "@UID"; |
||
2260 | param.Value = row["UID"].ToString(); |
||
2261 | cmd.Parameters.Add(param); |
||
2262 | } |
||
2263 | d1afd412 | 이지연 | |
2264 | 33cee849 | LJIYEON | { |
2265 | var param = cmd.CreateParameter(); |
||
2266 | param.ParameterName = "@Code"; |
||
2267 | param.Value = row["Code"].ToString(); |
||
2268 | cmd.Parameters.Add(param); |
||
2269 | } |
||
2270 | |||
2271 | { |
||
2272 | var param = cmd.CreateParameter(); |
||
2273 | param.ParameterName = "@Description"; |
||
2274 | param.Value = row["Description"].ToString(); |
||
2275 | cmd.Parameters.Add(param); |
||
2276 | } |
||
2277 | d1afd412 | 이지연 | |
2278 | 33cee849 | LJIYEON | { |
2279 | var param = cmd.CreateParameter(); |
||
2280 | param.ParameterName = "@Remarks"; |
||
2281 | param.Value = row["Remarks"].ToString(); |
||
2282 | cmd.Parameters.Add(param); |
||
2283 | } |
||
2284 | |||
2285 | connection.ExecuteNonQuery(cmd, txn); |
||
2286 | } |
||
2287 | |||
2288 | txn.Commit(); |
||
2289 | } |
||
2290 | catch (Exception ex) |
||
2291 | { |
||
2292 | txn.Rollback(); |
||
2293 | result = false; |
||
2294 | } |
||
2295 | } |
||
2296 | } |
||
2297 | catch (Exception ex) |
||
2298 | { |
||
2299 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
2300 | result = false; |
||
2301 | } |
||
2302 | } |
||
2303 | |||
2304 | return result; |
||
2305 | } |
||
2306 | 3210f690 | LJIYEON | |
2307 | 5c248ee3 | gaqhf | public static PSN GetDBPSN() |
2308 | 6b9e7a56 | gaqhf | { |
2309 | 5c248ee3 | gaqhf | PSN result = new PSN(); |
2310 | 6b9e7a56 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
2311 | |||
2312 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2313 | 6b9e7a56 | gaqhf | { |
2314 | try |
||
2315 | { |
||
2316 | 3210f690 | LJIYEON | //query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK}"; |
2317 | eb44d82c | LJIYEON | //using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
2318 | //{ |
||
2319 | 3210f690 | LJIYEON | // result.PipeSystemNetwork = ds.Tables[0].Copy(); |
2320 | eb44d82c | LJIYEON | //} |
2321 | |||
2322 | 3210f690 | LJIYEON | var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'"; |
2323 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2324 | { |
||
2325 | result.PipeSystemNetwork = ds.Tables[0].Clone(); |
||
2326 | result.PipeSystemNetwork.Columns["IsValid"].DataType = typeof(string); |
||
2327 | |||
2328 | foreach (DataRow row in ds.Tables[0].Rows) |
||
2329 | { |
||
2330 | DataRow newRow = result.PipeSystemNetwork.NewRow(); |
||
2331 | newRow["OID"] = row["OID"].ToString(); |
||
2332 | newRow["Type"] = row["Type"].ToString(); |
||
2333 | newRow["OrderNumber"] = row["OrderNumber"].ToString(); |
||
2334 | newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString(); |
||
2335 | newRow["FROM_DATA"] = row["FROM_DATA"].ToString(); |
||
2336 | newRow["TO_DATA"] = row["TO_DATA"].ToString(); |
||
2337 | newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString(); |
||
2338 | newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString(); |
||
2339 | |||
2340 | string IsValid = string.Empty; |
||
2341 | |||
2342 | if (Convert.ToInt32(row["IsValid"].ToString()) == 0) |
||
2343 | IsValid = string.Empty;//"OK"; |
||
2344 | else if (Convert.ToInt32(row["IsValid"].ToString()) == 1) |
||
2345 | IsValid = "InValid"; |
||
2346 | else if (Convert.ToInt32(row["IsValid"].ToString()) == -1) |
||
2347 | IsValid = "Error"; |
||
2348 | |||
2349 | newRow["IsValid"] = IsValid; |
||
2350 | |||
2351 | newRow["Status"] = row["Status"].ToString(); |
||
2352 | newRow["PBS"] = row["PBS"].ToString(); |
||
2353 | newRow["Drawings"] = row["Drawings"].ToString(); |
||
2354 | |||
2355 | newRow["IncludingVirtualData"] = row["IncludingVirtualData"].ToString(); |
||
2356 | newRow["PSNAccuracy"] = row["PSNAccuracy"].ToString(); |
||
2357 | |||
2358 | 08b33e44 | gaqhf | newRow["Pocket"] = row["Pocket"].ToString(); |
2359 | d1afd412 | 이지연 | |
2360 | newRow["EGTag"] = row["EGTag"].ToString(); |
||
2361 | newRow["HasMLTags"] = row["HasMLTags"].ToString(); |
||
2362 | 3210f690 | LJIYEON | result.PipeSystemNetwork.Rows.Add(newRow); |
2363 | } |
||
2364 | } |
||
2365 | |||
2366 | query = $"SELECT * FROM {PSN_EQUIPMENT}"; |
||
2367 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
2368 | 6b9e7a56 | gaqhf | { |
2369 | 23a96301 | humkyung | result.Equipment = ds.Tables[0].Copy(); |
2370 | } |
||
2371 | |||
2372 | query = $"SELECT * FROM {PSN_NOZZLE}"; |
||
2373 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2374 | { |
||
2375 | result.Nozzle = ds.Tables[0].Copy(); |
||
2376 | 6b9e7a56 | gaqhf | } |
2377 | 23a96301 | humkyung | |
2378 | query = $"SELECT * FROM {PSN_PATHITEMS}"; |
||
2379 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2380 | { |
||
2381 | result.PathItems = ds.Tables[0].Copy(); |
||
2382 | } |
||
2383 | |||
2384 | query = $"SELECT * FROM {PSN_SEQUENCEDATA}"; |
||
2385 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2386 | { |
||
2387 | result.SequenceData = ds.Tables[0].Copy(); |
||
2388 | } |
||
2389 | |||
2390 | aadd8450 | LJIYEON | query = $"SELECT * FROM {PSN_TOPOLOGYSET}"; |
2391 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2392 | { |
||
2393 | result.TopologySet = ds.Tables[0].Copy(); |
||
2394 | } |
||
2395 | |||
2396 | a36541fb | LJIYEON | query = $"SELECT * FROM {PSN_PIPELINE}"; |
2397 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2398 | { |
||
2399 | result.PipeLine = ds.Tables[0].Copy(); |
||
2400 | 531fb158 | LJIYEON | } |
2401 | |||
2402 | query = $"SELECT * FROM {PSN_PIPESYSTEM}"; |
||
2403 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2404 | { |
||
2405 | result.PipeSystem = ds.Tables[0].Copy(); |
||
2406 | } |
||
2407 | a36541fb | LJIYEON | |
2408 | 23a96301 | humkyung | result.Revision = GetRevision(); |
2409 | 6b9e7a56 | gaqhf | } |
2410 | catch (Exception ex) |
||
2411 | { |
||
2412 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
2413 | 5c248ee3 | gaqhf | result = null; |
2414 | 6b9e7a56 | gaqhf | } |
2415 | } |
||
2416 | 23a96301 | humkyung | |
2417 | 6b9e7a56 | gaqhf | return result; |
2418 | } |
||
2419 | 8f24b438 | gaqhf | |
2420 | public static int GetRevision() |
||
2421 | { |
||
2422 | int result = 0; |
||
2423 | ID2Info id2Info = ID2Info.GetInstance(); |
||
2424 | 23a96301 | humkyung | |
2425 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2426 | 8f24b438 | gaqhf | { |
2427 | try |
||
2428 | { |
||
2429 | 23a96301 | humkyung | var query = $"SELECT DISTINCT PSNRevisionNumber FROM {PSN_PIPESYSTEMNETWORK};"; |
2430 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2431 | 8f24b438 | gaqhf | { |
2432 | 23a96301 | humkyung | foreach (DataRow row in ds.Tables[0].Rows) |
2433 | 8f24b438 | gaqhf | { |
2434 | d5637426 | gaqhf | string value = row["PSNRevisionNumber"].ToString(); |
2435 | 36a45f13 | gaqhf | if (value.StartsWith("V")) |
2436 | d5637426 | gaqhf | value = value.Remove(0, 1); |
2437 | int revisionNumber = Convert.ToInt32(value); |
||
2438 | 8f24b438 | gaqhf | if (result < revisionNumber) |
2439 | result = revisionNumber; |
||
2440 | } |
||
2441 | } |
||
2442 | } |
||
2443 | catch (Exception ex) |
||
2444 | { |
||
2445 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2446 | result = -1; |
||
2447 | } |
||
2448 | } |
||
2449 | |||
2450 | return result; |
||
2451 | } |
||
2452 | |||
2453 | 5c248ee3 | gaqhf | public static DataTable GetPathItem() |
2454 | { |
||
2455 | 23a96301 | humkyung | DataTable dt = null; |
2456 | |||
2457 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
2458 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2459 | 5c248ee3 | gaqhf | { |
2460 | try |
||
2461 | { |
||
2462 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_PATHITEMS}"; |
2463 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2464 | 5c248ee3 | gaqhf | { |
2465 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
2466 | 5c248ee3 | gaqhf | } |
2467 | } |
||
2468 | catch (Exception ex) |
||
2469 | { |
||
2470 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2471 | } |
||
2472 | } |
||
2473 | 23a96301 | humkyung | |
2474 | 5c248ee3 | gaqhf | return dt; |
2475 | } |
||
2476 | 757ab2f2 | LJIYEON | |
2477 | 36a45f13 | gaqhf | public static DataTable GetTopologySet() |
2478 | 5c248ee3 | gaqhf | { |
2479 | 23a96301 | humkyung | DataTable dt = null; |
2480 | |||
2481 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
2482 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2483 | 5c248ee3 | gaqhf | { |
2484 | try |
||
2485 | { |
||
2486 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_TOPOLOGYSET}"; |
2487 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2488 | 5c248ee3 | gaqhf | { |
2489 | aadd8450 | LJIYEON | dt = ds.Tables[0].Clone(); |
2490 | foreach (DataRow row in ds.Tables[0].Rows) |
||
2491 | { |
||
2492 | DataRow newRow = dt.NewRow(); |
||
2493 | newRow["OID"] = row["OID"].ToString(); |
||
2494 | newRow["Type"] = row["Type"].ToString(); |
||
2495 | newRow["SubType"] = row["SubType"].ToString(); |
||
2496 | newRow["HeadItemTag"] = row["HeadItemTag"].ToString(); |
||
2497 | newRow["TailItemTag"] = row["TailItemTag"].ToString(); |
||
2498 | 72775f2e | LJIYEON | newRow["HeadItemSPID"] = row["HeadItemSPID"].ToString(); |
2499 | newRow["TailItemSPID"] = row["TailItemSPID"].ToString(); |
||
2500 | aadd8450 | LJIYEON | dt.Rows.Add(newRow); |
2501 | } |
||
2502 | 5c248ee3 | gaqhf | } |
2503 | } |
||
2504 | catch (Exception ex) |
||
2505 | { |
||
2506 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2507 | } |
||
2508 | } |
||
2509 | 23a96301 | humkyung | |
2510 | 5c248ee3 | gaqhf | return dt; |
2511 | } |
||
2512 | 757ab2f2 | LJIYEON | |
2513 | 5c248ee3 | gaqhf | public static DataTable GetPipeSystemNetwork() |
2514 | { |
||
2515 | 23a96301 | humkyung | DataTable dt = null; |
2516 | |||
2517 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
2518 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2519 | 5c248ee3 | gaqhf | { |
2520 | try |
||
2521 | { |
||
2522 | 811d7949 | LJIYEON | var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}' ORDER BY OID, OrderNumber"; |
2523 | 23a96301 | humkyung | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
2524 | 5c248ee3 | gaqhf | { |
2525 | 45529c16 | LJIYEON | dt = ds.Tables[0].Clone(); |
2526 | 72775f2e | LJIYEON | dt.Columns["IsValid"].DataType = typeof(string); |
2527 | 45529c16 | LJIYEON | foreach (DataRow row in ds.Tables[0].Rows) |
2528 | { |
||
2529 | DataRow newRow = dt.NewRow(); |
||
2530 | newRow["OID"] = row["OID"].ToString(); |
||
2531 | newRow["Type"] = row["Type"].ToString(); |
||
2532 | newRow["OrderNumber"] = row["OrderNumber"].ToString(); |
||
2533 | newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString(); |
||
2534 | newRow["FROM_DATA"] = row["FROM_DATA"].ToString(); |
||
2535 | newRow["TO_DATA"] = row["TO_DATA"].ToString(); |
||
2536 | newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString(); |
||
2537 | newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString(); |
||
2538 | eb44d82c | LJIYEON | |
2539 | 72775f2e | LJIYEON | string IsValid = string.Empty; |
2540 | 45529c16 | LJIYEON | |
2541 | 72775f2e | LJIYEON | if (Convert.ToInt32(row["IsValid"].ToString()) == 0) |
2542 | IsValid = string.Empty;//"OK"; |
||
2543 | else if (Convert.ToInt32(row["IsValid"].ToString()) == 1) |
||
2544 | IsValid = "InValid"; |
||
2545 | else if (Convert.ToInt32(row["IsValid"].ToString()) == -1) |
||
2546 | IsValid = "Error"; |
||
2547 | 45529c16 | LJIYEON | |
2548 | 72775f2e | LJIYEON | newRow["IsValid"] = IsValid; |
2549 | 45529c16 | LJIYEON | newRow["Status"] = row["Status"].ToString(); |
2550 | eb44d82c | LJIYEON | |
2551 | newRow["PBS"] = row["PBS"].ToString(); |
||
2552 | newRow["Drawings"] = row["Drawings"].ToString(); |
||
2553 | d1afd412 | 이지연 | |
2554 | ddc1c369 | LJIYEON | newRow["IncludingVirtualData"] = row["IncludingVirtualData"].ToString(); |
2555 | 08b33e44 | gaqhf | newRow["PSNAccuracy"] = row["PSNAccuracy"].ToString(); |
2556 | |||
2557 | newRow["Pocket"] = row["Pocket"].ToString(); |
||
2558 | d1afd412 | 이지연 | newRow["EGTag"] = row["EGTag"].ToString(); |
2559 | newRow["HasMLTags"] = row["HasMLTags"].ToString(); |
||
2560 | |||
2561 | 45529c16 | LJIYEON | dt.Rows.Add(newRow); |
2562 | } |
||
2563 | 5c248ee3 | gaqhf | } |
2564 | } |
||
2565 | catch (Exception ex) |
||
2566 | { |
||
2567 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2568 | } |
||
2569 | } |
||
2570 | 23a96301 | humkyung | |
2571 | 5c248ee3 | gaqhf | return dt; |
2572 | } |
||
2573 | 757ab2f2 | LJIYEON | |
2574 | 5c248ee3 | gaqhf | public static DataTable GetSequenceData() |
2575 | { |
||
2576 | 23a96301 | humkyung | DataTable dt = null; |
2577 | |||
2578 | 5c248ee3 | gaqhf | ID2Info id2Info = ID2Info.GetInstance(); |
2579 | 0ff2a9f1 | LJIYEON | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
2580 | 5c248ee3 | gaqhf | { |
2581 | try |
||
2582 | { |
||
2583 | 23a96301 | humkyung | var query = $"SELECT * FROM {PSN_SEQUENCEDATA}"; |
2584 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
2585 | 5c248ee3 | gaqhf | { |
2586 | 23a96301 | humkyung | dt = ds.Tables[0].Copy(); |
2587 | 5c248ee3 | gaqhf | } |
2588 | } |
||
2589 | catch (Exception ex) |
||
2590 | { |
||
2591 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
2592 | } |
||
2593 | } |
||
2594 | 23a96301 | humkyung | |
2595 | 5c248ee3 | gaqhf | return dt; |
2596 | } |
||
2597 | 3d842083 | LJIYEON | |
2598 | d1afd412 | 이지연 | |
2599 | 3d842083 | LJIYEON | //Anohter DB |
2600 | public static bool ConnTestAndCreateAnotherTable() |
||
2601 | { |
||
2602 | bool result = false; |
||
2603 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
2604 | |||
2605 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
2606 | { |
||
2607 | try |
||
2608 | { |
||
2609 | var names = connection.GetTableNames(); |
||
2610 | var matched = names.FirstOrDefault(param => param == PSN_HEADER_SETTING); |
||
2611 | Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
||
2612 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
2613 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
2614 | dicColCheck.Add("INDEX", "INTEGER"); |
||
2615 | dicColCheck.Add("NAME", "TEXT"); |
||
2616 | |||
2617 | if (matched == null) |
||
2618 | { |
||
2619 | var query = $"CREATE TABLE {PSN_HEADER_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
||
2620 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2621 | { |
||
2622 | cmd.ExecuteNonQuery(); |
||
2623 | } |
||
2624 | } |
||
2625 | else |
||
2626 | { |
||
2627 | AddColumn(PSN_HEADER_SETTING, dicColCheck); |
||
2628 | } |
||
2629 | |||
2630 | matched = names.FirstOrDefault(param => param == PSN_VENTDRAIN_SETTING); |
||
2631 | dicColCheck.Clear(); |
||
2632 | dicColCheck.Add("GROUP_ID", "TEXT"); |
||
2633 | dicColCheck.Add("DESCRIPTION", "TEXT"); |
||
2634 | dicColCheck.Add("INDEX", "INTEGER"); |
||
2635 | dicColCheck.Add("NAME", "TEXT"); |
||
2636 | if (matched == null) |
||
2637 | { |
||
2638 | var query = $"CREATE TABLE {PSN_VENTDRAIN_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)"; |
||
2639 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2640 | { |
||
2641 | cmd.ExecuteNonQuery(); |
||
2642 | } |
||
2643 | } |
||
2644 | else |
||
2645 | { |
||
2646 | AddColumn(PSN_VENTDRAIN_SETTING, dicColCheck); |
||
2647 | } |
||
2648 | |||
2649 | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGY_RULE); |
||
2650 | dicColCheck.Clear(); |
||
2651 | dicColCheck.Add("UID", "TEXT"); |
||
2652 | if (matched == null) |
||
2653 | { |
||
2654 | var query = $"CREATE TABLE {PSN_TOPOLOGY_RULE} (UID TEXT)"; |
||
2655 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2656 | { |
||
2657 | cmd.ExecuteNonQuery(); |
||
2658 | } |
||
2659 | |||
2660 | DataTable topologyRule = new DataTable(); |
||
2661 | topologyRule.Columns.Add("NAME", typeof(string)); |
||
2662 | |||
2663 | topologyRule.Rows.Add("FluidCode"); |
||
2664 | topologyRule.Rows.Add("-"); |
||
2665 | topologyRule.Rows.Add("PipingMaterialsClass"); |
||
2666 | topologyRule.Rows.Add("-"); |
||
2667 | topologyRule.Rows.Add("Tag Seq No"); |
||
2668 | |||
2669 | SaveTopologyRule(topologyRule); |
||
2670 | } |
||
2671 | //else |
||
2672 | //{ |
||
2673 | // AddColumn(PSN_TOPOLOGY_RULE, dicColCheck); |
||
2674 | //} |
||
2675 | |||
2676 | matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEMNETWORK); |
||
2677 | dicColCheck.Clear(); |
||
2678 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2679 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
2680 | dicColCheck.Add("OrderNumber", "NVARCHAR(255)"); |
||
2681 | dicColCheck.Add("Pipeline_OID", "NVARCHAR(255)"); |
||
2682 | dicColCheck.Add("From_Data", "NVARCHAR(255)"); |
||
2683 | dicColCheck.Add("To_Data", "NVARCHAR(255)"); |
||
2684 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(125)"); |
||
2685 | dicColCheck.Add("PSNRevisionNumber", "NVARCHAR(255)"); |
||
2686 | dicColCheck.Add("IsValid", "INT"); |
||
2687 | dicColCheck.Add("Status", "NVARCHAR(255)"); |
||
2688 | dicColCheck.Add("PBS", "NVARCHAR(255)"); |
||
2689 | dicColCheck.Add("Drawings", "NVARCHAR(255)"); |
||
2690 | dicColCheck.Add("IncludingVirtualData", "NVARCHAR(10)"); |
||
2691 | dicColCheck.Add("PSNAccuracy", "REAL"); |
||
2692 | 08b33e44 | gaqhf | dicColCheck.Add("Pocket", "NVARCHAR(10)"); |
2693 | d1afd412 | 이지연 | dicColCheck.Add("EGTag", "NVARCHAR(255)"); |
2694 | dicColCheck.Add("HasMLTags", "NVARCHAR(50)"); |
||
2695 | |||
2696 | 3d842083 | LJIYEON | if (matched == null) |
2697 | { |
||
2698 | var query = $"CREATE TABLE {PSN_PIPESYSTEMNETWORK} (OID NVARCHAR(255), Type NVARCHAR(255), OrderNumber NVARCHAR(255), Pipeline_OID NVARCHAR(255), From_Data NVARCHAR(255), " + |
||
2699 | "To_Data NVARCHAR(255), TopologySet_OID_Key NVARCHAR(125), PSNRevisionNumber NVARCHAR(255), IsValid INTEGER, Status NVARCHAR(255), PBS NVARCHAR(255), Drawings NVARCHAR(255), " + |
||
2700 | d1afd412 | 이지연 | "IncludingVirtualData NVARCHAR(10), PSNAccuracy REAL, Pocket NVARCHAR(10), EGTag NVARCHAR(255), HasMLTags NVARCHAR(50))"; |
2701 | 3d842083 | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
2702 | { |
||
2703 | cmd.ExecuteNonQuery(); |
||
2704 | } |
||
2705 | } |
||
2706 | else |
||
2707 | { |
||
2708 | AddColumn(PSN_PIPESYSTEMNETWORK, dicColCheck); |
||
2709 | } |
||
2710 | |||
2711 | matched = names.FirstOrDefault(param => param == PSN_EQUIPMENT); |
||
2712 | dicColCheck.Clear(); |
||
2713 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2714 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
2715 | dicColCheck.Add("Xcoords", "REAL"); |
||
2716 | dicColCheck.Add("Ycoords", "REAL"); |
||
2717 | if (matched == null) |
||
2718 | { |
||
2719 | var query = $"CREATE TABLE {PSN_EQUIPMENT} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL)"; |
||
2720 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2721 | { |
||
2722 | cmd.ExecuteNonQuery(); |
||
2723 | } |
||
2724 | } |
||
2725 | else |
||
2726 | { |
||
2727 | AddColumn(PSN_EQUIPMENT, dicColCheck); |
||
2728 | } |
||
2729 | |||
2730 | dicColCheck.Clear(); |
||
2731 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2732 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
2733 | dicColCheck.Add("Xcoords", "REAL"); |
||
2734 | dicColCheck.Add("Ycoords", "REAL"); |
||
2735 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
2736 | dicColCheck.Add("Fluid", "NVARCHAR(255)"); |
||
2737 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
2738 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
2739 | dicColCheck.Add("Rotation", "REAL"); |
||
2740 | dicColCheck.Add("FlowDirection", "NVARCHAR(255)"); |
||
2741 | |||
2742 | matched = names.FirstOrDefault(param => param == PSN_NOZZLE); |
||
2743 | if (matched == null) |
||
2744 | { |
||
2745 | var query = $"CREATE TABLE {PSN_NOZZLE} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL, Equipment_OID NVARCHAR(255), " + |
||
2746 | "Fluid NVARCHAR(255), NPD NVARCHAR(255), PMC NVARCHAR(255), Rotation REAL, FlowDirection NVARCHAR(255))"; |
||
2747 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2748 | { |
||
2749 | cmd.ExecuteNonQuery(); |
||
2750 | } |
||
2751 | } |
||
2752 | else |
||
2753 | { |
||
2754 | AddColumn(PSN_NOZZLE, dicColCheck); |
||
2755 | } |
||
2756 | |||
2757 | matched = names.FirstOrDefault(param => param == PSN_FLUIDCODE); |
||
2758 | dicColCheck.Clear(); |
||
2759 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
2760 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
2761 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
2762 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
2763 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
2764 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
2765 | if (matched == null) |
||
2766 | { |
||
2767 | var query = $"CREATE TABLE {PSN_FLUIDCODE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Condition NVARCHAR(255), Remarks NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
||
2768 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2769 | { |
||
2770 | cmd.ExecuteNonQuery(); |
||
2771 | } |
||
2772 | } |
||
2773 | else |
||
2774 | { |
||
2775 | AddColumn(PSN_FLUIDCODE, dicColCheck); |
||
2776 | } |
||
2777 | |||
2778 | matched = names.FirstOrDefault(param => param == PSN_PIPINGMATLCLASS); |
||
2779 | dicColCheck.Clear(); |
||
2780 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
2781 | dicColCheck.Add("Priority", "INTEGER"); |
||
2782 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
2783 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
2784 | dicColCheck.Add("Condition", "NVARCHAR(255)"); |
||
2785 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
2786 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
2787 | if (matched == null) |
||
2788 | { |
||
2789 | 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))"; |
||
2790 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2791 | { |
||
2792 | cmd.ExecuteNonQuery(); |
||
2793 | } |
||
2794 | } |
||
2795 | else |
||
2796 | { |
||
2797 | AddColumn(PSN_PIPINGMATLCLASS, dicColCheck); |
||
2798 | } |
||
2799 | |||
2800 | matched = names.FirstOrDefault(param => param == PSN_SEQUENCEDATA); |
||
2801 | dicColCheck.Clear(); |
||
2802 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2803 | dicColCheck.Add("SERIALNUMBER", "NVARCHAR(255)"); |
||
2804 | dicColCheck.Add("PathItem_OID", "NVARCHAR(255)"); |
||
2805 | dicColCheck.Add("TopologySet_OID_Key", "NVARCHAR(255)"); |
||
2806 | if (matched == null) |
||
2807 | { |
||
2808 | var query = $"CREATE TABLE {PSN_SEQUENCEDATA} (OID NVARCHAR(255), SERIALNUMBER NVARCHAR(255), PathItem_OID NVARCHAR(255), TopologySet_OID_Key NVARCHAR(255))"; |
||
2809 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2810 | { |
||
2811 | cmd.ExecuteNonQuery(); |
||
2812 | } |
||
2813 | } |
||
2814 | else |
||
2815 | { |
||
2816 | AddColumn(PSN_SEQUENCEDATA, dicColCheck); |
||
2817 | } |
||
2818 | |||
2819 | matched = names.FirstOrDefault(param => param == PSN_PATHITEMS); |
||
2820 | dicColCheck.Clear(); |
||
2821 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2822 | dicColCheck.Add("SequenceData_OID", "NVARCHAR(255)"); |
||
2823 | dicColCheck.Add("TopologySet_OID", "NVARCHAR(255)"); |
||
2824 | dicColCheck.Add("BranchTopologySet_OID", "NVARCHAR(255)"); |
||
2825 | dicColCheck.Add("PipeLine_OID", "NVARCHAR(255)"); |
||
2826 | dicColCheck.Add("ItemName", "NVARCHAR(255)"); |
||
2827 | dicColCheck.Add("ItemTag", "NVARCHAR(255)"); |
||
2828 | dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)"); |
||
2829 | dicColCheck.Add("CLASS", "NVARCHAR(255)"); |
||
2830 | dicColCheck.Add("SUBCLASS", "NVARCHAR(255)"); |
||
2831 | dicColCheck.Add("TYPE", "NVARCHAR(255)"); |
||
2832 | dicColCheck.Add("PIDNAME", "NVARCHAR(255)"); |
||
2833 | dicColCheck.Add("Equipment_OID", "NVARCHAR(255)"); |
||
2834 | dicColCheck.Add("NPD", "NVARCHAR(255)"); |
||
2835 | 811d7949 | LJIYEON | dicColCheck.Add("GROUPTAG", "NVARCHAR(255)"); |
2836 | 3d842083 | LJIYEON | dicColCheck.Add("PipeSystemNetwork_OID", "NVARCHAR(255)"); |
2837 | dicColCheck.Add("PipeRun_OID", "NVARCHAR(255)"); |
||
2838 | dicColCheck.Add("ViewPipeSystemNetwork_OID", "NVARCHAR(255)"); |
||
2839 | bf9e8432 | 이지연 | dicColCheck.Add("EqpGroupTag", "NVARCHAR(255)"); |
2840 | dicColCheck.Add("MainLineTag", "NVARCHAR(255)"); |
||
2841 | dicColCheck.Add("EGTConnectedPoint", "INT"); |
||
2842 | dicColCheck.Add("EGFlowDirection", "NVARCHAR(10)"); |
||
2843 | 3d842083 | LJIYEON | if (matched == null) |
2844 | { |
||
2845 | var query = $"CREATE TABLE {PSN_PATHITEMS} (OID NVARCHAR(255), SequenceData_OID NVARCHAR(255), " + |
||
2846 | "TopologySet_OID NVARCHAR(255), BranchTopologySet_OID NVARCHAR(255), PipeLine_OID NVARCHAR(255), ItemName NVARCHAR(255), ItemTag NVARCHAR(255), DESCRIPTION NVARCHAR(255), " + |
||
2847 | 811d7949 | LJIYEON | "CLASS NVARCHAR(255), SUBCLASS NVARCHAR(255), TYPE NVARCHAR(255), PIDNAME NVARCHAR(255), Equipment_OID NVARCHAR(255), NPD NVARCHAR(255), GROUPTAG NVARCHAR(255), PipeSystemNetwork_OID NVARCHAR(255), PipeRun_OID NVARCHAR(255), " + |
2848 | bf9e8432 | 이지연 | "ViewPipeSystemNetwork_OID NVARCHAR(255), EqpGroupTag NVARCHAR(255), MainLineTag NVARCHAR(255), EGTConnectedPoint INT, EGFlowDirection NVARCHAR(10))"; |
2849 | 3d842083 | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
2850 | { |
||
2851 | cmd.ExecuteNonQuery(); |
||
2852 | } |
||
2853 | } |
||
2854 | else |
||
2855 | { |
||
2856 | AddColumn(PSN_PATHITEMS, dicColCheck); |
||
2857 | } |
||
2858 | |||
2859 | matched = names.FirstOrDefault(param => param == PSN_VIEW); |
||
2860 | dicColCheck.Clear(); |
||
2861 | dicColCheck.Add("OID", "TEXT"); |
||
2862 | if (matched == null) |
||
2863 | { |
||
2864 | var query = $"CREATE TABLE {PSN_VIEW} (OID TEXT)"; |
||
2865 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2866 | { |
||
2867 | cmd.ExecuteNonQuery(); |
||
2868 | } |
||
2869 | } |
||
2870 | |||
2871 | matched = names.FirstOrDefault(param => param == PSN_TOPOLOGYSET); |
||
2872 | dicColCheck.Clear(); |
||
2873 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2874 | dicColCheck.Add("Type", "NVARCHAR(255)"); |
||
2875 | dicColCheck.Add("SubType", "NVARCHAR(255)"); |
||
2876 | dicColCheck.Add("HeadItemTag", "NVARCHAR(255)"); |
||
2877 | dicColCheck.Add("TailItemTag", "NVARCHAR(255)"); |
||
2878 | dicColCheck.Add("HeadItemSPID", "NVARCHAR(255)"); |
||
2879 | dicColCheck.Add("TailItemSPID", "NVARCHAR(255)"); |
||
2880 | |||
2881 | if (matched == null) |
||
2882 | { |
||
2883 | 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))"; |
||
2884 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2885 | { |
||
2886 | cmd.ExecuteNonQuery(); |
||
2887 | } |
||
2888 | } |
||
2889 | else |
||
2890 | { |
||
2891 | AddColumn(PSN_TOPOLOGYSET, dicColCheck); |
||
2892 | } |
||
2893 | |||
2894 | matched = names.FirstOrDefault(param => param == PSN_TRANSFORMKEYWORD_SETTING); |
||
2895 | dicColCheck.Clear(); |
||
2896 | b56d3ccb | LJIYEON | dicColCheck.Add("INDEX", "INTEGER"); |
2897 | dicColCheck.Add("NAME", "TEXT"); |
||
2898 | dicColCheck.Add("KEYWORD", "TEXT"); |
||
2899 | 3d842083 | LJIYEON | if (matched == null) |
2900 | { |
||
2901 | var query = $"CREATE TABLE {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX] INTEGER, [NAME] TEXT, [KEYWORD] TEXT)"; |
||
2902 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2903 | { |
||
2904 | cmd.ExecuteNonQuery(); |
||
2905 | } |
||
2906 | } |
||
2907 | else |
||
2908 | { |
||
2909 | AddColumn(PSN_TRANSFORMKEYWORD_SETTING, dicColCheck); |
||
2910 | } |
||
2911 | |||
2912 | matched = names.FirstOrDefault(param => param == PSN_PIPELINE); |
||
2913 | dicColCheck.Clear(); |
||
2914 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2915 | dicColCheck.Add("PipeSystem_OID", "NVARCHAR(255)"); |
||
2916 | dicColCheck.Add("FLUID", "NVARCHAR(255)"); |
||
2917 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
2918 | dicColCheck.Add("SEQNUMBER", "NVARCHAR(255)"); |
||
2919 | dicColCheck.Add("INSULATION", "NVARCHAR(255)"); |
||
2920 | dicColCheck.Add("FROM_DATA", "NVARCHAR(255)"); |
||
2921 | dicColCheck.Add("TO_DATA", "NVARCHAR(255)"); |
||
2922 | dicColCheck.Add("Unit", "NVARCHAR(100)"); |
||
2923 | if (matched == null) |
||
2924 | { |
||
2925 | 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), " + |
||
2926 | $"FROM_DATA NVARCHAR(255), TO_DATA NVARCHAR(255), Unit NVARCHAR(100))"; |
||
2927 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2928 | { |
||
2929 | cmd.ExecuteNonQuery(); |
||
2930 | } |
||
2931 | } |
||
2932 | else |
||
2933 | { |
||
2934 | AddColumn(PSN_PIPELINE, dicColCheck); |
||
2935 | } |
||
2936 | |||
2937 | matched = names.FirstOrDefault(param => param == PSN_INSULATIONPURPOSE); |
||
2938 | dicColCheck.Clear(); |
||
2939 | dicColCheck.Add("UID", "NVARCHAR(50)"); |
||
2940 | dicColCheck.Add("Code", "NVARCHAR(255)"); |
||
2941 | dicColCheck.Add("Description", "NVARCHAR(255)"); |
||
2942 | dicColCheck.Add("Remarks", "NVARCHAR(255)"); |
||
2943 | if (matched == null) |
||
2944 | { |
||
2945 | var query = $"CREATE TABLE {PSN_INSULATIONPURPOSE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Remarks NVARCHAR(255))"; |
||
2946 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2947 | { |
||
2948 | cmd.ExecuteNonQuery(); |
||
2949 | } |
||
2950 | } |
||
2951 | else |
||
2952 | { |
||
2953 | AddColumn(PSN_INSULATIONPURPOSE, dicColCheck); |
||
2954 | } |
||
2955 | |||
2956 | 811d7949 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_VALVEGROUP_SETTING); |
2957 | dicColCheck.Clear(); |
||
2958 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2959 | dicColCheck.Add("GroupType", "NVARCHAR(255)"); |
||
2960 | dicColCheck.Add("TagIdentifier", "NVARCHAR(50)"); |
||
2961 | dicColCheck.Add("AttributeName", "NVARCHAR(255)"); |
||
2962 | dicColCheck.Add("SppidSymbolName", "NVARCHAR(255)"); |
||
2963 | if (matched == null) |
||
2964 | { |
||
2965 | var query = $"CREATE TABLE {PSN_VALVEGROUP_SETTING} (OID NVARCHAR(50), GroupType NVARCHAR(255), TagIdentifier NVARCHAR(50), AttributeName NVARCHAR(255), SppidSymbolName NVARCHAR(255))"; |
||
2966 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2967 | { |
||
2968 | cmd.ExecuteNonQuery(); |
||
2969 | } |
||
2970 | } |
||
2971 | else |
||
2972 | { |
||
2973 | AddColumn(PSN_VALVEGROUP_SETTING, dicColCheck); |
||
2974 | } |
||
2975 | |||
2976 | 531fb158 | LJIYEON | matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEM); |
2977 | dicColCheck.Clear(); |
||
2978 | dicColCheck.Add("OID", "NVARCHAR(255)"); |
||
2979 | dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)"); |
||
2980 | dicColCheck.Add("FLUID", "NVARCHAR(255)"); |
||
2981 | dicColCheck.Add("PMC", "NVARCHAR(255)"); |
||
2982 | dicColCheck.Add("PipeLineQty", "NVARCHAR(255)"); |
||
2983 | dicColCheck.Add("GroundLevel", "NVARCHAR(20)"); |
||
2984 | if (matched == null) |
||
2985 | { |
||
2986 | var query = $"CREATE TABLE {PSN_PIPESYSTEM} (OID NVARCHAR(255), DESCRIPTION NVARCHAR(255), FLUID NVARCHAR(255), PMC NVARCHAR(255), PipeLineQty NVARCHAR(255), GroundLevel NVARCHAR(20))"; |
||
2987 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
2988 | { |
||
2989 | cmd.ExecuteNonQuery(); |
||
2990 | } |
||
2991 | } |
||
2992 | else |
||
2993 | { |
||
2994 | AddColumn(PSN_PIPESYSTEM, dicColCheck); |
||
2995 | } |
||
2996 | |||
2997 | 88c1965b | gaqhf | matched = names.FirstOrDefault(param => param == PSN_NOPOCKETSETTING); |
2998 | dicColCheck.Clear(); |
||
2999 | 284fa2c9 | 이지연 | dicColCheck.Add("INDEX", "INTEGER"); |
3000 | dicColCheck.Add("TYPE", "TEXT"); |
||
3001 | dicColCheck.Add("NAME", "TEXT"); |
||
3002 | 88c1965b | gaqhf | if (matched == null) |
3003 | { |
||
3004 | var query = $"CREATE TABLE {PSN_NOPOCKETSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [NAME] TEXT)"; |
||
3005 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
3006 | { |
||
3007 | cmd.ExecuteNonQuery(); |
||
3008 | } |
||
3009 | } |
||
3010 | else |
||
3011 | { |
||
3012 | AddColumn(PSN_NOPOCKETSETTING, dicColCheck); |
||
3013 | } |
||
3014 | 54b6df95 | LJIYEON | |
3015 | f2a63376 | 이지연 | matched = names.FirstOrDefault(param => param == PSN_AIRFINCOOLERSETTING); |
3016 | dicColCheck.Clear(); |
||
3017 | 284fa2c9 | 이지연 | dicColCheck.Add("INDEX", "INTEGER"); |
3018 | dicColCheck.Add("TYPE", "TEXT"); |
||
3019 | dicColCheck.Add("TagIdentifier", "NVARCHAR(50)"); |
||
3020 | dicColCheck.Add("AttributeName", "NVARCHAR(255)"); |
||
3021 | dicColCheck.Add("NAME", "TEXT"); |
||
3022 | |||
3023 | f2a63376 | 이지연 | if (matched == null) |
3024 | { |
||
3025 | 284fa2c9 | 이지연 | var query = $"CREATE TABLE {PSN_AIRFINCOOLERSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [TagIdentifier] TEXT, [AttributeName] TEXT, [NAME] TEXT)"; |
3026 | |||
3027 | f2a63376 | 이지연 | using (var cmd = connection.GetSqlStringCommand(query)) |
3028 | { |
||
3029 | cmd.ExecuteNonQuery(); |
||
3030 | } |
||
3031 | } |
||
3032 | else |
||
3033 | { |
||
3034 | AddColumn(PSN_AIRFINCOOLERSETTING, dicColCheck); |
||
3035 | } |
||
3036 | d1afd412 | 이지연 | |
3037 | f2a63376 | 이지연 | |
3038 | 54b6df95 | LJIYEON | var query2 = $"If(db_id(N'" + PSN_COMMON + "') IS NULL) CREATE DATABASE [" + PSN_COMMON + "]"; |
3039 | if (id2Info.ID2DBType == AnotherID2DB_Type.MSSQL) |
||
3040 | { |
||
3041 | //connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3042 | using (var cmd = connection.GetSqlStringCommand(query2)) |
||
3043 | { |
||
3044 | cmd.ExecuteNonQuery(); |
||
3045 | } |
||
3046 | } |
||
3047 | |||
3048 | 3d842083 | LJIYEON | void AddColumn(string TableName, Dictionary<string, string> dicCol) |
3049 | { |
||
3050 | var colnames = connection.GetColumnNames(TableName); |
||
3051 | bool check = false; |
||
3052 | if (colnames != null) |
||
3053 | { |
||
3054 | foreach (KeyValuePair<string, string> col in dicCol) |
||
3055 | { |
||
3056 | check = false; |
||
3057 | foreach (string c in colnames) |
||
3058 | { |
||
3059 | 7ad289b2 | LJIYEON | if (col.Key.ToUpper().Equals(c.ToUpper())) |
3060 | 3d842083 | LJIYEON | { |
3061 | check = true; |
||
3062 | break; |
||
3063 | } |
||
3064 | } |
||
3065 | |||
3066 | if (!check) //없으면 추가 |
||
3067 | { |
||
3068 | string i = string.Empty; |
||
3069 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
3070 | i = "DEFAULT 0"; |
||
3071 | |||
3072 | var query = $"ALTER TABLE " + TableName + " ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
||
3073 | using (var cmd = connection.GetSqlStringCommand(query)) |
||
3074 | { |
||
3075 | cmd.ExecuteNonQuery(); |
||
3076 | } |
||
3077 | } |
||
3078 | } |
||
3079 | } |
||
3080 | } |
||
3081 | |||
3082 | result = true; |
||
3083 | } |
||
3084 | catch (Exception ex) |
||
3085 | { |
||
3086 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
3087 | } |
||
3088 | } |
||
3089 | |||
3090 | return result; |
||
3091 | } |
||
3092 | |||
3093 | 54b6df95 | LJIYEON | public static bool SaveAnotherRevision(string ProjectCode, int RevNumber, string UserName, string PSNDatabasePath, string PsnByPBSFilter, string PsnByNPDFilter, |
3094 | int PidDrawings, int PipeSystems, int PipeLines, int Topologies, int PipeSystemNetworks, int InValidPSNs, int E2E, int E2B, int B2E, int HDE, int HD2, int HDB, int B2B) |
||
3095 | { |
||
3096 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
3097 | |||
3098 | bool result = true; |
||
3099 | |||
3100 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
3101 | { |
||
3102 | try |
||
3103 | { |
||
3104 | using (var txn = connection.BeginTransaction()) |
||
3105 | { |
||
3106 | try |
||
3107 | { |
||
3108 | |||
3109 | var query = $"INSERT INTO ARS_COMMON.dbo.PSNRevision (OID, Project_OID, ProjectCode, RevNumber, UserName, TimeData, PSNDatabasePath, " + |
||
3110 | $"PsnByPBSFilter, PsnByNPDFilter, PidDrawings, PipeSystems, PipeLines, Topologies, PipeSystemNetworks, InValidPSNs, E2E, E2B, B2E, HDE, " + |
||
3111 | 91c75c0b | 이지연 | $"HD2, HDB, B2B, LastModificationdate, ID2_PSN) VALUES (NEWID(), NEWID(), @ProjectCode, @RevNumber, @UserName, @TimeData, @PSNDatabasePath" + |
3112 | 54b6df95 | LJIYEON | $", @PsnByPBSFilter, @PsnByNPDFilter, @PidDrawings, @PipeSystems, @PipeLines, @Topologies, @PipeSystemNetworks, @InValidPSNs, " + |
3113 | 91c75c0b | 이지연 | $"@E2E, @E2B, @B2E, @HDE, @HD2, @HDB, @B2B, @LastModificationdate, @ID2_PSN)"; |
3114 | 54b6df95 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
3115 | AddWithValue(cmd, "@OID", Guid.NewGuid().ToString()); |
||
3116 | AddWithValue(cmd, "@Project_OID", Guid.NewGuid().ToString()); |
||
3117 | AddWithValue(cmd, "@ProjectCode", ProjectCode); |
||
3118 | AddWithValue(cmd, "@RevNumber", RevNumber); |
||
3119 | AddWithValue(cmd, "@UserName", UserName); |
||
3120 | |||
3121 | System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US"); |
||
3122 | d1afd412 | 이지연 | DateTime oDateTime = DateTime.Now; |
3123 | 54b6df95 | LJIYEON | |
3124 | AddWithValue(cmd, "@TimeData", oDateTime.ToString(ci)); //String.Format("{0:G}", dt) // DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") |
||
3125 | d1afd412 | 이지연 | |
3126 | 54b6df95 | LJIYEON | AddWithValue(cmd, "@PSNDatabasePath", PSNDatabasePath); |
3127 | |||
3128 | AddWithValue(cmd, "@PsnByPBSFilter", PsnByPBSFilter); |
||
3129 | AddWithValue(cmd, "@PsnByNPDFilter", PsnByNPDFilter); |
||
3130 | AddWithValue(cmd, "@PidDrawings", PidDrawings); |
||
3131 | AddWithValue(cmd, "@PipeSystems", PipeSystems); |
||
3132 | AddWithValue(cmd, "@PipeLines", PipeLines); |
||
3133 | |||
3134 | AddWithValue(cmd, "@Topologies", Topologies); |
||
3135 | AddWithValue(cmd, "@PipeSystemNetworks", PipeSystemNetworks); |
||
3136 | AddWithValue(cmd, "@InValidPSNs", InValidPSNs); |
||
3137 | AddWithValue(cmd, "@E2E", E2E); |
||
3138 | AddWithValue(cmd, "@E2B", E2B); |
||
3139 | AddWithValue(cmd, "@B2E", B2E); |
||
3140 | AddWithValue(cmd, "@HDE", HDE); |
||
3141 | AddWithValue(cmd, "@HD2", HD2); |
||
3142 | AddWithValue(cmd, "@HDB", HDB); |
||
3143 | AddWithValue(cmd, "@B2B", B2B); |
||
3144 | 7106e181 | LJIYEON | |
3145 | AddWithValue(cmd, "@LastModificationdate", oDateTime.ToString(ci)); |
||
3146 | 91c75c0b | 이지연 | AddWithValue(cmd, "@ID2_PSN", "Y"); |
3147 | d1afd412 | 이지연 | |
3148 | 54b6df95 | LJIYEON | connection.ExecuteNonQuery(cmd, txn); |
3149 | |||
3150 | txn.Commit(); |
||
3151 | } |
||
3152 | catch (Exception ex) |
||
3153 | { |
||
3154 | txn.Rollback(); |
||
3155 | result = false; |
||
3156 | } |
||
3157 | } |
||
3158 | } |
||
3159 | catch (Exception ex) |
||
3160 | { |
||
3161 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
3162 | result = false; |
||
3163 | } |
||
3164 | } |
||
3165 | |||
3166 | return result; |
||
3167 | } |
||
3168 | |||
3169 | public static bool ConnAnotherCreateRevisionTable(Dictionary<string, string> dicColCheck, List<string> names) |
||
3170 | { |
||
3171 | bool result = false; |
||
3172 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
3173 | |||
3174 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
3175 | { |
||
3176 | try |
||
3177 | { |
||
3178 | if (names.Count == 0) |
||
3179 | { |
||
3180 | |||
3181 | var query = $"CREATE TABLE ARS_COMMON.dbo.PSNRevision ([OID] [uniqueidentifier] ,[Project_OID] [uniqueidentifier] ," + |
||
3182 | $"[ProjectCode] nvarchar(255), [RevNumber] int ,[UserName] nvarchar(255) ,[TimeData] nvarchar(255) ," + |
||
3183 | $"[PSNDatabasePath] nvarchar(255) , [PsnByPBSFilter] varchar(20) ,[PsnByNPDFilter] varchar(20) ,[PidDrawings] int , " + |
||
3184 | $"[PipeSystems] int ,[PipeLines] int ,[Topologies] int ,[PipeSystemNetworks] int ,[InValidPSNs] int ,[E2E] int ," + |
||
3185 | 91c75c0b | 이지연 | $"[E2B] int ,[B2E] int ,[HDE] int ,[HD2] int ,[HDB] int ,[B2B] int , [LastModificationdate] nvarchar(255), [ID2_PSN] nvarchar(10))"; |
3186 | 54b6df95 | LJIYEON | using (var cmd = connection.GetSqlStringCommand(query)) |
3187 | { |
||
3188 | cmd.ExecuteNonQuery(); |
||
3189 | } |
||
3190 | } |
||
3191 | else |
||
3192 | { |
||
3193 | AddColumn(PSN_REVISION, dicColCheck, names); |
||
3194 | } |
||
3195 | |||
3196 | void AddColumn(string TableName, Dictionary<string, string> dicCol, List<string> colnames) |
||
3197 | { |
||
3198 | bool check = false; |
||
3199 | if (colnames != null) |
||
3200 | { |
||
3201 | foreach (KeyValuePair<string, string> col in dicCol) |
||
3202 | { |
||
3203 | check = false; |
||
3204 | foreach (string c in colnames) |
||
3205 | { |
||
3206 | if (col.Key.Contains(c)) |
||
3207 | { |
||
3208 | check = true; |
||
3209 | break; |
||
3210 | } |
||
3211 | } |
||
3212 | |||
3213 | if (!check) //없으면 추가 |
||
3214 | { |
||
3215 | string i = string.Empty; |
||
3216 | if (col.Value.ToString().ToUpper().Contains("INT") || col.Value.ToString().ToUpper().Contains("REAL")) |
||
3217 | i = "DEFAULT 0"; |
||
3218 | |||
3219 | var queryalter = $"ALTER TABLE ARS_COMMON.dbo.PSNRevision ADD [" + col.Key + "] " + col.Value + " " + i + ";"; |
||
3220 | using (var cmd = connection.GetSqlStringCommand(queryalter)) |
||
3221 | { |
||
3222 | cmd.ExecuteNonQuery(); |
||
3223 | } |
||
3224 | } |
||
3225 | } |
||
3226 | } |
||
3227 | } |
||
3228 | |||
3229 | result = true; |
||
3230 | } |
||
3231 | catch (Exception ex) |
||
3232 | { |
||
3233 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
3234 | } |
||
3235 | } |
||
3236 | |||
3237 | return result; |
||
3238 | } |
||
3239 | |||
3240 | 7106e181 | LJIYEON | public static DataTable SelectAnotherRevision() |
3241 | { |
||
3242 | DataTable dt = null; |
||
3243 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
3244 | |||
3245 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
3246 | { |
||
3247 | try |
||
3248 | { |
||
3249 | var query = $"SELECT * FROM ARS_COMMON.dbo.PSNREVISION"; |
||
3250 | |||
3251 | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
||
3252 | { |
||
3253 | dt = ds.Tables[0].Copy(); |
||
3254 | } |
||
3255 | } |
||
3256 | catch (Exception ex) |
||
3257 | { |
||
3258 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
3259 | } |
||
3260 | } |
||
3261 | |||
3262 | return dt; |
||
3263 | } |
||
3264 | |||
3265 | 54b6df95 | LJIYEON | public static DataTable SelectAnotherRevisionTable() |
3266 | { |
||
3267 | DataTable dt = null; |
||
3268 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
3269 | |||
3270 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
3271 | { |
||
3272 | try |
||
3273 | { |
||
3274 | 7106e181 | LJIYEON | var query = $"SELECT T.name AS table_name, C.name AS column_name FROM ARS_COMMON.sys.tables AS T INNER JOIN ARS_COMMON.sys.columns AS C ON T.object_id = C.object_id WHERE T.name = 'PSNREVISION'"; |
3275 | 54b6df95 | LJIYEON | using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query))) |
3276 | { |
||
3277 | dt = ds.Tables[0].Copy(); |
||
3278 | } |
||
3279 | } |
||
3280 | catch (Exception ex) |
||
3281 | { |
||
3282 | Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
||
3283 | } |
||
3284 | } |
||
3285 | |||
3286 | return dt; |
||
3287 | } |
||
3288 | |||
3289 | 3d842083 | LJIYEON | public static bool SaveAnotherPSNData(PSN item, List<HeaderInfo> headerInfos, List<VentDrainInfo> ventDrainInfos, |
3290 | 284fa2c9 | 이지연 | List<KeywordItem> keywordItems, DataTable dtTopologyRule, DataTable dtFluidCode, DataTable dtPMC, DataTable dtInsulation, DataTable dtvalvegrouping, DataTable dtnopocket, DataTable dtafc) |
3291 | 3d842083 | LJIYEON | { |
3292 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
3293 | |||
3294 | bool result = true; |
||
3295 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
3296 | { |
||
3297 | try |
||
3298 | { |
||
3299 | using (var txn = connection.BeginTransaction()) |
||
3300 | { |
||
3301 | try |
||
3302 | { |
||
3303 | // Path Items |
||
3304 | var query = $"DELETE FROM {PSN_PATHITEMS}"; |
||
3305 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3306 | for (int i = 0; i < item.PathItems.Rows.Count; i++) |
||
3307 | { |
||
3308 | DataRow row = item.PathItems.Rows[i]; |
||
3309 | query = $"INSERT INTO {PSN_PATHITEMS} " + |
||
3310 | $"(OID, SequenceData_OID, TopologySet_OID, BranchTopologySet_OID, PipeLine_OID, ItemName, ItemTag, DESCRIPTION, CLASS, SUBCLASS, TYPE, " + |
||
3311 | bf9e8432 | 이지연 | $"PIDNAME, Equipment_OID, NPD, GROUPTAG, PipeSystemNetwork_OID, PipeRun_OID, ViewPipeSystemNetwork_OID, EqpGroupTag , MainLineTag, EGTConnectedPoint, EGFlowDirection ) VALUES " + |
3312 | 811d7949 | LJIYEON | $"(@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @DESCRIPTION, @Class, @SubClass, @TYPE, @PIDNAME," + |
3313 | bf9e8432 | 이지연 | $" @Equipment_OID, @NPD, @GROUPTAG, @PipeSystemNetwork_OID,@PipeRun_OID, @ViewPipeSystemNetwork_OID, @EqpGroupTag , @MainLineTag, @EGTConnectedPoint, @EGFlowDirection )"; |
3314 | 3d842083 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
3315 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
3316 | AddWithValue(cmd, "@SequenceData_OID", string.IsNullOrEmpty(row["SequenceData_OID"].ToString()) ? "" : row["SequenceData_OID"].ToString()); |
||
3317 | AddWithValue(cmd, "@TopologySet_OID", string.IsNullOrEmpty(row["TopologySet_OID"].ToString()) ? "" : row["TopologySet_OID"].ToString()); |
||
3318 | AddWithValue(cmd, "@BranchTopologySet_OID", string.IsNullOrEmpty(row["BranchTopologySet_OID"].ToString()) ? "" : row["BranchTopologySet_OID"].ToString()); |
||
3319 | AddWithValue(cmd, "@PipeLine_OID", string.IsNullOrEmpty(row["PipeLine_OID"].ToString()) ? "" : row["PipeLine_OID"].ToString()); |
||
3320 | AddWithValue(cmd, "@ITEMNAME", string.IsNullOrEmpty(row["ITEMNAME"].ToString()) ? "" : row["ITEMNAME"].ToString()); |
||
3321 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
3322 | AddWithValue(cmd, "@DESCRIPTION", string.IsNullOrEmpty(row["DESCRIPTION"].ToString()) ? "" : row["DESCRIPTION"].ToString()); |
||
3323 | AddWithValue(cmd, "@Class", string.IsNullOrEmpty(row["Class"].ToString()) ? "" : row["Class"].ToString()); |
||
3324 | AddWithValue(cmd, "@SubClass", string.IsNullOrEmpty(row["SubClass"].ToString()) ? "" : row["SubClass"].ToString()); |
||
3325 | AddWithValue(cmd, "@TYPE", string.IsNullOrEmpty(row["TYPE"].ToString()) ? "" : row["TYPE"].ToString()); |
||
3326 | AddWithValue(cmd, "@PIDNAME", string.IsNullOrEmpty(row["PIDNAME"].ToString()) ? "" : row["PIDNAME"].ToString()); |
||
3327 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
3328 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
3329 | 811d7949 | LJIYEON | AddWithValue(cmd, "@GROUPTAG", string.IsNullOrEmpty(row["GROUPTAG"].ToString()) ? "" : row["GROUPTAG"].ToString()); |
3330 | 3d842083 | LJIYEON | AddWithValue(cmd, "@PipeSystemNetwork_OID", string.IsNullOrEmpty(row["PipeSystemNetwork_OID"].ToString()) ? "" : row["PipeSystemNetwork_OID"].ToString()); |
3331 | AddWithValue(cmd, "@ViewPipeSystemNetwork_OID", string.IsNullOrEmpty(row["ViewPipeSystemNetwork_OID"].ToString()) ? "" : row["ViewPipeSystemNetwork_OID"].ToString()); |
||
3332 | AddWithValue(cmd, "@PipeRun_OID", string.IsNullOrEmpty(row["PipeRun_OID"].ToString()) ? "" : row["PipeRun_OID"].ToString()); |
||
3333 | bf9e8432 | 이지연 | AddWithValue(cmd, "@EqpGroupTag", string.IsNullOrEmpty(row["EqpGroupTag"].ToString()) ? "" : row["EqpGroupTag"].ToString()); |
3334 | AddWithValue(cmd, "@MainLineTag", string.IsNullOrEmpty(row["MainLineTag"].ToString()) ? "" : row["MainLineTag"].ToString()); |
||
3335 | AddWithValue(cmd, "@EGTConnectedPoint", string.IsNullOrEmpty(row["EGTConnectedPoint"].ToString()) ? "0" : row["EGTConnectedPoint"].ToString()); |
||
3336 | AddWithValue(cmd, "@EGFlowDirection", string.IsNullOrEmpty(row["EGFlowDirection"].ToString()) ? "" : row["EGFlowDirection"].ToString()); |
||
3337 | |||
3338 | 3d842083 | LJIYEON | connection.ExecuteNonQuery(cmd, txn); |
3339 | } |
||
3340 | |||
3341 | // Sequence |
||
3342 | query = $"DELETE FROM {PSN_SEQUENCEDATA}"; |
||
3343 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3344 | foreach (DataRow row in item.SequenceData.Rows) |
||
3345 | { |
||
3346 | query = $"INSERT INTO {PSN_SEQUENCEDATA} (OID, SERIALNUMBER, PathItem_OID, TopologySet_OID_Key) VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)"; |
||
3347 | var cmd = connection.GetSqlStringCommand(query); |
||
3348 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
3349 | AddWithValue(cmd, "@SERIALNUMBER", string.IsNullOrEmpty(row["SERIALNUMBER"].ToString()) ? "" : row["SERIALNUMBER"].ToString()); |
||
3350 | AddWithValue(cmd, "@PathItem_OID", string.IsNullOrEmpty(row["PathItem_OID"].ToString()) ? "" : row["PathItem_OID"].ToString()); |
||
3351 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
3352 | connection.ExecuteNonQuery(cmd, txn); |
||
3353 | } |
||
3354 | |||
3355 | // Nozzle |
||
3356 | query = $"DELETE FROM {PSN_NOZZLE}"; |
||
3357 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3358 | foreach (DataRow row in item.Nozzle.Rows) |
||
3359 | { |
||
3360 | 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)"; |
||
3361 | var cmd = connection.GetSqlStringCommand(query); |
||
3362 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
3363 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
3364 | |||
3365 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
3366 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
3367 | else |
||
3368 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
3369 | |||
3370 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
3371 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
3372 | else |
||
3373 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
3374 | |||
3375 | AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); |
||
3376 | AddWithValue(cmd, "@FLUID", string.IsNullOrEmpty(row["FLUID"].ToString()) ? "" : row["FLUID"].ToString()); |
||
3377 | AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString()); |
||
3378 | AddWithValue(cmd, "@PMC", string.IsNullOrEmpty(row["PMC"].ToString()) ? "" : row["PMC"].ToString()); |
||
3379 | |||
3380 | if (string.IsNullOrEmpty(row["ROTATION"].ToString())) |
||
3381 | AddWithValue(cmd, "@ROTATION", DBNull.Value); |
||
3382 | else |
||
3383 | AddWithValue(cmd, "@ROTATION", row["ROTATION"].ToString()); |
||
3384 | |||
3385 | AddWithValue(cmd, "@FlowDirection", string.IsNullOrEmpty(row["FlowDirection"].ToString()) ? "" : row["FlowDirection"].ToString()); |
||
3386 | connection.ExecuteNonQuery(cmd, txn); |
||
3387 | } |
||
3388 | |||
3389 | //Equipment |
||
3390 | query = $"DELETE FROM {PSN_EQUIPMENT}"; |
||
3391 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3392 | foreach (DataRow row in item.Equipment.Rows) |
||
3393 | { |
||
3394 | query = $"INSERT INTO {PSN_EQUIPMENT} (OID, ItemTag, Xcoords, Ycoords) VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)"; |
||
3395 | var cmd = connection.GetSqlStringCommand(query); |
||
3396 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
3397 | AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString()); |
||
3398 | |||
3399 | if (string.IsNullOrEmpty(row["XCOORDS"].ToString())) |
||
3400 | AddWithValue(cmd, "@XCOORDS", DBNull.Value); |
||
3401 | else |
||
3402 | AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString()); |
||
3403 | |||
3404 | if (string.IsNullOrEmpty(row["YCOORDS"].ToString())) |
||
3405 | AddWithValue(cmd, "@YCOORDS", DBNull.Value); |
||
3406 | else |
||
3407 | AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString()); |
||
3408 | |||
3409 | connection.ExecuteNonQuery(cmd, txn); |
||
3410 | } |
||
3411 | |||
3412 | // TopologySet |
||
3413 | query = $"DELETE FROM {PSN_TOPOLOGYSET}"; |
||
3414 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3415 | foreach (DataRow row in item.TopologySet.Rows) |
||
3416 | { |
||
3417 | query = $"INSERT INTO {PSN_TOPOLOGYSET} (OID, Type, SubType, HeadItemTag, TailItemTag, HeadItemSPID, TailItemSPID) VALUES (@OID, @Type, @SubType, @HeadItemTag, @TailItemTag, @HeadItemSPID, @TailItemSPID)"; |
||
3418 | var cmd = connection.GetSqlStringCommand(query); |
||
3419 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
3420 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
3421 | AddWithValue(cmd, "@SubType", string.IsNullOrEmpty(row["SubType"].ToString()) ? "" : row["SubType"].ToString()); |
||
3422 | AddWithValue(cmd, "@HeadItemTag", string.IsNullOrEmpty(row["HeadItemTag"].ToString()) ? "" : row["HeadItemTag"].ToString()); |
||
3423 | AddWithValue(cmd, "@TailItemTag", string.IsNullOrEmpty(row["TailItemTag"].ToString()) ? "" : row["TailItemTag"].ToString()); |
||
3424 | AddWithValue(cmd, "@HeadItemSPID", string.IsNullOrEmpty(row["HeadItemSPID"].ToString()) ? "" : row["HeadItemSPID"].ToString()); |
||
3425 | AddWithValue(cmd, "@TailItemSPID", string.IsNullOrEmpty(row["TailItemSPID"].ToString()) ? "" : row["TailItemSPID"].ToString()); |
||
3426 | connection.ExecuteNonQuery(cmd, txn); |
||
3427 | } |
||
3428 | |||
3429 | // PSN |
||
3430 | query = $"DELETE FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", item.Revision)}'"; |
||
3431 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3432 | foreach (DataRow row in item.PipeSystemNetwork.Rows) |
||
3433 | { |
||
3434 | query = $"INSERT INTO {PSN_PIPESYSTEMNETWORK} " + |
||
3435 | d1afd412 | 이지연 | $"(OID, Type, OrderNumber, Pipeline_OID, FROM_DATA, TO_DATA, TopologySet_OID_Key, PSNRevisionNumber, PBS, Drawings, IsValid, Status, IncludingVirtualData, PSNAccuracy, Pocket, EGTag, HasMLTags) VALUES " + |
3436 | $"(@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber, @PBS, @Drawings, @IsValid, @Status, @IncludingVirtualData, @PSNAccuracy, @Pocket, @EGTag, @HasMLTags)"; |
||
3437 | 3d842083 | LJIYEON | var cmd = connection.GetSqlStringCommand(query); |
3438 | AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString()); |
||
3439 | AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString()); |
||
3440 | AddWithValue(cmd, "@OrderNumber", string.IsNullOrEmpty(row["OrderNumber"].ToString()) ? "" : row["OrderNumber"].ToString()); |
||
3441 | AddWithValue(cmd, "@Pipeline_OID", string.IsNullOrEmpty(row["Pipeline_OID"].ToString()) ? "" : row["Pipeline_OID"].ToString()); |
||
3442 | AddWithValue(cmd, "@FROM_DATA", string.IsNullOrEmpty(row["FROM_DATA"].ToString()) ? "" : row["FROM_DATA"].ToString()); |
||
3443 | AddWithValue(cmd, "@TO_DATA", string.IsNullOrEmpty(row["TO_DATA"].ToString()) ? "" : row["TO_DATA"].ToString()); |
||
3444 | AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString()); |
||
3445 | AddWithValue(cmd, "@PSNRevisionNumber", string.IsNullOrEmpty(row["PSNRevisionNumber"].ToString()) ? "" : row["PSNRevisionNumber"].ToString()); |
||
3446 | |||
3447 | int IsValid = 0; |
||
3448 | if (row["IsValid"].ToString() == string.Empty || row["IsValid"].ToString() == "OK") |
||
3449 | IsValid = 0; |
||
3450 | else if (row["IsValid"].ToString() == "InValid") |
||
3451 | IsValid = 1; |
||
3452 | else if (row["IsValid"].ToString() == "Error") |
||
3453 | IsValid = -1; |
||
3454 | |||
3455 | AddWithValue(cmd, "@IsValid", IsValid); |
||
3456 | AddWithValue(cmd, "@Status", string.IsNullOrEmpty(row["Status"].ToString()) ? "" : row["Status"].ToString()); |
||
3457 | |||
3458 | AddWithValue(cmd, "@PBS", string.IsNullOrEmpty(row["PBS"].ToString()) ? "" : row["PBS"].ToString()); |
||
3459 | AddWithValue(cmd, "@Drawings", string.IsNullOrEmpty(row["Drawings"].ToString()) ? "" : row["Drawings"].ToString()); |
||
3460 | |||
3461 | AddWithValue(cmd, "@IncludingVirtualData", string.IsNullOrEmpty(row["IncludingVirtualData"].ToString()) ? "" : row["IncludingVirtualData"].ToString()); |
||
3462 | if (string.IsNullOrEmpty(row["PSNAccuracy"].ToString())) |
||
3463 | AddWithValue(cmd, "@PSNAccuracy", DBNull.Value); |
||
3464 | else |
||
3465 | d3fbf0c0 | gaqhf | AddWithValue(cmd, "@PSNAccuracy", row["PSNAccuracy"].ToString().Replace("%", "")); |
3466 | 3d842083 | LJIYEON | |
3467 | 08b33e44 | gaqhf | AddWithValue(cmd, "@Pocket", string.IsNullOrEmpty(row["Pocket"].ToString()) ? "Yes" : row["Pocket"].ToString()); |
3468 | d1afd412 | 이지연 | AddWithValue(cmd, "@EGTag", string.IsNullOrEmpty(row["EGTag"].ToString()) ? "" : row["EGTag"].ToString()); |
3469 | AddWithValue(cmd, "@HasMLTags", string.IsNullOrEmpty(row["HasMLTags"].ToString()) ? "False" : row["HasMLTags"].ToString()); |
||
3470 | |||
3471 | 3d842083 | LJIYEON | connection.ExecuteNonQuery(cmd, txn); |
3472 | } |
||
3473 | |||
3474 | //Pipeline |
||
3475 | query = $"DELETE FROM {PSN_PIPELINE}"; |
||
3476 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3477 | foreach (DataRow row in item.PipeLine.Rows) |
||
3478 | { |
||
3479 | 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)"; |
||
3480 | var cmd = connection.GetSqlStringCommand(query); |
||
3481 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
3482 | AddWithValue(cmd, "@PipeSystem_OID", row["PipeSystem_OID"].ToString()); |
||
3483 | AddWithValue(cmd, "@FLUID", row["FLUID"].ToString()); |
||
3484 | AddWithValue(cmd, "@PMC", row["PMC"].ToString()); |
||
3485 | AddWithValue(cmd, "@SEQNUMBER", row["SEQNUMBER"].ToString()); |
||
3486 | AddWithValue(cmd, "@INSULATION", row["INSULATION"].ToString()); |
||
3487 | AddWithValue(cmd, "@FROM_DATA", row["FROM_DATA"].ToString()); |
||
3488 | AddWithValue(cmd, "@TO_DATA", row["TO_DATA"].ToString()); |
||
3489 | AddWithValue(cmd, "@Unit", row["Unit"].ToString()); |
||
3490 | connection.ExecuteNonQuery(cmd, txn); |
||
3491 | } |
||
3492 | |||
3493 | 531fb158 | LJIYEON | //PipeSystem |
3494 | query = $"DELETE FROM {PSN_PIPESYSTEM}"; |
||
3495 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3496 | foreach (DataRow row in item.PipeSystem.Rows) |
||
3497 | { |
||
3498 | query = $"INSERT INTO {PSN_PIPESYSTEM} (OID, DESCRIPTION, FLUID, PMC, PipeLineQty, GroundLevel) VALUES (@OID, @DESCRIPTION, @FLUID, @PMC, @PipeLineQty, @GroundLevel)"; |
||
3499 | var cmd = connection.GetSqlStringCommand(query); |
||
3500 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
3501 | AddWithValue(cmd, "@DESCRIPTION", row["DESCRIPTION"].ToString()); |
||
3502 | AddWithValue(cmd, "@FLUID", row["FLUID"].ToString()); |
||
3503 | AddWithValue(cmd, "@PMC", row["PMC"].ToString()); |
||
3504 | AddWithValue(cmd, "@PipeLineQty", row["PipeLineQty"].ToString()); |
||
3505 | AddWithValue(cmd, "@GroundLevel", row["GroundLevel"].ToString()); |
||
3506 | connection.ExecuteNonQuery(cmd, txn); |
||
3507 | } |
||
3508 | |||
3509 | 3d842083 | LJIYEON | //Header Setting |
3510 | query = $"DELETE FROM {PSN_HEADER_SETTING}"; |
||
3511 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3512 | |||
3513 | foreach (HeaderInfo headerInfo in headerInfos) |
||
3514 | { |
||
3515 | foreach (HeaderItem itemheader in headerInfo.HeaderItems) |
||
3516 | { |
||
3517 | query = $"INSERT INTO {PSN_HEADER_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
||
3518 | var cmd = connection.GetSqlStringCommand(query); |
||
3519 | AddWithValue(cmd, "@GROUP_ID", headerInfo.UID); |
||
3520 | AddWithValue(cmd, "@DESCRIPTION", headerInfo.Description); |
||
3521 | AddWithValue(cmd, "@INDEX", itemheader.Index); |
||
3522 | AddWithValue(cmd, "@NAME", itemheader.Name); |
||
3523 | connection.ExecuteNonQuery(cmd, txn); |
||
3524 | } |
||
3525 | } |
||
3526 | |||
3527 | //Vent/Drain Setting |
||
3528 | query = $"DELETE FROM {PSN_VENTDRAIN_SETTING}"; |
||
3529 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3530 | |||
3531 | foreach (VentDrainInfo ventDrainInfo in ventDrainInfos) |
||
3532 | { |
||
3533 | foreach (VentDrainItem itemventdrain in ventDrainInfo.VentDrainItems) |
||
3534 | { |
||
3535 | query = $"INSERT INTO {PSN_VENTDRAIN_SETTING} (GROUP_ID, DESCRIPTION, [INDEX], NAME) VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)"; |
||
3536 | var cmd = connection.GetSqlStringCommand(query); |
||
3537 | AddWithValue(cmd, "@GROUP_ID", ventDrainInfo.UID); |
||
3538 | AddWithValue(cmd, "@DESCRIPTION", ventDrainInfo.Description); |
||
3539 | AddWithValue(cmd, "@INDEX", itemventdrain.Index); |
||
3540 | AddWithValue(cmd, "@NAME", itemventdrain.Name); |
||
3541 | connection.ExecuteNonQuery(cmd, txn); |
||
3542 | } |
||
3543 | } |
||
3544 | |||
3545 | //Keyword Setting |
||
3546 | query = $"DELETE FROM {PSN_TRANSFORMKEYWORD_SETTING}"; |
||
3547 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3548 | |||
3549 | foreach (KeywordItem itemKeyword in keywordItems) |
||
3550 | { |
||
3551 | query = $"INSERT INTO {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX], NAME, KEYWORD) VALUES (@INDEX, @NAME, @KEYWORD)"; |
||
3552 | var cmd = connection.GetSqlStringCommand(query); |
||
3553 | AddWithValue(cmd, "@INDEX", itemKeyword.Index); |
||
3554 | AddWithValue(cmd, "@NAME", itemKeyword.Name); |
||
3555 | AddWithValue(cmd, "@KEYWORD", itemKeyword.Keyword); |
||
3556 | connection.ExecuteNonQuery(cmd, txn); |
||
3557 | } |
||
3558 | |||
3559 | //FulidCode |
||
3560 | query = $"DELETE FROM {PSN_FLUIDCODE}"; |
||
3561 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3562 | |||
3563 | foreach (DataRow row in dtFluidCode.Rows) |
||
3564 | { |
||
3565 | query = $"INSERT INTO {PSN_FLUIDCODE} (UID, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
||
3566 | var cmd = connection.GetSqlStringCommand(query); |
||
3567 | cmd.Parameters.Clear(); |
||
3568 | |||
3569 | { |
||
3570 | var param = cmd.CreateParameter(); |
||
3571 | param.ParameterName = "@UID"; |
||
3572 | param.Value = row["UID"].ToString(); |
||
3573 | cmd.Parameters.Add(param); |
||
3574 | } |
||
3575 | |||
3576 | { |
||
3577 | var param = cmd.CreateParameter(); |
||
3578 | param.ParameterName = "@Code"; |
||
3579 | param.Value = row["Code"].ToString(); |
||
3580 | cmd.Parameters.Add(param); |
||
3581 | } |
||
3582 | |||
3583 | { |
||
3584 | var param = cmd.CreateParameter(); |
||
3585 | param.ParameterName = "@Description"; |
||
3586 | param.Value = row["Description"].ToString(); |
||
3587 | cmd.Parameters.Add(param); |
||
3588 | } |
||
3589 | |||
3590 | { |
||
3591 | var param = cmd.CreateParameter(); |
||
3592 | param.ParameterName = "@Condition"; |
||
3593 | param.Value = row["Condition"].ToString(); |
||
3594 | cmd.Parameters.Add(param); |
||
3595 | } |
||
3596 | |||
3597 | { |
||
3598 | var param = cmd.CreateParameter(); |
||
3599 | param.ParameterName = "@Remarks"; |
||
3600 | param.Value = row["Remarks"].ToString(); |
||
3601 | cmd.Parameters.Add(param); |
||
3602 | } |
||
3603 | |||
3604 | { |
||
3605 | var param = cmd.CreateParameter(); |
||
3606 | param.ParameterName = "@GroundLevel"; |
||
3607 | param.Value = row["GroundLevel"].ToString(); |
||
3608 | cmd.Parameters.Add(param); |
||
3609 | } |
||
3610 | |||
3611 | connection.ExecuteNonQuery(cmd, txn); |
||
3612 | } |
||
3613 | |||
3614 | //PMC |
||
3615 | query = $"DELETE FROM {PSN_PIPINGMATLCLASS}"; |
||
3616 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3617 | |||
3618 | foreach (DataRow row in dtPMC.Rows) |
||
3619 | { |
||
3620 | query = $"INSERT INTO {PSN_PIPINGMATLCLASS} ( UID, Priority, Code, Description, Condition, Remarks, GroundLevel) VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)"; |
||
3621 | var cmd = connection.GetSqlStringCommand(query); |
||
3622 | cmd.Parameters.Clear(); |
||
3623 | |||
3624 | { |
||
3625 | var param = cmd.CreateParameter(); |
||
3626 | param.ParameterName = "@UID"; |
||
3627 | param.Value = row["UID"].ToString(); |
||
3628 | cmd.Parameters.Add(param); |
||
3629 | } |
||
3630 | |||
3631 | { |
||
3632 | var param = cmd.CreateParameter(); |
||
3633 | param.ParameterName = "@Priority"; |
||
3634 | param.Value = row["Priority"].ToString(); |
||
3635 | cmd.Parameters.Add(param); |
||
3636 | } |
||
3637 | |||
3638 | { |
||
3639 | var param = cmd.CreateParameter(); |
||
3640 | param.ParameterName = "@Code"; |
||
3641 | param.Value = row["Code"].ToString(); |
||
3642 | cmd.Parameters.Add(param); |
||
3643 | } |
||
3644 | |||
3645 | { |
||
3646 | var param = cmd.CreateParameter(); |
||
3647 | param.ParameterName = "@Description"; |
||
3648 | param.Value = row["Description"].ToString(); |
||
3649 | cmd.Parameters.Add(param); |
||
3650 | } |
||
3651 | |||
3652 | { |
||
3653 | var param = cmd.CreateParameter(); |
||
3654 | param.ParameterName = "@Condition"; |
||
3655 | param.Value = row["Condition"].ToString(); |
||
3656 | cmd.Parameters.Add(param); |
||
3657 | } |
||
3658 | |||
3659 | { |
||
3660 | var param = cmd.CreateParameter(); |
||
3661 | param.ParameterName = "@Remarks"; |
||
3662 | param.Value = row["Remarks"].ToString(); |
||
3663 | cmd.Parameters.Add(param); |
||
3664 | } |
||
3665 | |||
3666 | { |
||
3667 | var param = cmd.CreateParameter(); |
||
3668 | param.ParameterName = "@GroundLevel"; |
||
3669 | param.Value = row["GroundLevel"].ToString(); |
||
3670 | cmd.Parameters.Add(param); |
||
3671 | } |
||
3672 | |||
3673 | connection.ExecuteNonQuery(cmd, txn); |
||
3674 | } |
||
3675 | |||
3676 | //Insulation |
||
3677 | query = $"DELETE FROM {PSN_INSULATIONPURPOSE}"; |
||
3678 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3679 | |||
3680 | foreach (DataRow row in dtInsulation.Rows) |
||
3681 | { |
||
3682 | query = $"INSERT INTO {PSN_INSULATIONPURPOSE} (UID, Code, Description, Remarks) VALUES (@UID, @Code, @Description, @Remarks)"; |
||
3683 | var cmd = connection.GetSqlStringCommand(query); |
||
3684 | cmd.Parameters.Clear(); |
||
3685 | |||
3686 | { |
||
3687 | var param = cmd.CreateParameter(); |
||
3688 | param.ParameterName = "@UID"; |
||
3689 | param.Value = row["UID"].ToString(); |
||
3690 | cmd.Parameters.Add(param); |
||
3691 | } |
||
3692 | |||
3693 | { |
||
3694 | var param = cmd.CreateParameter(); |
||
3695 | param.ParameterName = "@Code"; |
||
3696 | param.Value = row["Code"].ToString(); |
||
3697 | cmd.Parameters.Add(param); |
||
3698 | } |
||
3699 | |||
3700 | { |
||
3701 | var param = cmd.CreateParameter(); |
||
3702 | param.ParameterName = "@Description"; |
||
3703 | param.Value = row["Description"].ToString(); |
||
3704 | cmd.Parameters.Add(param); |
||
3705 | } |
||
3706 | |||
3707 | { |
||
3708 | var param = cmd.CreateParameter(); |
||
3709 | param.ParameterName = "@Remarks"; |
||
3710 | param.Value = row["Remarks"].ToString(); |
||
3711 | cmd.Parameters.Add(param); |
||
3712 | } |
||
3713 | |||
3714 | connection.ExecuteNonQuery(cmd, txn); |
||
3715 | } |
||
3716 | |||
3717 | //Topology Rule |
||
3718 | query = $"DELETE FROM {PSN_TOPOLOGY_RULE}"; |
||
3719 | var cmdtopology = connection.GetSqlStringCommand(query); |
||
3720 | //connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3721 | connection.ExecuteNonQuery(cmdtopology, txn); |
||
3722 | |||
3723 | foreach (DataRow row in dtTopologyRule.Rows) |
||
3724 | { |
||
3725 | query = $"INSERT INTO {PSN_TOPOLOGY_RULE} (UID) VALUES (@UID)"; |
||
3726 | cmdtopology = connection.GetSqlStringCommand(query); |
||
3727 | AddWithValue(cmdtopology, "@UID", row["UID"].ToString()); |
||
3728 | connection.ExecuteNonQuery(cmdtopology, txn); |
||
3729 | } |
||
3730 | |||
3731 | 811d7949 | LJIYEON | //valve grouping |
3732 | query = $"DELETE FROM {PSN_VALVEGROUP_SETTING}"; |
||
3733 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3734 | |||
3735 | foreach (DataRow row in dtvalvegrouping.Rows) |
||
3736 | { |
||
3737 | query = $"INSERT INTO {PSN_VALVEGROUP_SETTING} (OID, GroupType, TagIdentifier, AttributeName, SppidSymbolName) " + |
||
3738 | $"VALUES (@OID, @GroupType, @TagIdentifier, @AttributeName, @SppidSymbolName)"; |
||
3739 | var cmd = connection.GetSqlStringCommand(query); |
||
3740 | AddWithValue(cmd, "@OID", row["OID"].ToString()); |
||
3741 | AddWithValue(cmd, "@GroupType", row["GroupType"].ToString()); |
||
3742 | AddWithValue(cmd, "@TagIdentifier", row["TagIdentifier"].ToString()); |
||
3743 | AddWithValue(cmd, "@AttributeName", row["AttributeName"].ToString()); |
||
3744 | AddWithValue(cmd, "@SppidSymbolName", row["SppidSymbolName"].ToString()); |
||
3745 | connection.ExecuteNonQuery(cmd, txn); |
||
3746 | } |
||
3747 | |||
3748 | 88c1965b | gaqhf | //no pocket Setting |
3749 | query = $"DELETE FROM {PSN_NOPOCKETSETTING}"; |
||
3750 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3751 | |||
3752 | foreach (DataRow row in dtnopocket.Rows) |
||
3753 | { |
||
3754 | query = $"INSERT INTO {PSN_NOPOCKETSETTING} ([INDEX], [TYPE], [NAME]) VALUES (@INDEX, @TYPE, @NAME)"; |
||
3755 | var cmd = connection.GetSqlStringCommand(query); |
||
3756 | AddWithValue(cmd, "@INDEX", row["INDEX"].ToString()); |
||
3757 | AddWithValue(cmd, "@TYPE", row["TYPE"].ToString()); |
||
3758 | AddWithValue(cmd, "@NAME", row["NAME"].ToString()); |
||
3759 | connection.ExecuteNonQuery(cmd, txn); |
||
3760 | } |
||
3761 | |||
3762 | f2a63376 | 이지연 | //air fin cooler Setting |
3763 | query = $"DELETE FROM {PSN_AIRFINCOOLERSETTING}"; |
||
3764 | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
||
3765 | 284fa2c9 | 이지연 | |
3766 | foreach (DataRow row in dtafc.Rows) |
||
3767 | f2a63376 | 이지연 | { |
3768 | 284fa2c9 | 이지연 | query = $"INSERT INTO {PSN_AIRFINCOOLERSETTING} ([INDEX], [TYPE], [TagIdentifier], [AttributeName], [NAME]) VALUES (@INDEX, @TYPE, @TagIdentifier, @AttributeName, @NAME)"; |
3769 | f2a63376 | 이지연 | var cmd = connection.GetSqlStringCommand(query); |
3770 | AddWithValue(cmd, "@INDEX", row["INDEX"].ToString()); |
||
3771 | AddWithValue(cmd, "@TYPE", row["TYPE"].ToString()); |
||
3772 | 284fa2c9 | 이지연 | AddWithValue(cmd, "@TagIdentifier", row["TagIdentifier"].ToString()); |
3773 | AddWithValue(cmd, "@AttributeName", row["AttributeName"].ToString()); |
||
3774 | f2a63376 | 이지연 | AddWithValue(cmd, "@NAME", row["NAME"].ToString()); |
3775 | connection.ExecuteNonQuery(cmd, txn); |
||
3776 | } |
||
3777 | d1afd412 | 이지연 | |
3778 | f2a63376 | 이지연 | |
3779 | 3d842083 | LJIYEON | txn.Commit(); |
3780 | } |
||
3781 | catch (Exception ex) |
||
3782 | { |
||
3783 | txn.Rollback(); |
||
3784 | result = false; |
||
3785 | } |
||
3786 | } |
||
3787 | } |
||
3788 | catch (Exception ex) |
||
3789 | { |
||
3790 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
3791 | result = false; |
||
3792 | } |
||
3793 | } |
||
3794 | |||
3795 | return result; |
||
3796 | } |
||
3797 | 1d46fca7 | LJIYEON | |
3798 | 54b6df95 | LJIYEON | public static bool CreatePSN_COMMON() |
3799 | { |
||
3800 | AnotherID2Info id2Info = AnotherID2Info.GetInstance(); |
||
3801 | |||
3802 | bool result = true; |
||
3803 | using (IAbstractDatabase connection = id2Info.CreateConnection()) |
||
3804 | { |
||
3805 | try |
||
3806 | { |
||
3807 | using (var txn = connection.BeginTransaction()) |
||
3808 | { |
||
3809 | try |
||
3810 | { |
||
3811 | d1afd412 | 이지연 | |
3812 | 54b6df95 | LJIYEON | var query = $"If(db_id(N'" + PSN_COMMON + "') IS NULL) CREATE DATABASE [" + PSN_COMMON + "]"; |
3813 | if (id2Info.ID2DBType == AnotherID2DB_Type.MSSQL) |
||
3814 | d1afd412 | 이지연 | { |
3815 | 54b6df95 | LJIYEON | connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn); |
3816 | } |
||
3817 | |||
3818 | txn.Commit(); |
||
3819 | } |
||
3820 | catch (Exception ex) |
||
3821 | { |
||
3822 | txn.Rollback(); |
||
3823 | result = false; |
||
3824 | } |
||
3825 | } |
||
3826 | } |
||
3827 | catch (Exception ex) |
||
3828 | { |
||
3829 | System.Windows.Forms.MessageBox.Show(ex.Message); |
||
3830 | result = false; |
||
3831 | } |
||
3832 | } |
||
3833 | |||
3834 | return result; |
||
3835 | } |
||
3836 | } |
||
3837 | 0dae5645 | gaqhf | } |
3838 | 54b6df95 | LJIYEON |