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