简单设置:建立基于SQL的跟踪服务(SqlTrackingService)
来源:优易学  2011-11-15 12:03:30   【优易学:中国教育考试门户网】   资料下载   IT书店
  工作流基础(Windows Workflow Foundation)提供了基于SQL的跟踪服务。SqlTrackingService将会把跟踪的数据保存在SQL数据库中。并提供每个类别(Type),每个实例(Instance)的跟踪档案。同时它还提供了一组SqlTrackingQuery的API用于某些场景下的数据查询。
  由于工作流是一个平台组件,我们没有试图在你安装工作流基础的时候设置并默认启用SqlTrackingService,你需要通过简单的步骤来设置并启用它:
  设置SqlTrackingService
  工作流基础提供了必要的脚本用于建立Schema和数据库对象,你需要:
  1)建立一个数据库命名为Tracking
  2)在你建立的数据库中依次执行C:\WINDOWS\WinFX\v3.0\Windows Workflow Foundation\SQL\EN下的Tracking_Schema.sql和Tracking_Logic.sql
  启用SqlTrackingService
  和任何工作流运行时服务类似,你可以通过代码或者config文件来启用它。
  通过代码
  1)建立你的数据库的连接字符串
  2)建立一个SqlTrackingService实例并在WorkflowRuntime启动前添加到WorkflowRuntime中
  你的代码可能如下(假设你的数据库名文Tracking并在本机):
  private void StartCaseManagementProcess()
  {
  WorkflowRuntime workflowRuntime = new WorkflowRuntime();
  string connectionstring =
  "Initial Catalog=Tracking;DataSource=localhost;Integrated Security=SSPI;";
  workflowRuntime.AddService(new SqlTrackingService(connectionstring));
  WorkflowInstance workflowInstance = workflowRuntime.CreateWorkflow(typeof(CaseManagementWorkflow));
  workflowInstance.Start();
  }
  通过config文件
  1)将SqlTrackingService添加到config文件中
  <WorkflowRuntime Name="ConfigSection ">
  <Services>
  <add type="System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  ConnectionString = "Initial Catalog=Tracking;Data Source=localhost;Integrated Security=SSPI;"
  UseDefaultProfile = "true"
  IsTransactional = "true"
  ProfileChangeCheckInterval = "60000"
  PartitionOnCompletion = "false"/>
  </Services>
  </WorkflowRuntime>
  2)通过配置文件中定义的名字建立你的WorkflowRuntime,代码如下:
  WorkflowRuntime workflowRuntime = new WorkflowRuntime("ConfigSection");

责任编辑:小草

文章搜索:
 相关文章
热点资讯
热门课程培训