2012-03-28 123 views
1

我嘗試用windows工作流基礎構建一個asp.net web應用程序。在windows工作流基礎上使用ASP.NET

我已經發現了一些有用的網站,如:

http://msdn.microsoft.com/en-us/library/bb628441%28v=vs.90%29.aspx

http://msdn.microsoft.com/en-us/library/bb675262%28v=vs.90%29.aspx

的工作流程是

<Activity mc:Ignorable="sap" x:Class="ApproachWithWorkflows.WriteLineActivity" sap:VirtualizedContainerService.HintSize="654,676" mva:VisualBasic.Settings="Assembly references and imported namespaces for internal implementation" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
<Flowchart sad:XamlDebuggerXmlReader.FileName="C:\Documents and Settings\hauke\Desktop\Uni\Masterarbeit SVN SE\Software\Workflowansatz\ApproachWithWorkflows\ApproachWithWorkflows\WriteLineActivity.xaml" sap:VirtualizedContainerService.HintSize="614,636"> 
<sap:WorkflowViewStateService.ViewState> 
    <scg3:Dictionary x:TypeArguments="x:String, x:Object"> 
    <x:Boolean x:Key="IsExpanded">False</x:Boolean> 
    <av:Point x:Key="ShapeLocation">270,2.5</av:Point> 
    <av:Size x:Key="ShapeSize">60,75</av:Size> 
    <av:PointCollection x:Key="ConnectorLocation">300,77.5 300,107.5 295.5,107.5 295.5,129</av:PointCollection> 
    </scg3:Dictionary> 
</sap:WorkflowViewStateService.ViewState> 
<Flowchart.StartNode> 
    <x:Reference>__ReferenceID0</x:Reference> 
</Flowchart.StartNode> 
<FlowStep x:Name="__ReferenceID0"> 
    <sap:WorkflowViewStateService.ViewState> 
    <scg3:Dictionary x:TypeArguments="x:String, x:Object"> 
     <av:Point x:Key="ShapeLocation">190,129</av:Point> 
     <av:Size x:Key="ShapeSize">211,59</av:Size> 
    </scg3:Dictionary> 
    </sap:WorkflowViewStateService.ViewState> 
    <WriteLine sap:VirtualizedContainerService.HintSize="211,59" Text="worked.." /> 
</FlowStep> 

我創建了一個asp的活動.NET項目有一個簡單的按鈕:

<asp:Button Text="Purchase" ID="Label1" runat="server" OnClick="btnClick" /> 

在後面的代碼,我嘗試調用工作流(和初始化通過的Application_Start在Global.asax的WorkflowRuntime的):現在

WorkflowRuntime workflowRuntime = Application["WorkflowRuntime"] as WorkflowRuntime; 
ManualWorkflowSchedulerService manualScheduler = 
    workflowRuntime.GetService(typeof(ManualWorkflowSchedulerService)) 
    as ManualWorkflowSchedulerService; 

WorkflowInstance instance = workflowRuntime.CreateWorkflow(
    typeof(ApproachWithWorkflows.WriteLineActivity)); 
instance.Start(); 
manualScheduler.RunWorkflow(instance.InstanceId); 

當我執行應用程序並按下按鈕,我會在CreateWorkflow處收到一個錯誤,如「輸入的工作流類型必須是活動。\ r \ n參數名稱:workflowType」。

但活動是一項活動!我究竟做錯了什麼?

回答

1

看起來您正在使用WF 3.5運行時類來執行WF 4.0活動。看看WorkflowInvoker或WorkflowApplication。

+0

謝謝。至少沒有例外。但我不知道工作流是否被執行:WriteLine的東西沒有寫在控制檯中。它是從另一個線程開始的嗎?但我知道我現在必須看的地方。 – Hauke 2012-03-29 08:51:46

相關問題