프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / ID2PSN / DB.cs @ 839708c6

이력 | 보기 | 이력해설 | 다운로드 (72.9 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Data;
4
using System.Data.Common;
5
using System.Data.SQLite;
6
using System.Linq;
7
using System.Text.RegularExpressions;
8

    
9
namespace ID2PSN
10
{
11
    public class DB
12
    {
13
        const string PSN_TOPOLOGY_RULE = "T_PSN_TOPOLOGY_RULE";
14
        const string PSN_HEADER_SETTING = "T_PSN_HEADER_SETTING";
15
        const string PSN_VENTDRAIN_SETTING = "T_PSN_VENTDRAIN_SETTING";
16
        const string PSN_VIEW = "T_PSN_VIEW";
17
        const string PSN_TRANSFORMKEYWORD_SETTING = "T_PSN_TRANSFORMKEYWORD_SETTING"; 
18

    
19
        const string PSN_PATHITEMS = "SPPIDPathItem";
20
        const string PSN_SEQUENCEDATA = "SPPIDSequenceData";
21
        const string PSN_PIPESYSTEMNETWORK = "SPPIDPipeSystemNetwork";
22
        const string PSN_EQUIPMENT = "SPPIDEquipment";
23
        const string PSN_NOZZLE = "SPPIDNozzle";
24
        const string PSN_FLUIDCODE = "SPPIDFluidCode";
25
        const string PSN_PIPINGMATLCLASS = "SPPIDPipingMatlClass";
26
        const string PSN_TOPOLOGYSET = "SPPIDTopologySet";
27
        //2021.11.17 추가 
28
        const string PSN_PIPELINE = "SPPIDPipeLine";
29
        //2021.11.26 추가
30
        const string PSN_INSULATIONPURPOSE = "SPPIDInsulationPurpose";
31
        /// <summary>
32
        ///  ID2 Project.db 데이터를 가져온다. 
33
        ///  DB 접속 정보 및 DBType (Sqlite, Mssql) 정보를 가져옴
34
        ///  - JY
35
        /// </summary>
36
        /// <returns></returns>
37
        public static DataTable GetProject()
38
        {
39
            DataTable dt = new DataTable();
40
            ID2Info id2Info = ID2Info.GetInstance();
41
            try
42
            {
43
                using (SQLiteConnection connection = new SQLiteConnection(@"Data Source = C:\ProgramData\Digital PID\Project.db", true))
44
                {
45
                    connection.Open();
46
                    if (connection.State.Equals(ConnectionState.Open))
47
                    {
48
                        using (SQLiteCommand cmd = connection.CreateCommand())
49
                        {
50
                            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]";
51
                            using (SQLiteDataReader dr = cmd.ExecuteReader())
52
                                dt.Load(dr);
53
                        }
54

    
55
                    }
56
                    connection.Close();
57
                }
58
            }
59
            catch (Exception ex)
60
            {
61
                System.Windows.Forms.MessageBox.Show(ex.Message);
62
            }
63

    
64
            dt.AcceptChanges();
65
            dt.DefaultView.Sort = "Name";
66
            dt = dt.DefaultView.ToTable();
67

    
68
            return dt;
69
        }
70

    
71
        /// <summary>
72
        ///  SQLite에 초기 DB 생성
73
        ///  - JY
74
        /// </summary>
75
        /// <returns></returns>
76
        public static bool ConnTestAndCreateTable()
77
        {
78
            bool result = false;
79
            ID2Info id2Info = ID2Info.GetInstance();
80

    
81
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
82
            {
83
                try
84
                {
85
                    var names = connection.GetTableNames();
86
                    var matched = names.FirstOrDefault(param => param == PSN_HEADER_SETTING);
87
                    if (matched == null)
88
                    {
89
                        var query = $"CREATE TABLE {PSN_HEADER_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)";
90
                        using (var cmd = connection.GetSqlStringCommand(query))
91
                        {
92
                            cmd.ExecuteNonQuery();
93
                        }
94
                    }
95

    
96
                    matched = names.FirstOrDefault(param => param == PSN_VENTDRAIN_SETTING);
97
                    if (matched == null)
98
                    {
99
                        var query = $"CREATE TABLE {PSN_VENTDRAIN_SETTING} (GROUP_ID TEXT, DESCRIPTION TEXT, [INDEX] INTEGER, NAME TEXT)";
100
                        using (var cmd = connection.GetSqlStringCommand(query))
101
                        {
102
                            cmd.ExecuteNonQuery();
103
                        }
104
                    }
105

    
106
                    matched = names.FirstOrDefault(param => param == PSN_TOPOLOGY_RULE);
107
                    if (matched == null)
108
                    {
109
                        var query = $"CREATE TABLE {PSN_TOPOLOGY_RULE} (UID TEXT)";
110
                        using (var cmd = connection.GetSqlStringCommand(query))
111
                        {
112
                            cmd.ExecuteNonQuery();
113
                        }
114

    
115
                        DataTable topologyRule = new DataTable();
116
                        topologyRule.Columns.Add("NAME", typeof(string));
117

    
118
                        topologyRule.Rows.Add("FluidCode");
119
                        topologyRule.Rows.Add("-");
120
                        topologyRule.Rows.Add("PipingMaterialsClass");
121
                        topologyRule.Rows.Add("-");
122
                        topologyRule.Rows.Add("Tag Seq No");
123

    
124
                        SaveTopologyRule(topologyRule);
125
                    }
126

    
127

    
128
                    matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEMNETWORK);
129
                    if (matched == null)
130
                    {
131
                        var query = $"CREATE TABLE {PSN_PIPESYSTEMNETWORK} (OID NVARCHAR(255), Type NVARCHAR(255), OrderNumber NVARCHAR(255), Pipeline_OID NVARCHAR(255), From_Data NVARCHAR(255), " +
132
                            "To_Data NVARCHAR(255), TopologySet_OID_Key NVARCHAR(125), PSNRevisionNumber NVARCHAR(255), IsValid INTEGER, Status NVARCHAR(255), PBS NVARCHAR(255), Drawings NVARCHAR(255), " +
133
                            "IncludingVirtualData NVARCHAR(10),  PSNAccuracy REAL)";
134
                        using (var cmd = connection.GetSqlStringCommand(query))
135
                        {
136
                            cmd.ExecuteNonQuery();
137
                        }
138
                    }
139

    
140
                    matched = names.FirstOrDefault(param => param == PSN_EQUIPMENT);
141
                    if (matched == null)
142
                    {
143
                        var query = $"CREATE TABLE {PSN_EQUIPMENT} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL)";
144
                        using (var cmd = connection.GetSqlStringCommand(query))
145
                        {
146
                            cmd.ExecuteNonQuery();
147
                        }
148
                    }
149

    
150
                    matched = names.FirstOrDefault(param => param == PSN_NOZZLE);
151
                    if (matched == null)
152
                    {
153
                        var query = $"CREATE TABLE {PSN_NOZZLE} (OID NVARCHAR(255), ItemTag NVARCHAR(255), Xcoords REAL, Ycoords REAL, Equipment_OID NVARCHAR(255), " +
154
                            "Fluid NVARCHAR(255), NPD NVARCHAR(255), Rotation REAL, FlowDirection NVARCHAR(255))";
155
                        using (var cmd = connection.GetSqlStringCommand(query))
156
                        {
157
                            cmd.ExecuteNonQuery();
158
                        }
159
                    }
160

    
161
                    matched = names.FirstOrDefault(param => param == PSN_FLUIDCODE);
162
                    if (matched == null)
163
                    {
164
                        var query = $"CREATE TABLE {PSN_FLUIDCODE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Condition NVARCHAR(255), Remarks NVARCHAR(255), GroundLevel NVARCHAR(20))";
165
                        using (var cmd = connection.GetSqlStringCommand(query))
166
                        {
167
                            cmd.ExecuteNonQuery();
168
                        }
169
                    }
170

    
171

    
172
                    matched = names.FirstOrDefault(param => param == PSN_PIPINGMATLCLASS);
173
                    if (matched == null)
174
                    {
175
                        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))";
176
                        using (var cmd = connection.GetSqlStringCommand(query))
177
                        {
178
                            cmd.ExecuteNonQuery();
179
                        }
180
                    }
181

    
182
                    matched = names.FirstOrDefault(param => param == PSN_SEQUENCEDATA);
183
                    if (matched == null)
184
                    {
185
                        var query = $"CREATE TABLE {PSN_SEQUENCEDATA} (OID NVARCHAR(255), SERIALNUMBER NVARCHAR(255), PathItem_OID NVARCHAR(255), TopologySet_OID_Key NVARCHAR(255))";
186
                        using (var cmd = connection.GetSqlStringCommand(query))
187
                        {
188
                            cmd.ExecuteNonQuery();
189
                        }
190
                    }
191

    
192
                    matched = names.FirstOrDefault(param => param == PSN_PATHITEMS);
193
                    if (matched == null)
194
                    {
195
                        var query = $"CREATE TABLE {PSN_PATHITEMS} (OID NVARCHAR(255), SequenceData_OID NVARCHAR(255), " +
196
                            "TopologySet_OID NVARCHAR(255), BranchTopologySet_OID NVARCHAR(255), PipeLine_OID NVARCHAR(255), ItemName NVARCHAR(255), ItemTag NVARCHAR(255), DESCRIPTION NVARCHAR(255), " +
197
                            "CLASS NVARCHAR(255), SUBCLASS NVARCHAR(255), TYPE NVARCHAR(255), PIDNAME NVARCHAR(255), Equipment_OID NVARCHAR(255), NPD NVARCHAR(255), PipeSystemNetwork_OID NVARCHAR(255), PipeRun_OID NVARCHAR(255), " +
198
                            "ViewPipeSystemNetwork_OID NVARCHAR(255))";
199
                        using (var cmd = connection.GetSqlStringCommand(query))
200
                        {
201
                            cmd.ExecuteNonQuery();
202
                        }
203
                    }
204
                    
205
                    matched = names.FirstOrDefault(param => param == PSN_VIEW);
206
                    if (matched == null)
207
                    {
208
                        var query = $"CREATE TABLE {PSN_VIEW} (OID TEXT)";
209
                        using (var cmd = connection.GetSqlStringCommand(query))
210
                        {
211
                            cmd.ExecuteNonQuery();
212
                        }
213
                    }
214

    
215
                    matched = names.FirstOrDefault(param => param == PSN_TOPOLOGYSET);
216
                    if (matched == null)
217
                    {
218
                        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))";
219
                        using (var cmd = connection.GetSqlStringCommand(query))
220
                        {
221
                            cmd.ExecuteNonQuery();
222
                        }
223
                    }
