如果您的工作流可以跨应用程序重用,您可以使用单个持久性数据库。
要在您的工作流程中启用自定义属性...AppId,您需要一个标有 ExternalDataExchangeAttribute 的本地通信接口。
定义您的自定义属性... AppId
[Serializable()]
public class MyWorkflowEventArgs : ExternalDataEventArgs
{
private Guid _AppId;
...
然后,当您启动每个工作流程时,您可以通过字典传递您的自定义属性...
System.Collections.Generic.Dictionary<String, Object> parameters = new System.Collections.Generic.Dictionary<String, Object>();
Guid appId;
StartWorkflowRuntime();
//Define the parameters for the workflow
parameters.Add("appId", appId);
// create the workflow instance
WorkflowInstance workflowInstance;
ManualWorkflowSchedulerService manualWorkflowSchedulerService;
workflowInstance =
(HttpContext.Current.Application[WorkflowRuntimeCacheKey] as WorkflowRuntime)
.CreateWorkflow(workflowclass, parameters);
// start the new workflowinstance
workflowInstance.Start();
然后,您可以在您的工作流程中跟踪哪个应用程序实例化了它...