개정판 dd624cbd
dev issue #1227 : fix MappingForm for opc
Change-Id: Icb5ca040676e1064cb7a8d6be4ee8fdf3fa336d2
DTI_PID/APIDConverter/DB/Project_DB.cs | ||
---|---|---|
81 | 81 |
} |
82 | 82 |
if (dt.Select(string.Format("NAME = '{0}'", APID_OPC_MAPPING_TABLE)).Length == 0) |
83 | 83 |
{ |
84 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, IN_SYMBOL TEXT, OUT_SYMBOL TEXT, Type INT)", APID_OPC_MAPPING_TABLE); |
|
84 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID TEXT PRIMARY KEY, IN_SYMBOL TEXT, OUT_SYMBOL TEXT, FlowType INT)", APID_OPC_MAPPING_TABLE);
|
|
85 | 85 |
cmd.ExecuteNonQuery(); |
86 | 86 |
} |
87 | 87 |
} |
... | ... | |
123 | 123 |
} |
124 | 124 |
if (dt.Select(string.Format("NAME = '{0}'", APID_OPC_MAPPING_TABLE)).Length == 0) |
125 | 125 |
{ |
126 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, IN_SYMBOL varchar(MAX), OUT_SYMBOL varchar(MAX), Type INT)", APID_OPC_MAPPING_TABLE); |
|
126 |
cmd.CommandText = string.Format("CREATE TABLE {0} (UID varchar(255) PRIMARY KEY, IN_SYMBOL varchar(MAX), OUT_SYMBOL varchar(MAX), FlowType INT)", APID_OPC_MAPPING_TABLE);
|
|
127 | 127 |
cmd.ExecuteNonQuery(); |
128 | 128 |
} |
129 | 129 |
} |
... | ... | |
226 | 226 |
|
227 | 227 |
return dt; |
228 | 228 |
} |
229 |
public static DataTable GetOPCMappingTable() |
|
230 |
{ |
|
231 |
DataTable dt = new DataTable(); |
|
232 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
233 |
if (projectInfo.DBType == ID2DB_Type.SQLite) |
|
234 |
{ |
|
235 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
236 |
{ |
|
237 |
try |
|
238 |
{ |
|
239 |
connection.Open(); |
|
240 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
241 |
{ |
|
242 |
cmd.CommandText = string.Format(@" |
|
243 |
SELECT s.UID, s.Name, st.Type, sp.IN_SYMBOL, sp.OUT_SYMBOL, sp.FlowType FROM {1} as st, {0} as s |
|
244 |
LEFT OUTER JOIN {2} as sp |
|
245 |
ON s.UID = SP.UID |
|
246 |
WHERE s.SymbolType_UID = st.UID |
|
247 |
AND (st.Type = 'Instrument OPC''s' OR st.Type = 'Piping OPC''s') |
|
248 |
ORDER BY st.TYPE ASC;", Symbol_TABLE, SymbolType_TABLE, APID_OPC_MAPPING_TABLE); |
|
249 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
250 |
dt.Load(dr); |
|
251 |
} |
|
252 |
connection.Close(); |
|
253 |
} |
|
254 |
catch (Exception ex) |
|
255 |
{ |
|
256 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
257 |
} |
|
258 |
finally |
|
259 |
{ |
|
260 |
connection.Dispose(); |
|
261 |
} |
|
262 |
} |
|
263 |
} |
|
264 |
else if (projectInfo.DBType == ID2DB_Type.MSSQL) |
|
265 |
{ |
|
266 |
using (SqlConnection connection = GetSqlConnection()) |
|
267 |
{ |
|
268 |
try |
|
269 |
{ |
|
270 |
if (connection != null && connection.State == ConnectionState.Open) |
|
271 |
{ |
|
272 |
using (SqlCommand cmd = connection.CreateCommand()) |
|
273 |
{ |
|
274 |
cmd.CommandText = string.Format(@" |
|
275 |
SELECT CONVERT(VARCHAR(255), s.UID) AS UID, s.Name, st.Type, sp.IN_SYMBOL, sp.OUT_SYMBOL, sp.FlowType FROM {1} as st, {0} as s |
|
276 |
LEFT OUTER JOIN {2} as sp |
|
277 |
ON CONVERT(VARCHAR(255), s.UID) = CONVERT(VARCHAR(255), SP.UID) |
|
278 |
WHERE s.SymbolType_UID = st.UID |
|
279 |
AND (st.Type = 'Instrument OPC''s' OR st.Type = 'Piping OPC''s') |
|
280 |
ORDER BY st.TYPE ASC;", Symbol_TABLE, SymbolType_TABLE, APID_OPC_MAPPING_TABLE); |
|
281 |
using (SqlDataReader dr = cmd.ExecuteReader()) |
|
282 |
dt.Load(dr); |
|
283 |
} |
|
284 |
connection.Close(); |
|
285 |
} |
|
286 |
} |
|
287 |
catch (Exception ex) |
|
288 |
{ |
|
289 |
Log.Write(ex.Message + "\r\n" + ex.StackTrace); |
|
290 |
} |
|
291 |
finally |
|
292 |
{ |
|
293 |
if (connection != null) |
|
294 |
connection.Dispose(); |
|
295 |
} |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
return dt; |
|
300 |
} |
|
229 | 301 |
public static DataTable GetLineMappingTable() |
230 | 302 |
{ |
231 | 303 |
DataTable dt = new DataTable(); |
내보내기 Unified diff