개정판 531fb158
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); |
내보내기 Unified diff