프로젝트

일반

사용자정보

개정판 f2a63376

IDf2a63376abc340b35d3db72fdd213ccbdc9f5ba6
상위 48c0701c
하위 df1424cb

이지연이(가) 약 3년 전에 추가함

issue #000: No Pocket, Air Fin Cooler Setting 창 요구사항 대로 재구성

Change-Id: I6de10a1d28fa35ddc15935d9b1118148bbbb2ef1

차이점 보기:

DTI_PID/ID2PSN/DB.cs
38 38

  
39 39
        //2022.02.03 추가
40 40
        const string PSN_NOPOCKETSETTING = "T_PSN_NOPOCKET_SETTING";
41
        const string PSN_AIRFINCOOLERSETTING = "T_PSN_AIRFINCOOLER_SETTING";
41 42
        /// <summary>
42 43
        ///  ID2 Project.db 데이터를 가져온다. 
43 44
        ///  DB 접속 정보 및 DBType (Sqlite, Mssql) 정보를 가져옴
......
493 494
                        AddColumn(PSN_NOPOCKETSETTING, dicColCheck);
494 495
                    }
495 496

  
497
                    matched = names.FirstOrDefault(param => param == PSN_AIRFINCOOLERSETTING);
498
                    dicColCheck.Clear();
499
                    dicColCheck.Add("[INDEX]", "INTEGER");
500
                    dicColCheck.Add("[TYPE]", "TEXT");
501
                    dicColCheck.Add("[NAME]", "TEXT");
502
                    if (matched == null)
503
                    {
504
                        var query = $"CREATE TABLE {PSN_AIRFINCOOLERSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [NAME] TEXT)";
505
                        using (var cmd = connection.GetSqlStringCommand(query))
506
                        {
507
                            cmd.ExecuteNonQuery();
508
                        }
509
                    }
510
                    else
511
                    {
512
                        AddColumn(PSN_AIRFINCOOLERSETTING, dicColCheck);
513
                    }
514

  
496 515

  
497 516
                    void AddColumn(string TableName, Dictionary<string, string> dicCol)
498 517
                    {
......
1137 1156
            return dt;
1138 1157
        }
1139 1158

  
1159
        public static DataTable SelectAirFinCoolerSetting()
1160
        {
1161
            DataTable dt = null;
1162
            ID2Info id2Info = ID2Info.GetInstance();
1163

  
1164
            using (IAbstractDatabase connection = id2Info.CreateConnection())
1165
            {
1166
                try
1167
                {
1168
                    var query = $@"SELECT [INDEX], [TYPE], [NAME] FROM {PSN_AIRFINCOOLERSETTING};";
1169
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1170
                    {
1171
                        dt = ds.Tables[0].Copy();
1172
                    }
1173
                }
1174
                catch (Exception ex)
1175
                {
1176
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1177
                }
1178
            }
1179

  
1180
            return dt;            
1181
        }
1182

  
1140 1183
        public static bool SaveHeaderSetting(List<HeaderInfo> headerInfos)
1141 1184
        {
1142 1185
            ID2Info id2Info = ID2Info.GetInstance();
......
1322 1365
            return true;
1323 1366
        }
1324 1367

  
1368
        public static bool SaveAirFinCoolerSetting(List<EquipmentAirFinCoolerItem> keywordItems)
1369
        {
1370
            ID2Info id2Info = ID2Info.GetInstance();
1371
            using (IAbstractDatabase connection = id2Info.CreateConnection())
1372
            {
1373
                using (var txn = connection.BeginTransaction())
1374
                {
1375
                    try
1376
                    {
1377
                        var query = $"DELETE FROM {PSN_AIRFINCOOLERSETTING}";
1378
                        connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1379

  
1380
                        foreach (EquipmentAirFinCoolerItem item in keywordItems)
1381
                        {
1382
                            query = $"INSERT INTO {PSN_AIRFINCOOLERSETTING} ([INDEX], [TYPE], [NAME]) VALUES (@INDEX, @TYPE, @NAME)";
1383
                            var cmd = connection.GetSqlStringCommand(query);
1384
                            AddWithValue(cmd, "@INDEX", item.Index);
1385
                            AddWithValue(cmd, "@TYPE", item.Type);
1386
                            AddWithValue(cmd, "@NAME", item.Name);
1387
                            connection.ExecuteNonQuery(cmd, txn);
1388
                        }
1389

  
1390
                        txn.Commit();
1391
                    }
1392
                    catch (Exception ex)
1393
                    {
1394
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1395
                        return false;
1396
                    }
1397
                }
1398
            }
1399

  
1400
            return true;
1401
        }
1402

  
1325 1403
        public static bool SaveTopologyRule(DataTable dt)
1326 1404
        {
1327 1405
            ID2Info id2Info = ID2Info.GetInstance();
......
2899 2977
                        AddColumn(PSN_NOPOCKETSETTING, dicColCheck);
2900 2978
                    }
2901 2979

  
2980
                    matched = names.FirstOrDefault(param => param == PSN_AIRFINCOOLERSETTING);
2981
                    dicColCheck.Clear();
2982
                    dicColCheck.Add("[INDEX]", "INTEGER");
2983
                    dicColCheck.Add("[TYPE]", "TEXT");
2984
                    dicColCheck.Add("[NAME]", "TEXT");
2985
                    if (matched == null)
2986
                    {
2987
                        var query = $"CREATE TABLE {PSN_AIRFINCOOLERSETTING}  ([INDEX] INTEGER, [TYPE] TEXT, [NAME] TEXT)";
2988
                        using (var cmd = connection.GetSqlStringCommand(query))
2989
                        {
2990
                            cmd.ExecuteNonQuery();
2991
                        }
2992
                    }
2993
                    else
2994
                    {
2995
                        AddColumn(PSN_AIRFINCOOLERSETTING, dicColCheck);
2996
                    }
2997
                    
2998

  
2902 2999
                    var query2 = $"If(db_id(N'" + PSN_COMMON + "') IS NULL) CREATE DATABASE [" + PSN_COMMON + "]";
2903 3000
                    if (id2Info.ID2DBType == AnotherID2DB_Type.MSSQL)
2904 3001
                    {
......
3613 3710
                                connection.ExecuteNonQuery(cmd, txn);
3614 3711
                            }
3615 3712

  
3713
                            //air fin cooler Setting
3714
                            query = $"DELETE FROM {PSN_AIRFINCOOLERSETTING}";
3715
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
3716

  
3717
                            foreach (DataRow row in dtnopocket.Rows)
3718
                            {
3719
                                query = $"INSERT INTO {PSN_AIRFINCOOLERSETTING} ([INDEX], [TYPE], [NAME]) VALUES (@INDEX, @TYPE, @NAME)";
3720
                                var cmd = connection.GetSqlStringCommand(query);
3721
                                AddWithValue(cmd, "@INDEX", row["INDEX"].ToString());
3722
                                AddWithValue(cmd, "@TYPE", row["TYPE"].ToString());
3723
                                AddWithValue(cmd, "@NAME", row["NAME"].ToString());
3724
                                connection.ExecuteNonQuery(cmd, txn);
3725
                            }
3726
                            
3727

  
3616 3728
                            txn.Commit();
3617 3729
                        }
3618 3730
                        catch (Exception ex)

내보내기 Unified diff

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