Beispiel #1
0
 public override void Close()
 {
     if ((this.State != ConnectionState.Closed) && (this.InnerConnection != null))
     {
         if (this.InnerConnection.IsEnlisted)
         {
             UtlConnection connection = new UtlConnection {
                 InnerConnection = this.InnerConnection
             };
             connection.InnerConnection.Owner = connection;
             connection.ConnectionString      = this.ConnectionString;
             connection._connectionOptions    = this._connectionOptions;
             connection.Version          = this.Version;
             connection._connectionState = this._connectionState;
             connection.InnerConnection.Enlistment.DbTransaction.Conn = connection;
             connection.InnerConnection.Enlistment.DisposeConnection  = true;
             this.InnerConnection = null;
         }
         try
         {
             if (this.InnerConnection != null)
             {
                 lock (this.InnerConnection)
                 {
                     this.InnerConnection.DisposeTransaction();
                     this.InnerConnection.Owner = null;
                     if (this._connectionOptions.Pooling)
                     {
                         UtlConnectionPool.Add(this._connectionString, this.InnerConnection, this._poolVersion);
                     }
                     else
                     {
                         this.InnerConnection.Dispose();
                     }
                 }
             }
             this.InnerConnection = null;
         }
         catch (Exception)
         {
         }
         finally
         {
             this.OnStateChange(ConnectionState.Closed);
         }
     }
 }
Beispiel #2
0
 public override void Open()
 {
     if (this._connectionState != ConnectionState.Closed)
     {
         throw new InvalidOperationException("Connection already open.");
     }
     if (this._connectionOptions.Enlist && (Transaction.Current == null))
     {
         throw new InvalidOperationException("No active Transaction to enlist.");
     }
     try
     {
         if (this._connectionOptions.Pooling)
         {
             this.InnerConnection = UtlConnectionPool.Remove(this._connectionString, this._connectionOptions.MaxPoolSize, this._connectionOptions.MinPoolSize, out this._poolVersion);
             if ((this.InnerConnection != null) && this.InnerConnection.SessionProxy.IsClosed())
             {
                 this.InnerConnection = null;
             }
         }
         if (this.InnerConnection == null)
         {
             this.InnerConnection = new UtlConnectionProxy(this._connectionOptions, this);
             this.InnerConnection.Open();
         }
         else
         {
             this.InnerConnection.Owner = this;
         }
         this.Version += 1L;
         ConnectionState state = this._connectionState;
         this._connectionState = ConnectionState.Open;
         if ((Transaction.Current != null) && this._connectionOptions.Enlist)
         {
             this.EnlistTransaction(Transaction.Current);
         }
         this._connectionState = state;
         this.OnStateChange(ConnectionState.Open);
     }
     catch (UtlException)
     {
         this.Close();
         throw;
     }
 }
Beispiel #3
0
 public static void ClearPool(UtlConnection connection)
 {
     UtlConnectionPool.ClearPool(connection.ConnectionString);
 }
Beispiel #4
0
 public static void ClearAllPools()
 {
     UtlConnectionPool.ClearAllPools();
 }