224
                   
225
                    matched = names.FirstOrDefault(param => param == PSN_TRANSFORMKEYWORD_SETTING);
226
                    if (matched == null)
227
                    {
228
                        var query = $"CREATE TABLE {PSN_TRANSFORMKEYWORD_SETTING} ([INDEX] INTEGER, [NAME] TEXT, [KEYWORD] TEXT)";
229
                        using (var cmd = connection.GetSqlStringCommand(query))
230
                        {
231
                            cmd.ExecuteNonQuery();
232
                        }
233
                    }
234

    
235
                    matched = names.FirstOrDefault(param => param == PSN_PIPELINE);
236
                    if (matched == null)
237
                    {
238
                        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), " +
239
                            $"FROM_DATA NVARCHAR(255), TO_DATA NVARCHAR(255), Unit NVARCHAR(100))";
240
                        using (var cmd = connection.GetSqlStringCommand(query))
241
                        {
242
                            cmd.ExecuteNonQuery();
243
                        }
244
                    }
245

    
246
                    matched = names.FirstOrDefault(param => param == PSN_INSULATIONPURPOSE);
247
                    if (matched == null)
248
                    {
249
                        var query = $"CREATE TABLE {PSN_INSULATIONPURPOSE} (UID NVARCHAR(50), Code NVARCHAR(255), Description NVARCHAR(255), Remarks NVARCHAR(255))";
250
                        using (var cmd = connection.GetSqlStringCommand(query))
251
                        {
252
                            cmd.ExecuteNonQuery();
253
                        }
254
                    }
255

    
256
                    result = true;
257
                }
258
                catch (Exception ex)
259
                {
260
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
261
                }
262
            }
263

    
264
            return result;
265
        }
266

    
267
        // ID2 DB 데이터
268
        /// <summary>
269
        /// ID2 데이타베이스에서 OPC 데이터를 조회
270
        /// </summary>
271
        /// <returns></returns>
272
        public static DataTable SelectOPCRelations()
273
        {
274
            DataTable dt = null;
275
            ID2Info id2Info = ID2Info.GetInstance();
276

    
277
            using (IAbstractDatabase connection = id2Info.CreateConnection())
278
            {
279
                try
280
                {
281
                    var query = "SELECT * FROM OPCRelations;";
282
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
283
                    {
284
                        dt = ds.Tables[0].Copy();
285
                    }
286
                }
287
                catch (Exception ex)
288
                {
289
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
290
                }
291
            }
292

    
293
            return dt;
294
        }
295

    
296
        /// <summary>
297
        /// ID2 데이타베이스에서 도면 데이터를 조회
298
        /// </summary>
299
        /// <returns></returns>
300
        public static DataTable SelectDrawings()
301
        {
302
            DataTable dt = null;
303
            ID2Info id2Info = ID2Info.GetInstance();
304

    
305
            using (IAbstractDatabase connection = id2Info.CreateConnection())
306
            {
307
                try
308
                {
309
                    var query = "SELECT * FROM Drawings";
310
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
311
                    {
312
                        dt = ds.Tables[0].Copy();
313
                    }
314
                }
315
                catch (Exception ex)
316
                {
317
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
318
                }
319
            }
320

    
321
            return dt;
322
        }
323

    
324
        public static DataTable SelectLineProperties()
325
        {
326
            DataTable dt = null;
327
            ID2Info id2Info = ID2Info.GetInstance();
328

    
329
            using (IAbstractDatabase connection = id2Info.CreateConnection())
330
            {
331
                try
332
                {
333
                    var query = "SELECT * FROM LineProperties";
334
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
335
                    {
336
                        dt = ds.Tables[0].Copy();
337
                    }
338
                }
339
                catch (Exception ex)
340
                {
341
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
342
                }
343
            }
344

    
345
            return dt;
346
        }
347

    
348
        public static DataTable SelectFluidCode()
349
        {
350
            DataTable dt = null;
351
            ID2Info id2Info = ID2Info.GetInstance();
352

    
353
            using (IAbstractDatabase connection = id2Info.CreateConnection())
354
            {
355
                try
356
                {
357
                    var query = "SELECT * FROM FluidCode";
358
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
359
                    {
360
                        dt = ds.Tables[0].Copy();
361
                    }
362
                }
363
                catch (Exception ex)
364
                {
365
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
366
                }
367
            }
368

    
369
            return dt;
370
        }
371

    
372
        public static DataTable SelectPipingMaterialsClass()
373
        {
374
            DataTable dt = null;
375
            ID2Info id2Info = ID2Info.GetInstance();
376

    
377
            using (IAbstractDatabase connection = id2Info.CreateConnection())
378
            {
379
                try
380
                {
381
                    var query = "SELECT * FROM PipingMaterialsClass";
382
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
383
                    {
384
                        dt = ds.Tables[0].Copy();
385
                    }
386
                }
387
                catch (Exception ex)
388
                {
389
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
390
                }
391
            }
392

    
393
            return dt;
394
        }
395

    
396
        public static DataTable SelectPSNPIPINGMATLCLASS()
397
        {
398
            DataTable dt = null;
399
            ID2Info id2Info = ID2Info.GetInstance();
400

    
401
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
402
            {
403
                try
404
                {
405
                    var query = $"SELECT * FROM {PSN_PIPINGMATLCLASS}";
406
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
407
                    {
408
                        dt = ds.Tables[0].Copy();
409
                    }
410
                }
411
                catch (Exception ex)
412
                {
413
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
414
                }
415
            }
416

    
417
            return dt;
418
        }
