i4connected Knowledgebase

The Workflow Engine

Abstract

This article describes the usage of the Windows Workflow Foundation workflows in conjunction to the DWH Server.

This article describes the usage of the Windows Workflow Foundation workflows in conjunction to the DWH Server.

The DWH Server allows the user to attach and run the Windows Workflow Foundation workflows. The user can create and trigger a workflow as follows:

Creating a Workflow

A reference to the workflow should exist in both file system (under the Server Workflows folder) and database.

The Windows Workflow Foundation workflow XAML file and the folder containing it should be placed in the Workflows folder of the server directory.

The folder that contains the XAML file must have the same name as the workflow; the file must have the same name as the workflow version it represents:

[Server Path]\Workflows\[Workflow Name]\[Workflow Version].xaml

For example:

%Program Files%\WEBfactory\Data Warehouse\Server\Workflows\Workflow 1\1.0.xaml

A corresponding entry should exist in the database, having the workflow name equal to the directory where it’s located.

For example

Workflow1.png

Database example

In the WorkflowVersions table of the database, an entry corresponding to each existing workflow version file should be created. When a workflow is started, it will retain its version until it finishes executing.

For example:

Workflow2.png

Workflow Versioning example

Triggering a Workflow

A workflow must be triggered by a query.

To invoke a workflow, a reference to the workflow manager should be included in the query constructor and the method StartWorkflow should be invoked passing the workflow name and a list of parameters.

For example:

public class SampleWorkflowTriggerQuery : ReactiveQuery
    {
        private readonly IWorkflowManager workflowManager;

        public SampleWorkflowTriggerQuery(IWorkflowManager workflowManager)
        {
            this.workflowManager = workflowManager;
        }

        protected override IDisposable Run()
        {
            return OnlineOccurrences
                .Sample(TimeSpan.FromSeconds(10))
                .Do(x => workflowManager.StartWorkflow("SampleWorkflow", new Dictionary<string, object>
                {
                    {"eventName", x.Uri.ToString()}
                }))
                .Select(x=>new OnlineEventUpdate("SampleWorkflowStarted"))
                .Subscribe(this);
        }
    }

Developing a Workflow

The DWH Server uses Windows Workflow Foundation 4.5.

To learn how to create custom workflows, please refer to the Microsoft documentation and resources available at the Microsoft Developer Network or follow the link below: Windows Workflow Foundation.