コード例 #1
0
        /// <summary>
        /// Commits the transaction.
        /// </summary>
        public static void Commit()
        {
            if (_notSupported)
            {
                return;
            }

            ITransactionProvider tran = ContextHandler.GetTransaction();

            if (tran == null)                          // !IsActive
            {
                throw new InvalidOperationException(); // Transaction is not Active.
            }
            try
            {
                tran.Commit();

                var queue = ContextHandler.GetTransactionQueue();
                if (queue != null)
                {
                    queue.Commit();
                }

                OnCommitTransaction(tran, EventArgs.Empty);
            }
            finally
            {
                Logger.WriteVerbose("Transaction: " + tran.Id + " COMMIT. Running time: " + (DateTime.UtcNow - tran.Started));
                ContextHandler.SetTransaction(null);
                ContextHandler.SetTransactionQueue(null);
                tran.Dispose();
            }
        }
コード例 #2
0
        internal static void Participate(ITransactionParticipant participant)
        {
            if (!IsActive)
            {
                return;
            }

            TransactionQueue queue = ContextHandler.GetTransactionQueue();

            if (queue == null)
            {
                queue = new TransactionQueue();
                ContextHandler.SetTransactionQueue(queue);
            }
            queue.Add(participant);
        }
コード例 #3
0
        /// <summary>
        /// Rollbacks the current transaction.
        /// </summary>
        public static void Rollback()
        {
            if (_notSupported)
            {
                return;
            }

            ITransactionProvider tran = ContextHandler.GetTransaction();

            if (tran == null) // Means: !IsActive (Transaction is not Active)
            {
                throw new InvalidOperationException("Transaction is not active");
            }

            try
            {
                tran.Rollback();

                var queue = ContextHandler.GetTransactionQueue();
                if (queue != null)
                {
                    queue.Rollback();
                }

                OnRollbackTransaction(tran, EventArgs.Empty);
            }
            finally
            {
                ////Cache.Clear(); // State "rollback" in cache. TODO: cache clear in cluster must be ensured.
                ////CACHE: Ez sose mûködött jól... Cache.Clear kéne.
                //DistributedApplication.Cache.Reset();
                Logger.WriteVerbose("Transaction: " + tran.Id + " ROLLBACK. Running time: " + (DateTime.UtcNow - tran.Started));
                ContextHandler.SetTransaction(null);
                ContextHandler.SetTransactionQueue(null);
                tran.Dispose();
            }
        }