Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Windows® Workflow
Foundation
Module 5: Creating and Managing Runtime Services
• Creating a Custom Runtime Service
• Monitoring Workflows
• Tracking Workflows
Lesson: Creating a Custom Runtime Service
• Overview of Runtime Services
ExternalDataExchangeService
WorkflowCommitWorkBatchService
WorkflowLoaderService
WorkflowPersistenceService
WorkflowSchedulerService
TrackingService
Options for Creating Custom Runtime Services
There are two ways to create new services that work
within Windows Workflow Foundation:
• Extend a base service
• Create an entirely new custom service
workflowRuntime.StartRuntime();
…
}
Removing a Service from the Runtime
To remove a service from the workflow runtime engine:
workflowRuntime.StopRuntime();
workflowRuntime.RemoveService(myService);
workflowRuntime.StartRuntime();
Demonstration: Creating a Custom Runtime Service
In this demonstration, you will see how to:
• Create a custom runtime service class
• Persistence Services
Dehydration
Persisted state
Hydration
Persistence database
Workflow runtime engine with
SqlWorkflowPersistenceService
Creating and Configuring a Persistence Database
To create a database for SqlWorkflowPersistenceService,
execute a SQL statement such as the following:
CREATE DATABASE MyWorkflowPersistenceStore
• %WINDIR%\Microsoft.NET\Framework\v3.0\
Windows Workflow Foundation\SQL\<language>
Adding the Persistence Service to the Workflow
Runtime Engine
<!-- Configuration file -->
<Services>
<add type="…SqlWorkflowPersistenceService…"
connectionString="…"
UnloadOnIdle="true"/>
</Services>
// Application code.
using (WorkflowRuntime runtime = new WorkflowRuntime())
{
string connectionString = … ;
SqlWorkflowPersistenceService persistenceService =
new SqlWorkflowPersistenceService(connectionString,
true,
TimeSpan.MaxValue,
new TimeSpan(0, 2, 0));
workflowRuntime.AddService(persistenceService);
…
}
Demonstration: Hydrating and Dehydrating Workflows
In this demonstration, you will see how to:
• Create a workflow that demonstrates the need for
hydration and dehydration
• Create a persistence database
<configuration>
…
<CustomWorkflowRuntimeSettings Name="Workflow1"
EnablePerformanceCounters="false">
…
</CustomWorkflowRuntimeSettings>
…
</configuration>
Demonstration: Viewing Workflow Performance
Counters
To view workflow performance counters:
• Use the Reliability and Performance Monitor (PerfMon.exe) utility
• Specify the Windows Workflow Foundation counters that you want
to view
• %WINDIR%\Microsoft.NET\Framework\v3.0\
Windows Workflow Foundation\SQL\<language>
Adding the Tracking Service to the Workflow
Runtime Engine
<!-- Configuration file -->
<Services>
</Services>
// Application code.
using (WorkflowRuntime runtime = new WorkflowRuntime())
{
string connectionString = … ;
SqlTrackingService trackingService =
new SqlTrackingService(connectionString);
workflowRuntime.AddService(trackingService);
}
Defining Tracking Profiles
You can define a tracking profile to filter tracking data
• You can create a tracking profile programmatically by using the
tracking profile object model
• Alternatively you can specify a tracking profile declaratively as XML
<?xml version="1.0"?>
<TrackingProfile ...>
<!-- Specify the activities and events that you want to track -->
</TrackingProfile>
SqlTrackingWorkflowInstance workflowInstance;
query.TryGetWorkflow(workflowInstanceId, out workflowInstance);
{
…
}
Logon information
Password Pa$$w0rd
• Best Practices