.NET Framework 4.5
动态更新。
WorkflowIdentity,则它是唯一的。
|
|
|---|
|
WorkflowIdentity 实例不应该包含任何 PII 数据,因为运行时将在跟踪记录中发出这些数据,任何有权查看跟踪记录的人都能够看到这些数据。 |
MortgageWorkflow 工作流定义创建的工作流实例相关联。
WorkflowIdentity identityV1 = new WorkflowIdentity
{
Name = "MortgageWorkflow v1",
Version = new Version(1, 0, 0, 0)
};
WorkflowApplication wfApp = new WorkflowApplication(new MortgageWorkflow(), identity);
// Configure the WorkflowApplication with persistence and desired workflow event handlers.
ConfigureWorkflowApplication(wfApp);
// Run the workflow.
wfApp.Run();
WorkflowIdentity。
WorkflowApplication wfApp = new WorkflowApplication(new MortgageWorkflow(), identityV1); // Configure the WorkflowApplication with persistence and desired workflow event handlers. ConfigureWorkflowApplication(wfApp); // Load the workflow. wfApp.Load(instanceId); // Resume the workflow...
WorkflowIdentity,该工作流与持久保存实例不匹配。
WorkflowApplication wfApp = new WorkflowApplication(new MortgageWorkflow_v2(), identityV2); // Configure the WorkflowApplication with persistence and desired workflow event handlers. ConfigureWorkflowApplication(wfApp); // Attempt to load the workflow instance. wfApp.Load(instanceId); // Resume the workflow...
VersionMismatchException。
可以使用不同的定义加载此实例,或使用动态更新更新此实例。
使用 WorkflowIdentity 并行执行
WorkflowIdentity 可用于在恢复工作流实例时确定和提供匹配的工作流定义。
WorkflowIdentity 在加载和恢复工作流实例时提供正确的工作流定义。
|
|
|---|
|
更新 .NET Framework 4 持久性数据库以支持工作流版本控制。 |
MortgageWorkflow 工作流定义来启动一个工作流。
WorkflowIdentity identityV1 = new WorkflowIdentity
{
Name = "MortgageWorkflow v1",
Version = new Version(1, 0, 0, 0)
};
WorkflowIdentity identityV2 = new WorkflowIdentity
{
Name = "MortgageWorkflow v2",
Version = new Version(2, 0, 0, 0)
};
Dictionary<WorkflowIdentity, Activity> WorkflowVersionMap = new Dictionary<WorkflowIdentity, Activity>();
WorkflowVersionMap.Add(identityV1, new MortgageWorkflow());
WorkflowVersionMap.Add(identityV2, new MortgageWorkflow_v2());
WorkflowApplication wfApp = new WorkflowApplication(new MortgageWorkflow(), identityV1);
// Configure the WorkflowApplication with persistence and desired workflow event handlers.
ConfigureWorkflowApplication(wfApp);
// Run the workflow.
wfApp.Run();
InstanceStore 属性。
|
|
|---|
|
The instance is configured with a different InstanceStore than this WorkflowApplication.。 |
// Get the WorkflowApplicationInstance of the desired workflow from the specified
// SqlWorkflowInstanceStore.
WorkflowApplicationInstance instance = WorkflowApplication.GetInstance(instanceId, store);
// Use the persisted WorkflowIdentity to retrieve the correct workflow
// definition from the dictionary.
Activity definition = WorkflowVersionMap[instance.DefinitionIdentity];
WorkflowApplication wfApp = new WorkflowApplication(definition, instance.DefinitionIdentity);
// Configure the WorkflowApplication with persistence and desired workflow event handlers.
ConfigureWorkflowApplication(wfApp);
// Load the persisted workflow instance.
wfApp.Load(instance);
// Resume the workflow...
数据库中任何持久化工作流实例都将获得默认的版本控制值,然后就可以参与并行执行和动态更新。
InstancePersistenceCommandException,并显示与以下消息内容类似的消息。
SqlWorkflowInstanceStore 的数据库版本为“4.0.0.0”。
InstancePersistenceCommand 'System.Activities.DurableInstancing.CreateWorkflowOwnerWithIdentityCommand' 无法针对此数据库版本运行。
请将此数据库升级为“4.5.0.0”。
升级数据库架构
-
.\SQLEXPRESS。
-
C:\Windows\Microsoft.NET\Framework\4.0.30319\sql\en
-
“打开”。
-
“可用数据库”下拉列表中选择持久性数据库的名称。
-
“执行”。
NULL 值,这表示空工作流标识。