419

    
420

    
421
        public static DataTable SelectInsulationPurpose()
422
        {
423
            DataTable dt = null;
424
            ID2Info id2Info = ID2Info.GetInstance();
425

    
426
            using (IAbstractDatabase connection = id2Info.CreateConnection())
427
            {
428
                try
429
                {
430
                    var query = "SELECT * FROM InsulationPurpose";
431
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
432
                    {
433
                        dt = ds.Tables[0].Copy();
434
                    }
435
                }
436
                catch (Exception ex)
437
                {
438
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
439
                }
440
            }
441

    
442
            return dt;
443
        }
444

    
445
        public static DataTable SelectPSNINSULATIONPURPOSE()
446
        {
447
            DataTable dt = null;
448
            ID2Info id2Info = ID2Info.GetInstance();
449

    
450
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
451
            {
452
                try
453
                {
454
                    var query = $"SELECT * FROM {PSN_INSULATIONPURPOSE}";
455
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
456
                    {
457
                        dt = ds.Tables[0].Copy();
458
                    }
459
                }
460
                catch (Exception ex)
461
                {
462
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
463
                }
464
            }
465

    
466
            return dt;
467
        }
468

    
469
        public static DataTable SelectNominalDiameter()
470
        {
471
            DataTable dt = null;
472
            ID2Info id2Info = ID2Info.GetInstance();
473

    
474
            using (IAbstractDatabase connection = id2Info.CreateConnection())
475
            {
476
                try
477
                {
478
                    var query = "SELECT * FROM NominalDiameter ORDER BY Metric DESC";
479
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
480
                    {
481
                        dt = ds.Tables[0].Copy();
482
                    }
483
                }
484
                catch (Exception ex)
485
                {
486
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
487
                }
488
            }
489

    
490
            ///TODO: need to check below code
491
            dt.Rows.RemoveAt(0);
492
            dt.Rows.RemoveAt(0);
493
            dt.Rows.RemoveAt(0);
494
            dt.Rows.RemoveAt(0);
495

    
496
            return dt;
497
        }
498

    
499
        public static DataTable SelectSymbolAttribute()
500
        {
501
            DataTable dt = null;
502
            ID2Info id2Info = ID2Info.GetInstance();
503

    
504
            using (IAbstractDatabase connection = id2Info.CreateConnection())
505
            {
506
                try
507
                {
508
                   // var query = "SELECT DISTINCT Attribute, DisplayAttribute FROM SymbolAttribute;";
509
                    var query = "SELECT DISTINCT Attribute FROM SymbolAttribute;";
510
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
511
                    {
512
                        dt = ds.Tables[0].Copy();
513
                    }
514
                }
515
                catch (Exception ex)
516
                {
517
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
518
                }
519
            }
520

    
521
            return dt;
522
        }
523

    
524
        public static DataTable SelectSymbolName()
525
        {
526
            DataTable dt = null;
527
            ID2Info id2Info = ID2Info.GetInstance();
528

    
529
            using (IAbstractDatabase connection = id2Info.CreateConnection())
530
            {
531
                try
532
                {
533
                    var query = "SELECT * FROM SymbolName;";
534
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
535
                    {
536
                        dt = ds.Tables[0].Copy();
537
                    }
538
                }
539
                catch (Exception ex)
540
                {
541
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
542
                }
543
            }
544

    
545
            return dt;
546
        }
547

    
548
        public static double[] GetDrawingSize()
549
        {
550
            double[] result = null;
551

    
552
            ID2Info id2Info = ID2Info.GetInstance();
553
            using (IAbstractDatabase connection = id2Info.CreateConnection())
554
            {
555
                try
556
                {
557
                    var query = "SELECT value FROM Configuration WHERE Section = 'Area' AND [Key] = 'Drawing';";
558
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
559
                    {
560
                        if (ds.Tables[0].Rows.Count == 1)
561
                        {
562
                            string value = ds.Tables[0].Rows[0][0].ToString();
563
                            string[] split = value.Split(new char[] { ',' });
564
                            result = new double[] {
565
                                Convert.ToDouble(Regex.Replace(split[0], @"[^0-9]", string.Empty)),
566
                                Convert.ToDouble(Regex.Replace(split[1], @"[^0-9]", string.Empty)),
567
                                Convert.ToDouble(Regex.Replace(split[2], @"[^0-9]", string.Empty)),
568
                                Convert.ToDouble(Regex.Replace(split[3], @"[^0-9]", string.Empty))
569
                                };
570
                            result = new double[] {
571
                                Math.Min(result[0], result[2]),
572
                                Math.Min(result[1], result[3]),
573
                                Math.Max(result[0], result[2]),
574
                                Math.Max(result[1], result[3])
575
                                };
576
                        }
577
                    }
578
                }
579
                catch (Exception ex)
580
                {
581
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
582
                }
583
            }
584

    
585
            return result;
586
        }
587

    
588
        public static DataTable GetEquipmentType()
589
        {
590
            DataTable dt = null;
591
            ID2Info id2Info = ID2Info.GetInstance();
592

    
593
            using (IAbstractDatabase connection = id2Info.CreateConnection())
594
            {
595
                try
596
                {
597
                    var query = "SELECT Type FROM SymbolType WHERE Category = 'Equipment';";
598
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
599
                    {
600
                        dt = ds.Tables[0].Copy();
601
                    }
602
                }
603
                catch (Exception ex)
604
                {
605
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
606
                }
607
            }
608

    
609
            return dt;
610
        }
611

    
612
        /// <summary>
613
        ///  Zoom 을 위하여 저장 T_PSN_VIEW 데이터로 PSN 데이터지만 Msqql 과 Sqlite 둘다 저장되어 있음
614
        ///  => ID2 가 DB 타입에 따라서 바라보는 DB가 mssql이냐 sqlite냐로 지정되기 때문에 zoom 기능을 그대로 사용하려면 해당 데이터는 psn도 id2 dbtype에 맞춰서 저장 및 로드해야함
615
        ///  => 더 이상 사용하지 않음
616
        /// </summary>
617
        /// <param name="values"></param>
618
        /// <returns></returns>
619
        public static bool SaveView(List<string> values)
620
        {
621
            ID2Info id2Info = ID2Info.GetInstance();
622

    
623
            bool result = true;
624

    
625
            using (IAbstractDatabase connection = id2Info.CreateConnection())
626
            {
627
                try
628
                {
629
                    using (var txn = connection.BeginTransaction())
630
                    {
631
                        try
632
                        {
633
                            var query = $"DELETE FROM {PSN_VIEW}";
634
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
635

    
636
                            foreach (string value in values)
637
                            {
638
                                query = $"INSERT INTO {PSN_VIEW} VALUES (@OID)";
639
                                var cmd = connection.GetSqlStringCommand(query);
640
                                AddWithValue(cmd, "@OID", value);
641
                                connection.ExecuteNonQuery(cmd, txn);
642
                            }
643
                            txn.Commit();
644
                        }
645
                        catch (Exception ex)
646
                        {
647
                            txn.Rollback();
648
                            result = false;
649
                        }
650
                    }
651
                }
652
                catch (Exception ex)
653
                {
654
                    System.Windows.Forms.MessageBox.Show(ex.Message);
655
                    result = false;
656
                }
657
            }
658

    
659
            return result;
660
        }
661

    
662
        public static bool DeleteView()
663
        {
664
            ID2Info id2Info = ID2Info.GetInstance();
665

    
666
            bool result = true;
667
            using (IAbstractDatabase connection = id2Info.CreateConnection())
668
            {
669
                try
670
                {
671
                    using (var txn = connection.BeginTransaction())
672
                    {
673
                        try
674
                        {
675
                            var query = $"DELETE FROM {PSN_VIEW}";
676
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
677
                            txn.Commit();
678
                        }
679
                        catch (Exception ex)
680
                        {
681
                            txn.Rollback();
682
                            result = false;
683
                        }
684
                    }
685
                }
686
                catch (Exception ex)
687
                {
688
                    System.Windows.Forms.MessageBox.Show(ex.Message);
689
                    result = false;
690
                }
691
            }
692

    
693
            return result;
694
        }
695

    
696
        //PSN Sqlite 
