프로젝트

일반

사용자정보

개정판 531fb158

ID531fb15886bc77e6b925fd250a2bd36c559d93bf
상위 291cf023
하위 0a2fbe44

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

issue #000: PipeSystem 추가

Change-Id: I0ac2e32fed334f7206ba2874aab3e33b7376a0e6

차이점 보기:

DTI_PID/ID2PSN/DB.cs
33 33
        //2022.01.12 추가 //ARS_COMMON DB
34 34
        const string PSN_REVISION = "PSNRevision";
35 35
        const string PSN_COMMON = "ARS_COMMON";
36
        //2022.01.19 추가
37
        const string PSN_PIPESYSTEM = "SPPIDPipeSystem";
36 38
        /// <summary>
37 39
        ///  ID2 Project.db 데이터를 가져온다. 
38 40
        ///  DB 접속 정보 및 DBType (Sqlite, Mssql) 정보를 가져옴
......
436 438
                    dicColCheck.Add("SppidSymbolName", "NVARCHAR(255)");
437 439
                    if (matched == null)
438 440
                    {
439
                        var query = $"CREATE TABLE {PSN_VALVEGROUP_SETTING} (OID NVARCHAR(50), GroupType NVARCHAR(255), TagIdentifier NVARCHAR(50), AttributeName NVARCHAR(255), SppidSymbolName NVARCHAR(255))";
441
                        var query = $"CREATE TABLE {PSN_VALVEGROUP_SETTING} (OID NVARCHAR(255), GroupType NVARCHAR(255), TagIdentifier NVARCHAR(50), AttributeName NVARCHAR(255), SppidSymbolName NVARCHAR(255))";
440 442
                        using (var cmd = connection.GetSqlStringCommand(query))
441 443
                        {
442 444
                            cmd.ExecuteNonQuery();
......
447 449
                        AddColumn(PSN_VALVEGROUP_SETTING, dicColCheck);
448 450
                    }
449 451

  
452
                    matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEM);
453
                    dicColCheck.Clear();
454
                    dicColCheck.Add("OID", "NVARCHAR(255)");
455
                    dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)");
456
                    dicColCheck.Add("FLUID", "NVARCHAR(255)");
457
                    dicColCheck.Add("PMC", "NVARCHAR(255)");
458
                    dicColCheck.Add("PipeLineQty", "NVARCHAR(255)");
459
                    dicColCheck.Add("GroundLevel", "NVARCHAR(20)");
460
                    if (matched == null)
461
                    {
462
                        var query = $"CREATE TABLE {PSN_PIPESYSTEM} (OID NVARCHAR(255), DESCRIPTION NVARCHAR(255), FLUID NVARCHAR(255), PMC NVARCHAR(255), PipeLineQty NVARCHAR(255), GroundLevel NVARCHAR(20))";
463
                        using (var cmd = connection.GetSqlStringCommand(query))
464
                        {
465
                            cmd.ExecuteNonQuery();
466
                        }
467
                    }
468
                    else
469
                    {
470
                        AddColumn(PSN_PIPESYSTEM, dicColCheck);
471
                    }
450 472
                    
451 473

  
452 474
                    void AddColumn(string TableName, Dictionary<string, string> dicCol)
......
1382 1404
                            AddWithValue(cmd, "@ProjectCode", ProjectCode);
1383 1405
                            AddWithValue(cmd, "@RevNumber", RevNumber);
1384 1406
                            AddWithValue(cmd, "@UserName", UserName);
1385
                            AddWithValue(cmd, "@TimeData", DateTime.Now.ToLongDateString());
1407
                            AddWithValue(cmd, "@TimeData", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
1386 1408
                            AddWithValue(cmd, "@PSNDatabasePath", PSNDatabasePath);
1387 1409

  
1388 1410
                            AddWithValue(cmd, "@PsnByPBSFilter", PsnByPBSFilter);
......
1617 1639
                                connection.ExecuteNonQuery(cmd, txn);
1618 1640
                            }
1619 1641

  
1620
                           
1642
                            //PipeSystem
1643
                            query = $"DELETE FROM {PSN_PIPESYSTEM}";
