public void InDoubt(Enlistment enlistment) { Rollback(enlistment); }
/// <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(); }
public void Commit(Enlistment enlistment) { foreach (var op in _journal) { op.CleanUp(); } _enlisted = false; _journal.Clear(); enlistment.Done(); }
public void Commit(Enlistment enlistment) { for (int i = 0; i < _journal.Count; i++) { _journal[i].CleanUp(); } _enlisted = false; _journal.Clear(); enlistment.Done(); }
/// <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); } }
/// <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); } } }
/// <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); } }