개정판 306a0af9
dev issue #1124 : Rev, Title 등 Drawing Attribute
Change-Id: Ie8f03675faee4134f6360a89239767eae826e76d
DTI_PID/SPPIDConverter/DB/Project_DB.cs | ||
---|---|---|
22 | 22 |
const string SPPID_LABEL_INFO_TABLE = "T_SPPID_LABEL_INFO"; |
23 | 23 |
const string SPPID_DRAWING_INFO = "T_SPPID_DRAWING_INFO"; |
24 | 24 |
const string SPPID_OPC_INFO = "T_SPPID_OPC_INFO"; |
25 |
const string ID2_DRAWINGATTRIBUTE_TABLE = "T_ID2_DRAWINGATTRIBUTE"; |
|
25 | 26 |
|
26 | 27 |
const string LineProperties_TABLE = "LineProperties"; |
27 | 28 |
const string LineTypes_TABLE = "LineTypes"; |
... | ... | |
29 | 30 |
const string SymbolAttribute_TABLE = "SymbolAttribute"; |
30 | 31 |
const string Symbol_TABLE = "Symbol"; |
31 | 32 |
const string OPCRelations_TABLE = "OPCRelations"; |
33 |
const string DrawingAttribute_Table = "TitleBlockProperties"; |
|
32 | 34 |
|
33 | 35 |
private static SqlConnection GetSqlConnection() |
34 | 36 |
{ |
... | ... | |
113 | 115 |
cmd.CommandText = string.Format("CREATE TABLE {0} (ID2_OPC_UID TEXT PRIMARY KEY, SPPID_OPC_MODELITEM_ID TEXT, ID2_DRAWING_UID TEXT, ATTRIBUTES TEXT, PAIRED BOOL)", SPPID_OPC_INFO); |
114 | 116 |
cmd.ExecuteNonQuery(); |
115 | 117 |
} |
118 |
if (dt.Select(string.Format("NAME = '{0}'", ID2_DRAWINGATTRIBUTE_TABLE)).Length == 0) |
|
119 |
{ |
|
120 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, NAME TEXT)", ID2_DRAWINGATTRIBUTE_TABLE); |
|
121 |
cmd.ExecuteNonQuery(); |
|
122 |
|
|
123 |
List<string> datas = new List<string>() { "Unit", "Rev No", "Drawing No" }; |
|
124 |
foreach (var data in datas) |
|
125 |
{ |
|
126 |
cmd.CommandText = string.Format("INSERT INTO {0} VALUES('{1}', '{1}')", ID2_DRAWINGATTRIBUTE_TABLE, data); |
|
127 |
cmd.ExecuteNonQuery(); |
|
128 |
} |
|
129 |
} |
|
116 | 130 |
} |
117 | 131 |
|
118 | 132 |
#region Check Column 업데이트시 예비용 |
... | ... | |
221 | 235 |
cmd.CommandText = string.Format("CREATE TABLE {0} (ID2_OPC_UID varchar(255) PRIMARY KEY, SPPID_OPC_MODELITEM_ID varchar(MAX), ID2_DRAWING_UID varchar(MAX), ATTRIBUTES varchar(MAX), PAIRED BIT)", SPPID_OPC_INFO); |
222 | 236 |
cmd.ExecuteNonQuery(); |
223 | 237 |
} |
238 |
if (dt.Select(string.Format("NAME = '{0}'", ID2_DRAWINGATTRIBUTE_TABLE)).Length == 0) |
|
239 |
{ |
|
240 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, NAME varchar(255))", ID2_DRAWINGATTRIBUTE_TABLE); |
|
241 |
cmd.ExecuteNonQuery(); |
|
242 |
|
|
243 |
List<string> datas = new List<string>() { "Unit", "Rev No", "Drawing No" }; |
|
244 |
foreach (var data in datas) |
|
245 |
{ |
|
246 |
cmd.CommandText = string.Format("INSERT INTO {0} VALUES('{1}', '{1}')", ID2_DRAWINGATTRIBUTE_TABLE, data); |
|
247 |
cmd.ExecuteNonQuery(); |
|
248 |
} |
|
249 |
} |
|
224 | 250 |
} |
225 | 251 |
|
226 | 252 |
#region Check Column 업데이트시 예비용 |
... | ... | |
963 | 989 |
return dt; |
964 | 990 |
} |
965 | 991 |
|
992 |
public static DataTable SelectDrawingProjectAttribute() |
|
993 |
{ |
|
994 |
DataTable dt = new DataTable(); |
|
995 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
996 |
if (projectInfo.DBType == ID2DB_Type.SQLite) |
|
997 |
{ |
|
998 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
999 |
{ |
|
1000 |
try |
|
1001 |
{ |
|
1002 |
connection.Open(); |
|
1003 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
1004 |
{ |
|
1005 |
cmd.CommandText = string.Format(@" |
|
1006 |
SELECT da.UID, da.NAME, sam.SPPID_ATTRIBUTE |
|
1007 |
FROM {0} as da |
|
1008 |
LEFT OUTER JOIN {1} as sam |
|
1009 |
ON da.UID = sam.UID; |
|
1010 |
", DrawingAttribute_Table, SPPID_ATTRIBUTE_MAPPING_TABLE); |
|
1011 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
1012 |
dt.Load(dr); |
|
1013 |
} |
|
1014 |
connection.Close(); |
|
1015 |
} |
|
1016 |
catch (Exception ex) |
|
1017 |
{ |
|
1018 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
1019 |
} |
|
1020 |
finally |
|
1021 |
{ |
|
1022 |
connection.Dispose(); |
|
1023 |
} |
|
1024 |
} |
|
1025 |
} |
|
1026 |
else if (projectInfo.DBType == ID2DB_Type.MSSQL) |
|
1027 |
{ |
|
1028 |
using (SqlConnection connection = GetSqlConnection()) |
|
1029 |
{ |
|
1030 |
try |
|
1031 |
{ |
|
1032 |
if (connection != null && connection.State == ConnectionState.Open) |
|
1033 |
{ |
|
1034 |
using (SqlCommand cmd = connection.CreateCommand()) |
|
1035 |
{ |
|
1036 |
cmd.CommandText = string.Format(@" |
|
1037 |
SELECT da.UID, da.NAME, sam.SPPID_ATTRIBUTE |
|
1038 |
FROM {0} as da |
|
1039 |
LEFT OUTER JOIN {1} as sam |
|
1040 |
ON da.UID = sam.UID; |
|
1041 |
", DrawingAttribute_Table, SPPID_ATTRIBUTE_MAPPING_TABLE); |
|
1042 |
using (SqlDataReader dr = cmd.ExecuteReader()) |
|
1043 |
dt.Load(dr); |
|
1044 |
} |
|
1045 |
connection.Close(); |
|
1046 |
} |
|
1047 |
} |
|
1048 |
catch (Exception ex) |
|
1049 |
{ |
|
1050 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
1051 |
} |
|
1052 |
finally |
|
1053 |
{ |
|
1054 |
if (connection != null) |
|
1055 |
connection.Dispose(); |
|
1056 |
} |
|
1057 |
} |
|
1058 |
} |
|
1059 |
|
|
1060 |
dt.Merge(SelectDrawingProjectAttribute2()); |
|
1061 |
|
|
1062 |
return dt; |
|
1063 |
} |
|
1064 |
private static DataTable SelectDrawingProjectAttribute2() |
|
1065 |
{ |
|
1066 |
DataTable dt = new DataTable(); |
|
1067 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
1068 |
if (projectInfo.DBType == ID2DB_Type.SQLite) |
|
1069 |
{ |
|
1070 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
1071 |
{ |
|
1072 |
try |
|
1073 |
{ |
|
1074 |
connection.Open(); |
|
1075 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
1076 |
{ |
|
1077 |
cmd.CommandText = string.Format(@" |
|
1078 |
SELECT da.UID, da.NAME, sam.SPPID_ATTRIBUTE |
|
1079 |
FROM {0} as da |
|
1080 |
LEFT OUTER JOIN {1} as sam |
|
1081 |
ON da.UID = sam.UID; |
|
1082 |
", ID2_DRAWINGATTRIBUTE_TABLE, SPPID_ATTRIBUTE_MAPPING_TABLE); |
|
1083 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
1084 |
dt.Load(dr); |
|
1085 |
} |
|
1086 |
connection.Close(); |
|
1087 |
} |
|
1088 |
catch (Exception ex) |
|
1089 |
{ |
|
1090 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
1091 |
} |
|
1092 |
finally |
|
1093 |
{ |
|
1094 |
connection.Dispose(); |
|
1095 |
} |
|
1096 |
} |
|
1097 |
} |
|
1098 |
else if (projectInfo.DBType == ID2DB_Type.MSSQL) |
|
1099 |
{ |
|
1100 |
using (SqlConnection connection = GetSqlConnection()) |
|
1101 |
{ |
|
1102 |
try |
|
1103 |
{ |
|
1104 |
if (connection != null && connection.State == ConnectionState.Open) |
|
1105 |
{ |
|
1106 |
using (SqlCommand cmd = connection.CreateCommand()) |
|
1107 |
{ |
|
1108 |
cmd.CommandText = string.Format(@" |
|
1109 |
SELECT da.UID, da.NAME, sam.SPPID_ATTRIBUTE |
|
1110 |
FROM {0} as da |
|
1111 |
LEFT OUTER JOIN {1} as sam |
|
1112 |
ON da.UID = sam.UID; |
|
1113 |
", ID2_DRAWINGATTRIBUTE_TABLE, SPPID_ATTRIBUTE_MAPPING_TABLE); |
|
1114 |
using (SqlDataReader dr = cmd.ExecuteReader()) |
|
1115 |
dt.Load(dr); |
|
1116 |
} |
|
1117 |
connection.Close(); |
|
1118 |
} |
|
1119 |
} |
|
1120 |
catch (Exception ex) |
|
1121 |
{ |
|
1122 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
1123 |
} |
|
1124 |
finally |
|
1125 |
{ |
|
1126 |
if (connection != null) |
|
1127 |
connection.Dispose(); |
|
1128 |
} |
|
1129 |
} |
|
1130 |
} |
|
1131 |
|
|
1132 |
return dt; |
|
1133 |
} |
|
1134 |
|
|
966 | 1135 |
public static DataTable SelectID2SymbolTable() |
967 | 1136 |
{ |
968 | 1137 |
DataTable dt = new DataTable(); |
내보내기 Unified diff