1644
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1645
                            foreach (DataRow row in item.PipeSystem.Rows)
1646
                            {
1647
                                query = $"INSERT INTO {PSN_PIPESYSTEM} (OID, DESCRIPTION, FLUID, PMC, PipeLineQty, GroundLevel) VALUES (@OID, @DESCRIPTION, @FLUID, @PMC, @PipeLineQty, @GroundLevel)";
1648
                                var cmd = connection.GetSqlStringCommand(query);
1649
                                AddWithValue(cmd, "@OID", row["OID"].ToString());
1650
                                AddWithValue(cmd, "@DESCRIPTION", row["DESCRIPTION"].ToString());
1651
                                AddWithValue(cmd, "@FLUID", row["FLUID"].ToString());
1652
                                AddWithValue(cmd, "@PMC", row["PMC"].ToString());
1653
                                AddWithValue(cmd, "@PipeLineQty", row["PipeLineQty"].ToString());
1654
                                AddWithValue(cmd, "@GroundLevel", row["GroundLevel"].ToString());
1655
                                connection.ExecuteNonQuery(cmd, txn);
1656
                            }
1657

  
1621 1658
                            query = $"If(db_id(N'" + PSN_COMMON + "') IS NULL) CREATE DATABASE [" + PSN_COMMON + "]";
1622 1659
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
1623 1660
                          
......
2033 2070
                        result.TopologySet = ds.Tables[0].Copy();
2034 2071
                    }
2035 2072

  
2036
                   
2037

  
2038 2073
                    query = $"SELECT * FROM {PSN_PIPELINE}";
2039 2074
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
2040 2075
                    {
2041 2076
                        result.PipeLine = ds.Tables[0].Copy();
2042
                    }                    
2077
                    }
2078

  
2079
                    query = $"SELECT * FROM {PSN_PIPESYSTEM}";
2080
                    using (var ds = connection.ExecuteDataSet(connection.GetSqlStringCommand(query)))
2081
                    {
2082
                        result.PipeSystem = ds.Tables[0].Copy();
2083
                    }
2043 2084

  
2044 2085
                    result.Revision = GetRevision();
2045 2086
                }
......
2598 2639
                        AddColumn(PSN_VALVEGROUP_SETTING, dicColCheck);
2599 2640
                    }
2600 2641

  
2642
                    matched = names.FirstOrDefault(param => param == PSN_PIPESYSTEM);
2643
                    dicColCheck.Clear();
2644
                    dicColCheck.Add("OID", "NVARCHAR(255)");
2645
                    dicColCheck.Add("DESCRIPTION", "NVARCHAR(255)");
2646
                    dicColCheck.Add("FLUID", "NVARCHAR(255)");
2647
                    dicColCheck.Add("PMC", "NVARCHAR(255)");
2648
                    dicColCheck.Add("PipeLineQty", "NVARCHAR(255)");
2649
                    dicColCheck.Add("GroundLevel", "NVARCHAR(20)");
2650
                    if (matched == null)
2651
                    {
2652
                        var query = $"CREATE TABLE {PSN_PIPESYSTEM} (OID NVARCHAR(255), DESCRIPTION NVARCHAR(255), FLUID NVARCHAR(255), PMC NVARCHAR(255), PipeLineQty NVARCHAR(255), GroundLevel NVARCHAR(20))";
2653
                        using (var cmd = connection.GetSqlStringCommand(query))
2654
                        {
2655
                            cmd.ExecuteNonQuery();
2656
                        }
2657
                    }
2658
                    else
2659
                    {
2660
                        AddColumn(PSN_PIPESYSTEM, dicColCheck);
2661
                    }
2662

  
2601 2663
                    void AddColumn(string TableName, Dictionary<string, string> dicCol)
2602 2664
                    {
2603 2665
                        var colnames = connection.GetColumnNames(TableName);
......
2838 2900
                                connection.ExecuteNonQuery(cmd, txn);
2839 2901
                            }
2840 2902

  
2903
                            //PipeSystem
2904
                            query = $"DELETE FROM {PSN_PIPESYSTEM}";