697
        public static DataTable SelectHeaderSetting()
698
        {
699
            DataTable dt = null;
700
            ID2Info id2Info = ID2Info.GetInstance();
701

    
702
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
703
            {
704
                try
705
                {
706
                    var query = $@"SELECT GROUP_ID, DESCRIPTION, [INDEX], NAME FROM {PSN_HEADER_SETTING};";
707
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
708
                    {
709
                        dt = ds.Tables[0].Copy();
710
                    }
711
                }
712
                catch (Exception ex)
713
                {
714
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
715
                }
716
            }
717

    
718
            return dt;
719
        }
720

    
721
        public static DataTable SelectVentDrainSetting()
722
        {
723
            DataTable dt = null;
724
            ID2Info id2Info = ID2Info.GetInstance();
725

    
726
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
727
            {
728
                try
729
                {
730
                    var query = $@"SELECT GROUP_ID, DESCRIPTION, [INDEX], NAME FROM {PSN_VENTDRAIN_SETTING};";
731
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
732
                    {
733
                        dt = ds.Tables[0].Copy();
734
                    }
735
                }
736
                catch (Exception ex)
737
                {
738
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
739
                }
740
            }
741

    
742
            return dt;
743
        }
744

    
745
        public static DataTable SelectKeywordsSetting()
746
        {
747
            DataTable dt = null;
748
            ID2Info id2Info = ID2Info.GetInstance();
749

    
750
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
751
            {
752
                try
753
                {
754
                    var query = $@"SELECT [KEYWORD], [INDEX], [NAME] FROM {PSN_TRANSFORMKEYWORD_SETTING};";
755
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
756
                    {
757
                        dt = ds.Tables[0].Copy();
758
                    }
759
                }
760
                catch (Exception ex)
761
                {
762
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
763
                }
764
            }
765

    
766
            return dt;
767
        }
768

    
769
        public static bool SaveHeaderSetting(List<HeaderInfo> headerInfos)
770
        {
771
            ID2Info id2Info = ID2Info.GetInstance();
772
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
773
            {
774
                try
775
                {
776
                    using (var txn = connection.BeginTransaction())
777
                    {
778
                        var query = $"DELETE FROM {PSN_HEADER_SETTING}";
779
                        connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
780

    
781
                        foreach (HeaderInfo headerInfo in headerInfos)
782
                        {
783
                            foreach (HeaderItem item in headerInfo.HeaderItems)
784
                            {
785
                                query = $"INSERT INTO {PSN_HEADER_SETTING} VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)";
786
                                var cmd = connection.GetSqlStringCommand(query);
787
                                AddWithValue(cmd, "@GROUP_ID", headerInfo.UID);
788
                                AddWithValue(cmd, "@DESCRIPTION", headerInfo.Description);
789
                                AddWithValue(cmd, "@INDEX", item.Index);
790
                                AddWithValue(cmd, "@NAME", item.Name);
791
                                connection.ExecuteNonQuery(cmd, txn);
792
                            }
793
                        }
794
                        txn.Commit();
795
                    }
796
                    
797
                }
798
                catch (Exception ex)
799
                {
800
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
801
                    return false;
802
                }
803
            }
804
            return true;
805
        }
806

    
807
        public static bool SaveVentDrainSetting(List<VentDrainInfo> ventDrainInfos)
808
        {
809
            ID2Info id2Info = ID2Info.GetInstance();
810
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
811
            {
812
                using (var txn = connection.BeginTransaction())
813
                {
814
                    try
815
                    {
816
                        var query = $"DELETE FROM {PSN_VENTDRAIN_SETTING}";
817
                        connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
818

    
819
                        foreach (VentDrainInfo ventDrainInfo in ventDrainInfos)
820
                        {
821
                            foreach (VentDrainItem item in ventDrainInfo.VentDrainItems)
822
                            {
823
                                query = $"INSERT INTO {PSN_VENTDRAIN_SETTING} VALUES (@GROUP_ID, @DESCRIPTION, @INDEX, @NAME)";
824
                                var cmd = connection.GetSqlStringCommand(query);
825
                                AddWithValue(cmd, "@GROUP_ID", ventDrainInfo.UID);
826
                                AddWithValue(cmd, "@DESCRIPTION", ventDrainInfo.Description);
827
                                AddWithValue(cmd, "@INDEX", item.Index);
828
                                AddWithValue(cmd, "@NAME", item.Name);
829
                                connection.ExecuteNonQuery(cmd, txn);
830
                            }
831
                        }
832

    
833
                        txn.Commit();
834
                    }
835
                    catch (Exception ex)
836
                    {
837
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
838
                        return false;
839
                    }
840
                }
841
            }
842

    
843
            return true;
844
        }
845

    
846
        public static bool SaveKeywordsSetting(List<KeywordItem> keywordItems)
847
        {
848
            ID2Info id2Info = ID2Info.GetInstance();
849
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
850
            {
851
                using (var txn = connection.BeginTransaction())
852
                {
853
                    try
854
                    {
855
                        var query = $"DELETE FROM {PSN_TRANSFORMKEYWORD_SETTING}";
856
                        connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
857
                        
858
                        foreach (KeywordItem item in keywordItems)
859
                        {
860
                            query = $"INSERT INTO {PSN_TRANSFORMKEYWORD_SETTING} VALUES (@INDEX, @NAME, @KEYWORD)";
861
                            var cmd = connection.GetSqlStringCommand(query);
862
                            AddWithValue(cmd, "@INDEX", item.Index);
863
                            AddWithValue(cmd, "@NAME", item.Name);
864
                            AddWithValue(cmd, "@KEYWORD", item.Keyword);                            
865
                            connection.ExecuteNonQuery(cmd, txn);
866
                        }
867
                        
868
                        txn.Commit();
869
                    }
870
                    catch (Exception ex)
871
                    {
872
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
873
                        return false;
874
                    }
875
                }
876
            }
877

    
878
            return true;
879
        }
880

    
881
        public static bool SaveTopologyRule(DataTable dt)
882
        {
883
            ID2Info id2Info = ID2Info.GetInstance();
884
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
885
            {
886
                using (var txn = connection.BeginTransaction())
887
                {
888
                    try
889
                    {
890
                        var query = $"DELETE FROM {PSN_TOPOLOGY_RULE}";
891
                        var cmd = connection.GetSqlStringCommand(query);
892
                        cmd.ExecuteNonQuery();
893

    
894
                        foreach (DataRow row in dt.Rows)
895
                        {
896
                            query = $"INSERT INTO {PSN_TOPOLOGY_RULE} VALUES (@UID)";
897
                            cmd = connection.GetSqlStringCommand(query);
898
                            AddWithValue(cmd, "@UID", row["NAME"].ToString());
899
                            connection.ExecuteNonQuery(cmd, txn);
900
                        }
901

    
902
                        txn.Commit();
903
                    }
904
                    catch (Exception ex)
905
                    {
906
                        txn.Rollback();
907
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
908
                        return false;
909
                    }
910
                }
911
            }
912

    
913
            return true;
914
        }
915

    
916
        public static DataTable SelectTopologyRule()
917
        {
918
            DataTable dt = null;
919

    
920
            ID2Info id2Info = ID2Info.GetInstance();
921
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
922
            {
923
                try
924
                {
925
                    var query = $"SELECT * FROM {PSN_TOPOLOGY_RULE}";
926
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
927
                    {
928
                        dt = ds.Tables[0].Copy();
929
                    }
930
                }
931
                catch (Exception ex)
932
                {
933
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
934
                }
935
            }
936

    
937
            return dt;
938
        }
939

    
940
        private static void AddWithValue(DbCommand cmd, string PropName, object Value)
941
        {
942
            var param = cmd.CreateParameter();
943
            param.ParameterName = PropName;
944
            param.Value = Value;
945
            cmd.Parameters.Add(param);
946
        }
947

    
948
        public static bool SavePSNData(PSN item)
