How to integrate

Integrating Workflow Engine into any application takes about an hour and consists of 5 simple steps. This article lists examples for ASP.NET MVC and MS SQL.

Integration with solutions based on other technologies (ASP.NET WebForms, .NET WinForms, ОМЬ) or databases (MySQL, PostgreSQL, Orcale, MongoDB and others) is roughly the same and should noe entail any difficulties.

2.4. Create a WorkflowInit.cs file. Add the following namespaces to the usings section:

using System.Xml.Linq;
using OptimaJet.Workflow.Core.Builder;
using OptimaJet.Workflow.Core.Bus;
using OptimaJet.Workflow.Core.Runtime;
using OptimaJet.Workflow.DbPersistence;

Add the initialization of the WorkflowRuntime object. It should look like this:

public static class WorkflowInit
{
private static readonly Lazy<WorkflowRuntime> LazyRuntime = new Lazy<WorkflowRuntime>(InitWorkflowRuntime);
public static WorkflowRuntime Runtime
{
get { return LazyRuntime.Value; }
}
private static WorkflowRuntime InitWorkflowRuntime()
{
//TODO If you have a license key, you have to register it here
//WorkflowRuntime.RegisterLicense("your license key text");
//TODO If you are using database different from SQL Server you have to use different persistence provider here.
var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
var dbProvider = new MSSQLProvider(connectionString);
var builder = new WorkflowBuilder<XElement>(
dbProvider,
new OptimaJet.Workflow.Core.Parser.XmlWorkflowParser(),
dbProvider
).WithDefaultCache();
var runtime = new WorkflowRuntime()
.WithBuilder(builder)
.WithPersistenceProvider(dbProvider)
.WithBus(new NullBus())
//TODO If you have planned use Timers uncomment following line of code
//.WithTimerManager(new TimerManager())
.EnableCodeActions()
.SwitchAutoUpdateSchemeBeforeGetAvailableCommandsOn();
//events subscription
runtime.ProcessActivityChanged += (sender, args) => { };
runtime.ProcessStatusChanged += (sender, args) => { };
//TODO If you have planned to use Code Actions functionality that required references to external assemblies you have to register them here
//runtime.RegisterAssemblyForCodeActions(Assembly.GetAssembly(typeof(SomeTypeFromMyAssembly)));
//starts the WorkflowRuntime
//TODO If you have planned use Timers the best way to start WorkflowRuntime is somwhere outside of this function in Global.asax for example
runtime.Start();
return runtime;
}
}

If you have a license key, add a call to the WorkflowRuntime.RegisterLicense method with the license key.