2905
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
2906
                            foreach (DataRow row in item.PipeSystem.Rows)
2907
                            {
2908
                                query = $"INSERT INTO {PSN_PIPESYSTEM} (OID, DESCRIPTION, FLUID, PMC, PipeLineQty, GroundLevel) VALUES (@OID, @DESCRIPTION, @FLUID, @PMC, @PipeLineQty, @GroundLevel)";
2909
                                var cmd = connection.GetSqlStringCommand(query);
2910
                                AddWithValue(cmd, "@OID", row["OID"].ToString());
2911
                                AddWithValue(cmd, "@DESCRIPTION", row["DESCRIPTION"].ToString());
2912
                                AddWithValue(cmd, "@FLUID", row["FLUID"].ToString());
2913
                                AddWithValue(cmd, "@PMC", row["PMC"].ToString());
2914
                                AddWithValue(cmd, "@PipeLineQty", row["PipeLineQty"].ToString());
2915
                                AddWithValue(cmd, "@GroundLevel", row["GroundLevel"].ToString());
2916
                                connection.ExecuteNonQuery(cmd, txn);
2917
                            }
2918

  
2841 2919
                            //Header Setting
2842 2920
                            query = $"DELETE FROM {PSN_HEADER_SETTING}";
2843 2921
                            connection.ExecuteNonQuery(connection.GetSqlStringCommand(query), txn);
DTI_PID/ID2PSN/Form/DBSettingForm.cs
206 206
                                DrawingCnt++;
207 207
                        }
208 208

  
209
                        int PipeSystems = 0; //아직테이블추가안됨 AG-UG할때추가
209
                        int PipeSystems = _currentPSN.PipeSystem.Rows.Count;
210 210
                        int PipeLines = _currentPSN.PipeLine.Rows.Count;
211 211
                        int Topologies = _currentPSN.TopologySet.Rows.Count;
212 212
                        int pipeSystemNetworks = _currentPSN.PipeSystemNetwork.Rows.Count;
DTI_PID/ID2PSN/PSN.cs
42 42
        public DataTable Equipment { get; set; }
43 43
        public DataTable Nozzle { get; set; }
44 44
        public DataTable PipeLine { get; set; }
45
        public DataTable PipeSystem { get; set; }
45 46

  
46 47
        public string Rule1 = "Missing LineNumber_1"; //Line Disconnected에서 변경
47 48
        public string Rule2 = "Missing LineNumber_2"; //Missing LineNumber에서 변경
......
1139 1140
                pipelineDT.Columns.Add("TO_DATA", typeof(string));
1140 1141
                pipelineDT.Columns.Add("Unit", typeof(string));
1141 1142

  
1143
                DataTable pipesystemDT = new DataTable();
1144
                pipesystemDT.Columns.Add("OID", typeof(string));
1145
                pipesystemDT.Columns.Add("DESCRIPTION", typeof(string));
1146
                pipesystemDT.Columns.Add("FLUID", typeof(string));
1147
                pipesystemDT.Columns.Add("PMC", typeof(string));
1148
                pipesystemDT.Columns.Add("PipeLineQty", typeof(string));
1149
                pipesystemDT.Columns.Add("GroundLevel", typeof(string));
1150

  
1142 1151
                // Set Vent/Drain Info
1143 1152
                List<VentDrainInfo> VentDrainInfos = new List<VentDrainInfo>();
1144 1153
                DataTable dt = DB.SelectVentDrainSetting();
......
1204 1213
                // key = 미입력 branch
1205 1214
                Dictionary<Item, Item> startBranchDic = new Dictionary<Item, Item>();
1206 1215
                Dictionary<Item, Item> endBranchDic = new Dictionary<Item, Item>();
1207
                int vgTagNum = 0;
1216
                DataTable PSNFluidDT = DB.SelectPSNFluidCode();
1217
                DataTable PSNPMCDT = DB.SelectPSNPIPINGMATLCLASS();
1208 1218
                foreach (PSNItem PSNItem in PSNItems)
