프로젝트

일반

사용자정보

개정판 cf924377

IDcf924377ba88bc0a7a0405658288932458d34fa6
상위 d5ec4d0f
하위 b265df51

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #000 : Label Symbol LEADERLINE 설정/ Symbol Mapping Table Column추가로 인하여 접속시 확인후 Table Column추가

Change-Id: I7e1fc5c669039fc21ceb8a40578f05493bfc6da6

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
216 216

  
217 217
                                if (!string.IsNullOrEmpty(sRep))
218 218
                                {
219
                                    bool leaderLine = false;
220
                                    SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == item.DBUID);
221
                                    if (symbolMapping != null)
222
                                        leaderLine = symbolMapping.LEADERLINE;
223

  
219 224
                                    LMSymbol _TargetItem = dataSource.GetSymbol(sRep);
220
                                    LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(item.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: true);
225
                                    LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(item.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine);
221 226
                                    LMModelItem _LMModelItem = _TargetItem.ModelItemObject;
222 227
                                    LMAAttributes _Attributes = _LMModelItem.Attributes;
223 228

  
......
247 252
                                        }
248 253
                                    }
249 254

  
255
                                    //Leader 선 센터로
250 256
                                    string OID = _LMLabelPresist.get_GraphicOID();
251 257
                                    DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject;
252 258
                                    if (dependency != null)
DTI_PID/SPPIDConverter/ConverterForm.cs
235 235
                        UID = row["UID"] == null ? "" : row["UID"].ToString(),
236 236
                        SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(),
237 237
                        SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(),
238
                        LEADERLINE = DBNull.Value.Equals(row["LEADERLINE"]) ? false : (bool)row["LEADERLINE"]
238 239
                    });
239 240
                }
240 241

  
DTI_PID/SPPIDConverter/DB/Project_DB.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Globalization;
7
using System.Data.SQLite;
8
using System.Data;
9

  
10
namespace Converter.BaseModel
11
{
12
    public class Project_DB
13
    {
14
        const string SPPID_DB_INFO_TABLE = "T_SPPID_CONNECTION_INFO";
15
        const string SPPID_SYMBOL_MAPPING_TABLE = "T_SPPID_SYMBOL_MAPPING";
16
        const string SPPID_ATTRIBUTE_MAPPING_TABLE = "T_SPPID_ATTRIBUTE_MAPPING";
17
        const string SPPID_ETC_SETTING_TABLE = "T_SPPID_ETC_SETTING_TABLE";
18
        const string SPPID_LABEL_INFO_TABLE = "T_SPPID_LABEL_INFO";
19

  
20
        const string LineProperties_TABLE = "LineProperties";
21
        const string LineTypes_TABLE = "LineTypes";
22
        const string SymbolType_TABLE = "SymbolType";
23
        const string SymbolAttribute_TABLE = "SymbolAttribute";
24
        const string Symbol_TABLE = "Symbol";
25

  
26
        public static bool ConnTestAndCreateTable()
27
        {
28
            bool result = false;
29
            Project_Info projectInfo = Project_Info.GetInstance();
30
            SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, @"Data Source = {0}", projectInfo.DBFilePath));
31
            try
32
            {
33
                connection.Open();
34
                if (connection.State == ConnectionState.Open)
35
                {
36
                    CreateTable(connection);
37
                    result = true;
38
                }
39
                connection.Close();
40
            }
41
            catch (Exception ex)
42
            {
43

  
44
            }
45
            finally
46
            {
47
                connection.Dispose();
48
            }
49

  
50
            return result;
51
        }
52

  
53
        public static bool SaveSPPID_DB_INFO(string jsonString)
54
        {
55
            Project_Info projectInfo = Project_Info.GetInstance();
56
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
57
            {
58

  
59
                try
60
                {
61
                    connection.Open();
62
                    using (SQLiteCommand cmd = connection.CreateCommand())
63
                    {
64
                        cmd.CommandText = string.Format("DELETE FROM {0}", SPPID_DB_INFO_TABLE);
65
                        cmd.ExecuteNonQuery();
66

  
67
                        cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@jsonString)", SPPID_DB_INFO_TABLE);
68
                        cmd.Parameters.AddWithValue("@jsonString", jsonString);
69
                        cmd.ExecuteNonQuery();
70
                    }
71
                    connection.Close();
72
                }
73
                catch (Exception ex)
74
                {
75
                    return false;
76
                }
77
                finally
78
                {
79
                    connection.Dispose();
80
                }
81
            }
82

  
83
            return true;
84
        }
85

  
86
        public static DataTable SelectSPPID_DB_INFO()
87
        {
88
            DataTable dt = new DataTable();
89
            Project_Info projectInfo = Project_Info.GetInstance();
90
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
91
            {
92
                try
93
                {
94
                    connection.Open();
95
                    using (SQLiteCommand cmd = connection.CreateCommand())
96
                    {
97
                        cmd.CommandText = string.Format("SELECT * FROM {0}", SPPID_DB_INFO_TABLE);
98
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
99
                            dt.Load(dr);
100
                    }
101
                    connection.Close();
102
                }
103
                catch (Exception ex)
104
                {
105

  
106
                }
107
                finally
108
                {
109
                    connection.Dispose();
110
                }
111
            }
112

  
113
            return dt;
114
        }
115

  
116
        public static bool SaveETCSetting(string jsonString)
117
        {
118
            Project_Info projectInfo = Project_Info.GetInstance();
119
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
120
            {
121

  
122
                try
123
                {
124
                    connection.Open();
125
                    using (SQLiteCommand cmd = connection.CreateCommand())
126
                    {
127
                        cmd.CommandText = string.Format("DELETE FROM {0}", SPPID_ETC_SETTING_TABLE);
128
                        cmd.ExecuteNonQuery();
129

  
130
                        cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@jsonString)", SPPID_ETC_SETTING_TABLE);
131
                        cmd.Parameters.AddWithValue("@jsonString", jsonString);
132
                        cmd.ExecuteNonQuery();
133
                    }
134
                    connection.Close();
135
                }
136
                catch (Exception ex)
137
                {
138
                    return false;
139
                }
140
                finally
141
                {
142
                    connection.Dispose();
143
                }
144
            }
145

  
146
            return true;
147
        }
148

  
149
        public static DataTable SelectETCSetting()
150
        {
151
            DataTable dt = new DataTable();
152
            Project_Info projectInfo = Project_Info.GetInstance();
153
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
154
            {
155
                try
156
                {
157
                    connection.Open();
158
                    using (SQLiteCommand cmd = connection.CreateCommand())
159
                    {
160
                        cmd.CommandText = string.Format("SELECT * FROM {0}", SPPID_ETC_SETTING_TABLE);
161
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
162
                            dt.Load(dr);
163
                    }
164
                    connection.Close();
165
                }
166
                catch (Exception ex)
167
                {
168

  
169
                }
170
                finally
171
                {
172
                    connection.Dispose();
173
                }
174
            }
175

  
176
            return dt;
177
        }
178

  
179
        private static void CreateTable(SQLiteConnection connection)
