- Timestamp:
- May 13, 2019, 1:20:39 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/Database.cs
r2 r7 26 26 public delegate void DatabaseInitializedHandler(); 27 27 public static event DatabaseInitializedHandler DatabaseInitialized; 28 public delegate void LogMessageHandler(string text); 29 public static event LogMessageHandler LogMessage; 28 30 public static string connectionString = ""; 29 31 public static string databaseName = ""; … … 71 73 { 72 74 result = false; 75 Log("When connecting to DB: " + ex.Message); 73 76 throw new Exception("When connecting to DB: " + ex.Message); 74 77 } … … 84 87 85 88 return result; 89 } 90 91 private static void Log(string message) 92 { 93 if (LogMessage != null) LogMessage(message); 86 94 } 87 95 … … 289 297 if ((error.Class > 10) && (error.Number != 3013)) 290 298 { 299 Log(error.ToString()); 291 300 throw new Exception(error.ToString()); 292 301 } … … 319 328 catch (DbException ex) 320 329 { 330 Log("When executing query sql command:\n" + query + "\nException text: " + ex.Message); 321 331 throw new Exception("When executing query sql command:\n" + query + "\nException text: " + ex.Message); 322 332 } … … 347 357 } 348 358 catch (DbException ex) 349 { 359 { 360 Log("When executing sql transaction:\nException text: " + ex.Message); 350 361 throw new Exception("When executing sql transaction:\nException text: " + ex.Message); 351 362 } … … 386 397 catch (DbException ex) 387 398 { 399 Log("When executing query sql command:\n" + query + "\nException text: " + ex.Message); 388 400 throw new Exception("When executing query sql command:\n" + query + "\nException text: " + ex.Message); 389 401 } … … 406 418 catch (DbException ex) 407 419 { 420 Log("When executing query sql command:\n" + query + "\nException text: " + ex.Message); 408 421 throw new Exception("When executing query sql command:\n" + query + "\nException text: " + ex.Message); 409 422 } … … 433 446 catch (DbException ex) 434 447 { 448 Log("When executing non query sql command:\n" + query + "\nException text: " + ex.Message); 435 449 throw new Exception("When executing non query sql command:\n" + query + "\nException text: " + ex.Message); 436 450 } … … 491 505 return result; 492 506 } 507 508 public static void CreateIndexOnColumn(string table, string column, string indexName = null) 509 { 510 if (indexName == null) indexName = table + "_" + column; 511 ExecuteNonQuery("CREATE INDEX " + indexName + " ON " + table + " (" + column + ")"); 512 } 493 513 } 494 514
Note:
See TracChangeset
for help on using the changeset viewer.