Sub Flows within XOML based workflows
Hi,
I have a workflow which is XOML based and the XOML and rules file is loaded dynamically from the DB.
With this I have a server control which manages all workflows loaded into with forward and back controls.
I want to implement sub flows now and am wondering how to go about this with XOML based workflows. I have a demo working with code based files but cannot get the XOML working?
Is it possible? if so, any pointers would be greatly appreciated.
Thanks!
[497 byte] By [
M_Laz] at [2007-12-23]
First change the StartWokflow method in CallWorkflowService to the following:
public void StartWorkflow(string xomlFilePath, string ruleFilePath, Dictionary<string,object> inparms, Guid caller, IComparable qn)
{
WorkflowRuntime wr = this.Runtime;
//Override the activity's Initialize method and throw InvalidArgumentException
//if the xoml file path does not exist.
XmlReader workflowDefinitionReader = XmlReader.Create(xomlFilePath);
XmlReader rulesReader = null;
if (File.Exists(ruleFilePath))
rulesReader = XmlReader.Create(ruleFilePath);
WorkflowInstance wi = wr.CreateWorkflow(workflowDefinitionReader, rulesReader, inparms);
wi.Start();
...
}
Next, remove the Type property from CallWorkflowActivity and add two string properties of type string like the below:
public static DependencyProperty WorkflowDefinitionPathProperty = System.Workflow.ComponentModel.DependencyProperty.Register("WorkflowDefinitionPath", typeof(string), typeof(CallWorkflowActivity));
[Description("This is the description which appears in the Property Browser")]
[Category("This is the category which will be displayed in the Property Browser")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string WorkflowDefinitionPath
{
get
{
return ((string)(base.GetValue(CallWorkflowActivity.WorkflowDefinitionPathProperty)));
}
set
{
base.SetValue(CallWorkflowActivity.WorkflowDefinitionPathProperty, value);
}
}
public static DependencyProperty RulesPathProperty = System.Workflow.ComponentModel.DependencyProperty.Register("RulesPath", typeof(string), typeof(CallWorkflowActivity));
[Description("This is the description which appears in the Property Browser")]
[Category("This is the category which will be displayed in the Property Browser")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public string RulesPath
{
get
{
return ((string)(base.GetValue(CallWorkflowActivity.RulesPathProperty)));
}
set
{
base.SetValue(CallWorkflowActivity.RulesPathProperty, value);
}
}
Finally change the call to StartWorkflow in CallWorkflowActivity.Execute to:
ws.StartWorkflow(WorkflowDefinitionPath, RulesPath, inparams, this.WorkflowInstanceId, qn);
There is some other work you will need to do related to parameters but this should get you going and if you just comment out the code for working with the workflow properties you should be able to get this running.