WorkflowPersistenceService 类
定义
注意
The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*
从中派生所有持久性服务的抽象基类。The abstract base class from which all persistence services are derived.
public ref class WorkflowPersistenceService abstract : System::Workflow::Runtime::Hosting::WorkflowRuntimeService
public abstract class WorkflowPersistenceService : System.Workflow.Runtime.Hosting.WorkflowRuntimeService
[System.Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
public abstract class WorkflowPersistenceService : System.Workflow.Runtime.Hosting.WorkflowRuntimeService
type WorkflowPersistenceService = class
inherit WorkflowRuntimeService
[<System.Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")>]
type WorkflowPersistenceService = class
inherit WorkflowRuntimeService
Public MustInherit Class WorkflowPersistenceService
Inherits WorkflowRuntimeService
- 继承
- 派生
- 属性
注解
备注
本材料讨论的类型和命名空间已废弃不用。This material discusses types and namespaces that are obsolete. 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型。For more information, see Deprecated Types in Windows Workflow Foundation 4.5.
在工作流运行过程中发生特定情况时,工作流运行时引擎将保留有关工作流实例的状态信息。When certain conditions occur while the workflow is running, the workflow runtime engine persists state information about the workflow instance. 例如,在原子事务完成时、工作流实例进入空闲状态时、主机对工作流实例调用 WorkflowInstance.Unload 时或工作流实例终止或完成时,会执行保留操作。Persistence can occur, for example, when an atomic transaction finishes, when the workflow instance becomes idle, when the host calls WorkflowInstance.Unload on the workflow instance, or when a workflow instance is terminated or finishes. 当工作流运行时引擎语义指示应执行保留操作时,工作流运行时引擎将调用由持久性服务提供的方法,保存有关工作流实例的状态信息。When the workflow runtime engine semantics dictate that persistence should occur, the workflow runtime engine calls methods that are supplied by a persistence service to save state information about the workflow instance. 同样,当工作流运行时引擎需要还原以前保留的工作流实例时,会调用由持久性服务提供的方法来加载此状态信息。Likewise, when the workflow runtime engine needs to restore a previously persisted workflow instance, it calls methods that are supplied by the persistence service to load this state information. 工作流运行时引擎处理所有关于何时执行保留操作的语义。The workflow runtime engine handles all the semantics regarding when to perform persistence. 持久性服务处理将工作流状态信息实际保存到数据存储区中以及从数据存储区中实际加载该信息的操作。The persistence service handles actually saving and loading the workflow state information to or from a data store.
可以通过从 WorkflowPersistenceService 类派生一个类来创建持久性服务。You can create a persistence service by deriving a class from the WorkflowPersistenceService class. 通过调用 AddService 或在应用程序配置文件中添加合适的项,可以将持久性服务添加到工作流运行时引擎。You can add your persistence service to the workflow runtime engine by calling AddService or by making an appropriate entry in the application configuration file. WorkflowRuntime 应只包含一个持久性服务。The WorkflowRuntime should only contain one persistence service. Windows Workflow Foundation 提供了 SqlWorkflowPersistenceService 类,这是一种全新的持久性服务,可以按原样使用或对其进行扩展。Windows Workflow Foundation provides the SqlWorkflowPersistenceService class, an out-of-box persistence service, which you can use as is or extend.
工作流运行时引擎具有锁定工作流状态信息的语义,当其他进程上运行的持久性服务有权访问单个数据存储区时,可以使用该语义。The workflow runtime engine has semantics for locking workflow state information for use in environments where persistence services that run in different processes might have access to a single data store. 通过为 WorkflowPersistenceService 提供指定是否应在数据存储区中解锁工作流实例状态信息的参数,并提供将先前锁定的工作流状态信息解锁的方法 SaveWorkflowInstanceState,UnlockWorkflowInstanceState 类提供了支持此工作流运行时引擎功能的能力。The WorkflowPersistenceService class provides the capability to support this functionality of the workflow runtime engine by providing a parameter to SaveWorkflowInstanceState that specifies whether the state information of a workflow instance should be unlocked in the data store, and by providing a method UnlockWorkflowInstanceState to unlock previously locked workflow state information. 在实现锁定的持久性服务中,对 LoadWorkflowInstanceState 的调用将锁定工作流实例的状态信息。In a persistence service that implements locking, a call to LoadWorkflowInstanceState should lock the state information for a workflow instance.
如果持久性服务无法将状态信息保存到其数据存储区,或者无法从其数据存储区加载状态信息,则应引发 PersistenceException。Your persistence service should throw a PersistenceException if it fails to save state information to its data store or load state information from its data store. 工作流运行时引擎需要此行为。The workflow runtime engine expects this behavior.
为使用持久性存储区来保存工作流状态信息的服务提供了批处理机制。A batching mechanism is provided for services that use a durable store to save workflow state information. 在这种情况下,在持久性服务使用的持久性存储区与工作流运行时引擎内部状态之间保持一致十分重要。It is important in these cases to maintain consistency between the durable store that is used by the persistence service and the internal state of the workflow runtime engine. 可以将 IPendingWork 接口定义的功能添加到服务中,然后通过将对数据存储区的更改作为工作项添加到 WorkflowCommitWorkBatchService 中,来参与 WorkBatch 提供的工作流事务批处理。You can add functionality defined by the IPendingWork interface to your service, and then participate in workflow transaction batching provided by the WorkflowCommitWorkBatchService by adding changes to your data store as work items to the WorkBatch. 持久存储区自身应实现 IEnlistmentNotification 接口,以便在事务回滚时正确保留工作流信息。The durable store itself should implement the IEnlistmentNotification interface, so that workflow information is not persisted incorrectly in the event of a transaction rollback. 有关详细信息,请参阅SaveCompletedContextActivity或SaveWorkflowInstanceState。For more information, see SaveCompletedContextActivity or SaveWorkflowInstanceState.
构造函数
| WorkflowPersistenceService() |
在派生类中实现时,初始化 WorkflowPersistenceService 类的新实例。When implemented in a derived class, initializes a new instance of the WorkflowPersistenceService class. |
属性
| Runtime |
获取此服务的 WorkflowRuntime。Gets the WorkflowRuntime for this service. (继承自 WorkflowRuntimeService) |
| State |
获取 WorkflowRuntimeService 的状态。Gets the state of the WorkflowRuntimeService. (继承自 WorkflowRuntimeService) |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetDefaultSerializedForm(Activity) |
检索 Activity 的序列化的默认窗体。Retrieves the serialized default form of the Activity. |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetIsBlocked(Activity) |
指示是否阻止给定的活动。Indicates whether the given activity is blocked. |
| GetSuspendOrTerminateInfo(Activity) |
检索给定活动的终止或挂起信息。Retrieves the termination or suspend information of the given activity. |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| GetWorkflowStatus(Activity) |
检索工作流的状态。Retrieves the status of the workflow. |
| LoadCompletedContextActivity(Guid, Activity) |
在派生类中实现时,将指定的已完成作用域加载回内存。When implemented in a derived class, loads the specified completed scope back into memory. |
| LoadWorkflowInstanceState(Guid) |
在派生类中实现时,将工作流实例的指定状态加载回内存。When implemented in a derived class, loads the specified state of the workflow instance back into memory. |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| OnStarted() |
在派生类中重写时,表示将在工作流运行时引擎引发 Started 事件时调用的方法。When overridden in a derived class, represents the method that will be called when the workflow runtime engine raises the Started event. (继承自 WorkflowRuntimeService) |
| OnStopped() |
在派生类中重写时,表示将在工作流运行时引擎引发 Stopped 事件时调用的方法。When overridden in a derived class, represents the method that will be called when the workflow runtime engine raises the Stopped event. (继承自 WorkflowRuntimeService) |
| RaiseServicesExceptionNotHandledEvent(Exception, Guid) |
引发 ServicesExceptionNotHandled 事件。Raises the ServicesExceptionNotHandled event. (继承自 WorkflowRuntimeService) |
| RestoreFromDefaultSerializedForm(Byte[], Activity) |
从其序列化的窗体中还原 Activity。Restores the Activity from its serialized form. |
| SaveCompletedContextActivity(Activity) |
在派生类中实现时,将指定的已完成作用域保存到数据存储区。When implemented in a derived class, saves the specified completed scope to a data store. |
| SaveWorkflowInstanceState(Activity, Boolean) |
在派生类中实现时,将工作流实例状态保存到数据存储区。When implemented in a derived class, saves the workflow instance state to a data store. |
| Start() |
在派生类中重写时,启动服务并将 State 更改为 Starting。When overridden in a derived class, starts the service and changes the State to Starting. (继承自 WorkflowRuntimeService) |
| Stop() |
在派生类中重写时,停止服务并将 State 更改为 Stopping。When overridden in a derived class, stops the service and changes the State to Stopping. (继承自 WorkflowRuntimeService) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |
| UnloadOnIdle(Activity) |
确定在工作流空闲时是否将其卸载。Determines whether a workflow should be unloaded when idle. |
| UnlockWorkflowInstanceState(Activity) |
在派生类中重写时,解除对工作流实例状态的锁定。When overridden in a derived class, unlocks the workflow instance state. |