1209 1219
                {
1210 1220
                    try
......
1217 1227
                        
1218 1228
                        List<Group> Groups = PSNItem.Groups;
1219 1229
                        Dictionary<string, List<Item>> keyValuePairs = new Dictionary<string, List<Item>>();
1220
                        List<Item> valveGroupingItem = new List<Item>();
1221
                        int bCnt = 0;
1222
                        
1223
                        int beforeCnt = 0;
1224
                        bool bCheck = false;
1225
                        //foreach (Group group in Groups)
1226
                        //{
1227
                        //    IEnumerable<Item> items = null;
1228
                        //    foreach (ValveGroupItem valveitem in ValveGrouping.ValveGroupItems)
1229
                        //    {
1230
                        //        beforeCnt = bCnt;
1231
                        //        items = group.Items.Where(x => x.ItemType == ItemType.Symbol && x.Name == valveitem.SppidSymbolName);
1232

  
1233
                        //        if (items.Count() > 0)
1234
                        //        {
1235
                        //            List<Item> lstitem = new List<Item>();
1236
                        //            foreach (Item item in group.Items)
1237
                        //            {
1238
                        //                lstitem.Add(item);
1239
                        //                if (item.BranchItems.Count > 0)
1240
                        //                {
1241
                        //                    bCheck = true;
1242
                        //                    foreach (Item it in lstitem)
1243
                        //                    {
1244
                        //                        if(it.Name == valveitem.SppidSymbolName)
1245
                        //                        {
1246
                        //                            //List<Item> allitem = ;
1247
                        //                            keyValuePairs.Add(valveitem.OID, lstitem.ToList());
1248
                        //                            bCnt++;
1249
                        //                        }
1250
                        //                    }
1251
                                            
1252
                        //                    lstitem.Clear();
1253
                        //                }
1254
                        //            }
1255

  
1256
                        //            if(!bCheck)
1257
                        //            {
1258
                        //                keyValuePairs.Add(valveitem.OID, lstitem);
1259
                        //                bCnt++;
1260
                        //            }
1261
                        //            if (items.Count() == bCnt - beforeCnt)
1262
                        //                continue;
1263
                        //        }
1264
                        //    }                          
1265
                        //}
1266
                        
1230
                        List<Item> valveGroupingItem = new List<Item>();                   
1267 1231
                        
1268 1232
                        //VentDrain 검사
1269 1233
                        if (PSNItem.Groups.Count.Equals(1))
......
1329 1293
                        }
1330 1294
                                                                       
1331 1295
                        try
