Any business process with predefined set of tasks/activities is a good candidate for Workflow. Especially, that takes time between each task like approval process, waiting on external events to be triggered like file drop or based on a new request from client through say SharePoint list item added.
Without workflow, the processes (applications) had to have its instance always waiting which wasted a lot of CPU cycles. WF provides capability to share the data between each task of the workflow instance. Ability to persist the state enables the application to be stopped when waiting on an event and again be invoked when the event occurs. It is not required for all the activities in a particular instance of a workflow to be executed by the same thread or even the same process.
Good Use Case would be for ASP.Net pages. They can be modeled in a WF (ex: purchase WF). It gives capabilities to change the WF dynamically without having to touch the pages.
Advantages of WF Framework
- Componentizing of code to execute a different chunk of software at each level
- Tools to create and modify workflows graphically
- Ability to monitor the status of the Workflow
- Rich error handling and provision for rolling back an activity
- Dynamically modifying the workflow by adding a task
The fundamental components of WF are the following:
Activity: A unit of work. (Some Business Process Managements use the term 'Task')
- Workflow: A set of activities. Defines the flow of the activities based on business logic.
- Workflow Designer: a graphical tool, typically hosted by Visual Studio that can be used to create and modify WF workflows and activities.
- Base activity library: Standard out of the box activities provided by WF.
- Runtime engine: a WF-supplied library that executes workflows. The runtime engine also provides other services, such as mechanisms for communicating with software outside the workflow. I.e. Assembly method, WCF Service etc.
- Runtime services: a group of services that workflows can use, including support for transactions, persisting a workflow’s state, tracking its execution, and more.
- Host process: a Windows application that hosts the WF runtime engine and any workflows it executes.
There are two kinds of WF
- Sequential (has a start and end)
- State Transition (jumps from one state to another based on the actions)
Checkout the msdn for the list of Activities of the base activity library.
You can Developing Workflows using Visual Studio designer or by writing code directly writing code.
You will use the following namespaces while coding.
System.Workflow.Activities, System.Workflow.ComponentModel, and System.Workflow.Runtime
Snippet to create a Workflow would be as follows:
using System.Workflow.Activities;
public class ExampleWorkflow : SequentialWorkflow
{
…
}
Workflows can also be defined using the XML-based extensible Application Markup Language (XAML).
ClrNamespace="System.Workflow.Activities"Assembly="System.Workflow.Activities" ?><="" x:class="ExampleWorkflow" font="">xmlns="Activities" xmlns:x="Definition">…
Simple way to create an activity in C# is
using System.Workflow.ComponentModel;
public class ExampleActivity : Activity
{
…
}
Common Hosting Program will be something like this,
using System.Workflow.Runtime;
class ExampleHost
{
static void Main()
{
WorkflowRuntime runtime = new WorkflowRuntime();
runtime.StartRuntime();
runtime.StartWorkflow(typeof(ExampleWorkflow));
…
}
}
WF ships with a set of services that allow the runtime to execute within ASP.NET applications.
The ASP.NET-based host that ships with WF relies on SQL Server for persistence.
The WF runtime acts as an intermediary for all communication with all workflows. i.e even for unloaded workflow which are waiting on an input/event to execute the activity.
To communicate with other objects in the same Windows process, a workflow can use two activities in the base activity library.
WF ships with some built-in support for roles defined using Windows accounts, Active Directory, and ASP.NET, but other role management systems can also be used.
Windows Workflow Foundation and Windows SharePoint Services:
Using standard WF tools, such as the Workflow Designer, developers can create workflow applications that address document collaboration and other kinds of information sharing.
Conclusion:
A very generic framework for designing and developing of Business Processes has been created in the form of Windows Workflow foundation. This should help the developers to speed up the programming and also ensure a better utilization of the Server Process CPU by unloading the idle Processes waiting on external inputs.
Using the framework, developers can also write tools that can help the Business users to track the status of each of the Workflow instances for better management purpose.
public class ExampleWorkflow : SequentialWorkflow
{
…
}
Workflows can also be defined using the XML-based extensible Application Markup Language (XAML).
ClrNamespace="System.Workflow.Activities"Assembly="System.Workflow.Activities" ?>
Simple way to create an activity in C# is
using System.Workflow.ComponentModel;
public class ExampleActivity : Activity
{
…
}
Common Hosting Program will be something like this,
using System.Workflow.Runtime;
class ExampleHost
{
static void Main()
{
WorkflowRuntime runtime = new WorkflowRuntime();
runtime.StartRuntime();
runtime.StartWorkflow(typeof(ExampleWorkflow));
…
}
}
WF ships with a set of services that allow the runtime to execute within ASP.NET applications.
The ASP.NET-based host that ships with WF relies on SQL Server for persistence.
The WF runtime acts as an intermediary for all communication with all workflows. i.e even for unloaded workflow which are waiting on an input/event to execute the activity.
To communicate with other objects in the same Windows process, a workflow can use two activities in the base activity library.
- CallExternalMethod activity: allows calling a method in an object outside the workflow
- HandleExternalEvent activity: allows receiving a call from an object outside the workflow.
- Send: Sends a request using WCF, then optionally waits for a response.
- Receive: Receives an incoming request via WCF, then sends a response.
WF ships with some built-in support for roles defined using Windows accounts, Active Directory, and ASP.NET, but other role management systems can also be used.
Windows Workflow Foundation and Windows SharePoint Services:
Using standard WF tools, such as the Workflow Designer, developers can create workflow applications that address document collaboration and other kinds of information sharing.
Conclusion:
A very generic framework for designing and developing of Business Processes has been created in the form of Windows Workflow foundation. This should help the developers to speed up the programming and also ensure a better utilization of the Server Process CPU by unloading the idle Processes waiting on external inputs.
Using the framework, developers can also write tools that can help the Business users to track the status of each of the Workflow instances for better management purpose.
No comments:
Post a Comment