Пример #1
0
      public void Commit(Enlistment enlistment)
      {
        foreach (var op in _journal)
        {
          op.CleanUp();
        }

        _enlisted = false;
        _journal.Clear();
        enlistment.Done();
      }
Пример #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();
      }
Пример #3
0
            public void Commit(Enlistment enlistment)
            {
                for (int i = 0; i < _journal.Count; i++)
                {
                    _journal[i].CleanUp();
                }

                _enlisted = false;
                _journal.Clear();
                enlistment.Done();
            }