GetTransaction() статический приватный Метод

static private GetTransaction ( ) : ITransactionProvider
Результат ITransactionProvider
Пример #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
            {
                ContextHandler.SetTransaction(null);
                ContextHandler.SetTransactionQueue(null);
                tran.Dispose();
            }
        }
Пример #2
0
        /// <summary>
        /// Commits the transaction and all its participants.
        /// </summary>
        public static void Commit()
        {
            if (_notSupported)
            {
                return;
            }

            var tran = ContextHandler.GetTransaction();

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

                var queue = ContextHandler.GetTransactionQueue();
                queue?.Commit();

                OnCommitTransaction(tran, EventArgs.Empty);
            }
            finally
            {
                SnTrace.Database.Write("Transaction COMMIT: {0}. Running time: {1}", tran.Id, (DateTime.UtcNow - tran.Started));
                ContextHandler.SetTransaction(null);
                ContextHandler.SetTransactionQueue(null);
                tran.Dispose();
            }
        }
Пример #3
0
        /// <summary>
        /// Rollbacks the current transaction and all its participants.
        /// </summary>
        public static void Rollback()
        {
            if (_notSupported)
            {
                return;
            }

            var tran = ContextHandler.GetTransaction();

            if (tran == null)
            {
                throw new InvalidOperationException("Transaction is not active");
            }

            try
            {
                tran.Rollback();

                var queue = ContextHandler.GetTransactionQueue();
                queue?.Rollback();

                OnRollbackTransaction(tran, EventArgs.Empty);
            }
            finally
            {
                SnTrace.Database.Write("Transaction ROLLBACK: {0}. Running time: {1}", tran.Id, (DateTime.UtcNow - tran.Started));
                ContextHandler.SetTransaction(null);
                ContextHandler.SetTransactionQueue(null);
                tran.Dispose();
            }
        }
Пример #4
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();
            }
        }
Пример #5
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();

                ContextHandler.SetTransaction(null);
                ContextHandler.SetTransactionQueue(null);
                tran.Dispose();
            }
        }