WF4 Bata 2

WF4 Bata 2

 

目录

Acticvity结构说明    1

WF4 Bate 2的Activity结构    1

WF4 Bate 2与WF4 Bate1的Activity结构变化对比说明    1

WF4 Bate 2与WF3.0/3.5 的Activity结构变化对比说明    3

运行环境说明    4

WF4 Bate 2的运行环境WorkflowApplication    4

WF4 Bate 2与WF4 Bate1的运行环境对比说明    5

WF4 Bate 2与WF3.0/3.5 的运行环境对比说明    5

工作流开发说明    6

WF4 Bate 2所提供的工作流模板    6

WF4 Bate 2与WF4 Bate1 所提供的工作流模板对比说明    9

WF4 Bate 2与WF3.0/3.5 所提供的工作流对模板比说明    10

工作流格式说明    11

其他功能说明    11

 

 

Acticvity结构说明

WF4 Bate 2的Activity结构

WF4 Bata 2_第1张图片

 

 

 

WF4 Bate 2与WF4 Bate1的Activity结构变化对比说明

 

1. 取消了[WorkflowElement], 与WF3.0一样,[Activity]成为了WF功能Activity的根类型

 

WF4 Bata 2_第2张图片

 

 

2. 增加了表达式Activity [ ActivityWithResult]

 

public sealed class wxwinterActivityResult :CodeActivity<string>

{

 

protected override string Execute(CodeActivityContext context)

{

return "wxwinter";

}

 

WF4 Bata 2_第3张图片

 

3. 增加了异步Activity [AsyncCodeActivity] 可以实现 Begin/End的异步执行方式

public sealed class wxwinterActivity : AsyncCodeActivity

{

protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)

{

return callback.BeginInvoke(null, null, null);

}

 

protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result)

{

 

}

}

 

4. 取消 [InvokePowershell] Activity

关于[InvokePowershell] Activity的介绍见我写的WF4.0 Beta1 调用PowerShell

( http://www.cnblogs.com/foundation/archive/2009/06/28/1512542.html)

 

5. 添加Activity [Rethrow] 以实现再次引发异常

WF4 Bata 2_第4张图片

 

WF4 Bate 2与WF3.0/3.5 的Activity结构变化对比说明

变化很大,基本上可以认为是两个产品

WF4 Bata 2_第5张图片

 

 

运行环境说明

WF4 Bate 2的运行环境WorkflowApplication

class Program

{

static void Main(string[] args)

{

WorkflowApplication instance = new WorkflowApplication(new wxwinterActivity());

instance.Run();

System.Console.Read();

 

}

 

}

public class wxwinterActivity : CodeActivity

{

protected override void Execute(CodeActivityContext context)

{

System.Console.WriteLine("wxd");

}

}

WF4 Bata 2_第6张图片

 

WF4 Bate 2与WF4 Bate1的运行环境对比说明

流程实例 [WorkflowInstance] 被 [WorkflowApplication] 取代

class Program

{

static void Main(string[] args)

{

WorkflowInstance instance = new WorkflowInstance(new wxwinterActivity());

instance.Run();

System.Console.Read();

 

}

 

}

public class wxwinterActivity : CodeActivity

{

 

protected override void Execute(CodeActivityContext context)

{

System.Console.WriteLine("wxd");

}

}

WF4 Bata 2_第7张图片

 

WF4 Bate 2与WF3.0/3.5 的运行环境对比说明

WF3.X与WF4运行环境最明显的变化是,在WF3.X中要创建实例要使用WorkflowRuntimeCreateWorkflow方法.

而在WF4中,不需要显示创建一个[WorkflowRuntime],而是直接使用[WorkflowInstance (bate1中)] 创建,这也是到了bate2中将[WorkflowInstance ]改名为[WorkflowApplication]的原因

class Program

{

static void Main(string[] args)

{

WorkflowRuntime workflowRuntime = new WorkflowRuntime();

WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(wxwinterActivity));

instance.Start();

System.Console.Read();

}

}

public class wxwinterActivity : System.Workflow.ComponentModel.Activity

{

protected override System.Workflow.ComponentModel.ActivityExecutionStatus Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)

{

System.Console.WriteLine("wxd");

return base.Execute(executionContext);

}

}

WF4 Bata 2_第8张图片

 

工作流开发说明

WF4 Bate 2所提供的工作流模板

WF4 Bate 2只提供了一个[Activity]的模板,

WF4 Bata 2_第9张图片

 

当使用个[Activity]的模板创建流程时,会提供一个只能放入一个控件的空环境

<Activity x:Class="ActivityLibrary1.wxwinterWorkFlow" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" 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: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:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions" 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">

</Activity>

WF4 Bata 2_第10张图片

 

当向空Activity中放入[Sequence]时,就可认为是[顺序工作流]

<Activity mc:Ignorable="sap" x:Class="ActivityLibrary1.wxwinterWorkFlow" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" 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:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions" 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">

