How to integrate

How to integrate


Article: How to integrate step by step.

Steps for the engine integration into your project:

  • Interface implementation: IWorkflowRuleProvider, IWorkflowActionProvider
  • Create WorkflowBuilder
  • Create WorkflowRuntime

 

Interface implementation: IWorkflowRuleProvider, IWorkflowActionProvider

IWorkflowRuleProvider - Interface of provider for Rules.

For using it you need to call the WithRuleProvider method from WorkflowRuntime class. The method is extension, for using it you need to add OptimaJet.Workflow.Core.Runtime to namespaces section.

public interface IWorkflowRuleProvider
{
    List<string> GetRules();      
    bool Check(ProcessInstance processInstance, string identityId, string ruleName, string parameter);
    IEnumerable<string> GetIdentities(ProcessInstance processInstance, string ruleName, string parameter);
}

IWorkflowActionProvider - Interface of provider for Actions.

For its activation call the WithActionProvider method from WorkflowRuntime class. The method is extension, for using it you need to add OptimaJet.Workflow.Core.Runtime to namespaces section.

public interface IWorkflowActionProvider
{
    void ExecuteAction(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter);
    bool ExecuteCondition(string name, ProcessInstance processInstance, WorkflowRuntime runtime, string actionParameter);
    List<string> GetActions();
}

Create IWorkflowBuilder

IWorkflowBuilder builder = new WorkflowBuilder<XElement>(
new DbXmlWorkflowGenerator(connectionString),
new XmlWorkflowParser(),
new DbSchemePersistenceProvider(connectionString)
    ).WithDefaultCache();

,where connectionString - connection string for database-provider

Create WorkflowRuntime

WorkflowRuntime runtime = new WorkflowRuntime(new Guid("{8D38DB8F-F3D5-4F26-A989-4FDD40F32D9D}"))
.WithBuilder(builder)
.WithPersistenceProvider(new DbPersistenceProvider(connectionString))
.WithTimerManager(new TimerManager()) .WithBus(new NullBus()) .SwitchAutoUpdateSchemeBeforeGetAvailableCommandsOn() .Start();