I'm trying to automatically resume workflows when the delay is over (using a delay activity) This is done automatically if you use WorkflowServiceHost, but I'm using WorkflowApplication.
There are a few codes on the internet that handle this, here is a sample I'm using WorkflowApplication to achieve these goals:
- A user create a task, and this task follow a workflow
- User design it's own workflow using a rehosted designer, and his workflow definition is saved in the database.
- Each workflow definitions can have different versions saved in the database to allow the user to modify its workflows, and the code use the correct version when an action is done on a task and it needs to resume bookmarks
- A task can be started using a workflow, so in the task table I store which workflow definition and which version is used for this task.
The problem I've now is when using delay activity Using the code linked above, when a runnable instance is detected I need to create a WorkflowApplication and use the LoadRunnableInstance method to load the workflow:
if (hasRunnableWorkflows)
{
Console.WriteLine("Found runnable workflows");
WorkflowApplication app = new WorkflowApplication(...);
app.InstanceStore = store;
app.LoadRunnableInstance();
}
Problem is:
- To call LoadRunnableInstance, I need to create the WorkflowApplication and so I need to give the root activity to the WorkflowApplication CTor
- To create the the root activity, I need to know which workflow (& version) I need to load from database
- To know which workflow to load, I need the task ID
- To know the task ID, I need to know the Workflow ID, which is only available after the call to LoadRunnableInstance
So ... I need to break this loop :)
Does someone know a way to have the Workflow ID before loading the workflow ?