详解WF4 Beta 2中新功能特性

开发 后端
在这里我们将介绍WF4 Beta 2中新功能特性,并进行WF4 Beta 2与WF4 Beta 1的对比,希望本文能对大家有所帮助。

本文将介绍WF4 Beta 2中新功能特性,并通过WF4 Beta 2与WF4 Beta 1的对比,使大家能更好的了解WF4 Beta 2。

Acticvity结构说明 WF4 Beta 2的Activity结构

WF4 Beta 2的Activity结构

WF4 Beta 2与WF4 Beta1的Activity结构变化对比说明

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

[Activity]

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

  1. public sealed class wxwinterActivityResult :CodeActivity<string>
  2. {
  3. protected override string Execute(CodeActivityContext context)
  4. {
  5. return "wxwinter";
  6. }

实现 Begin/End

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

  1. public sealed class wxwinterActivity : AsyncCodeActivity
  2. {
  3. protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
  4. {
  5. return callback.BeginInvoke(null, null, null);
  6. }
  7. protected override void EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
  8. {
  9. }
  10. }

4. 取消 [InvokePowershell] Activity

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

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

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

添加Activity [Rethrow]

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

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

WF4 Beta 2与WF3.0/3.5

运行环境说明 WF4 Beta 2的运行环境WorkflowApplication
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. WorkflowApplication instance = new WorkflowApplication(new wxwinterActivity());
  6. instance.Run();
  7. System.Console.Read();
  8. }
  9. }
  10. public class wxwinterActivity : CodeActivity
  11. {
  12. protected override void Execute(CodeActivityContext context)
  13. {
  14. System.Console.WriteLine("wxd");
  15. }
  16. }

WF4 Beta 2

WF4 Beta 2与WF4 Beta1的运行环境对比说明

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

  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. WorkflowInstance instance = new WorkflowInstance(new wxwinterActivity());
  6. instance.Run();
  7. System.Console.Read();
  8. }
  9. }
  10. public class wxwinterActivity : CodeActivity
  11. {
  12. protected override void Execute(CodeActivityContext context)
  13. {
  14. System.Console.WriteLine("wxd");
  15. }
  16. }

WF4 Beta 2

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

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

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

  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. WorkflowRuntime workflowRuntime = new WorkflowRuntime();
  6. WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(wxwinterActivity));
  7. instance.Start();
  8. System.Console.Read();
  9. }
  10. }
  11. public class wxwinterActivity : System.Workflow.ComponentModel.Activity
  12. {
  13. protected override System.Workflow.ComponentModel.ActivityExecutionStatus Execute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
  14. {
  15. System.Console.WriteLine("wxd");
  16. return base.Execute(executionContext);
  17. }
  18. }

工作流开发说明

工作流开发说明
WF4 Beta 2所提供的工作流模板

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

工作流开发说明

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

  1. <Activity x:Class="ActivityLibrary1.wxwinterWorkFlow" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"
  2. xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System"
  3. xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
  4. xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System"
  5. xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core"
  6. xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
  7. xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
  8. xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions"
  9. xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
  10. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  11. Activity>

[Sequence]

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

  1. <Activity x:Class="ActivityLibrary1.wxwinterWorkFlow"
  2. mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"
  3. xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System"
  4. xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
  5. xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System"
  6. xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core"
  7. xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel"
  8. xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib"
  9. xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions"
  10. xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:st="clr-namespace:System.Text;assembly=mscorlib"
  11. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  12. Activity>

[Flowchart]

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

  1. <Activity mc:Ignorable="sap" x:Class="ActivityLibrary1.wxwinterWorkFlow" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces"
  2. xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  3. xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
  4. xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml"
  5. xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities"
  6. xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System"
  7. xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core"
  8. xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data"
  9. xmlns:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core"
  10. xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  11. <Sequence sad:XamlDebuggerXmlReader.FileName="d:\users\wxd\documents\visual studio 2010\Projects\ActivityLibrary1\ActivityLibrary1\wxwinterWorkFlow.xaml"
  12. sap:VirtualizedContainerService.HintSize="235,288">
  13. <sap:WorkflowViewStateService.ViewState>
  14. <scg3:Dictionary x:TypeArguments="x:String, x:Object">
  15. <x:Boolean x:Key="IsExpanded">Truex:Boolean>
  16. scg3:Dictionary>
  17. sap:WorkflowViewStateService.ViewState>
  18. <WriteLine sap:VirtualizedContainerService.HintSize="213,62" />
  19. <WriteLine sap:VirtualizedContainerService.HintSize="213,62" />
  20. Sequence>
  21. Activity>
WF4 Beta 2
WF4 Beta 2与WF4 Beta1 所提供的工作流模板对比说明

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

顺序工作流

[顺序工作流]

顺序工作流

[Flowchart工作流]

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

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

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

Flowchart工作流

[状态机工作流]

状态机工作流

[顺序工作流]

顺序工作流

工作流格式说明

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

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

其他功能说明

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

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

原文标题:WF4 Beta 2

链接:http://www.cnblogs.com/foundation/archive/2009/10/22/1587798.html

【编辑推荐】

  1. 浅谈WF 4.0 Beta1中的 跟踪机制
  2. WF4.0 Beta1中的规则引擎变化
  3. 浅谈WF 4.0 beta1的跟踪配置
  4. 详解工作流架构与实现
  5. 解析UML工作流管理系统
责任编辑:彭凡 来源: 博客园
相关推荐

2009-10-30 09:04:18

WF4 Beta2

2009-12-01 10:08:23

WF4属性

2022-07-28 14:50:04

iOS苹果功能

2009-10-28 09:23:27

WF4.0 Beta2

2020-02-20 16:30:22

iOS 13.4苹果iPhone

2009-07-16 10:41:40

WF 4.0 beta

2009-12-11 09:15:13

2013-07-17 13:48:56

Chrome 29浏览器

2020-05-07 14:59:52

iOS 13.5苹果更新

2010-07-28 09:24:31

Flex2.0

2009-04-20 08:40:19

Iphone苹果移动OS

2020-07-08 15:12:29

iOSIpad OS苹果

2009-06-15 10:20:47

WF 4.0 Beta跟踪机制

2011-05-31 13:58:43

TouchPadwebOS 3.0惠普

2011-03-23 10:15:43

Opera 11.10

2021-07-28 09:39:48

iOS 15iPad OS 15苹果

2009-06-17 10:51:58

WF4.0规则引擎

2013-08-19 16:27:08

Windows 8.1

2012-08-22 15:45:29

Windows Ser

2009-11-05 10:29:14

Visual Stud
点赞
收藏

51CTO技术栈公众号