프로젝트

일반

사용자정보

개정판 88c1965b

ID88c1965b5a7c157d4563eca70ca6938ae37efda5
상위 7106e181
하위 22760b94

gaqhf 이(가) 약 3년 전에 추가함

issue #000: No Pocket Setting 추가

Change-Id: Ied94887f65d6a17df1d597b55e0381907c75e808

차이점 보기:

DTI_PID/ID2PSN/DB.cs
35 35
        const string PSN_COMMON = "ARS_COMMON";
36 36
        //2022.01.19 추가
37 37
        const string PSN_PIPESYSTEM = "SPPIDPipeSystem";
38

  
39
        //2022.02.03 추가
40
        const string PSN_NOPOCKETSETTING = "T_PSN_NOPOCKET_SETTING";
38 41
        /// <summary>
39 42
        ///  ID2 Project.db 데이터를 가져온다. 
40 43
        ///  DB 접속 정보 및 DBType (Sqlite, Mssql) 정보를 가져옴
......
357 360

  
358 361
                    if (matched == null)
359 362
                    {
360
                        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))";
363
                        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))";
361 364
                        using (var cmd = connection.GetSqlStringCommand(query))
362 365
                        {
363 366
                            cmd.ExecuteNonQuery();
......
470 473
                    {
471 474
                        AddColumn(PSN_PIPESYSTEM, dicColCheck);
472 475
                    }
473
                    
476

  
477
                    matched = names.FirstOrDefault(param => param == PSN_NOPOCKETSETTING);
478
                    dicColCheck.Clear();
479
                    dicColCheck.Add("[INDEX]", "INTEGER");
480
                    dicColCheck.Add("[TYPE]", "TEXT");
481
                    dicColCheck.Add("[NAME]", "TEXT");
482
                    if (matched == null)
483
                    {
484
                        var query = $"CREATE TABLE {PSN_NOPOCKETSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [NAME] TEXT)";
485
                        using (var cmd = connection.GetSqlStringCommand(query))
486
                        {
487
                            cmd.ExecuteNonQuery();
488
                        }
489
                    }
490
                    else
491
                    {
492
                        AddColumn(PSN_NOPOCKETSETTING, dicColCheck);
493
                    }
494

  
474 495

  
475 496
                    void AddColumn(string TableName, Dictionary<string, string> dicCol)
476 497
                    {
......
1090 1111
            return dt;
1091 1112
        }
1092 1113

  
1114
        public static DataTable SelectEquipmentNoPocketSetting()
1115
        {
1116
            DataTable dt = null;
1117
            ID2Info id2Info = ID2Info.GetInstance();
1118

  
1119
            using (IAbstractDatabase connection = id2Info.CreateConnection())
1120
            {
1121
                try
1122
                {
1123
                    var query = $@"SELECT [INDEX], [TYPE], [NAME] FROM {PSN_NOPOCKETSETTING};";
1124
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
1125
                    {
1126
                        dt = ds.Tables[0].Copy();
1127
                    }
1128
                }
1129
                catch (Exception ex)
1130
                {
1131
                    Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1132
                }
1133
            }
1134

  
1135
            return dt;
1136
        }
1137

  
1093 1138
        public static bool SaveHeaderSetting(List<HeaderInfo> headerInfos)
1094 1139
        {
1095 1140
            ID2Info id2Info = ID2Info.GetInstance();
......
1240 1285
            return true;
1241 1286
        }
1242 1287

  
1288
        public static bool SaveEquipmentNopocketSetting(List<EquipmentNoPocketItem> keywordItems)
1289
        {
1290
            ID2Info id2Info = ID2Info.GetInstance();
1291
            using (IAbstractDatabase connection = id2Info.CreateConnection())
1292
            {
1293
                using (var txn = connection.BeginTransaction())
1294
                {
1295
                    try
1296
                    {
1297
                        var query = $"DELETE FROM {PSN_NOPOCKETSETTING}";
1298
                        connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1299

  
1300
                        foreach (EquipmentNoPocketItem item in keywordItems)
1301
                        {
1302
                            query = $"INSERT INTO {PSN_NOPOCKETSETTING} ([INDEX], [TYPE], [NAME]) VALUES (@INDEX, @TYPE, @NAME)";
1303
                            var cmd = connection.GetSqlStringCommand(query);
1304
                            AddWithValue(cmd, "@INDEX", item.Index);
1305
                            AddWithValue(cmd, "@TYPE", item.Type);
1306
                            AddWithValue(cmd, "@NAME", item.Name);
1307
                            connection.ExecuteNonQuery(cmd, txn);
1308
                        }
1309

  
1310
                        txn.Commit();
1311
                    }
1312
                    catch (Exception ex)
1313
                    {
1314
                        Log.Write(ex.Message + "\r\n" + ex.StackTrace);
1315
                        return false;
1316
                    }
1317
                }
1318
            }
1319

  
1320
            return true;
1321
        }
1322

  
1243 1323
        public static bool SaveTopologyRule(DataTable dt)
1244 1324
        {
1245 1325
            ID2Info id2Info = ID2Info.GetInstance();
......
2791 2871
                        AddColumn(PSN_PIPESYSTEM, dicColCheck);
2792 2872
                    }
2793 2873

  
2874
                    matched = names.FirstOrDefault(param => param == PSN_NOPOCKETSETTING);
2875
                    dicColCheck.Clear();
2876
                    dicColCheck.Add("[INDEX]", "INTEGER");
2877
                    dicColCheck.Add("[TYPE]", "TEXT");
2878
                    dicColCheck.Add("[NAME]", "TEXT");
2879
                    if (matched == null)
2880
                    {
2881
                        var query = $"CREATE TABLE {PSN_NOPOCKETSETTING} ([INDEX] INTEGER, [TYPE] TEXT, [NAME] TEXT)";
2882
                        using (var cmd = connection.GetSqlStringCommand(query))
2883
                        {
2884
                            cmd.ExecuteNonQuery();
2885
                        }
2886
                    }
2887
                    else
2888
                    {
2889
                        AddColumn(PSN_NOPOCKETSETTING, dicColCheck);
2890
                    }
2794 2891

  
2795 2892
                    var query2 = $"If(db_id(N'" + PSN_COMMON + "') IS NULL) CREATE DATABASE [" + PSN_COMMON + "]";
2796 2893
                    if (id2Info.ID2DBType == AnotherID2DB_Type.MSSQL)
......
3042 3139
        }
