WF学习备忘(3)
持久化(msdn):
InstanceView 类:表示一个实例视图。例如,Execute(InstanceHandle, InstancePersistenceCommand, TimeSpan) 方法实现可返回一个 InstanceView 对象,该对象提供显示永久性存储区中的实例数据的视图。
每个 InstanceView 对象均与 InstanceHandle 关联。 对于从 InstanceStore.Execute 返回的 InstanceView,关联句柄是传递给 Execute 的句柄。 对于从 InstancePersistenceContext.InstanceView 返回的 InstanceView,关联句柄是传递给 TryCommand 的句柄。
在任何给定时间,InstanceHandle 可以具有 0 个或多个与之关联的 InstanceView 对象。 从 InstanceStore.Execute 返回的 InstanceView 对象是不可变的,并且表示成功执行此命令后已知实例状态的快照。 从 InstancePersistenceContext 返回的 InstanceView 对象是可变的,并且表示当前已知的实例状态,因为它会在执行此命令期间不断更新。 (如果此命令最终失败,则会丢弃此中间状态)。
public InstanceView Execute(
InstanceHandle handle,
InstancePersistenceCommand command,
TimeSpan timeout
)
- handle
- 类型:System.Runtime.DurableInstancing.InstanceHandle
一个实例句柄。
- command
- 类型:System.Runtime.DurableInstancing.InstancePersistenceCommand
要执行的命令。
- timeout
- 类型:System.TimeSpan
此操作的超时值。eg:返回值
类型:System.Runtime.DurableInstancing.InstanceView
一个 InstanceView 对象,表示成功完成此命令后此实例的已知状态。如果在事务下调用了 Execute,则此状态可以包含未提交的数据。一旦成功提交此事务,InstanceView 对象中的数据就被认为是已提交
static InstanceStore instanceStore;
instanceStore = new SqlWorkflowInstanceStore(@"Data Source=.;Initial Catalog=WF4;uid=sa;pwd=123456;Asynchronous Processing=True");
InstanceHandle handle = instanceStore.CreateInstanceHandle();
InstanceView view = instanceStore.Execute(handle, new CreateWorkflowOwnerCommand(), TimeSpan.FromSeconds(30));
handle.Free();
instanceStore.DefaultInstanceOwner = view.InstanceOwner;
...........
application.InstanceStore = instanceStore;
浙公网安备 33010602011771号