Question

I'm facing a problem concerning WF4 and CustomTrackingRecord for Child Workflow loaded dynamically from .xaml by WorkflowInvoker. The execution works really well and I'm able to track InArguments and OutArguments, but not internal activities as I already do for level 0 Workflows (parents). Here the code for InArgs and OutArgs tracking.

var userRecord = new CustomTrackingRecord("InArguments");
        foreach (var kvp in inArgs) {
            userRecord.Data.Add(kvp.Key, kvp.Value == null ? "" : kvp.Value.ToString());
        }
        context.Track(userRecord);

...

 WorkflowInvoker invoker = new WorkflowInvoker(dynamicActivity);
            outArgs = invoker.Invoke(inArgs);


            foreach (string argumentKey in outArgs.Keys) {
                this.ChildArguments[argumentKey].Set(context, outArgs[argumentKey]);
            }

            userRecord = new CustomTrackingRecord("OutArguments");
            foreach (var kvp in outArgs) {
                userRecord.Data.Add(kvp.Key, kvp.Value == null ? "" : kvp.Value.ToString());
            }
            context.Track(userRecord);

I'm pretty sure that invoker.Invoke(inArgs) should start the standard tracking system, in few words the perfectly working one used to know what happens into Activity, but it seems to ignore what happens into DynamicActivity.

Any Idea? Context issue? Type issue?

Thanks, Francesco

Was it helpful?

Solution

The WorkflowInvoker is a different execution with its own extensions. So to add those events to the same TrackingParticipant you need to add that to the invoker.Extensions collection.

Something like:

var invoker = new WorkflowInvoker(dynamicActivity);
var tracker = context.GetExtension<TrackingParticipant>();
invoker.Extensions.Add(tracker);
outArgs = invoker.Invoke(inArgs);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top