949
        {
950
            ID2Info id2Info = ID2Info.GetInstance();
951

    
952
            bool result = true;
953
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
954
            {
955
                try
956
                {
957
                    using (var txn = connection.BeginTransaction())
958
                    {
959
                        try
960
                        {
961
                            // Path Items
962
                            var query = $"DELETE FROM {PSN_PATHITEMS}";
963
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
964
                            for (int i = 0; i < item.PathItems.Rows.Count; i++)
965
                            {
966
                                DataRow row = item.PathItems.Rows[i];
967
                                query = $"INSERT INTO {PSN_PATHITEMS} VALUES (@OID, @SequenceData_OID, @TopologySet_OID, @BranchTopologySet_OID, @PipeLine_OID, @ITEMNAME, @ITEMTAG, @DESCRIPTION, @Class, @SubClass, @TYPE, @PIDNAME, @Equipment_OID, @NPD, @PipeSystemNetwork_OID, @ViewPipeSystemNetwork_OID, @PipeRun_OID)";
968
                                var cmd = connection.GetSqlStringCommand(query);
969
                                AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString());
970
                                AddWithValue(cmd, "@SequenceData_OID", string.IsNullOrEmpty(row["SequenceData_OID"].ToString()) ? "" : row["SequenceData_OID"].ToString());
971
                                AddWithValue(cmd, "@TopologySet_OID", string.IsNullOrEmpty(row["TopologySet_OID"].ToString()) ? "" : row["TopologySet_OID"].ToString());
972
                                AddWithValue(cmd, "@BranchTopologySet_OID", string.IsNullOrEmpty(row["BranchTopologySet_OID"].ToString()) ? "" : row["BranchTopologySet_OID"].ToString());
973
                                AddWithValue(cmd, "@PipeLine_OID", string.IsNullOrEmpty(row["PipeLine_OID"].ToString()) ? "" : row["PipeLine_OID"].ToString());
974
                                AddWithValue(cmd, "@ITEMNAME", string.IsNullOrEmpty(row["ITEMNAME"].ToString()) ? "" : row["ITEMNAME"].ToString());
975
                                AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString());
976
                                AddWithValue(cmd, "@DESCRIPTION", string.IsNullOrEmpty(row["DESCRIPTION"].ToString()) ? "" : row["DESCRIPTION"].ToString()); 
977
                                AddWithValue(cmd, "@Class", string.IsNullOrEmpty(row["Class"].ToString()) ? "" : row["Class"].ToString());
978
                                AddWithValue(cmd, "@SubClass", string.IsNullOrEmpty(row["SubClass"].ToString()) ? "" : row["SubClass"].ToString());
979
                                AddWithValue(cmd, "@TYPE", string.IsNullOrEmpty(row["TYPE"].ToString()) ? "" : row["TYPE"].ToString());
980
                                AddWithValue(cmd, "@PIDNAME", string.IsNullOrEmpty(row["PIDNAME"].ToString()) ? "" : row["PIDNAME"].ToString());
981
                                AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString()); 
982
                                AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString());
983
                                AddWithValue(cmd, "@PipeSystemNetwork_OID", string.IsNullOrEmpty(row["PipeSystemNetwork_OID"].ToString()) ? "" : row["PipeSystemNetwork_OID"].ToString());
984
                                AddWithValue(cmd, "@ViewPipeSystemNetwork_OID", string.IsNullOrEmpty(row["ViewPipeSystemNetwork_OID"].ToString()) ? "" : row["ViewPipeSystemNetwork_OID"].ToString());
985
                                AddWithValue(cmd, "@PipeRun_OID", string.IsNullOrEmpty(row["PipeRun_OID"].ToString()) ? "" : row["PipeRun_OID"].ToString());
986
                                connection.ExecuteNonQuery(cmd, txn);
987
                            }
988

    
989
                            // Sequence
990
                            query = $"DELETE FROM {PSN_SEQUENCEDATA}";
991
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
992
                            foreach (DataRow row in item.SequenceData.Rows)
993
                            {
994
                                query = $"INSERT INTO {PSN_SEQUENCEDATA} VALUES (@OID, @SERIALNUMBER, @PathItem_OID, @TopologySet_OID_Key)";
995
                                var cmd = connection.GetSqlStringCommand(query);
996
                                AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString());
997
                                AddWithValue(cmd, "@SERIALNUMBER", string.IsNullOrEmpty(row["SERIALNUMBER"].ToString()) ? "" : row["SERIALNUMBER"].ToString());
998
                                AddWithValue(cmd, "@PathItem_OID", string.IsNullOrEmpty(row["PathItem_OID"].ToString()) ? "" : row["PathItem_OID"].ToString());
999
                                AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString());
1000
                                connection.ExecuteNonQuery(cmd, txn);
1001
                            }
1002

    
1003
                            // Nozzle
1004
                            query = $"DELETE FROM {PSN_NOZZLE}";
1005
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1006
                            foreach (DataRow row in item.Nozzle.Rows)
1007
                            {
1008
                                query = $"INSERT INTO {PSN_NOZZLE} VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS, @Equipment_OID, @FLUID, @NPD, @ROTATION, @FlowDirection)";
1009
                                var cmd = connection.GetSqlStringCommand(query);
1010
                                AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString());
1011
                                AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString());
1012

    
1013
                                if (string.IsNullOrEmpty(row["XCOORDS"].ToString()))
1014
                                    AddWithValue(cmd, "@XCOORDS", DBNull.Value);
1015
                                else
1016
                                    AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString());
1017

    
1018
                                if (string.IsNullOrEmpty(row["YCOORDS"].ToString()))
1019
                                    AddWithValue(cmd, "@YCOORDS", DBNull.Value);
1020
                                else
1021
                                    AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString());
1022

    
1023
                                AddWithValue(cmd, "@Equipment_OID", string.IsNullOrEmpty(row["Equipment_OID"].ToString()) ? "" : row["Equipment_OID"].ToString());
1024
                                AddWithValue(cmd, "@FLUID", string.IsNullOrEmpty(row["FLUID"].ToString()) ? "" : row["FLUID"].ToString());
1025
                                AddWithValue(cmd, "@NPD", string.IsNullOrEmpty(row["NPD"].ToString()) ? "" : row["NPD"].ToString());
1026

    
1027
                                if (string.IsNullOrEmpty(row["ROTATION"].ToString()))
1028
                                    AddWithValue(cmd, "@ROTATION", DBNull.Value);
1029
                                else
1030
                                    AddWithValue(cmd, "@ROTATION", row["ROTATION"].ToString());
1031
                                
1032
                                AddWithValue(cmd, "@FlowDirection", string.IsNullOrEmpty(row["FlowDirection"].ToString()) ? "" : row["FlowDirection"].ToString());
1033
                                connection.ExecuteNonQuery(cmd, txn);
1034
                            }
1035

    
1036
                            //Equipment
1037
                            query = $"DELETE FROM {PSN_EQUIPMENT}";
1038
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1039
                            foreach (DataRow row in item.Equipment.Rows)
1040
                            {
1041
                                query = $"INSERT INTO {PSN_EQUIPMENT} VALUES (@OID, @ITEMTAG, @XCOORDS, @YCOORDS)";
1042
                                var cmd = connection.GetSqlStringCommand(query);
1043
                                AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString());
1044
                                AddWithValue(cmd, "@ITEMTAG", string.IsNullOrEmpty(row["ITEMTAG"].ToString()) ? "" : row["ITEMTAG"].ToString());
1045

    
1046
                                if (string.IsNullOrEmpty(row["XCOORDS"].ToString()))
1047
                                    AddWithValue(cmd, "@XCOORDS", DBNull.Value);
1048
                                else
1049
                                    AddWithValue(cmd, "@XCOORDS", row["XCOORDS"].ToString());
1050

    
1051
                                if (string.IsNullOrEmpty(row["YCOORDS"].ToString()))
1052
                                    AddWithValue(cmd, "@YCOORDS", DBNull.Value);
1053
                                else
1054
                                    AddWithValue(cmd, "@YCOORDS", row["YCOORDS"].ToString());
1055

    
1056
                                connection.ExecuteNonQuery(cmd, txn);
1057
                            }
1058

    
1059
                            // TopologySet
1060
                            query = $"DELETE FROM {PSN_TOPOLOGYSET}";