180
        {
181
            using (SQLiteCommand cmd = connection.CreateCommand())
182
            {
183
                cmd.CommandText = "SELECT NAME FROM sqlite_master WHERE type='table'";
184
                using (SQLiteDataReader dr = cmd.ExecuteReader())
185
                using (DataTable dt = new DataTable())
186
                {
187
                    dt.Load(dr);
188

  
189
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_DB_INFO_TABLE)).Length == 0)
190
                    {
191
                        cmd.CommandText = string.Format("CREATE TABLE {0} (JsonString TEXT)", SPPID_DB_INFO_TABLE);
192
                        cmd.ExecuteNonQuery();
193
                    }
194
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_ETC_SETTING_TABLE)).Length == 0)
195
                    {
196
                        cmd.CommandText = string.Format("CREATE TABLE {0} (JsonString TEXT)", SPPID_ETC_SETTING_TABLE);
197
                        cmd.ExecuteNonQuery();
198
                    }
199
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_SYMBOL_MAPPING_TABLE)).Length == 0)
200
                    {
201
                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, NAME TEXT, SPPID_SYMBOL_PATH TEXT, LEADERLINE BOOLEAN)", SPPID_SYMBOL_MAPPING_TABLE);
202
                        cmd.ExecuteNonQuery();
203
                    }
204
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_ATTRIBUTE_MAPPING_TABLE)).Length == 0)
205
                    {
206
                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, SPPID_ATTRIBUTE TEXT)", SPPID_ATTRIBUTE_MAPPING_TABLE);
207
                        cmd.ExecuteNonQuery();
208
                    }
209
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_LABEL_INFO_TABLE)).Length == 0)
210
                    {
211
                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, LOCATION INT DEFAULT 0, LEADERLINE BOOLEAN)", SPPID_LABEL_INFO_TABLE);
212
                        cmd.ExecuteNonQuery();
213
                    }
214
                }
215

  
216
                #region Check Column 업데이트시 예비용
217
                cmd.CommandText = string.Format("SELECT * FROM {0}", SPPID_SYMBOL_MAPPING_TABLE);
218
                using (SQLiteDataReader dr = cmd.ExecuteReader())
219
                using (DataTable dt = new DataTable())
220
                {
221
                    dt.Load(dr);
222
                    if (!dt.Columns.Contains("LEADERLINE"))
223
                    {
224
                        cmd.CommandText = string.Format("ALTER TABLE {0} ADD COLUMN LEADERLINE BOOLEAN", SPPID_SYMBOL_MAPPING_TABLE);
225
                        cmd.ExecuteNonQuery();
226
                    }
227
                }
228
                #endregion
229
            }
230
        }
231

  
232
        public static DataTable SelectProjectSymbol()
