static FbConnectionInternal CreateNewConnection(FbConnectionString connectionString) { var result = new FbConnectionInternal(connectionString); result.Connect(); return(result); }
static FbConnectionInternal CreateNewConnection(FbConnectionString connectionString, FbConnection owner) { var result = new FbConnectionInternal(connectionString); result.SetOwningConnection(owner); result.Connect(); return(result); }
public FbRemoteEvent(string connectionString) { _connection = new FbConnectionInternal(new FbConnectionString(connectionString)); _connection.Connect(); _revent = new RemoteEvent(_connection.Database); _revent.EventCountsCallback = OnRemoteEventCounts; _revent.EventErrorCallback = OnRemoteEventError; _synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext(); }
private FbConnectionInternal Create() { FbConnectionInternal connection = new FbConnectionInternal(this.options); connection.Connect(); connection.Pooled = true; connection.Created = DateTime.Now.Ticks; return(connection); }
public void Open() { if (_revent != null) { throw new InvalidOperationException($"{nameof(FbRemoteEvent)} already open."); } _connection.Connect(); _revent = new RemoteEvent(_connection.Database); _revent.EventCountsCallback = OnRemoteEventCounts; _revent.EventErrorCallback = OnRemoteEventError; _synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext(); }
private async Task OpenImpl(AsyncWrappingCommonArgs async) { if (_revent != null) { throw new InvalidOperationException($"{nameof(FbRemoteEvent)} already open."); } await _connection.Connect(async).ConfigureAwait(false); _revent = new RemoteEvent(_connection.Database); _revent.EventCountsCallback = OnRemoteEventCounts; _revent.EventErrorCallback = OnRemoteEventError; _synchronizationContext = SynchronizationContext.Current ?? new SynchronizationContext(); }
public override void Open() { lock (this) { if (string.IsNullOrEmpty(_connectionString)) { throw new InvalidOperationException("Connection String is not initialized."); } if (!IsClosed && _state != ConnectionState.Connecting) { throw new InvalidOperationException("Connection already Open."); } #if !NETCORE10 if (_options.Enlist && System.Transactions.Transaction.Current == null) { throw new InvalidOperationException("There is no active TransactionScope to enlist transactions."); } #endif try { OnStateChange(_state, ConnectionState.Connecting); if (_options.Pooling) { _innerConnection = FbConnectionPoolManager.Instance.Get(_options, this); } else { // Do not use Connection Pooling _innerConnection = new FbConnectionInternal(_options); _innerConnection.SetOwningConnection(this); _innerConnection.Connect(); } #if !NETCORE10 try { _innerConnection.EnlistTransaction(System.Transactions.Transaction.Current); } catch { // if enlistment fails clean up innerConnection _innerConnection.DisposeTransaction(); if (_options.Pooling) { // Send connection return back to the Pool FbConnectionPoolManager.Instance.Release(_innerConnection); } else { _innerConnection.Dispose(); _innerConnection = null; } throw; } #endif // Bind Warning messages event _innerConnection.Database.WarningMessage = new WarningMessageCallback(OnWarningMessage); // Update the connection state OnStateChange(_state, ConnectionState.Open); } catch (IscException ex) { OnStateChange(_state, ConnectionState.Closed); throw new FbException(ex.Message, ex); } catch { OnStateChange(_state, ConnectionState.Closed); throw; } } }
private FbConnectionInternal Create() { FbConnectionInternal connection = new FbConnectionInternal(this.options); connection.Connect(); connection.Pooled = true; connection.Created = DateTime.Now.Ticks; return connection; }
static FbConnectionInternal CreateNewConnection(FbConnectionString connectionString, FbConnection owner) { var result = new FbConnectionInternal(connectionString); result.SetOwningConnection(owner); result.Connect(); return result; }
public override void Open() { if (string.IsNullOrEmpty(_connectionString)) { throw new InvalidOperationException("Connection String is not initialized."); } if (!IsClosed && _state != ConnectionState.Connecting) { throw new InvalidOperationException("Connection already Open."); } try { OnStateChange(_state, ConnectionState.Connecting); var createdNew = default(bool); if (_options.Pooling) { _innerConnection = FbConnectionPoolManager.Instance.Get(_options, out createdNew); } else { _innerConnection = new FbConnectionInternal(_options); createdNew = true; } if (createdNew) { try { _innerConnection.Connect(); } catch (OperationCanceledException ex) { //cancellationToken.ThrowIfCancellationRequested(); throw new TimeoutException("Timeout while connecting.", ex); } catch { if (_options.Pooling) { FbConnectionPoolManager.Instance.Release(_innerConnection, false); } throw; } } _innerConnection.SetOwningConnection(this); if (_options.Enlist) { try { EnlistTransaction(System.Transactions.Transaction.Current); } catch { // if enlistment fails clean up innerConnection _innerConnection.DisposeTransaction(); if (_options.Pooling) { FbConnectionPoolManager.Instance.Release(_innerConnection, true); } else { _innerConnection.Disconnect(); _innerConnection = null; } throw; } } // Bind Warning messages event _innerConnection.Database.WarningMessage = OnWarningMessage; // Update the connection state OnStateChange(_state, ConnectionState.Open); } catch (IscException ex) { OnStateChange(_state, ConnectionState.Closed); throw FbException.Create(ex); } catch { OnStateChange(_state, ConnectionState.Closed); throw; } }
public override void Open() { lock (this) { if (string.IsNullOrEmpty(_connectionString)) { throw new InvalidOperationException("Connection String is not initialized."); } if (!IsClosed && _state != ConnectionState.Connecting) { throw new InvalidOperationException("Connection already Open."); } if (_options.Enlist && System.Transactions.Transaction.Current == null) { throw new InvalidOperationException("There is no active TransactionScope to enlist transactions."); } DemandPermission(); try { OnStateChange(_state, ConnectionState.Connecting); if (_options.Pooling) { _innerConnection = FbConnectionPoolManager.Instance.Get(_options, this); } else { // Do not use Connection Pooling _innerConnection = new FbConnectionInternal(_options); _innerConnection.SetOwningConnection(this); _innerConnection.Connect(); } try { _innerConnection.EnlistTransaction(System.Transactions.Transaction.Current); } catch { // if enlistment fails clean up innerConnection _innerConnection.DisposeTransaction(); if (_options.Pooling) { // Send connection return back to the Pool FbConnectionPoolManager.Instance.Release(_innerConnection); } else { _innerConnection.Dispose(); _innerConnection = null; } throw; } // Bind Warning messages event _innerConnection.Database.WarningMessage = new WarningMessageCallback(OnWarningMessage); // Update the connection state OnStateChange(_state, ConnectionState.Open); } catch (IscException ex) { OnStateChange(_state, ConnectionState.Closed); throw new FbException(ex.Message, ex); } catch { OnStateChange(_state, ConnectionState.Closed); throw; } } }
public override void Open() { if (string.IsNullOrEmpty(_connectionString)) { throw new InvalidOperationException("Connection String is not initialized."); } if (!IsClosed && _state != ConnectionState.Connecting) { throw new InvalidOperationException("Connection already Open."); } try { OnStateChange(_state, ConnectionState.Connecting); if (_options.Pooling) { _innerConnection = FbConnectionPoolManager.Instance.Get(_options, this); } else { _innerConnection = new FbConnectionInternal(_options); _innerConnection.SetOwningConnection(this); _innerConnection.Connect(); } if (_options.Enlist) { try { var transaction = System.Transactions.Transaction.Current; if (transaction != null) { _innerConnection.EnlistTransaction(transaction); } } catch { // if enlistment fails clean up innerConnection _innerConnection.DisposeTransaction(); if (_options.Pooling) { FbConnectionPoolManager.Instance.Release(_innerConnection, true); } else { _innerConnection.Dispose(); _innerConnection = null; } throw; } } // Bind Warning messages event _innerConnection.Database.WarningMessage = OnWarningMessage; // Update the connection state OnStateChange(_state, ConnectionState.Open); } catch (IscException ex) { OnStateChange(_state, ConnectionState.Closed); throw new FbException(ex.Message, ex); } catch { OnStateChange(_state, ConnectionState.Closed); throw; } }
private async Task OpenImpl(AsyncWrappingCommonArgs async) { if (string.IsNullOrEmpty(_connectionString)) { throw new InvalidOperationException("Connection String is not initialized."); } if (!IsClosed && _state != ConnectionState.Connecting) { throw new InvalidOperationException("Connection already Open."); } try { OnStateChange(_state, ConnectionState.Connecting); var createdNew = default(bool); if (_options.Pooling) { _innerConnection = FbConnectionPoolManager.Instance.Get(_options, out createdNew); } else { _innerConnection = new FbConnectionInternal(_options); createdNew = true; } if (createdNew) { try { await _innerConnection.Connect(async).ConfigureAwait(false); } catch { if (_options.Pooling) { FbConnectionPoolManager.Instance.Release(_innerConnection, false); } throw; } } _innerConnection.SetOwningConnection(this); if (_options.Enlist) { try { var transaction = System.Transactions.Transaction.Current; if (transaction != null) { _innerConnection.EnlistTransaction(transaction); } } catch { // if enlistment fails clean up innerConnection await _innerConnection.DisposeTransaction(async).ConfigureAwait(false); if (_options.Pooling) { FbConnectionPoolManager.Instance.Release(_innerConnection, true); } else { await _innerConnection.Disconnect(async).ConfigureAwait(false); _innerConnection = null; } throw; } } // Bind Warning messages event _innerConnection.Database.WarningMessage = OnWarningMessage; // Update the connection state OnStateChange(_state, ConnectionState.Open); } catch (IscException ex) { OnStateChange(_state, ConnectionState.Closed); throw new FbException(ex.Message, ex); } catch { OnStateChange(_state, ConnectionState.Closed); throw; } }
static FbConnectionInternal CreateNewConnection(FbConnectionString connectionString) { var result = new FbConnectionInternal(connectionString); result.Connect(); return result; }