Clerk Class
Writes records of transactional actions to a log.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
| 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() | Frees the resources of the current Clerk before it is reclaimed by the garbage collector.(Overrides Object::Finalize().) |
![]() | 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 the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
![]() | WriteLogRecord(Object^) | Writes unstructured log records to the log. |
Each clerk is associated with a compensator, which is called back to perform actions during the two-phase commit of the transaction.
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; } }
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