233
        {
234
            DataTable dt = new DataTable();
235
            Project_Info projectInfo = Project_Info.GetInstance();
236
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
237
            {
238
                try
239
                {
240
                    connection.Open();
241
                    using (SQLiteCommand cmd = connection.CreateCommand())
242
                    {
243
                        cmd.CommandText = string.Format(@"
244
                            SELECT s.UID, s.Name, st.Type, sp.SPPID_SYMBOL_PATH, sp.LEADERLINE FROM {1} as st, {0} as s 
245
                                LEFT OUTER JOIN {2} as sp 
246
                                    ON s.UID = SP.UID 
247
                            WHERE s.SymbolType_UID = st.UID 
248
                            ORDER BY st.TYPE ASC;", Symbol_TABLE, SymbolType_TABLE, SPPID_SYMBOL_MAPPING_TABLE);
249
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
250
                            dt.Load(dr);
251

  
252
                        DataTable dtClone = dt.Clone();
253
                        dtClone.Columns["UID"].DataType = typeof(string);
254
                        foreach (DataRow row in dt.Rows)
255
                        {
256
                            dtClone.ImportRow(row);
257
                        }
258
                        dt.Dispose();
259
                        dt = dtClone;
260
                    }
261
                    connection.Close();
262
                }
263
                catch (Exception ex)
264
                {
265

  
266
                }
267
                finally
268
                {
269
                    connection.Dispose();
270
                }
271
            }
272

  
273
            return dt;
274
        }
275

  
276
        public static DataTable SelectProjectChildSymbol()
277
        {
278
            DataTable result = new DataTable();
279
            result.Columns.Add("UID");
280
            result.Columns.Add("Name");
281
            result.Columns.Add("Type");
282
            result.Columns.Add("SPPID_SYMBOL_PATH");
283
            
284
            Project_Info projectInfo = Project_Info.GetInstance();
285
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
286
            using (DataTable dt = new DataTable())
287
            {
288
                try
289
                {
290
                    connection.Open();
291
                    using (SQLiteCommand cmd = connection.CreateCommand())
292
                    {
293
                        cmd.CommandText = string.Format(@"
294
                            SELECT AdditionalSymbol FROM Symbol");
295
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
296
                            dt.Load(dr);
297
                        List<string> childList = new List<string>();
298
                        foreach (DataRow row in dt.Rows)
299
                        {
300
                            if (!string.IsNullOrEmpty((string)row["AdditionalSymbol"]))
301
                            {
302
                                string[] array = row["AdditionalSymbol"].ToString().Split(new char[] { '/' });
303
                                foreach (var childString in array)
304
                                {
305
                                    childList.Add(childString.Split(new char[] { ',' })[2]);
306
                                }
307
                            }
308

  
309
                        }
310

  
311
                        dt.Clear();
312
                        cmd.Reset();
313
                        cmd.CommandText = string.Format(@"
314
                            SELECT * FROM {0}", SPPID_SYMBOL_MAPPING_TABLE);
315
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
316
                            dt.Load(dr);
317

  
318
                        childList = childList.Distinct().ToList();
319
                        foreach (var child in childList)
320
                        {
321
                            string mappingPath = string.Empty;
322
                            DataRow[] rows = dt.Select(string.Format("UID = '{0}'", child));
323
                            if (rows.Length == 1)
324
                                mappingPath = !DBNull.Value.Equals(rows[0]["SPPID_SYMBOL_PATH"]) ? (string)rows[0]["SPPID_SYMBOL_PATH"] : null;
325

  
326
                            DataRow newRow = result.NewRow();
327
                            newRow["UID"] = child;
328
                            newRow["Name"] = child;
329
                            newRow["Type"] = "Child Symbol";
330
                            newRow["SPPID_SYMBOL_PATH"] = mappingPath;
331
                            result.Rows.Add(newRow);
332
                        }
333
                    }
334
                    connection.Close();
335
                }
336
                catch (Exception ex)
337
                {
338

  
339
                }
340
                finally
341
                {
342
                    connection.Dispose();
343
                }
344
            }
345

  
346
            return result;
347
        }
348

  
349
        public static DataTable SelectProjectLine()
350
        {
351
            DataTable dt = new DataTable();
352
            Project_Info projectInfo = Project_Info.GetInstance();
353
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
354
            {
355
                try
356
                {
357
                    connection.Open();
358
                    using (SQLiteCommand cmd = connection.CreateCommand())
359
                    {
360
                        cmd.CommandText = string.Format(@"
361
                            SELECT l.UID, l.Name, sp.SPPID_SYMBOL_PATH FROM {0} as l 
362
                                LEFT OUTER JOIN {1} as sp 
363
                                    ON l.UID = SP.UID ;", LineTypes_TABLE, SPPID_SYMBOL_MAPPING_TABLE);
364
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
365
                            dt.Load(dr);
366
                    }
367
                    connection.Close();
368
                }
369
                catch (Exception ex)
370
                {
371

  
372
                }
373
                finally
374
                {
375
                    connection.Dispose();
376
                }
377
            }
378

  
379
            return dt;
380
        }
381

  
382
        public static DataTable SelectProjectLineProperties()
383
        {
384
            DataTable dt = new DataTable();
385
            Project_Info projectInfo = Project_Info.GetInstance();
386
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
387
            {
388
                try
389
                {
390
                    connection.Open();
391
                    using (SQLiteCommand cmd = connection.CreateCommand())
392
                    {
393
                        cmd.CommandText = string.Format(@"
394
                            SELECT lp.UID, lp.DisplayName, sp.SPPID_SYMBOL_PATH, spa.SPPID_ATTRIBUTE
395
                            FROM {0} as lp 
396
                                 LEFT OUTER JOIN {1} as sp 
397
                                      ON lp.UID = sp.UID
398
                                 LEFT OUTER JOIN {2} as spa 
399
                                      ON lp.UID = spa.UID;", LineProperties_TABLE, SPPID_SYMBOL_MAPPING_TABLE, SPPID_ATTRIBUTE_MAPPING_TABLE);
400
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
401
                            dt.Load(dr);
402
                    }
403
                    connection.Close();
404
                }
405
                catch (Exception ex)
406
                {
407

  
408
                }
409
                finally
410
                {
411
                    connection.Dispose();
412
                }
413
            }
414

  
415
            return dt;
416
        }
417

  
418
        public static DataTable SelectProjectAttribute()
419
        {
420
            DataTable dt = new DataTable();
421
            Project_Info projectInfo = Project_Info.GetInstance();
422
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
423
            {
424
                try
425
                {
426
                    connection.Open();
427
                    using (SQLiteCommand cmd = connection.CreateCommand())
428
                    {
429
                        cmd.CommandText = string.Format(@"
430
                            SELECT sa.UID, sa.DisplayAttribute, st.TYPE, spa.SPPID_ATTRIBUTE, sp.SPPID_SYMBOL_PATH, spl.LOCATION, spl.LEADERLINE 
431
                            FROM {1} as sa, {0} as st 
432
                                 LEFT OUTER JOIN {2} as sp 
433
                                      ON sa.UID = SP.UID 
434
                                LEFT OUTER JOIN {3} as spa 
435
                                     ON sa.UID = spa.UID
436
                                LEFT OUTER JOIN {4} as spl 
437
                                     ON sa.UID = spl.UID
438
                            WHERE sa.SymbolType_UID = st.UID;", SymbolType_TABLE, SymbolAttribute_TABLE, SPPID_SYMBOL_MAPPING_TABLE, SPPID_ATTRIBUTE_MAPPING_TABLE, SPPID_LABEL_INFO_TABLE);
439
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
440
                            dt.Load(dr);
441
                    }
442
                    connection.Close();
443
                }
444
                catch (Exception ex)
445
                {
446

  
447
                }
448
                finally
449
                {
450
                    connection.Dispose();
451
                }
452
            }
453

  
454
            return dt;
455
        }
456

  
457

  
458

  
459
        public static bool InsertSymbolMapping(List<Tuple<string, string, string, bool>> datas)
460
        {
461
            Project_Info projectInfo = Project_Info.GetInstance();
462
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
463
            {
464
                try
465
                {
466
                    connection.Open();
467
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
468
                    {
469
                        try
470
                        {
471
                            using (SQLiteCommand cmd = connection.CreateCommand())
472
                            {
473
                                foreach (var item in datas)
474
                                {
475
                                    cmd.Parameters.Clear();
476
                                    cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, NAME, SPPID_SYMBOL_PATH, LEADERLINE) VALUES (@UID, @NAME, @SPPID_SYMBOL_PATH, @LEADERLINE)", SPPID_SYMBOL_MAPPING_TABLE);
477
                                    cmd.Parameters.AddWithValue("@UID", item.Item1);
478
                                    cmd.Parameters.AddWithValue("@NAME", item.Item2);
479
                                    cmd.Parameters.AddWithValue("@SPPID_SYMBOL_PATH", item.Item3);
480
                                    cmd.Parameters.AddWithValue("@LEADERLINE", item.Item4);
481
                                    cmd.ExecuteNonQuery();
482
                                }
483
                            }
484
                            transaction.Commit();
485
                            connection.Close();
486
                        }
487
                        catch (Exception ex)
488
                        {
489
                            transaction.Rollback();
490
                        }
491
                        finally
492
                        {
493
                            transaction.Dispose();
494
                        }
495
                    }
496
                }
497
                catch (Exception ex)
498
                {
499
                    return false;
500
                }
501
                finally
502
                {
503
                    connection.Dispose();
504
                }
505
            }
506

  
507
            return true;
508
        }
509

  
510
        public static bool InsertAttributeMapping(List<Tuple<string, string>> datas)
511
        {
512
            Project_Info projectInfo = Project_Info.GetInstance();
513
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
514
            {
515
                try
516
                {
517
                    connection.Open();
518
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
519
                    {
520
                        try
521
                        {
522
                            using (SQLiteCommand cmd = connection.CreateCommand())
523
                            {
524
                                foreach (var item in datas)
525
                                {
526
                                    cmd.Parameters.Clear();
527
                                    cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, SPPID_ATTRIBUTE) VALUES (@UID, @SPPID_ATTRIBUTE)", SPPID_ATTRIBUTE_MAPPING_TABLE);
528
                                    cmd.Parameters.AddWithValue("@UID", item.Item1);
529
                                    cmd.Parameters.AddWithValue("@SPPID_ATTRIBUTE", item.Item2);
530
                                    cmd.ExecuteNonQuery();
531
                                }
532
                            }
533
                            transaction.Commit();
534
                            connection.Close();
535
                        }
536
                        catch (Exception ex)
537
                        {
538
                            transaction.Rollback();
539
                        }
540
                        finally
541
                        {
542
                            transaction.Dispose();
543
                        }
544
                    }
545
                }
546
                catch (Exception ex)
547
                {
548
                    return false;
549
                }
550
                finally
551
                {
552
                    connection.Dispose();
553
                }
554
            }
555
            return true;
556
        }
557

  
558
        public static bool InsertLabelInfoMapping(List<Tuple<string, int, bool>> datas)
559
        {
560
            Project_Info projectInfo = Project_Info.GetInstance();
561
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
562
            {
563
                try
564
                {
565
                    connection.Open();
566
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
567
                    {
568
                        try
569
                        {
570
                            using (SQLiteCommand cmd = connection.CreateCommand())
571
                            {
572
                                foreach (var item in datas)
573
                                {
574
                                    cmd.Parameters.Clear();
575
                                    cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, LOCATION, LEADERLINE) VALUES (@UID, @LOCATION, @LEADERLINE)", SPPID_LABEL_INFO_TABLE);
576
                                    cmd.Parameters.AddWithValue("@UID", item.Item1);
577
                                    cmd.Parameters.AddWithValue("@LOCATION", item.Item2);
578
                                    cmd.Parameters.AddWithValue("@LEADERLINE", item.Item3);
579
                                    cmd.ExecuteNonQuery();
580
                                }
581
                            }
582
                            transaction.Commit();
583
                            connection.Close();
584
                        }
585
                        catch (Exception ex)
586
                        {
587
                            transaction.Rollback();
588
                        }
589
                        finally
590
                        {
591
                            transaction.Dispose();
592
                        }
593
                    }
594
                }
595
                catch (Exception ex)
596
                {
597
                    return false;
598
                }
599
                finally
600
                {
601
                    connection.Dispose();
602
                }
603
            }
604
            return true;
605
        }
606
    }
607
}
DTI_PID/SPPIDConverter/DB/Project_Info.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.IO;
7

  
8
namespace Converter.BaseModel
9
{
10
    public class Project_Info
11
    {
12
        private static Project_Info projectInfo;
13
        private string _DefaultPath;
14
        private string _Name;
15
        private bool _Enable;
16
        private string _DBFilePath;
17
        private string _TempDirPath;
18
        private string _ImageDirPath;
19
        private string _SvgImageDirPath;
20
        private string _SPPID_ImageDirPath;
21

  
22
        public string DefaultPath {
23
            get { return _DefaultPath; }
24
            set {
25
                _DefaultPath = value;
26
                _Name = Path.GetFileName(value);
27
                _DBFilePath = value + @"\db\ITI_PID.db";
28
                _TempDirPath = value + @"\Temp\";
29
                _ImageDirPath = value + @"\image\";
30
                _SvgImageDirPath = value + @"\svg\";
31
                _SPPID_ImageDirPath = value + @"\SPPID_Image";
32
                Directory.CreateDirectory(_SPPID_ImageDirPath);
33
            }
34
        }
35

  
36
        public string Name
37
        {
38
            get { return _Name; }
39
        }
40

  
41
        public string DBFilePath
42
        {
43
            get { return _DBFilePath; }
44
        }
45
        public string TempDirPath
46
        {
47
            get { return _TempDirPath; }
48
        }
49

  
50
        public string ImageDirPath
51
        {
52
            get { return _ImageDirPath; }
53
        }
54
        public string SvgImageDirPath
55
        {
56
            get { return _SvgImageDirPath; }
57
        }
58

  
59
        public string SPPID_ImageDirPath
60
        {
61
            get { return _SPPID_ImageDirPath; }
62
        }
63

  
64
        public bool Enable { get => _Enable; set => _Enable = value; }
65

  
66

  
67
        public static Project_Info GetInstance()
68
        {
69
            if (projectInfo == null)
70
                projectInfo = new Project_Info();
71

  
72
            return projectInfo;
73
        }
74
    }
75
}
DTI_PID/SPPIDConverter/Form/MappingForm.Designer.cs
63 63
            this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem();
64 64
            this.splitterItem3 = new DevExpress.XtraLayout.SplitterItem();
65 65
            this.tabbedControlGroup = new DevExpress.XtraLayout.TabbedControlGroup();
66
            this.GroupLineNumber = new DevExpress.XtraLayout.LayoutControlGroup();
67
            this.layoutControlGroup8 = new DevExpress.XtraLayout.LayoutControlGroup();
68
            this.layoutControlItem13 = new DevExpress.XtraLayout.LayoutControlItem();
69
            this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
70
            this.layoutControlItem18 = new DevExpress.XtraLayout.LayoutControlItem();
71 66
            this.GroupSymbol = new DevExpress.XtraLayout.LayoutControlGroup();
72 67
            this.splitterItem1 = new DevExpress.XtraLayout.SplitterItem();
73 68
            this.layoutControlGroup3 = new DevExpress.XtraLayout.LayoutControlGroup();
......
80 75
            this.GroupLine = new DevExpress.XtraLayout.LayoutControlGroup();
81 76
            this.layoutControlGroup6 = new DevExpress.XtraLayout.LayoutControlGroup();
82 77
            this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
78
            this.GroupLineNumber = new DevExpress.XtraLayout.LayoutControlGroup();
79
            this.layoutControlGroup8 = new DevExpress.XtraLayout.LayoutControlGroup();
80
            this.layoutControlItem13 = new DevExpress.XtraLayout.LayoutControlItem();
81
            this.layoutControlItem3 = new DevExpress.XtraLayout.LayoutControlItem();
82
            this.layoutControlItem18 = new DevExpress.XtraLayout.LayoutControlItem();
83 83
            this.GroupAttribute = new DevExpress.XtraLayout.LayoutControlGroup();
84 84
            this.layoutControlGroup7 = new DevExpress.XtraLayout.LayoutControlGroup();
85 85
            this.layoutControlItem11 = new DevExpress.XtraLayout.LayoutControlItem();
......
127 127
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit();
128 128
            ((System.ComponentModel.ISupportInitialize)(this.splitterItem3)).BeginInit();
129 129
            ((System.ComponentModel.ISupportInitialize)(this.tabbedControlGroup)).BeginInit();
130
            ((System.ComponentModel.ISupportInitialize)(this.GroupLineNumber)).BeginInit();
131
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup8)).BeginInit();
132
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).BeginInit();
133
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
134
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem18)).BeginInit();
135 130
            ((System.ComponentModel.ISupportInitialize)(this.GroupSymbol)).BeginInit();
