This documentation is archived and is not being maintained.
Clerk Class
Visual Studio 2010
Writes records of transactional actions to a log.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
The Clerk type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Clerk(String, String, CompensatorOptions) | Initializes a new instance of the Clerk class. |
![]() | Clerk(Type, String, CompensatorOptions) | Initializes a new instance of the Clerk class. |
| Name | Description | |
|---|---|---|
![]() | LogRecordCount | Gets the number of log records. |
![]() | TransactionUOW | Gets a value representing the transaction unit of work (UOW). |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | ForceLog | Forces all log records to disk. |
![]() | ForceTransactionToAbort | Performs an immediate abort call on the transaction. |
![]() | ForgetLogRecord | Does not deliver the last log record that was written by this instance of this interface. |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | WriteLogRecord | Writes unstructured log records to the log. |
The following code example demonstrates the use of this class.
// A CRM Worker [Transaction] public ref class Account : public ServicedComponent { // A data member for the account file name. private: String^ filenameValue; public: property String^ Filename { String^ get() { return filenameValue; } void set( String^ value ) { filenameValue = value; } } // A boolean data member that determines whether to commit or abort the // transaction. private: bool allowCommitValue; public: property bool AllowCommit { bool get() { return allowCommitValue; } void set( bool value ) { allowCommitValue = value; } } // Debit the account, public: void DebitAccount(int amount) { // Create a new clerk using the AccountCompensator class. Clerk^ clerk = gcnew Clerk(AccountCompensator::typeid, "An account transaction compensator", CompensatorOptions::AllPhases); // Create a record of previous account status, and deliver it to the // clerk. int balance = ReadAccountBalance(Filename); array<Object^>^ record = gcnew array<Object^>(2); record[0] = Filename; record[1] = balance; clerk->WriteLogRecord(record); clerk->ForceLog(); // Perform the transaction balance -= amount; Console::WriteLine("{0}: {1}", Filename, balance); WriteAccountBalance(Filename, balance); // Commit or abort the transaction if (AllowCommit) { ContextUtil::SetComplete(); } else { ContextUtil::SetAbort(); } } };
The following code example demonstrates the corresponding Compensator class.
#using "System.EnterpriseServices.dll" using namespace System; [assembly: System::Reflection::AssemblyKeyFile("CrmServer.key")]; int main () { // Create a new account object. The object is created in a COM+ server application. Account^ account = gcnew Account(); // Transactionally debit the account. try { account->Filename = System::IO::Path::GetFullPath("JohnDoe"); account->AllowCommit = true; account->DebitAccount(3); } finally { delete account; } }
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
