Example #1
0
 public override DataTable GetSchema(string collection)
 {
     return(ConnectionPrimary?.State == ConnectionState.Open
         ? ConnectionPrimary.GetSchema(collection)
         : ConnectionSecondary?.State == ConnectionState.Open
             ? ConnectionSecondary.GetSchema(collection)
             : null);
 }
Example #2
0
 public override void Open()
 {
     if (ConnectionPrimary != null)
     {
         TimeSpan timeout = TimeSpan.FromSeconds(60);
         _idleTimeTimerPrimary = new Timer(_idleTimeTimerCallback, ConnectionPrimary, timeout, timeout);
         try
         {
             ConnectionPrimary.Open();
         }
         catch
         {
             StateRedundant = _stateRedundant | ConnectionStateRedundant.BrokenPrimary;
             _tryOpenSecondary();
             if (ConnectionSecondary == null || ConnectionSecondary.State != ConnectionState.Open)
             {
                 throw;
             }
         }
     }
     _tryOpenSecondary();
 }
Example #3
0
 public override void Close()
 {
     if (ConnectionPrimary != null)
     {
         lock (ConnectionPrimary)
         {
             _idleTimeTimerPrimary.Dispose();
             _idleTimeTimerPrimary = null;
             ConnectionPrimary.Close();
             ConnectionPrimary.StateChange -= _connection_StateChange;
         }
     }
     if (ConnectionSecondary != null)
     {
         lock (ConnectionSecondary)
         {
             _idleTimeTimerSecondary.Dispose();
             _idleTimeTimerSecondary = null;
             ConnectionSecondary.Close();
             ConnectionSecondary.StateChange -= _connection_StateChange;
         }
     }
 }