|
i have created one SequentialWorkflow project and placed IfActivity
and put one codeActivity1 in elsebranch1 and CodeActivity2 in elsebranch2
when i set Rule condition it automatically creates one .rules file.
but from host i need to apply new .rules file?
i have given following code
workflowInstance1 = workflowRuntime.CreateWorkflow(type, parameters);
ChangeRules(workflowInstance1);
workflowInstance1.Start();
waitHandle.WaitOne();
---------------------
static void ChangeRules(WorkflowInstance Instance)
{
if (wasChanged)
return;
wasChanged = true;
// Dynamic update of rule
WorkflowChanges workflowchanges = new WorkflowChanges(Instance.GetWorkflowDefinition());
CompositeActivity transient = workflowchanges.TransientWorkflow;
RuleDefinitions ruleDefinitions = (RuleDefinitions)transient.GetValue(RuleDefinitions.RuleDefinitionsProperty);
WorkflowMarkupSerializer serializer = new WorkflowMarkupSerializer();
object obj = serializer.Deserialize(new XmlTextReader("C:\\DynamicRulesWorkflow.rules"));
ruleDefinitions = ( RuleDefinitions) obj ;
Instance.ApplyWorkflowChanges(workflowchanges);
Console.WriteLine(ruleDefinitions.Conditions[0].ToString());
}
but it is taking old .rule file
what is the solution for this issue? |