136 131
            ((System.ComponentModel.ISupportInitialize)(this.splitterItem1)).BeginInit();
137 132
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).BeginInit();
......
144 139
            ((System.ComponentModel.ISupportInitialize)(this.GroupLine)).BeginInit();
145 140
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup6)).BeginInit();
146 141
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
142
            ((System.ComponentModel.ISupportInitialize)(this.GroupLineNumber)).BeginInit();
143
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup8)).BeginInit();
144
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).BeginInit();
145
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).BeginInit();
146
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem18)).BeginInit();
147 147
            ((System.ComponentModel.ISupportInitialize)(this.GroupAttribute)).BeginInit();
148 148
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup7)).BeginInit();
149 149
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem11)).BeginInit();
......
374 374
            // 
375 375
            this.gridViewSymbol.GridControl = this.gridControlSymbol;
376 376
            this.gridViewSymbol.Name = "gridViewSymbol";
377
            this.gridViewSymbol.OptionsBehavior.ReadOnly = true;
378 377
            this.gridViewSymbol.OptionsCustomization.AllowGroup = false;
379 378
            this.gridViewSymbol.OptionsView.ShowAutoFilterRow = true;
380 379
            this.gridViewSymbol.OptionsView.ShowGroupPanel = false;
......
533 532
            this.GroupAttribute,
534 533
            this.GroupETCSetting});
535 534
            // 
536
            // GroupLineNumber
537
            // 
538
            this.GroupLineNumber.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
539
            this.layoutControlGroup8});
540
            this.GroupLineNumber.Location = new System.Drawing.Point(0, 0);
541
            this.GroupLineNumber.Name = "GroupLineNumber";
542
            this.GroupLineNumber.Size = new System.Drawing.Size(691, 632);
543
            this.GroupLineNumber.Text = "Line Number";
544
            // 
545
            // layoutControlGroup8
546
            // 
547
            this.layoutControlGroup8.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
548
            this.layoutControlItem13,
549
            this.layoutControlItem3,
550
            this.layoutControlItem18});
