Compensator.AbortRecord(LogRecord) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
在中止階段期間傳送記錄檔資料錄至 Compensating Resource Manager (CRM) 補償器。
public:
virtual bool AbortRecord(System::EnterpriseServices::CompensatingResourceManager::LogRecord ^ rec);
public virtual bool AbortRecord (System.EnterpriseServices.CompensatingResourceManager.LogRecord rec);
abstract member AbortRecord : System.EnterpriseServices.CompensatingResourceManager.LogRecord -> bool
override this.AbortRecord : System.EnterpriseServices.CompensatingResourceManager.LogRecord -> bool
Public Overridable Function AbortRecord (rec As LogRecord) As Boolean
參數
- rec
- LogRecord
要傳送的記錄檔資料錄。
傳回
如果應該忘記已傳送的資料錄,則為 true
,否則為 false
。
範例
下列程式代碼範例示範此方法的實作。
public:
virtual bool AbortRecord(LogRecord^ log) override
{
// Check the validity of the record.
if (log == nullptr)
{
return true;
}
array<Object^>^ record = dynamic_cast<array<Object^>^>(log->Record);
if (record == nullptr)
{
return true;
}
if (record->Length != 2)
{
return true;
}
// Extract old account data from the record.
String^ filename = (String^) record[0];
int balance = (int) record[1];
// Restore the old state of the account.
WriteAccountBalance(filename, balance);
return false;
}
public override bool AbortRecord (LogRecord log)
{
// Check the validity of the record.
if (log == null) return(true);
Object[] record = log.Record as Object[];
if (record == null) return(true);
if (record.Length != 2) return(true);
// Extract old account data from the record.
string filename = (string) record[0];
int balance = (int) record[1];
// Restore the old state of the account.
AccountManager.WriteAccountBalance(filename, balance);
return(false);
}
Public Overrides Function AbortRecord(ByVal log As LogRecord) As Boolean
' Check the validity of the record.
If log Is Nothing Then
Return True
End If
Dim record As [Object]() = log.Record
If record Is Nothing Then
Return True
End If
If record.Length <> 2 Then
Return True
End If
' Extract old account data from the record.
Dim filename As String = CStr(record(0))
Dim balance As Integer = Fix(record(1))
' Restore the old state of the account.
AccountManager.WriteAccountBalance(filename, balance)
Return False
End Function 'AbortRecord