2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

Similar documents
Visual Basic D 3D

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

untitled

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

untitled

Microsoft Word - 01.DOC

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

基于ECO的UML模型驱动的数据库应用开发1.doc

untitled

投影片 1

epub83-1

第一章 章标题-F2 上空24,下空24

untitled

untitled

《大话设计模式》第一章

untitled

Microsoft PowerPoint - VB14.ppt

穨文件1

Microsoft Word - 小心翼翼的二十一點N.doc

IsPostBack 2

untitled

ActiveX Control

ThreeDtunnel.doc

TwinCAT 1. TwinCAT TwinCAT PLC PLC IEC TwinCAT TwinCAT Masc

untitled

untitled

untitled

Outline USB Application Requirements Variable Definition Communications Code for VB Code for Keil C Practice

2 SGML, XML Document Traditional WYSIWYG Document Content Presentation Content Presentation Structure Structure? XML/SGML 3 2 SGML SGML Standard Gener

<ADB6ADB1C25EA8FAA6DB2D4D56432E706466>

untitled

untitled

VB控件教程大全

Microsoft PowerPoint - OPVB1基本VB.ppt

Visual C# 2010 與 UML 開發實戰 C# 第 5 章物件導向基礎 C# C# 第 6 章資料與變數 C# 第 7 章判斷式與迴圈 C# 第 8 章陣列與集合 C# 第 9 章偵錯與例外狀況處理 Visual Studio 2010 C# try...catch ix

VB程序设计教程

多層次傳銷與獎金系統

投稿類別:電子工程類

Partition Key: 字 符 串 类 型, 表 示 当 前 Entity 的 分 区 信 息 这 个 Property 对 于 Table Service 自 动 纵 向 和 横 向 扩 展 至 关 重 要 Row Key: 字 符 串 类 型, 在 给 定 Partition Key 的

untitled

untitled

概述

Chapter 16 集合

Microsoft Office SharePoint Server MOSS Web SharePoint Web SharePoint 22 Web SharePoint Web Web SharePoint Web Web f Lists.asmx Web Web CAML f

mvc

EJB-Programming-4-cn.doc

2

untitled

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

投影片 1

Microsoft Word - ch04三校.doc

Java

FY.DOC

(DMO) 1 1 Microsoft Windows SQL Server 2005 SQL Server Analysis ServicesNotification Services SQL Server 8 SQL Server IP SQL Server 2005 SQL Server 20

上海市教育考试院关于印发新修订的

摘 要 在 這 忙 碌 的 社 會 中, 普 遍 人 們 運 動 時 間 其 實 並 不 充 裕, 體 力 越 來 越 差 的 情 況 下 還 隨 意 飲 食 導 致 身 體 健 康 越 來 越 差, 因 此 本 專 題 打 算 利 用 健 康 飲 食 的 方 式 改 善 這 些 人 的 體 質,

Microsoft Word - CX1000-HMI_程序开发_PLC通讯

untitled

NIIT APP T ECH,,,,,, C++ : C++, C++,,, C++,,,,, : ,,,, ;,, ( CIP) C++ /,,. :, (21.) ISBN C..

填 写 要 求 1. 以 word 文 档 格 式 如 实 填 写 各 项 2. 表 格 文 本 中 外 文 名 词 第 一 次 出 现 时, 要 写 清 全 称 和 缩 写, 再 次 出 现 时 可 以 使 用 缩 写 3. 本 表 栏 目 未 涵 盖 的 内 容, 需 要 说 明 的, 请 在

EJB-Programming-3.PDF

全国计算机技术与软件专业技术资格(水平)考试

Microsoft Word - 專題製作研究報告書.doc

<4D F736F F D20C9CFBAA3CAD0BCC6CBE3BBFAB5C8BCB6BFBCCAD4C8FDBCB6BFBCCAD4B4F3B8D95FBDA8D2E9B8E55F5F E646F63>

RUN_PC連載_10_.doc

untitled

chp6.ppt

四川省普通高等学校

新版 明解C++入門編

1. 2. Flex Adobe 3.

(TestFailure) JUnit Framework AssertionFailedError JUnit Composite TestSuite Test TestSuite run() run() JUnit

