Beispiel #1
0
 /// <summary>
 /// Called whenever there seems to be no sql connection
 /// </summary>
 public static void ReastablishSQL(FunctionThatFailed functionThatFailed, string message)
 {
     if (fixingconnection)                                                                                       //if we are already fixing the connection
     {
         while (fixingconnection)                                                                                //dont touch anything and just sleep for a little bit
         {
             Thread.Sleep(100);
         }
     }
     else                                                                                                        //otherwise fix the connection
     {
         fixingconnection = true;                                                                                //and tell others not to
         try
         {
             DiagnosticItems.Enqueue(new DiagnosticItem("Connecting SQL Database", 2));                          //logggggggggiittttttttt
             ENGDBConnection                = new SqlConnectionStringBuilder();                                  //builder to connect to the database
             ENGDBConnection.DataSource     = ENG_DBDataSource;                                                  //pass it the ip username password and starting database
             ENGDBConnection.UserID         = ENG_DBUserID;
             ENGDBConnection.Password       = ENG_DBPassword;
             ENGDBConnection.InitialCatalog = ENG_DBInitialCatalog;
         }
         catch (Exception ex) { DiagnosticItems.Enqueue(new DiagnosticItem(ex.ToString(), 1)); }                 //logit
         fixingconnection = false;                                                                               //unlock it
     }
     functionThatFailed(message);                                                                                //recall the function that failed
 }
 /// <summary>
 /// Called whenever there seems to be no sql connection
 /// </summary>
 public void ReastablishSQL(FunctionThatFailed functionThatFailed, string message)
 {
     if (fixingconnection)
     {
         while (fixingconnection)
         {
             Thread.Sleep(100);
         }
     }
     else
     {
         fixingconnection = true;
         try
         {
             DiagnosticOut("Connecting SQL Database", 2);
             SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
             builder.DataSource     = QAENG_DBDataSource;
             builder.UserID         = ENG_DBUserID;
             builder.Password       = ENG_DBPassword;
             builder.InitialCatalog = ENG_DBInitialCatalog;
             ENGDBConnection        = new SqlConnection(builder.ConnectionString);
             ENGDBConnection.Open();
             ThingsToDispose.Add(new Disposable(nameof(ENGDBConnection), ENGDBConnection));
         }
         catch (Exception ex) { DiagnosticOut(ex.ToString(), 1); }
         fixingconnection = false;
     }
     functionThatFailed(message);
 }