3043 3140

  
3044 3141
        public static bool SaveAnotherPSNData(PSN item, List<HeaderInfo> headerInfos, List<VentDrainInfo> ventDrainInfos,
3045
          List<KeywordItem> keywordItems, DataTable dtTopologyRule, DataTable dtFluidCode, DataTable dtPMC, DataTable dtInsulation, DataTable dtvalvegrouping)
3142
          List<KeywordItem> keywordItems, DataTable dtTopologyRule, DataTable dtFluidCode, DataTable dtPMC, DataTable dtInsulation, DataTable dtvalvegrouping, DataTable dtnopocket)
3046 3143
        {
3047 3144
            AnotherID2Info id2Info = AnotherID2Info.GetInstance();
3048 3145

  
......
3491 3588
                                connection.ExecuteNonQuery(cmd, txn);
3492 3589
                            }
3493 3590

  
3591
                            //no pocket Setting
3592
                            query = $"DELETE FROM {PSN_NOPOCKETSETTING}";
3593
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
3594

  
3595
                            foreach (DataRow row in dtnopocket.Rows)
3596
                            {
3597
                                query = $"INSERT INTO {PSN_NOPOCKETSETTING} ([INDEX], [TYPE], [NAME]) VALUES (@INDEX, @TYPE, @NAME)";
3598
                                var cmd = connection.GetSqlStringCommand(query);
3599
                                AddWithValue(cmd, "@INDEX", row["INDEX"].ToString());
3600
                                AddWithValue(cmd, "@TYPE", row["TYPE"].ToString());
3601
                                AddWithValue(cmd, "@NAME", row["NAME"].ToString());
3602
                                connection.ExecuteNonQuery(cmd, txn);
3603
                            }
3604

  
3494 3605
                            txn.Commit();
3495 3606
                        }
3496 3607
                        catch (Exception ex)

내보내기 Unified diff

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