Workflow Engine
In .NET Core
Using Workflow Core
With a simple example
Keivan Damirchi
What is a Workflow Engine?
A workflow engine automates and orchestrates
tasks, activities, and processes in an organization.
It helps to ensure that everything is done in the
right order, with the right information and by the
right people.
It includes tools for creating, editing, and managing
workflows, as well as monitoring and reporting on
their progress.
Before implementing a Workflow Engine, you must understand the
process that needs to be automated. Identify the steps involved, the
decision points, and the people or systems involved.
1
How it helps automate
business processes?
A workflow engine automates business processes
by centralizing task management, reducing errors,
increasing efficiency, enforcing rules and policies,
and providing real-time visibility into progress.
A simple pizza delivery process model.
This helps organizations save time and resources,
improve productivity, enhance collaboration, and
ensure compliance with regulations and policies.
2
Benefits of using a
workflow engine!
Here are the benefits of using a workflow engine:
Automation of repetitive and manual tasks.
Improved collaboration between stakeholders.
Real-time visibility into the progress of workflows.
Flexibility to handle complex, multi-step processes.
Standardizes workflows based on rules and policies.
Scalability to adapt to changing organizational needs.
Reduction of errors and increase in efficiency.
3
Examples of business processes
that can be automated!
There are numerous business processes that can
be automated using a workflow engine. Here are
some examples:
Employee onboarding:
Its automates onboarding for faster,
more accurate processing, freeing
up HR staff for strategic tasks while
reducing errors and saving time.
Invoice processing:
Automating the processing of invoices,
from receipt to payment, by routing
them to the appropriate stakeholders
for approval and payment.
4
Examples of business processes
that can be automated!
Customer service requests:
Workflow Engine automates customer service
requests for quicker resolutions, efficient
resource utilization and happier customers.
Purchase order management:
Its purchase order management for
efficient processing, saving time and
freeing up staff for other tasks.
These are just a few examples of business processes
that can be automated using a workflow engine. In
general, any process that involves multiple steps
and stakeholders, repetitive tasks, and can benefit
from standardization and automation can be
automated using a workflow engine.
5
Overview of Workflow Core
Workflow Core is a light weight embeddable
workflow engine that allows developers to create
and execute workflows within their applications.
It's lightweight, flexible, and scalable, and can be used
in a wide range of applications and environments.
Workflow Core
https://github.com/danielgerlag/workflow-core
6
Getting Started with Workflow Core
To get started with Workflow Core, developers can
follow these steps:
Install the Workflow Core NuGet package
1 in their project:
dotnet add package WorkflowCore
There are many Workflow Engines available in the
market. Choose the one that best suits your needs
based on factors such as complexity, scalability,
and integration capabilities.
7
Getting Started with Workflow Core
2 Define workflows and activities using C#
code or YAML files.
Developers using Workflow Core can define
workflows and activities with C# code or YAML files.
C# offers more control, while YAML is simpler and
more intuitive.
Define your workflows with the fluent API.
8
Getting Started with Workflow Core
Define workflows and activities using C# code or YAML files.
Define your workflows in JSON or YAML
Need to install WorkFlowCore.DSL
9
Getting Started with Workflow Core
To use Workflow Core, developers must configure
the workflow host, which is responsible for
executing workflows and managing their state.
Create a new instance of the IWorkflowHost interface, which
1
represents the workflow host.
Configure the workflow host by setting the necessary
2 options, such as the storage provider for workflow state and
the maximum number of parallel workflows to execute.
Start the workflow host, which will begin executing
3
workflows and handling events.
10
Getting Started with Workflow Core
Here's an example of how to configure the workflow
host using the default options:
The AddWorkflow method is used to register Workflow
Core services and dependencies with the
ServiceCollection. The MyWorkflow class is then registered
with the workflow host using the RegisterWorkflow method,
and the host is started using the Start method.
11
Getting Started with Workflow Core
Start and manage workflows
To start a new workflow instance, developers can
create a new instance of the workflow class and
pass it to the IWorkflowHost.StartWorkflowAsync
method.
Use the IWorkflowHost interface to manage running workflow
instances. Call the method IWorkflowHost.GetStatusAsync
with the instance ID to query its status.
Workflow Core provides extensive documentation and examples on its
official website to help developers get started and integrate it into their
applications.
https://workflow-core.readthedocs.io
12
Workflow Core Concepts
Activities
An activity in Workflow Core represents a single unit of work
that can be executed by the workflow.
Steps
A step in Workflow Core is a logical unit of work that consists
of one or more activities.
Persistence
Workflow Core provides built-in support for persistence to
ensure that workflow state is not lost during application
restarts or failures.
Events
An event in Workflow Core is a signal that triggers a
workflow to execute or pause.
13
Workflows as Code
Workflow Core allows workflows to be defined
as code using C#. Defining workflows as code
provides a number of benefits, including:
- Version control: Workflows defined as code can be
managed using version control tools like Git, allowing
for easy tracking of changes over time.
- Code reuse: Workflows can be created as reusable
code libraries, allowing for easy integration into
multiple applications.
- Maintainability: Defining workflows as code makes it
easier to maintain and update them as business
processes change.
To create a workflow using Workflow Core, decorate the
Workflow class with the Workflow attribute and define its
steps and activities in C# code. Finally, execute the
workflow using the Workflow Core API.
14
Close();
Keivan Damirchi