1061
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1062
                            foreach (DataRow row in item.TopologySet.Rows)
1063
                            {
1064
                                query = $"INSERT INTO {PSN_TOPOLOGYSET} VALUES (@OID, @Type, @SubType, @HeadItemTag, @TailItemTag, @HeadItemSPID, @TailItemSPID)";
1065
                                var cmd = connection.GetSqlStringCommand(query);
1066
                                AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString());
1067
                                AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString());
1068
                                AddWithValue(cmd, "@SubType", string.IsNullOrEmpty(row["SubType"].ToString()) ? "" : row["SubType"].ToString());
1069
                                AddWithValue(cmd, "@HeadItemTag", string.IsNullOrEmpty(row["HeadItemTag"].ToString()) ? "" : row["HeadItemTag"].ToString());
1070
                                AddWithValue(cmd, "@TailItemTag", string.IsNullOrEmpty(row["TailItemTag"].ToString()) ? "" : row["TailItemTag"].ToString());
1071
                                AddWithValue(cmd, "@HeadItemSPID", string.IsNullOrEmpty(row["HeadItemSPID"].ToString()) ? "" : row["HeadItemSPID"].ToString());
1072
                                AddWithValue(cmd, "@TailItemSPID", string.IsNullOrEmpty(row["TailItemSPID"].ToString()) ? "" : row["TailItemSPID"].ToString());
1073
                                connection.ExecuteNonQuery(cmd, txn);
1074
                            }
1075

    
1076
                            // PSN
1077
                            query = $"DELETE FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", item.Revision)}'";
1078
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1079
                            foreach (DataRow row in item.PipeSystemNetwork.Rows)
1080
                            {
1081
                                query = $"INSERT INTO {PSN_PIPESYSTEMNETWORK} " +
1082
                                    $"(OID, Type, OrderNumber, Pipeline_OID, FROM_DATA, TO_DATA, TopologySet_OID_Key, PSNRevisionNumber, PBS, Drawings, IsValid, Status, IncludingVirtualData, PSNAccuracy) VALUES " +
1083
                                    $"(@OID, @Type, @OrderNumber, @Pipeline_OID, @FROM_DATA, @TO_DATA, @TopologySet_OID_Key, @PSNRevisionNumber,  @PBS, @Drawings, @IsValid, @Status, @IncludingVirtualData, @PSNAccuracy)";
1084
                                var cmd = connection.GetSqlStringCommand(query);
1085
                                AddWithValue(cmd, "@OID", string.IsNullOrEmpty(row["OID"].ToString()) ? "" : row["OID"].ToString());
1086
                                AddWithValue(cmd, "@Type", string.IsNullOrEmpty(row["Type"].ToString()) ? "" : row["Type"].ToString());
1087
                                AddWithValue(cmd, "@OrderNumber", string.IsNullOrEmpty(row["OrderNumber"].ToString()) ? "" : row["OrderNumber"].ToString());
1088
                                AddWithValue(cmd, "@Pipeline_OID", string.IsNullOrEmpty(row["Pipeline_OID"].ToString()) ? "" : row["Pipeline_OID"].ToString());
1089
                                AddWithValue(cmd, "@FROM_DATA", string.IsNullOrEmpty(row["FROM_DATA"].ToString()) ? "" : row["FROM_DATA"].ToString());
1090
                                AddWithValue(cmd, "@TO_DATA", string.IsNullOrEmpty(row["TO_DATA"].ToString()) ? "" : row["TO_DATA"].ToString());
1091
                                AddWithValue(cmd, "@TopologySet_OID_Key", string.IsNullOrEmpty(row["TopologySet_OID_Key"].ToString()) ? "" : row["TopologySet_OID_Key"].ToString());
1092
                                AddWithValue(cmd, "@PSNRevisionNumber", string.IsNullOrEmpty(row["PSNRevisionNumber"].ToString()) ? "" : row["PSNRevisionNumber"].ToString());
1093

    
1094
                                int IsValid = 0;
1095
                                if (row["IsValid"].ToString() == string.Empty || row["IsValid"].ToString() == "OK")
1096
                                    IsValid = 0;
1097
                                else if (row["IsValid"].ToString() == "InValid")
1098
                                    IsValid = 1;
1099
                                else if (row["IsValid"].ToString() == "Error")
1100
                                    IsValid = -1;
1101

    
1102
                                AddWithValue(cmd, "@IsValid", IsValid);
1103
                                AddWithValue(cmd, "@Status", string.IsNullOrEmpty(row["Status"].ToString()) ? "" : row["Status"].ToString());
1104

    
1105
                                AddWithValue(cmd, "@PBS", string.IsNullOrEmpty(row["PBS"].ToString()) ? "" : row["PBS"].ToString());
1106
                                AddWithValue(cmd, "@Drawings", string.IsNullOrEmpty(row["Drawings"].ToString()) ? "" : row["Drawings"].ToString());
1107

    
1108
                                AddWithValue(cmd, "@IncludingVirtualData", string.IsNullOrEmpty(row["IncludingVirtualData"].ToString()) ? "" : row["IncludingVirtualData"].ToString());
1109
                                if (string.IsNullOrEmpty(row["PSNAccuracy"].ToString()))
1110
                                    AddWithValue(cmd, "@PSNAccuracy", DBNull.Value);
1111
                                else
1112
                                    AddWithValue(cmd, "@PSNAccuracy", row["PSNAccuracy"].ToString());
1113

    
1114
                                connection.ExecuteNonQuery(cmd, txn);
1115
                            }
1116

    
1117
                            //Pipeline
1118
                            query = $"DELETE FROM {PSN_PIPELINE}";
1119
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1120
                            foreach (DataRow row in item.PipeLine.Rows)
1121
                            {
1122
                                query = $"INSERT INTO {PSN_PIPELINE} VALUES (@OID, @PipeSystem_OID, @FLUID, @PMC, @SEQNUMBER, @INSULATION, @FROM_DATA, @TO_DATA, @Unit)";
1123
                                var cmd = connection.GetSqlStringCommand(query);
1124
                                AddWithValue(cmd, "@OID", row["OID"].ToString());
1125
                                AddWithValue(cmd, "@PipeSystem_OID", row["PipeSystem_OID"].ToString());
1126
                                AddWithValue(cmd, "@FLUID", row["FLUID"].ToString());
1127
                                AddWithValue(cmd, "@PMC", row["PMC"].ToString());
1128
                                AddWithValue(cmd, "@SEQNUMBER", row["SEQNUMBER"].ToString());
1129
                                AddWithValue(cmd, "@INSULATION", row["INSULATION"].ToString());
1130
                                AddWithValue(cmd, "@FROM_DATA", row["FROM_DATA"].ToString());
1131
                                AddWithValue(cmd, "@TO_DATA", row["TO_DATA"].ToString());
1132
                                AddWithValue(cmd, "@Unit", row["Unit"].ToString());
1133
                                connection.ExecuteNonQuery(cmd, txn);
1134
                            }
1135

    
1136
                            txn.Commit();
1137
                        }
1138
                        catch (Exception ex)
1139
                        {
1140
                            txn.Rollback();
1141
                            result = false;
1142
                        }
1143
                    }
1144
                }
1145
                catch (Exception ex)
1146
                {
1147
                    System.Windows.Forms.MessageBox.Show(ex.Message);
1148
                    result = false;
1149
                }
1150
            }
1151

    
1152
            return result;
1153
        }
1154

    
1155
        public static bool SavePSNFluidCode(DataTable dt)
