개정판 1621e1e9
issue #000: revision create table, insert data
Change-Id: If40a59cd2e42af54de325806a7c91d9cbc2d0b56
DTI_PID/ID2PSN/DB.cs | ||
---|---|---|
1354 | 1354 |
return result; |
1355 | 1355 |
} |
1356 | 1356 | |
1357 |
public static bool SaveRevision(string ProjectCode, int RevNumber, string UserName, string PSNDatabasePath, string PsnByPBSFilter, string PsnByNPDFilter, |
|
1358 |
int PidDrawings, int PipeSystems, int PipeLines, int Topologies, int PipeSystemNetworks, int InValidPSNs, int E2E, int E2B, int B2E, int HDE, int HD2, int HDB, int B2B) |
|
1359 |
{ |
|
1360 |
ID2Info id2Info = ID2Info.GetInstance(); |
|
1361 | ||
1362 |
bool result = true; |
|
1363 | ||
1364 |
using (IAbstractDatabase connection = id2Info.CreateConnection()) |
|
1365 |
{ |
|
1366 |
try |
|
1367 |
{ |
|
1368 |
using (var txn = connection.BeginTransaction()) |
|
1369 |
{ |
|
1370 |
try |
|
1371 |
{ |
|
1372 |
|
|
1373 |
var query = $"INSERT INTO ARS_COMMON.dbo.PSNRevision (OID, Project_OID, ProjectCode, RevNumber, UserName, TimeData, PSNDatabasePath, " + |
|
1374 |
$"PsnByPBSFilter, PsnByNPDFilter, PidDrawings, PipeSystems, PipeLines, Topologies, PipeSystemNetworks, InValidPSNs, E2E, E2B, B2E, HDE, " + |
|
1375 |
$"HD2, HDB, B2B) VALUES (NEWID(), NEWID(), @ProjectCode, @RevNumber, @UserName, @TimeData, @PSNDatabasePath" + |
|
1376 |
$", @PsnByPBSFilter, @PsnByNPDFilter, @PidDrawings, @PipeSystems, @PipeLines, @Topologies, @PipeSystemNetworks, @InValidPSNs, " + |
|
1377 |
$"@E2E, @E2B, @B2E, @HDE, @HD2, @HDB, @B2B)"; |
|
1378 |
var cmd = connection.GetSqlStringCommand(query); |
|
1379 |
AddWithValue(cmd, "@OID", Guid.NewGuid().ToString()); |
|
1380 |
AddWithValue(cmd, "@Project_OID", Guid.NewGuid().ToString()); |
|
1381 |
AddWithValue(cmd, "@ProjectCode", ProjectCode); |
|
1382 |
AddWithValue(cmd, "@RevNumber", RevNumber); |
|
1383 |
AddWithValue(cmd, "@UserName", UserName); |
|
1384 |
AddWithValue(cmd, "@TimeData", DateTime.Now.ToLongDateString()); |
|
1385 |
AddWithValue(cmd, "@PSNDatabasePath", PSNDatabasePath); |
|
1386 | ||
1387 |
AddWithValue(cmd, "@PsnByPBSFilter", PsnByPBSFilter); |
|
1388 |
AddWithValue(cmd, "@PsnByNPDFilter", PsnByNPDFilter); |
|
1389 |
AddWithValue(cmd, "@PidDrawings", PidDrawings); |
|
1390 |
AddWithValue(cmd, "@PipeSystems", PipeSystems); |
|
1391 |
AddWithValue(cmd, "@PipeLines", PipeLines); |
|
1392 | ||
1393 |
AddWithValue(cmd, "@Topologies", Topologies); |
|
1394 |
AddWithValue(cmd, "@PipeSystemNetworks", PipeSystemNetworks); |
|
1395 |
AddWithValue(cmd, "@InValidPSNs", InValidPSNs); |
|
1396 |
AddWithValue(cmd, "@E2E", E2E); |
|
1397 |
AddWithValue(cmd, "@E2B", E2B); |
|
1398 |
AddWithValue(cmd, "@B2E", B2E); |
|
1399 |
AddWithValue(cmd, "@HDE", HDE); |
|
1400 |
AddWithValue(cmd, "@HD2", HD2); |
|
1401 |
AddWithValue(cmd, "@HDB", HDB); |
|
1402 |
AddWithValue(cmd, "@B2B", B2B); |
|
1403 |
connection.ExecuteNonQuery(cmd, txn); |
|
1404 |
|
|
1405 |
txn.Commit(); |
|
1406 |
} |
|
1407 |
catch (Exception ex) |
|
1408 |
{ |
|
1409 |
txn.Rollback(); |
|
1410 |
result = false; |
|
1411 |
} |
|
1412 |
} |
|
1413 |
} |
|
1414 |
catch (Exception ex) |
|
1415 |
{ |
|
1416 |
System.Windows.Forms.MessageBox.Show(ex.Message); |
|
1417 |
result = false; |
|
1418 |
} |
|
1419 |
} |
|
1420 | ||
1421 |
return result; |
|
1422 |
} |
|
1423 | ||
1357 | 1424 |
public static bool SavePSNData(PSN item) |
1358 | 1425 |
{ |
1359 | 1426 |
ID2Info id2Info = ID2Info.GetInstance(); |
DTI_PID/ID2PSN/Form/DBSettingForm.cs | ||
---|---|---|
175 | 175 |
//Save |
176 | 176 |
if (DB.SaveAnotherPSNData(_currentPSN, HeaderInfos, VentDrainInfos, KeywordInfos.KeywordItems, dtTopologyRule, PSNFluidDT, PSNPMCDT, PSNINSULATIONDT)) |
177 | 177 |
{ |
178 |
if (rgDbSetting.SelectedIndex == 1) |
|
179 |
{ |
|
180 |
DataTable revisiondt = DB.SelectRevisionTable(); |
|
181 |
List<string> names = new List<string>(); |
|
182 |
foreach (DataRow dr in revisiondt.Rows) |
|
183 |
{ |
|
184 |
names.Add(dr.Field<string>("column_name")); |
|
185 |
} |
|
186 |
Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
|
187 | ||
188 |
dicColCheck.Add("OID", "uniqueidentifier"); |
|
189 |
dicColCheck.Add("Project_OID", "uniqueidentifier"); |
|
190 |
dicColCheck.Add("ProjectCode", "nvarchar(255)"); |
|
191 |
dicColCheck.Add("RevNumber", "int"); |
|
192 |
dicColCheck.Add("UserName", "nvarchar(255)"); |
|
193 |
dicColCheck.Add("TimeData", "nvarchar(255)"); |
|
194 |
dicColCheck.Add("PSNDatabasePath", "nvarchar(255)"); |
|
195 |
dicColCheck.Add("PsnByPBSFilter", "varchar(20)"); |
|
196 |
string PBS = Properties.Settings.Default.PBSSetting; |
|
197 |
dicColCheck.Add("PsnByNPDFilter", "varchar(20)"); |
|
198 |
dicColCheck.Add("PidDrawings", "int"); |
|
199 |
DataTable lstDrawings = DB.SelectDrawings(); |
|
200 |
int DrawingCnt = 0; |
|
201 |
foreach (DataRow row in lstDrawings.Rows) |
|
202 |
{ |
|
203 |
string filePath = string.Format(ID2Info.TempDirPath + "{0}.xml", Path.GetFileNameWithoutExtension(row["NAME"].ToString())); |
|
204 |
if (File.Exists(filePath)) |
|
205 |
DrawingCnt++; |
|
206 |
} |
|
207 | ||
208 |
int PipeSystems = 0; //아직테이블추가안됨 AG-UG할때추가 |
|
209 |
int PipeLines = _currentPSN.PipeLine.Rows.Count; |
|
210 |
int Topologies = _currentPSN.TopologySet.Rows.Count; |
|
211 |
int pipeSystemNetworks = _currentPSN.PipeSystemNetwork.Rows.Count; |
|
212 |
int InValidPSNs = _currentPSN.PipeSystemNetwork.Select("IsValid = 'Yes'").Count(); |
|
213 |
dicColCheck.Add("PipeSystems", "int"); |
|
214 |
dicColCheck.Add("PipeLines", "int"); |
|
215 |
dicColCheck.Add("Topologies", "int"); |
|
216 |
dicColCheck.Add("PipeSystemNetworks", "int"); |
|
217 |
dicColCheck.Add("InValidPSNs", "int"); |
|
218 |
dicColCheck.Add("E2E", "int"); |
|
219 |
dicColCheck.Add("E2B", "int"); |
|
220 |
dicColCheck.Add("B2E", "int"); |
|
221 |
dicColCheck.Add("HDE", "int"); |
|
222 |
dicColCheck.Add("HD2", "int"); |
|
223 |
dicColCheck.Add("HDB", "int"); |
|
224 |
dicColCheck.Add("B2B", "int"); |
|
225 |
//string ProjectOID = ID2Info.Database; |
|
226 |
// string ProjectCode = ID2Info.Database; |
|
227 |
string PsnByNPDFilter = string.Empty; |
|
228 |
int E2E = _currentPSN.PipeSystemNetwork.Select("Type = 'E2E'").Count(); |
|
229 |
int E2B = _currentPSN.PipeSystemNetwork.Select("Type = 'E2B'").Count(); |
|
230 |
int B2E = _currentPSN.PipeSystemNetwork.Select("Type = 'B2E'").Count(); |
|
231 |
int HDE = _currentPSN.PipeSystemNetwork.Select("Type = 'HDE'").Count(); |
|
232 |
int HD2 = _currentPSN.PipeSystemNetwork.Select("Type = 'HD2'").Count(); |
|
233 |
int HDB = _currentPSN.PipeSystemNetwork.Select("Type = 'HDB'").Count(); |
|
234 |
int B2B = _currentPSN.PipeSystemNetwork.Select("Type = 'B2B'").Count(); |
|
235 |
string UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; |
|
236 |
DB.ConnCreateRevisionTable(dicColCheck, names); |
|
237 | ||
238 |
string PSNDatabasePath = AnotherID2Info.ServerIP; |
|
239 |
if (!string.IsNullOrEmpty(AnotherID2Info.Port)) |
|
240 |
PSNDatabasePath += ", " + AnotherID2Info.Port; |
|
241 | ||
242 |
string ProjectCode = AnotherID2Info.Database; |
|
243 |
DB.SaveRevision(ProjectCode, DB.GetRevision(), UserName, PSNDatabasePath, PBS, PsnByNPDFilter, DrawingCnt, PipeSystems, PipeLines, Topologies, pipeSystemNetworks, |
|
244 |
InValidPSNs, E2E, E2B, B2E, HDE, HD2, HDB, B2B); |
|
245 |
} |
|
246 | ||
178 | 247 |
splashScreenManager1.CloseWaitForm(); |
179 | 248 |
MessageBox.Show("Save was successful.", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
180 | 249 |
} |
DTI_PID/ID2PSN/Form/MainForm.cs | ||
---|---|---|
315 | 315 | |
316 | 316 |
if (DB.SavePSNData(currentPSN)) |
317 | 317 |
{ |
318 |
DataTable dt = DB.SelectRevisionTable(); |
|
319 |
List<string> names = new List<string>(); |
|
320 |
foreach (DataRow dr in dt.Rows) |
|
318 |
if(ID2Info.ID2DBType == ID2DB_Type.MSSQL) |
|
321 | 319 |
{ |
322 |
names.Add(dr.Field<string>("column_name")); |
|
323 |
} |
|
324 |
Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
|
325 |
|
|
326 |
dicColCheck.Add("OID", "uniqueidentifier"); |
|
327 |
dicColCheck.Add("Project_OID", "uniqueidentifier"); |
|
328 |
dicColCheck.Add("ProjectCode", "nvarchar(255)"); |
|
329 |
dicColCheck.Add("RevNumber", "int"); |
|
330 |
dicColCheck.Add("UserName", "nvarchar(255)"); |
|
331 |
dicColCheck.Add("TimeData", "nvarchar(255)"); |
|
332 |
dicColCheck.Add("PSNDatabasePath", "nvarchar(255)"); |
|
333 |
dicColCheck.Add("PsnByPBSFilter", "varchar(20)"); |
|
334 |
string PBS = Settings.Default.PBSSetting; |
|
335 |
dicColCheck.Add("PsnByNPDFilter", "varchar(20)"); |
|
336 |
dicColCheck.Add("PidDrawings", "int"); |
|
337 |
DataTable lstDrawings = DB.SelectDrawings(); |
|
338 |
int DrawingCnt = 0; |
|
339 |
foreach (DataRow row in dt.Rows) |
|
340 |
{ |
|
341 |
string filePath = string.Format(ID2Info.TempDirPath + "{0}.xml", Path.GetFileNameWithoutExtension(row["NAME"].ToString())); |
|
342 |
if (File.Exists(filePath)) |
|
343 |
DrawingCnt++; |
|
344 |
} |
|
345 | ||
346 |
dicColCheck.Add("PipeSystems", "int"); |
|
347 |
dicColCheck.Add("PipeLines", "int"); |
|
348 |
dicColCheck.Add("Topologies", "int"); |
|
349 |
dicColCheck.Add("PipeSystemNetworks", "int"); |
|
350 |
dicColCheck.Add("InValidPSNs", "int"); |
|
351 |
dicColCheck.Add("E2E", "int"); |
|
352 |
dicColCheck.Add("E2B", "int"); |
|
353 |
dicColCheck.Add("B2E", "int"); |
|
354 |
dicColCheck.Add("HDE", "int"); |
|
355 |
dicColCheck.Add("HD2", "int"); |
|
356 |
dicColCheck.Add("HDB", "int"); |
|
357 |
dicColCheck.Add("B2B", "int"); |
|
358 | ||
359 |
DB.ConnCreateRevisionTable(dicColCheck, names); |
|
320 |
DataTable dt = DB.SelectRevisionTable(); |
|
321 |
List<string> names = new List<string>(); |
|
322 |
foreach (DataRow dr in dt.Rows) |
|
323 |
{ |
|
324 |
names.Add(dr.Field<string>("column_name")); |
|
325 |
} |
|
326 |
Dictionary<string, string> dicColCheck = new Dictionary<string, string>(); |
|
327 | ||
328 |
dicColCheck.Add("OID", "uniqueidentifier"); |
|
329 |
dicColCheck.Add("Project_OID", "uniqueidentifier"); |
|
330 |
dicColCheck.Add("ProjectCode", "nvarchar(255)"); |
|
331 |
dicColCheck.Add("RevNumber", "int"); |
|
332 |
dicColCheck.Add("UserName", "nvarchar(255)"); |
|
333 |
dicColCheck.Add("TimeData", "nvarchar(255)"); |
|
334 |
dicColCheck.Add("PSNDatabasePath", "nvarchar(255)"); |
|
335 |
dicColCheck.Add("PsnByPBSFilter", "varchar(20)"); |
|
336 |
string PBS = Settings.Default.PBSSetting; |
|
337 |
dicColCheck.Add("PsnByNPDFilter", "varchar(20)"); |
|
338 |
dicColCheck.Add("PidDrawings", "int"); |
|
339 |
DataTable lstDrawings = DB.SelectDrawings(); |
|
340 |
int DrawingCnt = 0; |
|
341 |
foreach (DataRow row in lstDrawings.Rows) |
|
342 |
{ |
|
343 |
string filePath = string.Format(ID2Info.TempDirPath + "{0}.xml", Path.GetFileNameWithoutExtension(row["NAME"].ToString())); |
|
344 |
if (File.Exists(filePath)) |
|
345 |
DrawingCnt++; |
|
346 |
} |
|
360 | 347 | |
348 |
int PipeSystems = 0; //아직테이블추가안됨 AG-UG할때추가 |
|
349 |
int PipeLines = currentPSN.PipeLine.Rows.Count; |
|
350 |
int Topologies = currentPSN.TopologySet.Rows.Count; |
|
351 |
int pipeSystemNetworks = currentPSN.PipeSystemNetwork.Rows.Count; |
|
352 |
int InValidPSNs = currentPSN.PipeSystemNetwork.Select("IsValid = 'Yes'").Count(); |
|
353 |
dicColCheck.Add("PipeSystems", "int"); |
|
354 |
dicColCheck.Add("PipeLines", "int"); |
|
355 |
dicColCheck.Add("Topologies", "int"); |
|
356 |
dicColCheck.Add("PipeSystemNetworks", "int"); |
|
357 |
dicColCheck.Add("InValidPSNs", "int"); |
|
358 |
dicColCheck.Add("E2E", "int"); |
|
359 |
dicColCheck.Add("E2B", "int"); |
|
360 |
dicColCheck.Add("B2E", "int"); |
|
361 |
dicColCheck.Add("HDE", "int"); |
|
362 |
dicColCheck.Add("HD2", "int"); |
|
363 |
dicColCheck.Add("HDB", "int"); |
|
364 |
dicColCheck.Add("B2B", "int"); |
|
365 | ||
366 |
string PsnByNPDFilter = string.Empty; |
|
367 |
int E2E = currentPSN.PipeSystemNetwork.Select("Type = 'E2E'").Count(); |
|
368 |
int E2B = currentPSN.PipeSystemNetwork.Select("Type = 'E2B'").Count(); |
|
369 |
int B2E = currentPSN.PipeSystemNetwork.Select("Type = 'B2E'").Count(); |
|
370 |
int HDE = currentPSN.PipeSystemNetwork.Select("Type = 'HDE'").Count(); |
|
371 |
int HD2 = currentPSN.PipeSystemNetwork.Select("Type = 'HD2'").Count(); |
|
372 |
int HDB = currentPSN.PipeSystemNetwork.Select("Type = 'HDB'").Count(); |
|
373 |
int B2B = currentPSN.PipeSystemNetwork.Select("Type = 'B2B'").Count(); |
|
374 |
string UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; |
|
375 |
DB.ConnCreateRevisionTable(dicColCheck, names); |
|
376 | ||
377 |
string PSNDatabasePath = ID2Info.ServerIP; |
|
378 |
if (!string.IsNullOrEmpty(ID2Info.Port)) |
|
379 |
PSNDatabasePath += ", " + ID2Info.Port; |
|
380 | ||
381 |
string ProjectCode = ID2Info.Database; |
|
382 | ||
383 |
DB.SaveRevision(ProjectCode, DB.GetRevision(), UserName, PSNDatabasePath, PBS, PsnByNPDFilter, DrawingCnt, PipeSystems, PipeLines, Topologies, pipeSystemNetworks, |
|
384 |
InValidPSNs, E2E, E2B, B2E, HDE, HD2, HDB, B2B); |
|
385 |
} |
|
386 |
|
|
361 | 387 |
splashScreenManager1.CloseWaitForm(); |
362 | 388 |
MessageBox.Show("Save was successful.", "ID2 " + ID2Info.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Information); |
363 | 389 |
} |
내보내기 Unified diff