Example #1
0
 public void InDoubt(Enlistment enlistment)
 {
   Rollback(enlistment);
 }
Example #2
0
      /// <summary>
      /// Notifies an enlisted object that a transaction is being rolled back (aborted).
      /// </summary>
      /// <param name="enlistment">A <see cref="T:System.Transactions.Enlistment"></see> object used to send a response to the transaction manager.</param>
      /// <remarks>This is typically called on a different thread from the transaction thread.</remarks>
      public void Rollback(Enlistment enlistment)
      {
        try
        {
          // Roll back journal items in reverse order
          for (var i = _journal.Count - 1; i >= 0; i--)
          {
            _journal[i].Rollback();
            _journal[i].CleanUp();
          }

          _enlisted = false;
          _journal.Clear();
        }
        catch (Exception e)
        {
          if (IgnoreExceptionsInRollback)
          {
            EventLog.WriteEntry(GetType().FullName, "Failed to rollback." + Environment.NewLine + e,
                                EventLogEntryType.Warning);
          }
          else
          {
            throw new TransactionException("Failed to roll back.", e);
          }
        }
        finally
        {
          _enlisted = false;
          if (_journal != null)
          {
            _journal.Clear();
          }
        }

        enlistment.Done();
      }
Example #3
0
      public void Commit(Enlistment enlistment)
      {
        foreach (var op in _journal)
        {
          op.CleanUp();
        }

        _enlisted = false;
        _journal.Clear();
        enlistment.Done();
      }
Example #4
0
            public void Commit(Enlistment enlistment)
            {
                for (int i = 0; i < _journal.Count; i++)
                {
                    _journal[i].CleanUp();
                }

                _enlisted = false;
                _journal.Clear();
                enlistment.Done();
            }
Example #5
0
        /// <summary>
        /// Tells the participating resource managers to rollback their changes.
        /// </summary>
        public void Rollback()
        {
            if (TransactionInformation.Status == TransactionStatus.Aborted)
              {
            return;
              }

              var lstExceptions =
            new List<RollbackException.ExceptedResourceManager>();
              for (var i = m_lstNotifications.Count - 1; i >= 0; i--)
              {
            var entNotification = m_lstNotifications[i];
            var eltEnlistment = new Enlistment();
            try
            {
              entNotification.Rollback(eltEnlistment);
            }
            catch (Exception e)
            {
              lstExceptions.Add(new RollbackException.ExceptedResourceManager(entNotification, e));
            }
            if (eltEnlistment.DoneProcessing)
            {
              m_lstNotifications.RemoveAt(i);
            }
              }
              if (m_lstNotifications.Count > 0)
              {
            TransactionInformation.Status = TransactionStatus.InDoubt;
            NotifyInDoubt();
              }
              else
              {
            TransactionInformation.Status = TransactionStatus.Aborted;
              }

              if (lstExceptions.Count > 0)
              {
            throw new RollbackException(lstExceptions);
              }
        }
Example #6
0
        /// <summary>
        /// Tells the participating resource managers that the transaction status is in doubt.
        /// </summary>
        protected void NotifyInDoubt()
        {
            if (TransactionInformation.Status != TransactionStatus.InDoubt)
              {
            return;
              }

              for (var i = m_lstNotifications.Count - 1; i >= 0; i--)
              {
            var entNotification = m_lstNotifications[i];
            var eltEnlistment = new Enlistment();
            entNotification.InDoubt(eltEnlistment);
            if (eltEnlistment.DoneProcessing)
            {
              m_lstNotifications.RemoveAt(i);
            }
              }
        }
Example #7
0
        /// <summary>
        /// Tells the participating resource managers that the transaction status is in doubt.
        /// </summary>
        protected void NotifyInDoubt()
        {
            if (TransactionInformation.Status != TransactionStatus.InDoubt)
                return;

            Enlistment eltEnlistment = null;
            IEnlistmentNotification entNotification = null;
            for (Int32 i = m_lstNotifications.Count - 1; i >= 0; i--)
            {
                entNotification = m_lstNotifications[i];
                eltEnlistment = new Enlistment();
                entNotification.InDoubt(eltEnlistment);
                if (eltEnlistment.DoneProcessing)
                    m_lstNotifications.RemoveAt(i);
            }
        }