Mike G
Mike G

Reputation: 1994

Child Activities in Windows Workflow Not Emitting Tracking Data

I created a Windows Workflow 4 workflow that does one specific task. The requirements changed, as they always do in software development, and now the workflow needs to do the task a number of times.

My solution was to create another workflow that executed the first workflow for every time in a collection. This works fine. However, our tracking participant does not emit any records for what is now the child workflow.

The participant still emits data for the main workflow but it isn't ideal since it only contains information regarding looping over the collection. When executing the inner workflow we could see the detailed output.

Is there something we're missing on setting up our tracking? Preferably I don't want to structure the workflows differently as I can imagine that as we're developing workflows we'll encounter this scenario again and will want a similar resolution.

  StatusTrackingParticipant stp = new StatusTrackingParticipant
  {
    TrackingProfile = new TrackingProfile
    {
      Queries = 
      {
        //Querying all states. 
        new ActivityStateQuery
        {
            ActivityName = "*",
            States = { "*" }
        },

        //querying all activty schedules ? not sure on the terminology here.
        new ActivityScheduledQuery
        {
          ActivityName = "*",
          ChildActivityName = "*"
        },

        new BookmarkResumptionQuery
        {
          Name = "*"
        },

        new CancelRequestedQuery
        {
          ActivityName = "*",
          ChildActivityName = "*"              
        },

        new CustomTrackingQuery
        {
          ActivityName = "*",
          Name = "*"
        },

        new FaultPropagationQuery
        {
          FaultHandlerActivityName = "*",
          FaultSourceActivityName = "*"
        },

        //Querying all workflow instances ? not sure on the terminology here.
        new WorkflowInstanceQuery
        {
          States = { "*" }
        },
      }
    }
  };

Upvotes: 0

Views: 160

Answers (1)

Joao
Joao

Reputation: 7486

I all comes down to the Tracking Profile you're using and how it's configured.

You probably only have a WorkflowInstanceQuery on your TrackingProfile's queries and it all worked out fine while the workflow that does one specific task was your main workflow.

Now that it's an inner activity inside the main workflow, you've to configure your Queries to also look at those inner activities using ActivityStateQuery.

Something like this, if your tracking profile is being configured through code:

new MyCustomTrackingParticipant
{
    TrackingProfile = new TrackingProfile
    {
        Queries =
        {
            new WorkflowInstanceQuery
            {
                States = { WorkflowInstanceStates.Completed }
            },

            // Also add this query to profile's queries
            new ActivityStateQuery
            {
                States = { ActivityStates.Executing, ActivityStates.Closed }
            }
        }
    }
 }

Or through configuration:

<trackingProfile name="Sample Tracking Profile">
    <workflow activityDefinitionId="*">
        <workflowInstanceQueries>
            <workflowInstanceQuery>
                <states>
                    <state name="Completed"/>
                </states>
            </workflowInstanceQuery>
            <activityStateQuery>
                <states>
                    <state name="Executing"/>
                    <state name="Closed"/>
                </states>
            </activityStateQuery>
        </workflowInstanceQueries>
    </workflow>
</trackingProfile> 

Note that you have to actively specify which queries and states you want to track, otherwise they own't be tracked by default. You can also specify the activity's name if you want to track only a specific activity.

Edit:

Other possible solution is one of those hard to remember, but most probably where your problem lies on. Check TrackingProfile's ImplementationVisibility property which is RootScope by default. Set it to ImplementationVisibility.All:

new TrackingProfile
{
    ImplementationVisibility = ImplementationVisibility.All,
    Queries = ...
}

Remarks:

If implementationVisibility is RootScope and the composite activity is not the root activity for the workflow, only the top level activity within the composite activity is tracked. When set to RootScope, this flag suppresses the tracking records for activities that are not visible from the root of the workflow. Only the root activity and its implementation are tracked. If the implementation contains activities that are composite activities, then the composite activity is tracked but not its implementation.

Upvotes: 1

Related Questions