05 CHAPTER Information.IsNumeric ( ) Information.IsDate ( ) True False Date Date True False Y Y Information.IsArray ( ) True False Y Information.IsErr

導讀 ASP.NET HTML ASP 第一篇 基礎篇第 1 章 認識 ASP.NET ASP.NET ASP.NET ASP.NET ASP.NET 第 2 章 認識 Visual Studio 20 開發環境 Visual Studio 20 Visual Studio 20 第二篇 C# 程式

<4D F736F F D D342DA57CA7DEA447B14D2DA475B57BBB50BADEB27AC3FEB14DA447B8D5C344>

ebook215-5

untitled

目錄 C ontents Chapter MTA Chapter Chapter

學 習 目 標 1. 了 解 有 計 畫 的 運 動 之 前, 實 施 身 體 檢 查 的 重 要 性 2. 了 解 熱 身 與 緩 和 運 動 可 以 預 防 運 動 傷 害 3. 了 解 包 紮 護 具 裝 備 與 場 地 器 材 的 維 護, 可 以 避 免 傷 害 發 生 4. 了 解 食

epub 94-3

Microsoft Word - 11.doc

untitled

Microsoft Word - 苹果脚本跟我学.doc

「西醫基層總額支付委員會《第28次委員會議紀錄

Microsoft Word - PHP7Ch01.docx

Microsoft PowerPoint - ch6 [相容模式]

Android Android Android SDK iv

广西民族学院(下)

untitled

Chapter 9: Objects and Classes

SSIS 2012SSIS 2005SSISVisual Studio Visual Studio 2010Package SSISSSIS Integration Services SSIS /2008/ R2 SSIS D Integration Serv

Microsoft PowerPoint - ds-1.ppt [兼容模式]

, 即 使 是 在 昏 暗 的 灯 光 下, 她 仍 然 可 以 那 么 耀 眼 我 没 有 地 方 去, 你 会 带 着 我 么 杜 晗 像 是 在 嘲 笑 一 般, 嘴 角 的 一 抹 冷 笑 有 着 不 适 合 这 个 年 龄 的 冷 酷 和 无 情, 看 着 江 华 的 眼 神 毫 无 温

untitled

西班牙语专业本科培养方案

Microsoft Word - Learn Objective-C.doc

PowerPoint Presentation

3 Driver do Microsoft Access (*.mdb) hisdata IFIX 1.4

TopTest_Adminstrator.doc

Microsoft PowerPoint - CON230_王筱东.ppt

2 ADO.NET Internet 1.2

Transcription:

Chapter 2 WF 2.1 WF 2.2 2. XAML 2.

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

WF WF WF WF EDI API WF Visual Studio Designer 1 2.1 WF Windows Workflow Foundation

2 WF 1 WF Domain-Specific Language DSL WF DSL Object AccountReceivable Bill AccountReceivable Bill AccountReceivable AccountReceivable AccountReceivable DSL

2.2 WF WF 1 WF Microsoft SQL Server.NET Framework 2.0 ADO.NET Windows WF Microsoft Visio 2-1 WF 1 2.2 2-1 Windows Workflow Foundation 7

2 WF 1 RFQProcess RFQFlow RFQ Request For Quotation WF Code IfElse Code 2-2 Code 2-2 WF 8

RFQRequest RFQResponse Quotation DeliveryMethod Email Fax PostMail Visual Studio 200 2- RFQBusinessEntity 1 2.2 2-2.2.1 RFQRequest Windows Workflow Foundation 9

2 WF 1 1 WF Dictionary System.ArgumentException OutputParameters R F Q P r o c e s s RFQBusinessEntity RFQFlow.xoml Private _QuotationRequest As RFQBusinessEntitiy.RFQRequest Public WriteOnly Property RuotationRequest() As _ RFQBusinessEntitiy.RFQRequest Set(ByVal value As RFQBusinessEntitiy.RFQRequest) _QuotationRequest = value End Set End Property Private _QuotationResponse As RFQBusinessEntitiy.RFQResponse Public ReadOnly Property QuotationResponse() As _ RFQBusinessEntitiy.RFQResponse Get Return _QuotationResponse End Get End Property Private _Quotation As RFQBusinessEntitiy.Quotation 0 QuotationRequest QuotationResponse _Quotation