551
            this.layoutControlGroup8.Location = new System.Drawing.Point(0, 0);
552
            this.layoutControlGroup8.Name = "layoutControlGroup8";
553
            this.layoutControlGroup8.Size = new System.Drawing.Size(691, 632);
554
            this.layoutControlGroup8.Text = "ID2 Line Number";
555
            // 
556
            // layoutControlItem13
557
            // 
558
            this.layoutControlItem13.Control = this.gridControlLineNumber;
559
            this.layoutControlItem13.Location = new System.Drawing.Point(0, 24);
560
            this.layoutControlItem13.Name = "layoutControlItem13";
561
            this.layoutControlItem13.Size = new System.Drawing.Size(667, 563);
562
            this.layoutControlItem13.TextSize = new System.Drawing.Size(0, 0);
563
            this.layoutControlItem13.TextVisible = false;
564
            // 
565
            // layoutControlItem3
566
            // 
567
            this.layoutControlItem3.Control = this.textBoxLineNumberPath;
568
            this.layoutControlItem3.Location = new System.Drawing.Point(0, 0);
569
            this.layoutControlItem3.Name = "layoutControlItem3";
570
            this.layoutControlItem3.Size = new System.Drawing.Size(410, 24);
571
            this.layoutControlItem3.Text = "SPPID Line Number Label Path";
572
            this.layoutControlItem3.TextAlignMode = DevExpress.XtraLayout.TextAlignModeItem.AutoSize;
573
            this.layoutControlItem3.TextSize = new System.Drawing.Size(167, 14);
574
            this.layoutControlItem3.TextToControlDistance = 5;
575
            // 
576
            // layoutControlItem18
577
            // 
578
            this.layoutControlItem18.Control = this.checkComboBoxLineNumberLocation;
579
            this.layoutControlItem18.Location = new System.Drawing.Point(410, 0);
580
            this.layoutControlItem18.Name = "layoutControlItem18";
581
            this.layoutControlItem18.Size = new System.Drawing.Size(257, 24);
582
            this.layoutControlItem18.Text = "Label Location";
583
            this.layoutControlItem18.TextAlignMode = DevExpress.XtraLayout.TextAlignModeItem.AutoSize;
584
            this.layoutControlItem18.TextSize = new System.Drawing.Size(78, 14);
585
            this.layoutControlItem18.TextToControlDistance = 5;
586
            // 
587 535
            // GroupSymbol
588 536
            // 
589 537
            this.GroupSymbol.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
......
692 640
            this.layoutControlItem10.TextSize = new System.Drawing.Size(0, 0);
693 641
            this.layoutControlItem10.TextVisible = false;
694 642
            // 
643
            // GroupLineNumber
644
            // 
645
            this.GroupLineNumber.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
646
            this.layoutControlGroup8});
647
            this.GroupLineNumber.Location = new System.Drawing.Point(0, 0);
648
            this.GroupLineNumber.Name = "GroupLineNumber";
649
            this.GroupLineNumber.Size = new System.Drawing.Size(691, 632);
650
            this.GroupLineNumber.Text = "Line Number";
651
            // 
652
            // layoutControlGroup8
653
            // 
654
            this.layoutControlGroup8.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
655
            this.layoutControlItem13,
656
            this.layoutControlItem3,
657
            this.layoutControlItem18});
658
            this.layoutControlGroup8.Location = new System.Drawing.Point(0, 0);
659
            this.layoutControlGroup8.Name = "layoutControlGroup8";
660
            this.layoutControlGroup8.Size = new System.Drawing.Size(691, 632);
661
            this.layoutControlGroup8.Text = "ID2 Line Number";
662
            // 
663
            // layoutControlItem13
664
            // 
665
            this.layoutControlItem13.Control = this.gridControlLineNumber;
666
            this.layoutControlItem13.Location = new System.Drawing.Point(0, 24);
667
            this.layoutControlItem13.Name = "layoutControlItem13";
668
            this.layoutControlItem13.Size = new System.Drawing.Size(667, 563);
669
            this.layoutControlItem13.TextSize = new System.Drawing.Size(0, 0);
670
            this.layoutControlItem13.TextVisible = false;
671
            // 
672
            // layoutControlItem3
673
            // 
674
            this.layoutControlItem3.Control = this.textBoxLineNumberPath;
675
            this.layoutControlItem3.Location = new System.Drawing.Point(0, 0);
676
            this.layoutControlItem3.Name = "layoutControlItem3";
677
            this.layoutControlItem3.Size = new System.Drawing.Size(410, 24);
678
            this.layoutControlItem3.Text = "SPPID Line Number Label Path";
679
            this.layoutControlItem3.TextAlignMode = DevExpress.XtraLayout.TextAlignModeItem.AutoSize;
680
            this.layoutControlItem3.TextSize = new System.Drawing.Size(167, 14);
681
            this.layoutControlItem3.TextToControlDistance = 5;
682
            // 
683
            // layoutControlItem18
684
            // 
685
            this.layoutControlItem18.Control = this.checkComboBoxLineNumberLocation;
686
            this.layoutControlItem18.Location = new System.Drawing.Point(410, 0);
687
            this.layoutControlItem18.Name = "layoutControlItem18";
688
            this.layoutControlItem18.Size = new System.Drawing.Size(257, 24);
689
            this.layoutControlItem18.Text = "Label Location";
690
            this.layoutControlItem18.TextAlignMode = DevExpress.XtraLayout.TextAlignModeItem.AutoSize;
691
            this.layoutControlItem18.TextSize = new System.Drawing.Size(78, 14);
692
            this.layoutControlItem18.TextToControlDistance = 5;
693
            // 
695 694
            // GroupAttribute
696 695
            // 
697 696
            this.GroupAttribute.Items.AddRange(new DevExpress.XtraLayout.BaseLayoutItem[] {
......
888 887
            ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit();
889 888
            ((System.ComponentModel.ISupportInitialize)(this.splitterItem3)).EndInit();
890 889
            ((System.ComponentModel.ISupportInitialize)(this.tabbedControlGroup)).EndInit();
891
            ((System.ComponentModel.ISupportInitialize)(this.GroupLineNumber)).EndInit();
892
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup8)).EndInit();
893
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).EndInit();
894
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
895
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem18)).EndInit();
896 890
            ((System.ComponentModel.ISupportInitialize)(this.GroupSymbol)).EndInit();
897 891
            ((System.ComponentModel.ISupportInitialize)(this.splitterItem1)).EndInit();
898 892
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup3)).EndInit();
......
905 899
            ((System.ComponentModel.ISupportInitialize)(this.GroupLine)).EndInit();
906 900
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup6)).EndInit();
907 901
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
902
            ((System.ComponentModel.ISupportInitialize)(this.GroupLineNumber)).EndInit();
903
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup8)).EndInit();
904
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem13)).EndInit();
905
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem3)).EndInit();
906
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem18)).EndInit();
908 907
            ((System.ComponentModel.ISupportInitialize)(this.GroupAttribute)).EndInit();
909 908
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlGroup7)).EndInit();
910 909
            ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem11)).EndInit();
DTI_PID/SPPIDConverter/Form/MappingForm.cs
110 110
            gridViewSymbol.Columns["Type"].GroupIndex = 0;
