c# - Sub Workflow in Windows Workflow Foundation and Persistence -
i have custom activity should call sub workflow according name passed in inargument.
public class callsubworkflowactivtiy : nativeactivity {
public inargument<string> selectedworkflow { get; set; } protected override void execute(nativeactivitycontext context) { activity subworkflow = activityfactory.createactivity(selectedworkflow.get(context)); context.scheduleactivity(activity); } protected override void cachemetadata(nativeactivitymetadata metadata) { }}
my prefered solution invoke child activity context.scheduleactivity. doesn't work because can't add metadata.addimplementationchild(subworkflow) in cachemeta(context) because haven't access inarguments @ point. 
a solution hack around access inarguments in cachemetadata. isn't solution should implemented.
another solution came use workflowinstance or workflowinvoker execute subworkflow activities.
public class callsubworkflowactivtiy : nativeactivity { public inargument selectedworkflow { get; set; }
protected override void execute(nativeactivitycontext context) { activity subworkflow = activityfactory.createactivity(selectedworkflow.get(context)); workflowapplication wfinstance = new workflowapplication(subworkflow); }}
this solution practically work. not sure how persistance handled in subworkflow how parent workflow continues when child workflow finishes.
my questions now:
- is there way call subworkflow activities context.scheduleactivity(...) if activity wasn't added practically 
metadata.addimplementationchild(subworkflow) - if use workflowinstance class how persistance handled , how continue parent workflow if child workflow finishes.
 
i solved problem follows:
 protected override void cachemetadatainternal(system.activities.nativeactivitymetadata metadata)         {             inargument<string> workflowversionargument = selectedworkflow;             if (workflowversionargument != null && workflowversionargument.expression != null)             {                 string selectedworkflowstring = workflowversionargument.expression.tostring();                 if (selectedworkflowstring != null)                 {                     workflowversion wfversion = workflowversion.loadfromxml(selectedworkflowstring);                     if (wfversion != null && wfversion.workflowname != null)                     {                         versionedactivity subworkflow = activityfactory.instance.createactivity(wfversion.workflowname, wfversion.version);                         if (subworkflow != null && subworkflow.activityprop != null)                         {                             subworkflowinternal = subworkflow.activityprop;                             metadata.addimplementationchild(subworkflowinternal);                         }                     }                 }             }         }      
Comments
Post a Comment