<Sequence sad:XamlDebuggerXmlReader.FileName="d:\users\wxd\documents\visual studio 2010\Projects\ActivityLibrary1\ActivityLibrary1\wxwinterWorkFlow.xaml" sap:VirtualizedContainerService.HintSize="235,288">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<x:Boolean x:Key="IsExpanded">True</x:Boolean>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<WriteLine sap:VirtualizedContainerService.HintSize="213,62" />

<WriteLine sap:VirtualizedContainerService.HintSize="213,62" />

</Sequence>

</Activity>

WF4 Bata 2_第11张图片

 

当向空Activity中放入[Flowchart]时,就可认为是[Flowchart工作流]

<Activity mc:Ignorable="sap" x:Class="ActivityLibrary1.wxwinterWorkFlow" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" 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:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions" 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="d:\users\wxd\documents\visual studio 2010\Projects\ActivityLibrary1\ActivityLibrary1\wxwinterWorkFlow.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 160,107.5 160,129</av:PointCollection>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart.StartNode>

<x:Reference>__ReferenceID3</x:Reference>

</Flowchart.StartNode>

<FlowStep x:Name="__ReferenceID3">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<av:Point x:Key="ShapeLocation">60,129</av:Point>

<av:Size x:Key="ShapeSize">200,52</av:Size>

<av:PointCollection x:Key="ConnectorLocation">160,181 150,181 150,202.5</av:PointCollection>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart sap:VirtualizedContainerService.HintSize="200,52">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<x:Boolean x:Key="IsExpanded">False</x:Boolean>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart.StartNode>

<x:Null />

</Flowchart.StartNode>

</Flowchart>

<FlowStep.Next>

<FlowDecision x:Name="__ReferenceID1" sap:VirtualizedContainerService.HintSize="60,75">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<av:Point x:Key="ShapeLocation">120,202.5</av:Point>

<av:Size x:Key="ShapeSize">60,75</av:Size>

<av:PointCollection x:Key="FalseConnector">180,240 210,240 210,255 280,255</av:PointCollection>

<av:PointCollection x:Key="TrueConnector">120,240 100,240 100,299</av:PointCollection>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<FlowDecision.True>

<FlowStep x:Name="__ReferenceID2">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<av:Point x:Key="ShapeLocation">0,299</av:Point>

<av:Size x:Key="ShapeSize">200,52</av:Size>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart sap:VirtualizedContainerService.HintSize="200,52">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<x:Boolean x:Key="IsExpanded">False</x:Boolean>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart.StartNode>

<x:Null />

</Flowchart.StartNode>

</Flowchart>

</FlowStep>

</FlowDecision.True>

<FlowDecision.False>

<FlowStep x:Name="__ReferenceID0">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<av:Point x:Key="ShapeLocation">280,229</av:Point>

<av:Size x:Key="ShapeSize">200,52</av:Size>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart sap:VirtualizedContainerService.HintSize="200,52">

<sap:WorkflowViewStateService.ViewState>

<scg3:Dictionary x:TypeArguments="x:String, x:Object">

<x:Boolean x:Key="IsExpanded">False</x:Boolean>

</scg3:Dictionary>

</sap:WorkflowViewStateService.ViewState>

<Flowchart.StartNode>

<x:Null />

</Flowchart.StartNode>

</Flowchart>

</FlowStep>

</FlowDecision.False>

</FlowDecision>

</FlowStep.Next>

</FlowStep>

<x:Reference>__ReferenceID0</x:Reference>

<x:Reference>__ReferenceID1</x:Reference>

<x:Reference>__ReferenceID2</x:Reference>

</Flowchart>

</Activity>

WF4 Bata 2_第12张图片

 

WF4 Bate 2与WF4 Bate1 所提供的工作流模板对比说明

WF4 Bate1 非常鲜明的提供了两个工作流模板[Flowchart工作流], [顺序工作流]

WF4 Bata 2_第13张图片

 

[顺序工作流]

WF4 Bata 2_第14张图片

 

 

[Flowchart工作流]

WF4 Bata 2_第15张图片

 

WF4 Bate 2与WF3.0/3.5 所提供的工作流对模板比说明

WF3.0/3.5也提供了两个工作流模板[状态机工作流], [顺序工作流]

其中[状态机工作流]与[Flowchart工作流]有相似之处

 

WF4 Bata 2_第16张图片

 

[状态机工作流]

WF4 Bata 2_第17张图片

 

[顺序工作流]

WF4 Bata 2_第18张图片

 

工作流格式说明

WF4 的工作流可以是用代码构建的,也可以是由xaml构建的, xaml可以动态/静态的编译为一个类,也可以直接以字符串方式加载

WF3.X的工作流可以是用代码构建的,也可以是由xoml构建的,带class头的xoml可以动态/静态的编译为一个类,没有class头的xoml可以直接以字符串方式加载

 

其他功能说明

WF4与WF3.5都提供了持久化,跟踪,通讯,阻塞等功能,但实现方式不同,也不通用.

WF4与WF3.5的流程设计器从UI风格与实现方式上也有很大不同

 

 

先写到这里,WF4 Bate2 的具体功能我会在以后的文章中详细讲解

 

 

 

你可能感兴趣的:(bat)