Raza Ali

Raza Ali I am Currently working as an Architect and a Consultant at a Microsoft partner company. I have broad technology interests but find myself more interested in ASP.Net and backend server techonlogies. This blog for me is a means to share whatever I come to learn. Hope you find something useful here.
E-mail me Send mail
MCTS

Recent comments

Recent posts

Files I've Posted

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in

WF session at Nuvica Pakistan

by raza 6/8/2008 10:41:08 PM

On Saturday I delivered an introductory session on WF at the Nuvica Pakistan office. The slides for this session  and the sample code for the series of posts I have written on WF can be found on the Download page. I would welcome all comments on the session and what could we do further in this regard.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

WF | Sessions

Learning WF - Part 10

by raza 6/6/2008 2:05:38 AM

In this installment we will look at the tracking capabilities built into WF. Tracking basically allows you to "log" all the actions your workflows are performing. This includes both the standard trace messages which signal different things such as activities completing, state changes, rule executions exceptions and custom messages placed by the user.

Setting up the WF tracking is quite simple, you just have to add a service to the runtime. Like persistence, there is a ready made service for tracking which can we easily incorporate and should suffice for most cases. Let's add that service now to begin exploring the tracking capabilities. image

We have added the service to our program but we haven't yet setup the database for it. To do that pick up the two script files from C:\<WINDOWS DIR>\ Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<LANGUAGE DIR> and run them in the SQL Server database we created previously or in a new database if you like.

The WF runtime does its tracking using what is called a tracking profile. The tracking profile is simply a definition of what needs to be tracked. This tracking profile can be created using the object model or simply as an xml file which can be saved in the database. The default profile from the database looks like this:

<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<TrackingProfile xmlns="http://schemas.microsoft.com/winfx/2006/workflow/trackingprofile" version="1.0.0">
    <TrackPoints>
        <ActivityTrackPoint>
            <MatchingLocations>
                <ActivityTrackingLocation>
                    <Activity>
                        <Type>System.Workflow.ComponentModel.Activity, System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Type>
                        <MatchDerivedTypes>true</MatchDerivedTypes>

                    </Activity>
                    <ExecutionStatusEvents>
                        <ExecutionStatus>Initialized</ExecutionStatus>
                        <ExecutionStatus>Executing</ExecutionStatus>
                        <ExecutionStatus>Compensating</ExecutionStatus>
                        <ExecutionStatus>Canceling</ExecutionStatus>
                        <ExecutionStatus>Closed</ExecutionStatus>
                        <ExecutionStatus>Faulting</ExecutionStatus>

                    </ExecutionStatusEvents>
                </ActivityTrackingLocation>
            </MatchingLocations>
        </ActivityTrackPoint>
        <WorkflowTrackPoint>
            <MatchingLocation>
                <WorkflowTrackingLocation>
                    <TrackingWorkflowEvents>
                        <TrackingWorkflowEvent>Created</TrackingWorkflowEvent>                       
                        <TrackingWorkflowEvent>Completed</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Idle</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Suspended</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Resumed</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Persisted</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Unloaded</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Loaded</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Exception</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Terminated</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Aborted</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Changed</TrackingWorkflowEvent>
                        <TrackingWorkflowEvent>Started</TrackingWorkflowEvent>
                   
</TrackingWorkflowEvents>
                </WorkflowTrackingLocation>
            </MatchingLocation>
        </WorkflowTrackPoint>
        <UserTrackPoint>
            <MatchingLocations>
                <UserTrackingLocation>
                    <Activity>
                        <Type>System.Workflow.ComponentModel.Activity, System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Type>
                        <MatchDerivedTypes>true</MatchDerivedTypes>
                    </Activity>
                    <Argument>
                        <Type>System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</Type>
                        <MatchDerivedTypes>true</MatchDerivedTypes>
                    </Argument>
                </UserTrackingLocation>
            </MatchingLocations>
        </UserTrackPoint>
    </TrackPoints>
</TrackingProfile>

As you can see the workflow tracking profile allows you to trace specific workflows using their type as the matching criteria, plus you can specify if all derived types should be tracked as well. In this case the type Activity has been chosen with derived types, meaning all activities would be tracked. Second, you can track activity execution states and third you can track workflow states. As, for user generated messages they can be anything and produced from anywhere.

Lets create a simple workflow that we want to track.

image

In every code activity we print a message on screen and each delay is of 2 seconds. Lets execute this twice and see what it generates in the database.

image

After the execution of the workflow, lets explore the generated data from top down that is by looking at the workflow first and then the activities within them. If you open the table Workflow you will see a row like this:

image 

This table uniquely lists the workflows that we are tracking. The next level is at the instance of this workflow, for which you should open WorkflowInstance:

image

This table list the individual instances of the particular workflow tracked. There is a field called WorkflowTypeId which links it back to the previous database identifying the workflow type. At the next level we see what events get generated at each workflow instance level:

image

As you can see there are two sets of event lists, representing each instance of execution, and there are fields that link it back to the previous tables. As you can see the progression of data captured, you should be able to relate further information to it. For example, if we open the tables Activities the data should be obvious to us:

image

At the next level:

image

include another reference table in here:

image

and the table next lists down every state the activity went through:

image

I'll leave the database details at this level, so you can explore further.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

.Net | WF

Powered by BlogEngine.NET 1.4.0.0
Theme by Mads Kristensen