private void CommitInternal() { if (null == _transaction) { return; } if (null != _nestedTransaction) { OleDbTransaction transaction = (OleDbTransaction)_nestedTransaction.Target; if ((null != transaction) && _nestedTransaction.IsAlive) { transaction.CommitInternal(); } _nestedTransaction = null; } OleDbHResult hr = _transaction.Commit(); if (!_transaction.MustComplete) { _transaction.Dispose(); _transaction = null; DisposeManaged(); } if (hr < 0) { // if an exception is thrown, user can try to commit their transaction again ProcessResults(hr); } }
private void CommitInternal() { if (this._transaction != null) { if (this._nestedTransaction != null) { OleDbTransaction target = (OleDbTransaction)this._nestedTransaction.Target; if ((target != null) && this._nestedTransaction.IsAlive) { target.CommitInternal(); } this._nestedTransaction = null; } OleDbHResult hr = this._transaction.Commit(); if (!this._transaction.MustComplete) { this._transaction.Dispose(); this._transaction = null; this.DisposeManaged(); } if (hr < OleDbHResult.S_OK) { this.ProcessResults(hr); } } }
internal void Release(WrappedTransaction transaction) { if (currentTransaction == transaction) { currentTransaction = null; } }
/// <summary> /// Begins a database transaction. /// </summary> /// <returns> /// An object representing the new transaction. /// </returns> public IDbTransaction BeginTransaction() { var actualTransaction = actualConnection.BeginTransaction(); currentTransaction = new WrappedTransaction(this, actualTransaction); return(currentTransaction); }
/// roll back the transaction public void Rollback() { string TransactionIdentifier = null; bool TransactionValid = false; IsolationLevel TransactionIsolationLevel = IsolationLevel.Unspecified; // Attempt to roll back the DB Transaction. try { // 'Sanity Check': Check that TheTransaction hasn't been committed or rolled back yet. if (!Valid) { var Exc1 = new EDBAttemptingToUseTransactionThatIsInvalidException( "TDataBase.RollbackTransaction called on DB Transaction that isn't valid", ThreadingHelper.GetThreadIdentifier(ThreadThatTransactionWasStartedOn), ThreadingHelper.GetCurrentThreadIdentifier()); TLogging.Log(Exc1.ToString()); throw Exc1; } if (TLogging.DL >= DBAccess.DB_DEBUGLEVEL_TRANSACTION_DETAIL) { // Gather information for logging TransactionIdentifier = GetDBTransactionIdentifier(); TransactionValid = Valid; TransactionIsolationLevel = IsolationLevel; } WrappedTransaction.Rollback(); TLogging.LogAtLevel(DBAccess.DB_DEBUGLEVEL_TRANSACTION, " Transaction " + FTransactionName + " in Connection " + FTDataBaseInstanceThatTransactionBelongsTo.ConnectionName + " rolled back"); // Rollback was OK, now clean up. Dispose(); TLogging.LogAtLevel(DBAccess.DB_DEBUGLEVEL_TRANSACTION_DETAIL, String.Format( "DB Transaction{0} got rolled back. Before that, its DB Transaction Properties were: Valid: {1}, " + "IsolationLevel: {2} (it got started on Thread {3} in AppDomain '{4}').", TransactionIdentifier, TransactionValid, TransactionIsolationLevel, ThreadThatTransactionWasStartedOn, AppDomainNameThatTransactionWasStartedIn) ); } catch (Exception Exc) { // This catch block will handle any errors that may have occurred // on the server that would cause the rollback to fail, such as // a closed connection. // // MSDN says: "Try/Catch exception handling should always be used when rolling back a // transaction. A Rollback generates an InvalidOperationException if the connection is // terminated or if the transaction has already been rolled back on the server." TLogging.Log("Exception while attempting Transaction rollback: " + Exc.ToString()); } }
internal void BeginInternal(UnsafeNativeMethods.ITransactionLocal transaction) { OleDbHResult result; this._transaction = new WrappedTransaction(transaction, (int)this._isolationLevel, out result); if (result < OleDbHResult.S_OK) { this._transaction.Dispose(); this._transaction = null; this.ProcessResults(result); } }
internal void BeginInternal(UnsafeNativeMethods.ITransactionLocal transaction) { OleDbHResult hr; _transaction = new WrappedTransaction(transaction, (int)_isolationLevel, out hr); if (hr < 0) { _transaction.Dispose(); _transaction = null; ProcessResults(hr); } }
/*protected virtual*/ internal OleDbHResult RollbackInternal(bool exceptionHandling) { OleDbHResult hr = 0; if (null != _transaction) { if (null != _nestedTransaction) { OleDbTransaction transaction = (OleDbTransaction)_nestedTransaction.Target; if ((null != transaction) && _nestedTransaction.IsAlive) { hr = transaction.RollbackInternal(exceptionHandling); if (exceptionHandling && (hr < 0)) { SafeNativeMethods.Wrapper.ClearErrorInfo(); return(hr); } } _nestedTransaction = null; } hr = _transaction.Abort(); _transaction.Dispose(); _transaction = null; if (hr < 0) { if (exceptionHandling) { ProcessResults(hr); } else { SafeNativeMethods.Wrapper.ClearErrorInfo(); } } } return(hr); }
internal OleDbHResult RollbackInternal(bool exceptionHandling) { OleDbHResult hr = OleDbHResult.S_OK; if (this._transaction != null) { if (this._nestedTransaction != null) { OleDbTransaction target = (OleDbTransaction)this._nestedTransaction.Target; if ((target != null) && this._nestedTransaction.IsAlive) { hr = target.RollbackInternal(exceptionHandling); if (exceptionHandling && (hr < OleDbHResult.S_OK)) { SafeNativeMethods.Wrapper.ClearErrorInfo(); return(hr); } } this._nestedTransaction = null; } hr = this._transaction.Abort(); this._transaction.Dispose(); this._transaction = null; if (hr >= OleDbHResult.S_OK) { return(hr); } if (exceptionHandling) { this.ProcessResults(hr); return(hr); } SafeNativeMethods.Wrapper.ClearErrorInfo(); } return(hr); }
internal void BeginInternal(UnsafeNativeMethods.ITransactionLocal transaction) { OleDbHResult hr; _transaction = new WrappedTransaction(transaction, (int) _isolationLevel, out hr); if (hr < 0) { _transaction.Dispose(); _transaction = null; ProcessResults(hr); } }
public override void Rollback() { LogHelper.ShowCommandHeader("^^^ Rollback"); WrappedTransaction.Rollback(); _connection.ActiveTransaction = null; }
private void CommitInternal() { if (this._transaction != null) { if (this._nestedTransaction != null) { OleDbTransaction target = (OleDbTransaction) this._nestedTransaction.Target; if ((target != null) && this._nestedTransaction.IsAlive) { target.CommitInternal(); } this._nestedTransaction = null; } OleDbHResult hr = this._transaction.Commit(); if (!this._transaction.MustComplete) { this._transaction.Dispose(); this._transaction = null; this.DisposeManaged(); } if (hr < OleDbHResult.S_OK) { this.ProcessResults(hr); } } }
internal void BeginInternal(UnsafeNativeMethods.ITransactionLocal transaction) { OleDbHResult result; this._transaction = new WrappedTransaction(transaction, (int) this._isolationLevel, out result); if (result < OleDbHResult.S_OK) { this._transaction.Dispose(); this._transaction = null; this.ProcessResults(result); } }
internal OleDbHResult RollbackInternal(bool exceptionHandling) { OleDbHResult hr = OleDbHResult.S_OK; if (this._transaction != null) { if (this._nestedTransaction != null) { OleDbTransaction target = (OleDbTransaction) this._nestedTransaction.Target; if ((target != null) && this._nestedTransaction.IsAlive) { hr = target.RollbackInternal(exceptionHandling); if (exceptionHandling && (hr < OleDbHResult.S_OK)) { SafeNativeMethods.Wrapper.ClearErrorInfo(); return hr; } } this._nestedTransaction = null; } hr = this._transaction.Abort(); this._transaction.Dispose(); this._transaction = null; if (hr >= OleDbHResult.S_OK) { return hr; } if (exceptionHandling) { this.ProcessResults(hr); return hr; } SafeNativeMethods.Wrapper.ClearErrorInfo(); } return hr; }
private void CommitInternal() { if (null == _transaction) { return; } if (null != _nestedTransaction) { OleDbTransaction transaction = (OleDbTransaction) _nestedTransaction.Target; if ((null != transaction) && _nestedTransaction.IsAlive) { transaction.CommitInternal(); } _nestedTransaction = null; } OleDbHResult hr = _transaction.Commit(); if (!_transaction.MustComplete) { _transaction.Dispose(); _transaction = null; DisposeManaged(); } if (hr < 0) { // if an exception is thrown, user can try to commit their transaction again ProcessResults(hr); } }
/*protected virtual*/internal OleDbHResult RollbackInternal(bool exceptionHandling) { OleDbHResult hr = 0; if (null != _transaction) { if (null != _nestedTransaction) { OleDbTransaction transaction = (OleDbTransaction) _nestedTransaction.Target; if ((null != transaction) && _nestedTransaction.IsAlive) { hr = transaction.RollbackInternal(exceptionHandling); if (exceptionHandling && (hr < 0)) { SafeNativeMethods.Wrapper.ClearErrorInfo(); return hr; } } _nestedTransaction = null; } hr = _transaction.Abort(); _transaction.Dispose(); _transaction = null; if (hr < 0) { if (exceptionHandling) { ProcessResults(hr); } else { SafeNativeMethods.Wrapper.ClearErrorInfo(); } } } return hr; }
public override void Rollback() { WrappedTransaction.Rollback(); }