Exemple #1
0
        public void Run()
        {
            var currentState = _metadataProvider.GetCurrentState();

            _transactionProvider.Start();
            try
            {
                foreach (var script in _scriptProvider.GetAllScripts())
                {
                    if (ScriptShouldBeRun(script, currentState))
                    {
                        if (_scriptApplicator.ApplyScript(script))
                        {
                            WriteUpdateEntry(script, currentState);
                        }
                    }
                }

                _transactionProvider.Commit();
            }
            catch (Exception e)
            {
                _transactionProvider.Rollback();
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #2
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();
            }
        }