111 111
            gridViewSymbol.Columns["SPPID_SYMBOL_PATH"].OptionsColumn.AllowEdit = false;
112 112
            gridViewSymbol.Columns["Name"].OptionsColumn.AllowEdit = false;
113
            gridViewSymbol.Columns["LEADERLINE"].Caption = "Show Leader Line(If Label Symbol)";
113 114
            gridControlSymbol.RepositoryItems.Add(clearButton);
114 115
            gridViewSymbol.ExpandAllGroups();
115 116

  
117
            foreach (DataRow item in symbolDT.Rows)
118
            {
119
                if (DBNull.Value.Equals(item["LEADERLINE"]))
120
                    item["LEADERLINE"] = false;
121
            }
122

  
116 123
            // Line GridView
117 124
            gridControlLine.DataSource = lineDT;
118 125
            gridViewLine.Columns["UID"].Visible = false;
......
308 315
        private void btnSave_Click(object sender, EventArgs e)
309 316
        {
310 317
            Cursor = Cursors.WaitCursor;
311
            List<Tuple<string, string, string>> symbolDatas = new List<Tuple<string, string, string>>();
318
            List<Tuple<string, string, string, bool>> symbolDatas = new List<Tuple<string, string, string, bool>>();
312 319
            List<Tuple<string, string>> attributeDatas = new List<Tuple<string, string>>();
313 320
            List<Tuple<string, int, bool>> labelDatas = new List<Tuple<string, int, bool>>();
314 321
            foreach (DataRow row in symbolDT.Rows)
......
316 323
                string _uid = row["UID"].ToString();
317 324
                string _name = row["Name"].ToString();
318 325
                string _SPPIDSymbolPath = row["SPPID_SYMBOL_PATH"] == DBNull.Value ? null : row["SPPID_SYMBOL_PATH"].ToString();
319
                symbolDatas.Add(new Tuple<string, string, string>(_uid, _name, _SPPIDSymbolPath));
326
                bool _LEADERLINE = (bool)row["LEADERLINE"];
327
                symbolDatas.Add(new Tuple<string, string, string, bool>(_uid, _name, _SPPIDSymbolPath, _LEADERLINE));
320 328
            }
321 329

  
322 330
            foreach (DataRow row in lineDT.Rows)
......
324 332
                string _uid = row["UID"].ToString();
325 333
                string _name = row["Name"].ToString();
326 334
                string _SPPIDSymbolPath = row["SPPID_SYMBOL_PATH"] == DBNull.Value ? null : row["SPPID_SYMBOL_PATH"].ToString();
327
                symbolDatas.Add(new Tuple<string, string, string>(_uid, _name, _SPPIDSymbolPath));
335
                symbolDatas.Add(new Tuple<string, string, string, bool>(_uid, _name, _SPPIDSymbolPath, false));
328 336
            }
329 337

  
330 338

  
......
333 341
                string _uid = row["UID"].ToString();
334 342
                string _name = row["DisplayName"].ToString();
335 343
                string _SPPIDSymbolPath = textBoxLineNumberPath.Text;
336
                symbolDatas.Add(new Tuple<string, string, string>(_uid, _name, _SPPIDSymbolPath));
344
                symbolDatas.Add(new Tuple<string, string, string, bool>(_uid, _name, _SPPIDSymbolPath, false));
337 345

  
338 346
                string _SPPID_Attribute = row["SPPID_ATTRIBUTE"] == DBNull.Value ? null : row["SPPID_ATTRIBUTE"].ToString();
339 347
                attributeDatas.Add(new Tuple<string, string>(_uid, _SPPID_Attribute));
......
344 352
                string _uid = row["UID"].ToString();
345 353
                string _name = row["DisplayAttribute"].ToString();
346 354
                string _SPPIDSymbolPath = row["SPPID_SYMBOL_PATH"] == DBNull.Value ? null : row["SPPID_SYMBOL_PATH"].ToString();
347
                symbolDatas.Add(new Tuple<string, string, string>(_uid, _name, _SPPIDSymbolPath));
355
                symbolDatas.Add(new Tuple<string, string, string, bool>(_uid, _name, _SPPIDSymbolPath, false));
348 356

  
349 357
                string _SPPID_Attribute = row["SPPID_ATTRIBUTE"] == DBNull.Value ? null : row["SPPID_ATTRIBUTE"].ToString();
350 358
                attributeDatas.Add(new Tuple<string, string>(_uid, _SPPID_Attribute));
......
367 375

  
368 376
            if (Project_DB.InsertSymbolMapping(symbolDatas) &&
369 377
                Project_DB.InsertAttributeMapping(attributeDatas) &&
370
                Project_DB.InsertLocationMapping(labelDatas) &&
378
                Project_DB.InsertLabelInfoMapping(labelDatas) &&
371 379
                Project_DB.SaveETCSetting(jsonString))
372 380
                MessageBox.Show(Msg.SuccessSave, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
373 381
            else
DTI_PID/SPPIDConverter/Project_DB.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Globalization;
7
using System.Data.SQLite;
8
using System.Data;
9

  
10
namespace Converter.BaseModel
11
{
12
    public class Project_DB
13
    {
14
        const string SPPID_DB_INFO_TABLE = "T_SPPID_CONNECTION_INFO";
15
        const string SPPID_SYMBOL_MAPPING_TABLE = "T_SPPID_SYMBOL_MAPPING";
16
        const string SPPID_ATTRIBUTE_MAPPING_TABLE = "T_SPPID_ATTRIBUTE_MAPPING";
17
        const string SPPID_ETC_SETTING_TABLE = "T_SPPID_ETC_SETTING_TABLE";
18
        const string SPPID_LABEL_INFO_TABLE = "T_SPPID_LABEL_INFO";
19

  
20
        const string LineProperties_TABLE = "LineProperties";
21
        const string LineTypes_TABLE = "LineTypes";
22
        const string SymbolType_TABLE = "SymbolType";
23
        const string SymbolAttribute_TABLE = "SymbolAttribute";
24
        const string Symbol_TABLE = "Symbol";
25

  
26
        public static bool ConnTestAndCreateTable()
27
        {
28
            bool result = false;
29
            Project_Info projectInfo = Project_Info.GetInstance();
30
            SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, @"Data Source = {0}", projectInfo.DBFilePath));
31
            try
32
            {
33
                connection.Open();
34
                if (connection.State == ConnectionState.Open)
35
                {
36
                    CreateTable(connection);
37
                    result = true;
38
                }
39
                connection.Close();
40
            }
41
            catch (Exception ex)
42
            {
43

  
44
            }
45
            finally
46
            {
47
                connection.Dispose();
48
            }
49

  
50
            return result;
51
        }
52

  
53
        public static bool SaveSPPID_DB_INFO(string jsonString)
54
        {
55
            Project_Info projectInfo = Project_Info.GetInstance();
56
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
57
            {
58

  
59
                try
60
                {
61
                    connection.Open();
62
                    using (SQLiteCommand cmd = connection.CreateCommand())
63
                    {
64
                        cmd.CommandText = string.Format("DELETE FROM {0}", SPPID_DB_INFO_TABLE);
65
                        cmd.ExecuteNonQuery();
66

  
67
                        cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@jsonString)", SPPID_DB_INFO_TABLE);
68
                        cmd.Parameters.AddWithValue("@jsonString", jsonString);
69
                        cmd.ExecuteNonQuery();
70
                    }
71
                    connection.Close();
72
                }
73
                catch (Exception ex)
74
                {
75
                    return false;
76
                }
77
                finally
78
                {
79
                    connection.Dispose();
80
                }
81
            }
82

  
83
            return true;
84
        }
