Clerk Class
.NET Framework 3.5
Writes records of transactional actions to a log.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
The following code example demonstrates the use of this class.
// A CRM Worker [Transaction] public class Account : ServicedComponent { // A data member for the account file name. private string filename; public string Filename { get { return(filename); } set { filename = value; } } // A boolean data member that determines whether to commit or abort the transaction. private bool commit; public bool AllowCommit { get { return(commit); } set { commit = value; } } // Debit the account, public void DebitAccount (int ammount) { // Create a new clerk using the AccountCompensator class. Clerk clerk = new Clerk(typeof(AccountCompensator), "An account transaction compensator", CompensatorOptions.AllPhases); // Create a record of previous account status, and deliver it to the clerk. int balance = AccountManager.ReadAccountBalance(filename); Object[] record = new Object[2]; record[0] = filename; record[1] = balance; clerk.WriteLogRecord(record); clerk.ForceLog(); // Perform the transaction balance -= ammount; AccountManager.WriteAccountBalance(filename, balance); // Commit or abort the transaction if (commit) { ContextUtil.SetComplete(); } else { ContextUtil.SetAbort(); } } }
The following code example demonstrates the corresponding Compensator class.
using System; public class CrmClient { public static void Main () { // Create a new account object. The object is created in a COM+ server application. Account account = new Account(); // Transactionally debit the account. try { account.Filename = System.IO.Path.GetFullPath("JohnDoe"); account.AllowCommit = true; account.DebitAccount(3); } finally { account.Dispose(); } } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.