/// <summary> /// Publisher function for TxnScopeGlobalDisposeEvent event. /// This function is used for internal testing purpose only. /// </summary> /// <param name="args">Argument to capture transaction finish action</param> protected void OnDisposeEvent(SqlStoreEventArgs args) { EventHandler<SqlStoreEventArgs> handler = TxnScopeLocalDisposeEvent; if (handler != null) { handler(this, args); } }
/// <summary> /// Subscriber function for SqlTransactionScopeLocal.TxnScopeLocalDisposeEvent event. /// This function is used for internal testing purpose only. /// </summary> /// <param name="sender">sender object (SqlTransactionScopeLocal)</param> /// <param name="arg">event argument</param> internal void TxnScopeLocalEventHandler(object sender, SqlStoreEventArgs arg) { this.OnSqlStoreEventLocal(arg); }
/// <summary> /// Completes the currently active transaction. /// </summary> internal void FinishTransaction() { Debug.Assert(this.conn != null); Debug.Assert(this.tran != null); try { #if DEBUG // Raise event and check if current transaction should be aborted. // SqlStoreEventArgs eventArgs = new SqlStoreEventArgs(); OnDisposeEvent(eventArgs); if (eventArgs.action == SqlStoreEventArgs.SqlStoreTxnFinishAction.TxnAbort) { throw new StoreException( Errors.SqlTransactionScopeLocal_SqlException, this.Success ? "Commit" : "Rollback", this.Location); } else #endif // DEBUG { if (this.Success) { this.tran.Commit(); } else { this.tran.Rollback(); } } } catch (SqlException se) { throw new StoreException( Errors.SqlTransactionScopeLocal_SqlException, se, this.Success ? "Commit" : "Rollback", this.Location); } finally { this.tran.Dispose(); this.conn.Dispose(); SqlTransactionScopeLocal.current = null; } }
/// <summary> /// Publisher for SqlStoreEventLocal event. /// </summary> /// <param name="ssArgs">Event argument to handle transaction finishing action</param> internal void OnSqlStoreEventLocal(SqlStoreEventArgs ssArgs) { EventHandler<SqlStoreEventArgs> handler = this.SqlStoreEventLocal; if (handler != null) { handler(this, ssArgs); } }