Ejemplo n.º 1
0
 public void RebuildTableIndexes(string tableName, string indexName, SqlConnection connection)
 {
     try
     {
         Log.Info("[DistributedDb] RebuildTableIndexes Start - [" + tableName + "] ON " + indexName, this);
         connection.Open();
         var command = @"
             ALTER INDEX " + indexName + @" ON " + tableName + @" REBUILD WITH (FILLFACTOR = 80);
         ";
         using (var sqlCommand = new SqlCommand(command, connection))
         {
             //sqlCommand.CommandTimeout = 30;
             SyncTracer.Info("Rebuild index table " + indexName + " ON " + tableName);
             SyncTracerExtended.TraceCommandAndParameters((IDbCommand)sqlCommand);
             sqlCommand.ExecuteNonQuery();
         }
         connection.Close();
         Log.Info("[DistributedDb] RebuildTableIndexes End - [" + tableName + "] ON " + indexName, this);
     }
     catch (Exception ex)
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
         }
         Log.Error("[DistributedDb] RebuildTableIndexes Error - [" + tableName + "] ON " + indexName, ex, this);
     }
 }
Ejemplo n.º 2
0
 public void TruncateTable(string tableName, SqlConnection connection)
 {
     try
     {
         Log.Info("[DistributedDb] TruncateTable Start - [" + tableName + "]", this);
         connection.Open();
         var command = @"
             TRUNCATE TABLE " + tableName + @";
         ";
         using (var sqlCommand = new SqlCommand(command, connection))
         {
             SyncTracer.Info("Truncate table " + tableName);
             SyncTracerExtended.TraceCommandAndParameters((IDbCommand)sqlCommand);
             sqlCommand.ExecuteNonQuery();
         }
         connection.Close();
         Log.Info("[DistributedDb] TruncateTable End - " + tableName + "]", this);
     }
     catch (Exception ex)
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
         }
         Log.Error("[DistributedDb] TruncateTable Error - " + tableName + "]", ex, this);
     }
 }
Ejemplo n.º 3
0
 public void UpdateTriggerScripts(string tableName, string cmdText, SqlConnection connection)
 {
     try
     {
         connection.Open();
         using (var sqlCommand = new SqlCommand(cmdText, connection))
         {
             //sqlCommand.CommandTimeout = 30;
             SyncTracer.Info("Update Trigger GETDATE() to GETUTCDATE() for table " + tableName);
             SyncTracerExtended.TraceCommandAndParameters((IDbCommand)sqlCommand);
             sqlCommand.ExecuteNonQuery();
         }
         connection.Close();
     } catch (Exception ex)
     {
         if (connection.State == ConnectionState.Open)
         {
             connection.Close();
         }
         Log.Error("[DistributedDb] UpdateTriggerScripts Error", ex, this);
     }
 }