Describes the enlistment of a resource manager in a transaction.
			/// <summary>
			/// Used to notify an enlisted resource manager that the transaction is being rolled back.
			/// </summary>
			/// <param name="p_eltEnlistment">The enlistment class used to communicate with the resource manager.</param>
			public void Rollback(Enlistment p_eltEnlistment)
			{
				m_booEnlisted = false;
				m_amrModKeys.Clear();
				m_dicInstalledFiles.Clear();
				m_dicInstalledIniEdits.Clear();
				m_dicInstalledGameSpecificValueEdits.Clear();
				m_dicEnlistments.Remove(CurrentTransaction.TransactionInformation.LocalIdentifier);
				p_eltEnlistment.Done();
			}
			/// <summary>
			/// Used to notify an enlisted resource manager that the transaction is being committed.
			/// </summary>
			/// <param name="p_eltEnlistment">The enlistment class used to communicate with the resource manager.</param>
			public void Commit(Enlistment p_eltEnlistment)
			{
				try
				{
					Commit();
					m_dicEnlistments.Remove(CurrentTransaction.TransactionInformation.LocalIdentifier);
					p_eltEnlistment.Done();
				}
				catch (Exception e)
				{
					throw new TransactionException("Problem whilst committing Install Log.", e);
				}
			}
			/// <summary>
			/// Used to notify an enlisted resource manager that the transaction is in doubt.
			/// </summary>
			/// <remarks>
			/// A transaction is in doubt if it has not received votes from all enlisted resource managers
			/// as to the state of the transaciton.
			/// </remarks>
			/// <param name="p_eltEnlistment">The enlistment class used to communicate with the resource manager.</param>
			public void InDoubt(Enlistment p_eltEnlistment)
			{
				Rollback(p_eltEnlistment);
			}
		/// <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);
			}
		}
		/// <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);
		}
			/// <summary>
			/// Used to notify an enlisted resource manager that the transaction is being committed.
			/// </summary>
			/// <param name="p_eltEnlistment">The enlistment class used to communicate with the resource manager.</param>
			public void Commit(Enlistment p_eltEnlistment)
			{
				Commit();
				m_dicEnlistments.Remove(CurrentTransaction.TransactionInformation.LocalIdentifier);
				p_eltEnlistment.Done();
			}
			/// <summary>
			/// Used to notify an enlisted resource manager that the transaction is being rolled back.
			/// </summary>
			/// <param name="p_eltEnlistment">The enlistment class used to communicate with the resource manager.</param>
			public void Rollback(Enlistment p_eltEnlistment)
			{
				m_booEnlisted = false;
				m_setManagedPlugins.Clear();
				m_setRemovedPlugins.Clear();
				m_dicEnlistments.Remove(CurrentTransaction.TransactionInformation.LocalIdentifier);
				p_eltEnlistment.Done();
			}
示例#8
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 (int 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.ToString(), EventLogEntryType.Warning);
					}
					else
					{
						throw new TransactionException("Failed to roll back.", e);
					}
				}
				finally
				{
					_enlisted = false;
					if (_journal != null)
					{
						_journal.Clear();
					}
				}
				_enlistments.Remove(_tx.TransactionInformation.LocalIdentifier);
				enlistment.Done();
			}
示例#9
0
			public void InDoubt(Enlistment enlistment)
			{
				Rollback(enlistment);
			}
示例#10
0
			public void Commit(Enlistment enlistment)
			{
				for (int i = 0; i < _journal.Count; i++)
				{
					_journal[i].CleanUp();
				}

				_enlisted = false;
				_journal.Clear();
				_enlistments.Remove(_tx.TransactionInformation.LocalIdentifier);
				enlistment.Done();
			}