This sample demonstrates how to write a custom SQL tracking participant, that writes tracking records to a SQL database. Windows Workflow Foundation (WF) provides workflow tracking to gain visibility into the execution of a workflow instance. The tracking runtime emits workflow tracking records during the execution of the workflow. For more information about workflow tracking, see Workflow Tracking and Tracing.
To use this sample
Verify you have SQL Server 2008, SQL Server 2008 Express or newer installed. The scripts packaged with the sample assume the use of a SQL Express instance on your local computer. If you have a different instance please modify the database-related scripts before running the sample.
Create the SQL Server tracking database by running Trackingsetup.cmd in the scripts directory (\WF\Basic\Tracking\SqlTracking\CS\Scripts). This creates a database called TrackingSample.
The script creates the database on the default instance of SQL Express. If you want to install it on a different database instance, edit the Trackingsetup.cmd script.
Open SqlTrackingSample.sln in Visual Studio 2010.
Press CTRL+SHIFT+B to build the solution.
Press F5 to run the application.
The browser window opens and shows the directory listing for the application.
In the browser, click StockPriceService.xamlx.
The browser displays the StockPriceService page, which contains the local service WSDL address. Copy this address.
An example of the local service WSDL address is http://localhost:65193/StockPriceService.xamlx?wsdl.
Using File Explorer, run the WCF test client (WcfTestClient.exe). It is located in the Microsoft Visual Studio 10.0\Common7\IDE directory.
In the WCF test client, click the File menu and select Add Service. Paste the local service address in the textbox. Click OK to close the dialog.
In the WCF test client, double click GetStockPrice. This opens the
GetStockPriceoperation that takes one parameter, type in the value
Contosoand click Invoke.
The emitted tracking records are written to a SQL database. To view the tracking records, open the TrackingSample database in SQL Management Studio and navigate to the tables. For more information about SQL Server Management Studio, see Introducing SQL Server Management Studio. SQL Server 2008 Management Studio Express can be downloaded here. Running a select query on the tables displays the data within the tracking records stored in the respective tables.
To uninstall the sample
Run theTrackingcleanup.cmd script in the sample directory (\WF\Basic\Tracking\SqlTracking).
The Trackingcleanup.cmd attempts to delete the database in your local computer SQL Express. If you are using another SQL server instance, edit Trackingcleanup.cmd.
The samples may already be installed on your computer. Check for the following (default) directory before continuing.
If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.