views:

178

answers:

2

We are running several ASP.NET applications (one per customer) based on our custom framework (which just extend ASP.NET). Each web application use its own database (Initial Catalog in the term of connection string). Now we would like to add workflow capability to the applications (to our framework respectively). The particular workflows will be the same for all the applications only some initial settings of each workflow can vary, e.g. in one application the e-mail will be send to the user X, but in other application to the user Y.

The question is if we can install one workflow engine (with one database for persistence) and share this for all workflows in all web applications.

If so, how then workflow engine get knows the particular workflow belongs to which web application? Should we store some application identifier somewhere in workflow?

Thanks for suggestions!

+1  A: 

If all workflows are the same you can use a single WorkflowServiceHost for each customers and provide the additional information like email address as a startup parameter. However if you think you are going to tweak the worklflows for different client I would create a different host for each specific client. Of course you could always add this later.

Maurice
A: 

You could use a single persistence database if your workflows can be re-used across applications.

To enable a custom property in your workflow...the AppId you'll need a local communication interface marked with ExternalDataExchangeAttribute.

Define your custom property... AppId

[Serializable()]
public class MyWorkflowEventArgs : ExternalDataEventArgs
{

    private Guid _AppId;

...

Then when you start each workflow, you can pass your custom property in via a Dictionary...

       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();

You can then track within your workflow which app has instantiated it...

Konrad
This is WF3 material and the question is tagged WF4.
Maurice