SqlTrackingService  
Author Message
ericrtodd





PostPosted: Windows Workflow Foundation, SqlTrackingService Top

How would someone go about using the SqlTrackingService to track public properties on a given workflow My goal is to be able to query a state machine workflow from a given series of data values (e.g. first name, last name, etc) using a SqlTrackingQuery.

Here is how I have tried going about it:

private void ExecuteWorkflow(object type) {

WorkflowRuntime runtime;

WorkflowInstance instance;

Type workflowType;

AutoResetEvent waitHandle;

waitHandle = new AutoResetEvent(false);

workflowType = type as Type;

using(runtime = new WorkflowRuntime()) {

runtime.AddService(new SqlWorkflowPersistenceService(ConnectionString));

runtime.AddService(new SqlTrackingService(ConnectionString));

runtime.WorkflowCompleted += delegate(object sender,WorkflowCompletedEventArgs args) {

waitHandle.Set();

};

runtime.WorkflowTerminated += delegate(object sender,WorkflowTerminatedEventArgs args) {

waitHandle.Set();

};

runtime.StartRuntime();

instance = runtime.CreateWorkflow(workflowType);

instance.Start();

waitHandle.WaitOne();

runtime.StopRuntime();

}

}

When I run the workflow, however, I don't see any changes in the Tracking database. Sample workflows that I have created have been overly simple (e.g. perform some activity, delay a couple of minutes, perform another activity).

What do I need to do to create a workflow, track its public properties, and be able query the properties from a SqlTrackingQuery Or am I going about it all wrong Any help would be greatly appreciated.



Software Development for Windows Vista12  
 
 
Matt Milner - Pluralsight





PostPosted: Windows Workflow Foundation, SqlTrackingService Top

If you want to be able to track properties, you need to define data extracts. Take a look at the tracking profile designer in the SDK application samples.

You'll need to create a tracking profile for your workflow that defines the data you want to extract. Then deploy that profile to the database (you can do this from the tracking profile designer, or through your own code).

Matt



 
 
ericrtodd





PostPosted: Windows Workflow Foundation, SqlTrackingService Top

I'd been working with creating profiles, but still having no success with being able to track data. The difference was setting the IsTransactional property to false on my SqlTrackingService. Thank you for the tip to use the SDK sample, though. It really explained the structure of the profiles.

Just one more question, if I may. How does the tracking service know which profile to use Does it just take the one with the highest version number, or is there a way to programmatically dictate which profile to use

 
 
SonaliC





PostPosted: Windows Workflow Foundation, SqlTrackingService Top

Tracking service looks for the highest version number and uses that. There is no way to programmatically configure which version to use.
While updating the tracking profile, you can either update default profile (using UpdateDefaultTrackingProfile strored proc) or associate a profile with a specific type of workflow (using UpdateTrackingProfile stored proc).