The Workflow Service Engine is used to process workflow definitions created by our LlamachantFramework.Workflow module. The engine allows you to embed the processing logic into any application. We suggest one of the following:
Windows Service
Azure Function (Timer Based)
Console Application that is invoked by Task Scheduler
Getting Started
Install the LlamachantFramework.Workflow.Service from NuGet into your solution
Create an instance of your XAF Application
Initialize the WorkflowService.Instance
Configure your custom Email Service (Optional)
Process the workflows
Sample Windows Service
public partial class MyWorkflowService : ServiceBase
{
//You can utilize the built in WorkflowQueueController to handle timing for you
WorkflowQueueController queue = new WorkflowQueueController();
public MyWorkflowService()
{
InitializeComponent();
Tracing.Initialize();
MyWindowsFormsApplication app = new MyWindowsFormsApplication();
app.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
app.SplashScreen = null;
app.Setup();
IObjectSpace space = app.ObjectSpaceProvider.CreateUpdatingObjectSpace(false);
AuthenticationStandardLogonParameters p = (AuthenticationStandardLogonParameters)app.Security.LogonParameters;
p.UserName = "Admin";
app.GetSecurityStrategy().Logon(space);
WorkflowService.Instance.Initialize(app, new FileSystemLogger(@"C:\Logs\"));
//Set this to your custom IWorkflowEmailService if necessary
//WorkflowService.Instance.EmailService = new DummyEmailService();
}
protected override void OnStart(string[] args)
{
//Set the number of seconds between checks for new workflows (60 seconds recommended)
queue.SetInterval(60);
queue.Start();
}
protected override void OnStop()
{
queue.Stop();
}
}
Sample Console Application
public class MyConsoleApp
{
public static void Main(string[] args)
{
Tracing.Initialize();
LlamaFrameworkTestMyWindowsFormsApplication app = new MyWindowsFormsApplication();
app.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
app.SplashScreen = null;
app.Setup();
IObjectSpace space = app.ObjectSpaceProvider.CreateUpdatingObjectSpace(false);
AuthenticationStandardLogonParameters p = (AuthenticationStandardLogonParameters)app.Security.LogonParameters;
p.UserName = "Admin";
app.GetSecurityStrategy().Logon(space);
WorkflowService.Instance.Initialize(app, new FileSystemLogger(@"C:\Logs\"));
//Set this to your custom IWorkflowEmailService if necessary
//WorkflowService.Instance.EmailService = new DummyEmailService();
WorkflowService.Instance.RunWorkflow();
}
}
Managing Workflow Definition Dates
Handle the ProgressWorkflowDefinitionDate event in the WorkflowService.Instance to push the NextRunDate field out further. This is useful if you want to skip holidays or weekends.