개정판 4b4dbca9
dev issue #000 : child Symbol Modeling
Change-Id: I26536f33fec33160b1efaf92f4fc5b45ccd48f9b
DTI_PID/BaseModel/Project_DB.cs | ||
---|---|---|
221 | 221 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
222 | 222 |
{ |
223 | 223 |
cmd.CommandText = string.Format(@" |
224 |
SELECT s.UID, s.Name, st.Type, sp.SPPID_SYMBOL_PATH FROM {1} as st, {0} as s |
|
224 |
SELECT sp.UID, s.Name, st.Type, sp.SPPID_SYMBOL_PATH FROM {1} as st, {0} as s
|
|
225 | 225 |
LEFT OUTER JOIN {2} as sp |
226 | 226 |
ON s.UID = SP.UID |
227 | 227 |
WHERE s.SymbolType_UID = st.UID |
... | ... | |
244 | 244 |
return dt; |
245 | 245 |
} |
246 | 246 |
|
247 |
public static DataTable SelectProjectChildSymbol() |
|
248 |
{ |
|
249 |
DataTable result = new DataTable(); |
|
250 |
result.Columns.Add("UID"); |
|
251 |
result.Columns.Add("Name"); |
|
252 |
result.Columns.Add("Type"); |
|
253 |
result.Columns.Add("SPPID_SYMBOL_PATH"); |
|
254 |
|
|
255 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
256 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
257 |
using (DataTable dt = new DataTable()) |
|
258 |
{ |
|
259 |
try |
|
260 |
{ |
|
261 |
connection.Open(); |
|
262 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
263 |
{ |
|
264 |
cmd.CommandText = string.Format(@" |
|
265 |
SELECT AdditionalSymbol FROM Symbol"); |
|
266 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
267 |
dt.Load(dr); |
|
268 |
List<string> childList = new List<string>(); |
|
269 |
foreach (DataRow row in dt.Rows) |
|
270 |
{ |
|
271 |
if (!string.IsNullOrEmpty((string)row["AdditionalSymbol"])) |
|
272 |
{ |
|
273 |
string[] array = row["AdditionalSymbol"].ToString().Split(new char[] { '/' }); |
|
274 |
foreach (var childString in array) |
|
275 |
{ |
|
276 |
childList.Add(childString.Split(new char[] { ',' })[2]); |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
dt.Clear(); |
|
283 |
cmd.Reset(); |
|
284 |
cmd.CommandText = string.Format(@" |
|
285 |
SELECT * FROM {0}", SPPID_SYMBOL_MAPPING_TABLE); |
|
286 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
287 |
dt.Load(dr); |
|
288 |
|
|
289 |
childList = childList.Distinct().ToList(); |
|
290 |
foreach (var child in childList) |
|
291 |
{ |
|
292 |
string mappingPath = string.Empty; |
|
293 |
DataRow[] rows = dt.Select(string.Format("UID = '{0}'", child)); |
|
294 |
if (rows.Length == 1) |
|
295 |
mappingPath = !DBNull.Value.Equals(rows[0]["SPPID_SYMBOL_PATH"]) ? (string)rows[0]["SPPID_SYMBOL_PATH"] : null; |
|
296 |
|
|
297 |
DataRow newRow = result.NewRow(); |
|
298 |
newRow["UID"] = child; |
|
299 |
newRow["Name"] = child; |
|
300 |
newRow["Type"] = "Child Symbol"; |
|
301 |
newRow["SPPID_SYMBOL_PATH"] = mappingPath; |
|
302 |
result.Rows.Add(newRow); |
|
303 |
} |
|
304 |
} |
|
305 |
connection.Close(); |
|
306 |
} |
|
307 |
catch (Exception ex) |
|
308 |
{ |
|
309 |
|
|
310 |
} |
|
311 |
finally |
|
312 |
{ |
|
313 |
connection.Dispose(); |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
return result; |
|
318 |
} |
|
319 |
|
|
247 | 320 |
public static DataTable SelectProjectLine() |
248 | 321 |
{ |
249 | 322 |
DataTable dt = new DataTable(); |
내보내기 Unified diff