1156
        {
1157
            ID2Info id2Info = ID2Info.GetInstance();
1158

    
1159
            bool result = true;
1160
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1161
            {
1162
                try
1163
                {
1164
                    using (var txn = connection.BeginTransaction())
1165
                    {
1166
                        try
1167
                        {
1168
                            var query = $"DELETE FROM {PSN_FLUIDCODE}";
1169
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1170

    
1171
                            foreach (DataRow row in dt.Rows)
1172
                            {
1173
                                query = $"INSERT INTO {PSN_FLUIDCODE} VALUES (@UID, @Code, @Description, @Condition, @Remarks, @GroundLevel)";
1174
                                var cmd = connection.GetSqlStringCommand(query);
1175
                                cmd.Parameters.Clear();
1176

    
1177
                                {
1178
                                    var param = cmd.CreateParameter();
1179
                                    param.ParameterName = "@UID";
1180
                                    param.Value = row["UID"].ToString();
1181
                                    cmd.Parameters.Add(param);
1182
                                }
1183

    
1184
                                {
1185
                                    var param = cmd.CreateParameter();
1186
                                    param.ParameterName = "@Code";
1187
                                    param.Value = row["Code"].ToString();
1188
                                    cmd.Parameters.Add(param);
1189
                                }
1190

    
1191
                                {
1192
                                    var param = cmd.CreateParameter();
1193
                                    param.ParameterName = "@Description";
1194
                                    param.Value = row["Description"].ToString();
1195
                                    cmd.Parameters.Add(param);
1196
                                }
1197

    
1198
                                {
1199
                                    var param = cmd.CreateParameter();
1200
                                    param.ParameterName = "@Condition";
1201
                                    param.Value = row["Condition"].ToString();
1202
                                    cmd.Parameters.Add(param);
1203
                                }
1204

    
1205
                                {
1206
                                    var param = cmd.CreateParameter();
1207
                                    param.ParameterName = "@Remarks";
1208
                                    param.Value = row["Remarks"].ToString();
1209
                                    cmd.Parameters.Add(param);
1210
                                }
1211

    
1212
                                {
1213
                                    var param = cmd.CreateParameter();
1214
                                    param.ParameterName = "@GroundLevel";
1215
                                    param.Value = row["GroundLevel"].ToString();
1216
                                    cmd.Parameters.Add(param);
1217
                                }
1218

    
1219
                                connection.ExecuteNonQuery(cmd, txn);
1220
                            }
1221
                            txn.Commit();
1222
                        }
1223
                        catch (Exception ex)
1224
                        {
1225
                            txn.Rollback();
1226
                            result = false;
1227
                        }
1228
                    }
1229
                }
1230
                catch (Exception ex)
1231
                {
1232
                    System.Windows.Forms.MessageBox.Show(ex.Message);
1233
                    result = false;
1234
                }
1235
            }
1236

    
1237
            return result;
1238
        }
1239

    
1240
        public static DataTable SelectPSNFluidCode()
1241
        {
1242
            DataTable dt = null;
1243
            ID2Info id2Info = ID2Info.GetInstance();
1244

    
1245
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1246
            {
1247
                try
1248
                {
1249
                    var query = $"SELECT * FROM {PSN_FLUIDCODE}";
1250
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1251
                    {
1252
                        dt = ds.Tables[0].Copy();
1253
                    }
1254
                }
1255
                catch (Exception ex)
1256
                {
1257
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1258
                }
1259
            }
1260

    
1261
            return dt;
1262
        }
1263

    
1264
        public static bool SavePSNPMC(DataTable dt)
1265
        {
1266
            ID2Info id2Info = ID2Info.GetInstance();
1267

    
1268
            bool result = true;
1269
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1270
            {
1271
                try
1272
                {
1273
                    using (var txn = connection.BeginTransaction())
1274
                    {
1275
                        try
1276
                        {
1277
                            var query = $"DELETE FROM {PSN_PIPINGMATLCLASS}";
1278
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1279

    
1280
                            foreach (DataRow row in dt.Rows)
1281
                            {
1282
                                query = $"INSERT INTO {PSN_PIPINGMATLCLASS} VALUES (@UID, @Priority, @Code, @Description, @Condition, @Remarks, @GroundLevel)";
1283
                                var cmd = connection.GetSqlStringCommand(query);
1284
                                cmd.Parameters.Clear();
1285

    
1286
                                {
1287
                                    var param = cmd.CreateParameter();
1288
                                    param.ParameterName = "@UID";
1289
                                    param.Value = row["UID"].ToString();
1290
                                    cmd.Parameters.Add(param);
1291
                                }
1292

    
1293
                                {
1294
                                    var param = cmd.CreateParameter();
1295
                                    param.ParameterName = "@Priority";
1296
                                    param.Value = row["Priority"].ToString();
1297
                                    cmd.Parameters.Add(param);
1298
                                }
1299

    
1300
                                {
1301
                                    var param = cmd.CreateParameter();
1302
                                    param.ParameterName = "@Code";
1303
                                    param.Value = row["Code"].ToString();
1304
                                    cmd.Parameters.Add(param);
1305
                                }
1306

    
1307
                                {
1308
                                    var param = cmd.CreateParameter();
1309
                                    param.ParameterName = "@Description";
1310
                                    param.Value = row["Description"].ToString();
1311
                                    cmd.Parameters.Add(param);
1312
                                }
1313

    
1314
                                {
1315
                                    var param = cmd.CreateParameter();
1316
                                    param.ParameterName = "@Condition";
1317
                                    param.Value = row["Condition"].ToString();
1318
                                    cmd.Parameters.Add(param);
1319
                                }
1320

    
1321
                                {
1322
                                    var param = cmd.CreateParameter();
1323
                                    param.ParameterName = "@Remarks";
1324
                                    param.Value = row["Remarks"].ToString();
1325
                                    cmd.Parameters.Add(param);
1326
                                }
1327

    
1328
                                {
1329
                                    var param = cmd.CreateParameter();
1330
                                    param.ParameterName = "@GroundLevel";
1331
                                    param.Value = row["GroundLevel"].ToString();
1332
                                    cmd.Parameters.Add(param);
1333
                                }
1334

    
1335
                                connection.ExecuteNonQuery(cmd, txn);
1336
                            }
1337

    
1338
                            txn.Commit();
1339
                        }
1340
                        catch (Exception ex)
1341
                        {
1342
                            txn.Rollback();
1343
                            result = false;
1344
                        }
1345
                    }
1346
                }
1347
                catch (Exception ex)
1348
                {
1349
                    System.Windows.Forms.MessageBox.Show(ex.Message);
1350
                    result = false;
1351
                }
1352
            }
1353

    
1354
            return result;
1355
        }
1356

    
1357
        public static PSN GetDBPSN()
1358
        {
1359
            PSN result = new PSN();
1360
            ID2Info id2Info = ID2Info.GetInstance();
1361

    
1362
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1363
            {
1364
                try
1365
                {
1366
                    //var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'";
1367
                    //using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1368
                    //{
1369
                    //    result.PipeSystemNetwork = ds.Tables[0].Clone();
1370
                    //    result.PipeSystemNetwork.Columns["IsValid"].DataType = typeof(string);
1371

    
1372
                    //    foreach (DataRow row in ds.Tables[0].Rows)
1373
                    //    {
1374
                    //        DataRow newRow = result.PipeSystemNetwork.NewRow();
1375
                    //        newRow["OID"] = row["OID"].ToString();
1376
                    //        newRow["Type"] = row["Type"].ToString();
1377
                    //        newRow["OrderNumber"] = row["OrderNumber"].ToString();
1378
                    //        newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString();
1379
                    //        newRow["FROM_DATA"] = row["FROM_DATA"].ToString();
1380
                    //        newRow["TO_DATA"] = row["TO_DATA"].ToString();
1381
                    //        newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString();
1382
                    //        newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString();
1383
                           
1384
                    //        string IsValid = string.Empty;
1385

    
1386
                    //        if (Convert.ToInt32(row["IsValid"].ToString()) == 0)
1387
                    //            IsValid = string.Empty;//"OK";
1388
                    //        else if (Convert.ToInt32(row["IsValid"].ToString()) == 1)
1389
                    //            IsValid = "InValid";
1390
                    //        else if (Convert.ToInt32(row["IsValid"].ToString()) == -1)
1391
                    //            IsValid = "Error";
1392

    
1393
                    //        newRow["IsValid"] = IsValid;
1394

    
1395
                    //        newRow["Status"] = row["Status"].ToString();
1396
                    //        newRow["PBS"] = row["PBS"].ToString();
1397
                    //        newRow["Drawings"] = row["Drawings"].ToString();
1398

    
1399
                    //        newRow["IncludingVirtualData"] = row["IncludingVirtualData"].ToString();
1400
                    //        newRow["PSNAccuracy"] = row["PSNAccuracy"].ToString();
1401

    
1402
                    //        result.PipeSystemNetwork.Rows.Add(newRow);
1403
                    //    }
1404
                    //}
1405

    
1406
                    var query = $"SELECT * FROM {PSN_EQUIPMENT}";
1407
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1408
                    {
1409
                        result.Equipment = ds.Tables[0].Copy();
1410
                    }
1411

    
1412
                    query = $"SELECT * FROM {PSN_NOZZLE}";
1413
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1414
                    {
1415
                        result.Nozzle = ds.Tables[0].Copy();
1416
                    }
1417

    
1418
                    query = $"SELECT * FROM {PSN_PATHITEMS}";
1419
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1420
                    {
1421
                        result.PathItems = ds.Tables[0].Copy();
1422
                    }
1423

    
1424
                    query = $"SELECT * FROM {PSN_SEQUENCEDATA}";
1425
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1426
                    {
1427
                        result.SequenceData = ds.Tables[0].Copy();
1428
                    }
1429

    
1430
                    query = $"SELECT * FROM {PSN_TOPOLOGYSET}";
1431
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1432
                    {
1433
                        result.TopologySet = ds.Tables[0].Copy();
1434
                    }
1435

    
1436
                    query = $"SELECT * FROM {PSN_PIPELINE}";
1437
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1438
                    {
1439
                        result.PipeLine = ds.Tables[0].Copy();
1440
                    }                    
1441

    
1442
                    result.Revision = GetRevision();
1443
                }
1444
                catch (Exception ex)
1445
                {
1446
                    System.Windows.Forms.MessageBox.Show(ex.Message);
1447
                    result = null;
1448
                }
1449
            }
1450

    
1451
            return result;
1452
        }