85

  
86
        public static DataTable SelectSPPID_DB_INFO()
87
        {
88
            DataTable dt = new DataTable();
89
            Project_Info projectInfo = Project_Info.GetInstance();
90
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
91
            {
92
                try
93
                {
94
                    connection.Open();
95
                    using (SQLiteCommand cmd = connection.CreateCommand())
96
                    {
97
                        cmd.CommandText = string.Format("SELECT * FROM {0}", SPPID_DB_INFO_TABLE);
98
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
99
                            dt.Load(dr);
100
                    }
101
                    connection.Close();
102
                }
103
                catch (Exception ex)
104
                {
105

  
106
                }
107
                finally
108
                {
109
                    connection.Dispose();
110
                }
111
            }
112

  
113
            return dt;
114
        }
115

  
116
        public static bool SaveETCSetting(string jsonString)
117
        {
118
            Project_Info projectInfo = Project_Info.GetInstance();
119
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
120
            {
121

  
122
                try
123
                {
124
                    connection.Open();
125
                    using (SQLiteCommand cmd = connection.CreateCommand())
126
                    {
127
                        cmd.CommandText = string.Format("DELETE FROM {0}", SPPID_ETC_SETTING_TABLE);
128
                        cmd.ExecuteNonQuery();
129

  
130
                        cmd.CommandText = string.Format("INSERT INTO {0} VALUES (@jsonString)", SPPID_ETC_SETTING_TABLE);
131
                        cmd.Parameters.AddWithValue("@jsonString", jsonString);
132
                        cmd.ExecuteNonQuery();
133
                    }
134
                    connection.Close();
135
                }
136
                catch (Exception ex)
137
                {
138
                    return false;
139
                }
140
                finally
141
                {
142
                    connection.Dispose();
143
                }
144
            }
145

  
146
            return true;
147
        }
148

  
149
        public static DataTable SelectETCSetting()
150
        {
151
            DataTable dt = new DataTable();
152
            Project_Info projectInfo = Project_Info.GetInstance();
153
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
154
            {
155
                try
156
                {
157
                    connection.Open();
158
                    using (SQLiteCommand cmd = connection.CreateCommand())
159
                    {
160
                        cmd.CommandText = string.Format("SELECT * FROM {0}", SPPID_ETC_SETTING_TABLE);
161
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
162
                            dt.Load(dr);
163
                    }
164
                    connection.Close();
165
                }
166
                catch (Exception ex)
167
                {
168

  
169
                }
170
                finally
171
                {
172
                    connection.Dispose();
173
                }
174
            }
175

  
176
            return dt;
177
        }
178

  
179
        private static void CreateTable(SQLiteConnection connection)
180
        {
181
            using (SQLiteCommand cmd = connection.CreateCommand())
182
            {
183
                cmd.CommandText = "SELECT NAME FROM sqlite_master WHERE type='table'";
184
                using (SQLiteDataReader dr = cmd.ExecuteReader())
185
                using (DataTable dt = new DataTable())
186
                {
187
                    dt.Load(dr);
188

  
189
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_DB_INFO_TABLE)).Length == 0)
190
                    {
191
                        cmd.CommandText = string.Format("CREATE TABLE {0} (JsonString TEXT)", SPPID_DB_INFO_TABLE);
192
                        cmd.ExecuteNonQuery();
193
                    }
194
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_ETC_SETTING_TABLE)).Length == 0)
195
                    {
196
                        cmd.CommandText = string.Format("CREATE TABLE {0} (JsonString TEXT)", SPPID_ETC_SETTING_TABLE);
197
                        cmd.ExecuteNonQuery();
198
                    }
199
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_SYMBOL_MAPPING_TABLE)).Length == 0)
200
                    {
201
                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, NAME TEXT, SPPID_SYMBOL_PATH TEXT)", SPPID_SYMBOL_MAPPING_TABLE);
202
                        cmd.ExecuteNonQuery();
203
                    }
204
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_ATTRIBUTE_MAPPING_TABLE)).Length == 0)
205
                    {
206
                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, SPPID_ATTRIBUTE TEXT)", SPPID_ATTRIBUTE_MAPPING_TABLE);
207
                        cmd.ExecuteNonQuery();
208
                    }
209
                    if (dt.Select(string.Format("NAME = '{0}'", SPPID_LABEL_INFO_TABLE)).Length == 0)
210
                    {
211
                        cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, LOCATION INT DEFAULT 0, LEADERLINE BOOLEAN)", SPPID_LABEL_INFO_TABLE);
212
                        cmd.ExecuteNonQuery();
213
                    }
214
                }
215
            }
216
        }
217

  
218
        public static DataTable SelectProjectSymbol()
