共用方式為


WorkflowPersistenceService.LoadCompletedContextActivity 方法

定義

在衍生類別中實作時,將指定的完成範圍載回記憶體中。

protected public:
 abstract System::Workflow::ComponentModel::Activity ^ LoadCompletedContextActivity(Guid scopeId, System::Workflow::ComponentModel::Activity ^ outerActivity);
protected internal abstract System.Workflow.ComponentModel.Activity LoadCompletedContextActivity (Guid scopeId, System.Workflow.ComponentModel.Activity outerActivity);
abstract member LoadCompletedContextActivity : Guid * System.Workflow.ComponentModel.Activity -> System.Workflow.ComponentModel.Activity
Protected Friend MustOverride Function LoadCompletedContextActivity (scopeId As Guid, outerActivity As Activity) As Activity

參數

scopeId
Guid

已完成範圍的 Guid

outerActivity
Activity

Activity,表示包圍已完成範圍的活動。

傳回

Activity

表示已完成範圍的 Activity

範例

下列範例示範 LoadCompletedContextActivity 方法的實作。 這個範例來自 FilePersistenceService.cs 檔案中的<自訂持續性服務>範例。 如需詳細資訊,請參閱 自訂持續性服務範例

// Load the completed activity state.
protected override Activity LoadCompletedContextActivity(Guid activityId, Activity outerActivity)
{
    Console.WriteLine("Loading completed activity context: {0}", activityId);
    byte[] workflowBytes = DeserializeFromFile(activityId);
    Activity deserializedActivities = WorkflowPersistenceService.RestoreFromDefaultSerializedForm(workflowBytes, outerActivity);
    return deserializedActivities;
}
' Load completed activity state.
Protected Overrides Function LoadCompletedContextActivity(ByVal scopeId As System.Guid, ByVal outerActivity As System.Workflow.ComponentModel.Activity) As System.Workflow.ComponentModel.Activity
    Console.WriteLine("Loading completed activity context: 0}", scopeId)
    Dim workflowBytes As Byte() = DeserializeFromFile(scopeId)
    Dim deserializedActivities As Activity = WorkflowPersistenceService.RestoreFromDefaultSerializedForm(workflowBytes, outerActivity)
    Return deserializedActivities
End Function

備註

工作流程執行階段引擎使用 LoadCompletedContextActivity 實作補償。 您必須還原已完成範圍的相同複本。 若要執行這項作業,您必須從資料存放區中的已完成範圍代表項還原有效的 Stream。 然後您必須將此 Stream 傳遞至 Load 的其中一個多載方法,以執行範圍的還原序列化。

如果您的持續性服務無法從它的資料存放區中載入已完成的範圍,應該擲回有適當錯誤訊息的 PersistenceException

適用於