Пример #1
0
 void IEnlistmentNotificationInternal.Rollback(
     IPromotedEnlistment enlistment
     )
 {
     _promotedEnlistment = enlistment;
     _twoPhaseNotifications.Rollback(Enlistment);
 }
        /// <summary>
        /// Tells the participating resource managers to rollback their changes.
        /// </summary>
        public void Rollback()
        {
            if (TransactionInformation.Status == TransactionStatus.Aborted)
            {
                return;
            }

            List <RollbackException.ExceptedResourceManager> lstExceptions = new List <RollbackException.ExceptedResourceManager>();
            Enlistment eltEnlistment = null;
            IEnlistmentNotification entNotification = null;

            for (Int32 i = m_lstNotifications.Count - 1; i >= 0; i--)
            {
                entNotification = m_lstNotifications[i];
                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);
            }
        }