1453

    
1454
        public static int GetRevision()
1455
        {
1456
            int result = 0;
1457
            ID2Info id2Info = ID2Info.GetInstance();
1458

    
1459
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1460
            {
1461
                try
1462
                {
1463
                    var query = $"SELECT DISTINCT PSNRevisionNumber FROM {PSN_PIPESYSTEMNETWORK};";
1464
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1465
                    {
1466
                        foreach (DataRow row in ds.Tables[0].Rows)
1467
                        {
1468
                            string value = row["PSNRevisionNumber"].ToString();
1469
                            if (value.StartsWith("V"))
1470
                                value = value.Remove(0, 1);
1471
                            int revisionNumber = Convert.ToInt32(value);
1472
                            if (result < revisionNumber)
1473
                                result = revisionNumber;
1474
                        }
1475
                    }
1476
                }
1477
                catch (Exception ex)
1478
                {
1479
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1480
                    result = -1;
1481
                }
1482
            }
1483

    
1484
            return result;
1485
        }
1486

    
1487
        public static DataTable GetPathItem()
1488
        {
1489
            DataTable dt = null;
1490

    
1491
            ID2Info id2Info = ID2Info.GetInstance();
1492
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1493
            {
1494
                try
1495
                {
1496
                    var query = $"SELECT * FROM {PSN_PATHITEMS}";
1497
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1498
                    {
1499
                        dt = ds.Tables[0].Copy();
1500
                    }
1501
                }
1502
                catch (Exception ex)
1503
                {
1504
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1505
                }
1506
            }
1507

    
1508
            return dt;
1509
        }
1510

    
1511
        public static DataTable GetTopologySet()
1512
        {
1513
            DataTable dt = null;
1514

    
1515
            ID2Info id2Info = ID2Info.GetInstance();
1516
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1517
            {
1518
                try
1519
                {
1520
                    var query = $"SELECT * FROM {PSN_TOPOLOGYSET}";
1521
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1522
                    {
1523
                        dt = ds.Tables[0].Clone();
1524
                        foreach (DataRow row in ds.Tables[0].Rows)
1525
                        {
1526
                            DataRow newRow = dt.NewRow();
1527
                            newRow["OID"] = row["OID"].ToString();
1528
                            newRow["Type"] = row["Type"].ToString();
1529
                            newRow["SubType"] = row["SubType"].ToString();
1530
                            newRow["HeadItemTag"] = row["HeadItemTag"].ToString();
1531
                            newRow["TailItemTag"] = row["TailItemTag"].ToString();
1532
                            newRow["HeadItemSPID"] = row["HeadItemSPID"].ToString();
1533
                            newRow["TailItemSPID"] = row["TailItemSPID"].ToString();
1534
                            dt.Rows.Add(newRow);
1535
                        }
1536
                    }
1537
                }
1538
                catch (Exception ex)
1539
                {
1540
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1541
                }
1542
            }
1543

    
1544
            return dt;
1545
        }
1546

    
1547
        public static DataTable GetPipeSystemNetwork()
1548
        {
1549
            DataTable dt = null;
1550

    
1551
            ID2Info id2Info = ID2Info.GetInstance();
1552
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1553
            {
1554
                try
1555
                {
1556
                    var query = $"SELECT * FROM {PSN_PIPESYSTEMNETWORK} WHERE PSNRevisionNumber = '{string.Format("V{0:D4}", GetRevision())}'";
1557
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1558
                    {
1559
                        dt = ds.Tables[0].Clone();
1560
                        dt.Columns["IsValid"].DataType = typeof(string);
1561
                        foreach (DataRow row in ds.Tables[0].Rows)
1562
                        {
1563
                            DataRow newRow = dt.NewRow();
1564
                            newRow["OID"] = row["OID"].ToString();
1565
                            newRow["Type"] = row["Type"].ToString();
1566
                            newRow["OrderNumber"] = row["OrderNumber"].ToString();
1567
                            newRow["Pipeline_OID"] = row["Pipeline_OID"].ToString();
1568
                            newRow["FROM_DATA"] = row["FROM_DATA"].ToString();
1569
                            newRow["TO_DATA"] = row["TO_DATA"].ToString();
1570
                            newRow["TopologySet_OID_Key"] = row["TopologySet_OID_Key"].ToString();
1571
                            newRow["PSNRevisionNumber"] = row["PSNRevisionNumber"].ToString();
1572

    
1573
                            string IsValid = string.Empty;
1574

    
1575
                            if (Convert.ToInt32(row["IsValid"].ToString()) == 0)
1576
                                IsValid = string.Empty;//"OK";
1577
                            else if (Convert.ToInt32(row["IsValid"].ToString()) == 1)
1578
                                IsValid = "InValid";
1579
                            else if (Convert.ToInt32(row["IsValid"].ToString()) == -1)
1580
                                IsValid = "Error";
1581

    
1582
                            newRow["IsValid"] = IsValid;
1583
                            newRow["Status"] = row["Status"].ToString();
1584

    
1585
                            newRow["PBS"] = row["PBS"].ToString();
1586
                            newRow["Drawings"] = row["Drawings"].ToString();
1587
                            
1588
                            newRow["IncludingVirtualData"] = row["IncludingVirtualData"].ToString();
1589
                            newRow["PSNAccuracy"] = row["PSNAccuracy"].ToString();                                           
1590
                                                        
1591
                            dt.Rows.Add(newRow);
1592
                        }
1593
                    }
1594
                }
1595
                catch (Exception ex)
1596
                {
1597
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1598
                }
1599
            }
1600

    
1601
            return dt;
1602
        }
1603

    
1604
        public static DataTable GetSequenceData()
1605
        {
1606
            DataTable dt = null;
1607

    
1608
            ID2Info id2Info = ID2Info.GetInstance();
1609
            using (IAbstractDatabase connection = id2Info.CreateConnection(ID2DB_Type.SQLite))
1610
            {
1611
                try
1612
                {
1613
                    var query = $"SELECT * FROM {PSN_SEQUENCEDATA}";
1614
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1615
                    {
1616
                        dt = ds.Tables[0].Copy();
1617
                    }
1618
                }
1619
                catch (Exception ex)
1620
                {
1621
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1622
                }
1623
            }
1624

    
1625
            return dt;
1626
        }
1627
    }
1628
}
클립보드 이미지 추가 (최대 크기: 500 MB)