Ejemplo n.º 1
0
        public void CommitInner()
        {
            if (disposed)
            {
                throw new ObjectDisposedException($"{nameof(TransactionManager<TInner, TOuter>)}");
            }

            if (complete || innerComplete)
            {
                throw new InvalidOperationException("Inner Transaction already completed!");
            }

            if (timedOut)
            {
                throw new InvalidOperationException("Transaction timed out!");
            }

            try
            {
                //innerComplete = true;
                //complete = innerComplete && outerComplete;
                Inner.Commit();
            }
            catch (TransactionException txEx)
            {
                Log.Debug("Inner Commit transaction failed.");
                Rollback();
                throw new TransactionException("Inner Commit transaction failed", txEx);
            }
        }
 /// <inheritdoc/>
 public override void Commit()
 {
     try
     {
         Inner.Commit();
     }
     catch (TException ex)
     {
         if (!Handler.Invoke(ex))
         {
             throw;
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// helper method for commit.
        /// </summary>
        private void commit()
        {
            TransactionException toBeThrown = null;
            var innerFailed = false;
            var outerFailed = false;

            //commit inner transaction
            try
            {
                Inner.Commit();
            }
            catch (TransactionException txEx)
            {
                innerFailed = true;
                Log.Debug("Commit transaction failed.");
                Log.Trace(Inner.TraceTransaction());
                toBeThrown = new TransactionException("Commit Inner transaction failed", txEx);
            }

            //if ok commit outer transaction
            if (!innerFailed)
            {
                try
                {
                    Outer.Commit();
                }
                catch (TransactionException txEx)
                {
                    outerFailed = true;
                    Log.Debug("Commit transaction failed.");
                    Log.Trace(Outer.TraceTransaction());
                    toBeThrown = new TransactionException("Commit Outer transaction failed", txEx);
                }
            }

            //something bad happened
            if (innerFailed || outerFailed)
            {
                throw toBeThrown;
            }

            complete = true;
        }
Ejemplo n.º 4
0
 /// <inheritdoc/>
 public override void Commit()
 {
     Inner.Commit();
     Tap.Commit();
 }
 /// <inheritdoc/>
 public Task CommitAsync() => Task.Run(() => Inner.Commit());