zoukankan      html  css  js  c++  java
  • WF 创建 SQL 持久性数据库

    Windows Workflow Foundation 安装程序并不安装 SqlWorkflowPersistenceService 服务所需的数据库,但会安装为这些服务创建和配置数据库所用的 SQL 脚本。 本部分详细说明正确配置供 SqlWorkflowPersistenceService 服务使用的 SQL Server 数据库所需执行的步骤。

    由 Windows Workflow Foundation 安装的 SQL 服务使用 SQL Server 来存储信息。 对于这些任务,可以使用 Microsoft SQL Server 2005 Express、SQL Server 2000 或更高版本或 SQL Server 2000 Desktop Engine (MSDE)。

    创建 SQL 持久性数据库

    1. 在 SQL Server 2005 Express、SQL Server 2000 或更高版本或 SQL Server 2000 Desktop Engine (MSDE) 中,使用以下 SQL 查询语句创建一个名为 WorkflowPersistenceStore 的新数据库:CREATE DATABASE WorkflowPersistenceStore。

       
    2. 在 SQL 查询分析器工作区中,从可用数据库列表中选择在步骤 1 中创建的数据库。

    3. 在“文件”菜单上,单击“打开”,然后打开 SQL 脚本 %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<语言>\SqlPersistence_Schema

    4. 通过单击“执行”或按 F5 来运行查询,以便创建 SQL 持久性服务表。

    5. 在“文件”菜单上,单击“打开”,然后打开 SQL 脚本 %WINDIR%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\<语言>\SqlPersistence_Logic

    6. 通过单击“执行”或按 F5 来运行查询,以便创建 SQL 持久性服务存储过程。

    向运行时引擎添加 SqlWorkflowPersistenceService

    可以编程方式或通过使用应用程序配置文件,向 Windows Workflow Foundation 运行时引擎添加运行时服务。

    修改 SqlWorkflowPersistenceService 的 app.config

    1. 在 app.config 文件的 Services 元素中,创建一个名为 add 的新元素。

    2. add 元素添加名为 type 的属性,该属性的值为 System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

    3. add 元素添加名为 connectionString 的属性,该属性的值为 Initial Catalog=WorkflowPersistenceStore;Data Source=localhost;Integrated Security=SSPI

    注意:

    可能需要修改连接字符串,具体取决于 SQL Server 的配置。 此处显示的连接字符串假定,数据库名称为 WorkflowPersistenceStore,且 SQL Server 已安装在用于应用程序开发的同一个系统上。

    1. 通过添加与 SqlWorkflowPersistenceService 类中定义的可配置属性 (property) 相对应的属性 (attribute),对 SqlWorkflowPersistenceService 服务进行配置。

      例如,若要指定应在工作流进入空闲状态时将其卸载(例如在使用了 DelayActivity 活动的情况下),请向 add 元素添加名为 UnloadOnIdle 的属性,并为该属性指定 true 值。

    2. <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionString="Initial Catalog=WorkflowPersistenceStore;Data Source=localhost;Integrated Security=SSPI;" UnloadOnIdle="true"/>

      以编程方式向运行时引擎添加 SqlWorkflowPersistenceService

      1. 调用 WorkflowRuntime 类中定义的 AddService 方法,传递 SqlWorkflowPersistenceService 的新实例。

        下面的示例演示如何使用与前面的过程中显示的示例相同的配置来创建 SqlWorkflowPersistenceService 服务。 在此示例中,instanceOwnershipDuration 设置为 TimeSpan.MaxValue,而 loadingInterval 设置为 2 分钟。 这些值是在 SqlWorkflowPersistenceService 类中使用的默认值。

      2. [C#]

       复制代码
      using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())                {                // Create the SqlWorkflowPersistenceService.                string connectionString = ="Initial Catalog=WorkflowPersistenceStore;Data Source=localhost;Integrated Security=SSPI;"                bool unloadOnIdle = true;                TimeSpan instanceOwnershipDuration = TimeSpan.MaxValue;                TimeSpan loadingInterval = new TimeSpan(0, 2, 0);                SqlWorkflowPersistenceService persistService = new SqlWorkflowPersistenceService(connectionString, unloadOnIdle, instanceOwnershipDuration, loadingInterval);                // Add the SqlWorkflowPersistenceService to the runtime engine.                workflowRuntime.AddService( persistService );                // ...                }
  • 相关阅读:
    ReportViewer,RDLC 报表开发之分页
    Mvc2.0 处理自定义错误.
    使用 WPS中粘贴VS里的代码,并整理格式
    Sql2008中添加程序集.
    快速整理列说明.SQL2008.
    ASP.NET MVC在IIS6下部署的小技巧
    MS SQL Server将数据导出Insert语句的存储过程
    在IE6下发生Internet Explorer cannot open the Internet site错误
    Windows7 中配置IIS7的方法(HTTP 错误 404.3 Not Found)
    安卓2.2手动开启APP2SD方法
  • 原文地址:https://www.cnblogs.com/soundcode/p/1922325.html
Copyright © 2011-2022 走看看