219
        {
220
            DataTable dt = new DataTable();
221
            Project_Info projectInfo = Project_Info.GetInstance();
222
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
223
            {
224
                try
225
                {
226
                    connection.Open();
227
                    using (SQLiteCommand cmd = connection.CreateCommand())
228
                    {
229
                        cmd.CommandText = string.Format(@"
230
                            SELECT s.UID, s.Name, st.Type, sp.SPPID_SYMBOL_PATH FROM {1} as st, {0} as s 
231
                                LEFT OUTER JOIN {2} as sp 
232
                                    ON s.UID = SP.UID 
233
                            WHERE s.SymbolType_UID = st.UID 
234
                            ORDER BY st.TYPE ASC;", Symbol_TABLE, SymbolType_TABLE, SPPID_SYMBOL_MAPPING_TABLE);
235
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
236
                            dt.Load(dr);
237

  
238
                        DataTable dtClone = dt.Clone();
239
                        dtClone.Columns["UID"].DataType = typeof(string);
240
                        foreach (DataRow row in dt.Rows)
241
                        {
242
                            dtClone.ImportRow(row);
243
                        }
244
                        dt.Dispose();
245
                        dt = dtClone;
246
                    }
247
                    connection.Close();
248
                }
249
                catch (Exception ex)
250
                {
251

  
252
                }
253
                finally
254
                {
255
                    connection.Dispose();
256
                }
257
            }
258

  
259
            return dt;
260
        }
261

  
262
        public static DataTable SelectProjectChildSymbol()
263
        {
264
            DataTable result = new DataTable();
265
            result.Columns.Add("UID");
266
            result.Columns.Add("Name");
267
            result.Columns.Add("Type");
268
            result.Columns.Add("SPPID_SYMBOL_PATH");
269
            
270
            Project_Info projectInfo = Project_Info.GetInstance();
271
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
272
            using (DataTable dt = new DataTable())
273
            {
274
                try
275
                {
276
                    connection.Open();
277
                    using (SQLiteCommand cmd = connection.CreateCommand())
278
                    {
279
                        cmd.CommandText = string.Format(@"
280
                            SELECT AdditionalSymbol FROM Symbol");
281
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
282
                            dt.Load(dr);
283
                        List<string> childList = new List<string>();
284
                        foreach (DataRow row in dt.Rows)
285
                        {
286
                            if (!string.IsNullOrEmpty((string)row["AdditionalSymbol"]))
287
                            {
288
                                string[] array = row["AdditionalSymbol"].ToString().Split(new char[] { '/' });
289
                                foreach (var childString in array)
290
                                {
291
                                    childList.Add(childString.Split(new char[] { ',' })[2]);
292
                                }
293
                            }
294

  
295
                        }
296

  
297
                        dt.Clear();
298
                        cmd.Reset();
299
                        cmd.CommandText = string.Format(@"
300
                            SELECT * FROM {0}", SPPID_SYMBOL_MAPPING_TABLE);
301
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
302
                            dt.Load(dr);
303

  
304
                        childList = childList.Distinct().ToList();
305
                        foreach (var child in childList)
306
                        {
307
                            string mappingPath = string.Empty;
308
                            DataRow[] rows = dt.Select(string.Format("UID = '{0}'", child));
309
                            if (rows.Length == 1)
310
                                mappingPath = !DBNull.Value.Equals(rows[0]["SPPID_SYMBOL_PATH"]) ? (string)rows[0]["SPPID_SYMBOL_PATH"] : null;
311

  
312
                            DataRow newRow = result.NewRow();
313
                            newRow["UID"] = child;
314
                            newRow["Name"] = child;
315
                            newRow["Type"] = "Child Symbol";
316
                            newRow["SPPID_SYMBOL_PATH"] = mappingPath;
317
                            result.Rows.Add(newRow);
318
                        }
319
                    }
320
                    connection.Close();
321
                }
322
                catch (Exception ex)
323
                {
324

  
325
                }
326
                finally
327
                {
328
                    connection.Dispose();
329
                }
330
            }
331

  
332
            return result;
333
        }
334

  
335
        public static DataTable SelectProjectLine()
336
        {
337
            DataTable dt = new DataTable();
338
            Project_Info projectInfo = Project_Info.GetInstance();
339
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
340
            {
341
                try
342
                {
343
                    connection.Open();
344
                    using (SQLiteCommand cmd = connection.CreateCommand())
345
                    {
346
                        cmd.CommandText = string.Format(@"
347
                            SELECT l.UID, l.Name, sp.SPPID_SYMBOL_PATH FROM {0} as l 
348
                                LEFT OUTER JOIN {1} as sp 
349
                                    ON l.UID = SP.UID ;", LineTypes_TABLE, SPPID_SYMBOL_MAPPING_TABLE);
350
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
351
                            dt.Load(dr);
352
                    }
353
                    connection.Close();
354
                }
355
                catch (Exception ex)
356
                {
357

  
358
                }
359
                finally
360
                {
361
                    connection.Dispose();
362
                }
363
            }
364

  
365
            return dt;
366
        }
367

  
368
        public static DataTable SelectProjectLineProperties()
369
        {
370
            DataTable dt = new DataTable();
371
            Project_Info projectInfo = Project_Info.GetInstance();
372
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
373
            {
374
                try
375
                {
376
                    connection.Open();
377
                    using (SQLiteCommand cmd = connection.CreateCommand())
378
                    {
379
                        cmd.CommandText = string.Format(@"
380
                            SELECT lp.UID, lp.DisplayName, sp.SPPID_SYMBOL_PATH, spa.SPPID_ATTRIBUTE
381
                            FROM {0} as lp 
382
                                 LEFT OUTER JOIN {1} as sp 
383
                                      ON lp.UID = sp.UID
384
                                 LEFT OUTER JOIN {2} as spa 
385
                                      ON lp.UID = spa.UID;", LineProperties_TABLE, SPPID_SYMBOL_MAPPING_TABLE, SPPID_ATTRIBUTE_MAPPING_TABLE);
386
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
387
                            dt.Load(dr);
388
                    }
389
                    connection.Close();
390
                }
391
                catch (Exception ex)
392
                {
393

  
394
                }
395
                finally
396
                {
397
                    connection.Dispose();
398
                }
399
            }
400

  
401
            return dt;
402
        }
403

  
404
        public static DataTable SelectProjectAttribute()
405
        {
406
            DataTable dt = new DataTable();
407
            Project_Info projectInfo = Project_Info.GetInstance();
408
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
409
            {
410
                try
411
                {
412
                    connection.Open();
413
                    using (SQLiteCommand cmd = connection.CreateCommand())
414
                    {
415
                        cmd.CommandText = string.Format(@"
416
                            SELECT sa.UID, sa.DisplayAttribute, st.TYPE, spa.SPPID_ATTRIBUTE, sp.SPPID_SYMBOL_PATH, spl.LOCATION, spl.LEADERLINE 
417
                            FROM {1} as sa, {0} as st 
418
                                 LEFT OUTER JOIN {2} as sp 
419
                                      ON sa.UID = SP.UID 
420
                                LEFT OUTER JOIN {3} as spa 
421
                                     ON sa.UID = spa.UID
422
                                LEFT OUTER JOIN {4} as spl 
423
                                     ON sa.UID = spl.UID
424
                            WHERE sa.SymbolType_UID = st.UID;", SymbolType_TABLE, SymbolAttribute_TABLE, SPPID_SYMBOL_MAPPING_TABLE, SPPID_ATTRIBUTE_MAPPING_TABLE, SPPID_LABEL_INFO_TABLE);
425
                        using (SQLiteDataReader dr = cmd.ExecuteReader())
426
                            dt.Load(dr);
427
                    }
428
                    connection.Close();
429
                }
430
                catch (Exception ex)
431
                {
432

  
433
                }
434
                finally
435
                {
436
                    connection.Dispose();
437
                }
438
            }
439

  
440
            return dt;
441
        }
442

  
443

  
444

  
445
        public static bool InsertSymbolMapping(List<Tuple<string, string, string>> datas)
446
        {
447
            Project_Info projectInfo = Project_Info.GetInstance();
448
            using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath)))
449
            {
450
                try
451
                {
452
                    connection.Open();
453
                    using (SQLiteTransaction transaction = connection.BeginTransaction())
454
                    {
455
                        try
456
                        {
457
                            using (SQLiteCommand cmd = connection.CreateCommand())
458
                            {
459
                                foreach (var item in datas)
460
                                {
461
                                    cmd.Parameters.Clear();
462
                                    cmd.CommandText = string.Format("INSERT OR REPLACE INTO {0} (UID, NAME, SPPID_SYMBOL_PATH) VALUES (@UID, @NAME, @SPPID_SYMBOL_PATH)", SPPID_SYMBOL_MAPPING_TABLE);
463
                                    cmd.Parameters.AddWithValue("@UID", item.Item1);
464
                                    cmd.Parameters.AddWithValue("@NAME", item.Item2);
465
                                    cmd.Parameters.AddWithValue("@SPPID_SYMBOL_PATH", item.Item3);
466
                                    cmd.ExecuteNonQuery();
467
                                }
468
                            }
469
                            transaction.Commit();
470
                            connection.Close();
471
                        }
472
                        catch (Exception ex)
473
                        {
474
                            transaction.Rollback();
475
                        }
476
                        finally
477
                        {
478
                            transaction.Dispose();
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)