1332
                        {
1333
                            //   Prefix + "-" + 선택한 Attribute 값으로 VG Tag 생성
1334
                            //-> Use ID2 Attribute는 No selection으로 콤보 박스에 포함시키고, 그런 경우 Prefix +"-XXXXX"로 자동 넘버 생성
1335
                            //PSN, PathItems, SequenceData 관련
1336
                            
1296
                        {                            
1337 1297
                            foreach (Group group in PSNItem.Groups)
1338
                            {
1339
                                //IEnumerable<Item> bFindBranch = group.Items.Where(x => x.BranchItems.Count() > 0);
1340
                               
1298
                            {                               
1341 1299
                                foreach (Item item in group.Items)
1342
                                {
1343
                                    //string VGTag = string.Empty;
1344
                                    //if (keyValuePairs.Count > 0)
1345
                                    //{
1346
                                    //    foreach(KeyValuePair<string, List<Item>> valuePair in keyValuePairs)
1347
                                    //    {
1348
                                    //        if(valuePair.Value.Select(x => x.UID == item.UID).Count() > 0)
1349
                                    //        {
1350

  
1351
                                    //            ValveGroupItem valveitem = ValveGrouping.ValveGroupItems.Where(x => x.OID == valuePair.Key).First();
1352
                                    //            if(valveitem.AttributeName == "NoSelection")
1353
                                    //            {
1354
                                    //                VGTag = valveitem.TagIdentifier + string.Format("-{0}", string.Format("{0:D5}", vgTagNum));
1355
                                    //                vgTagNum++;
1356
                                    //            }
1357
                                    //            else
1358
                                    //            {
1359
                                    //                Item attValue = valuePair.Value.Where(x => x.Name == valveitem.SppidSymbolName).First();
1360
                                    //                string value = attValue.Attributes.Find(x => x.Name == valveitem.AttributeName).Value;
1361
                                    //                VGTag = valveitem.TagIdentifier +"-"+ value;
1362
                                    //            }
1363
                                    //        }
1364
                                    //    }
1365
                                    //}
1366
                                    
1300
                                {            
1367 1301
                                    string VgTag = string.Empty;
1368 1302
                                    if (ValveGrouping.ValveGroupItems.Where(x => x.SppidSymbolName == item.Name).Count() >0)
1369 1303
                                    {
......
1404 1338
                                    }
1405 1339
                                    
1406 1340
                                    if (bPSNStart)
1407
                                    {
1408
                                        
1341
                                    {                                        
1409 1342
                                        CreatePipeSystemNetworkDataRow();
1410 1343
                                        sPSNData = item.TopologyData;
1411 1344
                                        //i
......
1502 1435
                                                if (!string.IsNullOrEmpty(INSULATION)) oid.Add(INSULATION);
1503 1436

  
1504 1437
                                                string OID = string.Join("-", oid);
1438
                                                string FluidCodeGL = string.Empty;
1439
                                                string PMCGL = string.Empty;
1440
                                                
1505 1441

  
1506 1442
                                                if (pipelineDT.Select(string.Format("OID = '{0}'", OID)).Count() == 0)
1507 1443
                                                {
......
1515 1451
                                                    newPipelineRow["FROM_DATA"] = string.Empty;
1516 1452
                                                    newPipelineRow["TO_DATA"] = string.Empty;
1517 1453
                                                    newPipelineRow["Unit"] = PSNItem.GetPBSData();
1518
                                                    pipelineDT.Rows.Add(newPipelineRow);
1454
                                                    pipelineDT.Rows.Add(newPipelineRow);                                                   
1455
                                                }
1456

  
1457
                                                if (pipesystemDT.Select(string.Format("OID = '{0}'", PipeSystem_OID)).Count() == 0)
1458
                                                {
1459
                                                    //DataRow newPipesystemRow = pipesystemDT.NewRow();
1460
                                                    //newPipesystemRow["OID"] = PipeSystem_OID;
1461
                                                    //newPipesystemRow["DESCRIPTION"] = string.Empty;
1462
                                                    //newPipesystemRow["FLUID"] = FluidCode;
1463
                                                    //newPipesystemRow["PMC"] = PMC;
1464
                                                    //newPipesystemRow["PipeLineQty"] = string.Empty;
1465
                                                    //string GroundLevel = string.Empty;
1466
                                                    //if (!string.IsNullOrEmpty(FluidCode) && !string.IsNullOrEmpty(PMC))
1467
                                                    //{
1468
                                                    //    FluidCodeGL = PSNFluidDT.Select(string.Format("Code = '{0}'", FluidCode)).FirstOrDefault().Field<string>("GroundLevel");
1469
                                                    //    PMCGL = PSNPMCDT.Select(string.Format("Code= '{0}'", PMC)).FirstOrDefault().Field<string>("GroundLevel");
1470
                                                    //    if (FluidCodeGL == "AG" && PMCGL == "AG")
1471
                                                    //        GroundLevel = "AG";
1472
                                                    //    else if (FluidCodeGL == "UG" && PMCGL == "UG")
1473
                                                    //        GroundLevel = "UG";
1474
                                                    //    else
1475
                                                    //        GroundLevel = "AG_UG";
1476
                                                    //}
1477
                                                    //newPipesystemRow["GroundLevel"] = GroundLevel;
1478

  
1479
                                                    //pipesystemDT.Rows.Add(newPipesystemRow);
1519 1480
                                                }
1520 1481
                                            }
1521 1482
                                        }
......
1745 1706
                PipeSystemNetwork = pipeSystemNetworkDT;
1746 1707
                TopologySet = topologySetDT;
1747 1708
                PipeLine = pipelineDT;
1709
                PipeSystem = pipesystemDT;
1748 1710
            }
1749 1711
            catch (Exception ex)
1750 1712
            {

내보내기 Unified diff

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