ASP.NET中hosting wf

 在自己带的demo中hosting全部是winform程序,如果是asp.net程序可以有下面几种办法

1.利用webconfig配置好所有的服务

<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    
<configSections>
        
<section name="WorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    
</configSections>
    
<appSettings/>
    
<connectionStrings/>
    
<system.web>
        
<authentication mode="Windows"/>
        
<compilation debug="true">
            
<assemblies>
                
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                
<add assembly="System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                
<add assembly="System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                
<add assembly="System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                
<add assembly="System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                
<add assembly="System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                
<add assembly="Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                
<add assembly="System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                
<add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                
<add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                
<add assembly="Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                
<add assembly="Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
            
</assemblies>
        
</compilation>
    
</system.web>
  
  
<!--注册服务-->
    
<WorkflowRuntime Name="WorkflowServiceContainer">
        
<Services>
      
<add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      
<add type="System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      
<add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" UnloadOnIdle="true" ConnectionString="Initial Catalog=PersistenceStore;Data Source=localhost;Integrated Security=SSPI;"/>
      
<add type="System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" ConnectionString="Initial Catalog=TrackingStore;Data Source=localhost;Integrated Security=SSPI;"/>
    
</Services>
    
</WorkflowRuntime>

  
<!--设置追踪,会在网站根目录下出现WFTrace.log文件-->
  
<system.diagnostics>
    
<switches>
      
<add name="WorkflowTraceToDefault" value="1" />
      
<add name="Host" value="All" />
      
<add name="Runtime" value="All" />
      
<add name="Tracking" value="All" />
      
<add name="Activity" value="All" />
      
<add name="Rules" value="All" />
    
</switches>
    
<trace autoflush="true" indentsize="4">
      
<listeners>
        
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="WFTrace.log" />
      
</listeners>
    
</trace>
  
</system.diagnostics>
</configuration>

System.Workflow.Runtime.WorkflowRuntime workflowRuntime = new System.Workflow.Runtime.WorkflowRuntime("WorkflowRuntime")把workflowruntime加载到httpapplication中去,之后调用

2.使用WorkflowWebRequestContext

WorkflowRuntime workflowRuntime = WorkflowWebRequestContext.Current.WorkflowRuntime;
        workflowRuntime.StopRuntime();
        workflowRuntime.AddService(new SqlTrackingService(connectionStringTracking));
        workflowRuntime.AddService(new SqlWorkflowPersistenceService(connectionStringPersistence));
        workflowRuntime.StartRuntime();
我一般都使用第一种方法
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值