2.2.2 Code Activity Code ReceiveQuotationRequest ExecuteCode ExecuteCode ExecuteCode Code XXXX_ExecuteCode XXXX ReceiveQuotationRequest Private Sub ReceiveQuotationRequest_ExecuteCode (ByVal sender As _ System.Object, ByVal e As System.EventArgs) Sysem.EventArgs ReceiveQuotationRequest RFQResponse 1 2.2 Private Sub ReceiveQuotationRequest_ExecuteCode (ByVal sender As _ System.Object, ByVal e As System.EventArgs) _QuotationResponse = New RFQBusinessEntitiy.RFQResponse _QuotationResponse.DeliverMethod = _QuotationRequest.PreferDeliverMethod _QuotationResponse.RFQNo = _QuotationRequest.RFQNumber Windows Workflow Foundation 1

2 WF 1 CreateCustomer RFQBusinessEntity DBHelper Private Sub CreateCustomer_ExecuteCode(ByVal sender As System.Object, _ ByVal e As System.EventArgs) DBHelper.CreateCustomerInDB(_QuotationRequest.Customer, QuotationRequest.FaxNumber, QuotationRequest.Address, _QuotationRequest.Email) WF Code IfElse While CreateQuotation Private Sub CreateQuotation_ExecuteCode(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Dim QuotationID As Int2 Dim ProductPrice As Decimal Dim CustomerID As Int2 CustomerID = DBHelper.GetCustomerId(_QuotationRequest.Customer) DBHelper.CreateRFQInDB(_QuotationRequest.RFQNumber, CustomerID, QuotationRequest.ProductName, _QuotationRequest.Quantity, QuotationRequest.RequireDate, _QuotationRequest.CustomerRFQNo) ProductPrice = DBHelper.GetProductPrice(_QuotationRequest.ProductName) 2

QuotationID = DBHelper.CreateQuotationInDB(CustomerID, QuotationRequest.RFQNumber, _QuotationRequest.ProductName, QuotationRequest.Quantity, _ ProductPrice, Today.Add(New TimeSpan(0, 0, 0, 0))) _Quotation = New RFQBusinessEntitiy.Quotation With _Quotation.Customer = _QuotationRequest.Customer.ExpireDate = Today.Add(New TimeSpan(0, 0, 0, 0)).Price = ProductPrice.ProductName = _QuotationRequest.ProductName.Quantity = _QuotationRequest.Quantity.QuotationNo = QuotationID.ToString("00000").RFQNumber = _QuotationRequest.RFQNumber End With WF Code MailQuotation 1 2.2 Private Sub MailQuotation_ExecuteCode(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Dim SMTPMessage As New Mail.MailMessage("WF@demo.local", QuotationRequest.Email, _ "Quotation of " & _Quotation.RFQNumber, _ "Dear " & _Quotation.Customer & ":" & ControlChars.NewLine & _ "The price of " & _QuotationRequest.ProductName & " is : " & Quotation.Price.ToString) Windows Workflow Foundation

2 WF 1 Dim MailClient As New Mail.SmtpClient("localhost") Try MailClient.Send(SMTPMessage) Catch ex As Exception Throw New Exception(ex.Message) End Try.NET Framework System.Net.Mail SMTP Private Sub MailQuotation_ExecuteCode(ByVal sender As System.Object, _ ByVal e As System.EventArgs) SendMail("WF@demo.local", QuotationRequest.Email, _ "Quotation of " & _Quotation.RFQNumber, _ "Dear " & _Quotation.Customer & ":" & ControlChars.NewLine & _ "The price of " & _QuotationRequest.ProductName & " is : " & Quotation.Price.ToString) Private Sub SendMail(ByVal From As String, ByVal [To] As String, _ ByVal Subject As String, ByVal Body As String) Dim SMTPMessage As New Mail.MailMessage(From, [To], _ Subject, Body) Dim MailClient As New Mail.SmtpClient("localhost") Try MailClient.Send(SMTPMessage) Catch ex As Exception Throw New Exception(ex.Message) End Try SendMail Code

SendMail 2.2. IfElse IfElse Visual Basic C# Select Case, switch, If ElseIf IfElse IfElse Condition 2-1 2.2 2- Windows Workflow Foundation

2 WF 1 _QuotationRequest PreferDeliverMethod DeliveryMethod. Fax 2-2- IsNewCustomer Private Sub IsNewCustomer(ByVal sender As System.Object, _ ByVal e As System.Workflow.Activities.ConditionalEventArgs) If DBHelper.IsCustomerExist(_QuotationRequest.Customer) Then e.result = False Else e.result = True End If S y s e t m. Workflow.Activities.ConditionalEventArgs Result WF

2.2. WF Code RFQWinClient Window Form RFQForm 2-1 2.2 2- WF WF Private _WFRuntime As WorkflowRuntime Load WF StartRuntime Windows Workflow Foundation 7

2 WF 1 Private Sub RFQForm_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load _WFRuntime = New WorkflowRuntime _WFRuntime.StartRuntime() AddHandler _WFRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted RefreshRFQ() WF WorkflowRuntime W o r k f l o w A b o r t e d WorkflowInstance Abort WorkflowAborted WorkflowCompleted WorkflowCreated WorkflowRuntime CreateWrokflow WorkflowIdled WorkflowLoaded WorkflowPersisted WorkflowSuspended Suspend WorkflowResumed WorkflowStarted 8

WorkflowTerminated WorkflowTe rminatedeventargs WorkflowUnloaded Submit Submit Click WF WorkflowInstance InstanceID Guid InstanceID Submit Click 1 2.2 Private Sub btnsubmit_click(byval sender As System.Object, _ ByVal e As System.EventArgs) Handles btnsubmit.click Dim WFInstance As WorkflowInstance Dim RFQ As RFQBusinessEntitiy.RFQRequest Dim DeliveryMethod As RFQBusinessEntitiy.DeliveryMethod If rdbemail.checked Then DeliveryMethod = RFQBusinessEntitiy.DeliveryMethod.Email Else DeliveryMethod = RFQBusinessEntitiy.DeliveryMethod.Fax End If RFQ = New RFQBusinessEntitiy.RFQRequest(txtRFQNo.Text, _ txtcustomerrfqno.text, txtcustomer.text, _ txtaddress.text, CDate(txtRequireDate.Text), _ txtemail.text, txtfaxno.text, txtproductname.text, _ txtquantity.text, DeliveryMethod) Dim WFParameters As New Dictionary(Of String, Object) WFParameters.Add("QuotationRequest", RFQ) WFInstance = _WFRuntime.CreateWorkflow(GetType(RFQProcess.RFQFlow), _ WFParameters) WFInstance.Start() txtmessage.text &= "New Quotation Submitted, ID of instance : " & _ Windows Workflow Foundation 9

2 WF 1 WFInstance.InstanceId.ToString & ControlChars.NewLine RefreshRFQ() C l i c k AutoResetEvent WF AutoResetEvent InstanceID Workflow CpmpletedEventArgs WorkflowInstance WorkflowInstance InstanceId Private Sub OnWorkflowCompleted(ByVal sender As Object, _ ByVal e As System.Workflow.Runtime.WorkflowCompletedEventArgs) Dim Response As RFQBusinessEntitiy.RFQResponse Response = CType(e.OutputParameters("QuotationResponse"), _ RFQBusinessEntitiy.RFQResponse) SetText(String.Format("Instance : {0} return response, " & _ "Quotation No is {1}, Send date is {2}", _ e.workflowinstance.instanceid.tostring, _ Response.QuotationNo, Response.SendDate.ToString)) Form_Load StopRuntime FormClosed Private Sub RFQForm_FormClosed(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed _WFRuntime.StopRuntime() 0

WorkflowRuntime IsStarted False StartRuntime 2. XAML WF RFQProcess RFQFlow.xoml Visual Studio 200 2-7 XML 1 2. X AML 2-7 XAML SequentialWorkflow Activity Windows Workflow Foundation 1

2 WF 1 CodeActivity XML XML XAML extendsible Application Markup Language X M L W F.NET Framework.0 Windows Presentation Foundation XAML WPF Hello World! <Panel> <Button> Hello World! </Button> </Panel> XAML XAML XML.NET XML.NET 2..1 XAML XML.NET 2

<SequentialWorkflowActivity x:class="ch02.quotation.rfqprocess.rfqflow" x:name="rfqflow" xmlns:x="http://schemas.microsoft.com/winfx/200/xaml" xmlns="http://schemas.microsoft.com/winfx/200/xaml/workflow"> <CodeActivity x:name="receivequotationrequest" ExecuteCode="ReceiveQuotationRequest_ExecuteCode" /> </SequentialWorkflowActivity> xmlns WF.NET Framework System.Workflow.Activities x XAML x:name XAML x:class XAML WF CH02.Quotation.RFQProcess.RFQFlow WF.xoml WF XAML WF XAML 1 ToGetMax XOML <SequentialWorkflowActivity x:class="firstwf.workflow2" x:name="workflow2" xmlns:ns0="clr-namespace:firstwf" xmlns:x="http://schemas.microsoft.com/winfx/200/xaml" xmlns="http://schemas.microsoft.com/winfx/200/xaml/workflow"> <ns0:togetmax x:name="togetmax1" FirstNumber="0" SecondNumber="0" Result="0" /> </SequentialWorkflowActivity> 1 2. X AML ns0 clr-namespace:firstwf ToGetMax XAML Windows Workflow Foundation

2 WF 1 clrnamespace.net XML.NET XAML <SequentialWorkflowActivity x:class="firstwf.workflow2" x:name="workflow2" xmlns:wfn="http://schemas.wfn.idv.tw/winwf/activities" xmlns:x="http://schemas.microsoft.com/winfx/200/xaml" xmlns="http://schemas.microsoft.com/winfx/200/xaml/workflow"> <wfn:togetmax x:name="togetmax1" FirstNumber="0" SecondNumber="0" Result="0" /> </SequentialWorkflowActivity> <Assembly: XmlnsDefinition( _ "http://schemas.wfn.idv.tw/winwf/activities", _ "CH01.FirstWF.Activities")> XAML XML.NET.xoml http://schemas.wfn.idv.tw/winwf/activities.net CH01.FirstWF.Activities CH01.FirstWF.Activities. ToGetMax 2..2 XAML XAML Visual Studio 200 RFQProcess RFQFlow.xoml RFQFlow.xoml.vb 2-8

.xoml.xoml ExecuteCode WF 1 2. 2-8 Code Behind 2-8 RFQFlow.xoml.vb RFQFlow.rules Visual Studio XML XAML.xoml Visual Studio X AML Visual Studio.xoml XML CDATA Windows Workflow Foundation

2 WF 1 <SequentialWorkflowActivity xmlns:x="http://schemas.microsoft.com/winfx/200/xaml" xmlns="http://schemas.microsoft.com/winfx/200/xaml/workflow" x:class="purexaml"> <CodeActivity ExecuteCode="SayHello"> <x:code> <![CDATA[ Private Sub SayHello(ByVal sender As Object, ByVal e As EventArgs) Console.WriteLine("Hello, Pure XAML!") ]]> </x:code> </CodeActivity> </SequentialWorkflowActivity> CDATA ExecuteCode XAML 2.. WF WFC.exe XAML WF wfc.exe Windows Vista SDK XOML PureXAMLFlow.xoml wfc purexamlflow.xoml -language:vb -out:purexamlflow.dll WF Type GetType GetType PureXAML XOML

x:class PureXAMLFlow 1 Shared Sub Main() Using workflowruntime As New WorkflowRuntime() AddHandler workflowruntime.workflowcompleted, _ AddressOf OnWorkflowCompleted AddHandler workflowruntime.workflowterminated, _ AddressOf OnWorkflowTerminated Try Dim WorkflowType As Type WorkflowType = Type.GetType("PureXAML, PureXAMLFlow") Dim workflowinstance As WorkflowInstance workflowinstance = _ workflowruntime.createworkflow(workflowtype) workflowinstance.start() WaitHandle.WaitOne() Catch ex As Exception Console.WriteLine(ex.Message) Console.ReadLine() End Try End Using XOML 2. 2. RFQ Windows Workflow Foundation 7

2 WF 1 WF WF WF WF WF 8