예제 #1
0
 /// <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);
     }
 }
예제 #2
0
 /// <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);
 }
예제 #3
0
        /// <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;
            }
        }
예제 #4
0
        /// <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);
            }
        }