1. Trang chủ
  2. » Công Nghệ Thông Tin

beginning wf

471 3.2K 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

www.it-ebooks.info Beginning WF Windows Workflow in .NET 4.0 n n n Mark J. Collins www.it-ebooks.info Beginning WF: Windows Workflow in .NET 4.0 Copyright © 2010 by Mark J. Collins All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2485-3 ISBN-13 (electronic): 978-1-4302-2486-0 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. President and Publisher: Paul Manning Lead Editor: Jonathan Hassell Technical Reviewer: Michael Mayberry Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Debra Kelly Copy Editor: Nancy Sixsmith Compositor: Laureltech Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at www.apress.com. www.it-ebooks.info Dedicated to my wife, Donna. Your worth is far above rubies (Prov 31:10). I love you! www.it-ebooks.info v Contents at a Glance Contents vii About the Author xix About the Technical Reviewer xx Acknowledgments xxi Introduction xxii n Part 1: Introduction 1 n Chapter 1: Building a Simple Workflow 3 n Chapter 2: Coded Workflows 23 n Chapter 3: Flowchart Workflow 33 n Part 2: Designing Workflows 43 n Chapter 4: Passing Arguments 45 n Chapter 5: Replicated Activities 59 n Chapter 6: Exception Handling 69 n Chapter 7: Extending the Built-In Activities 79 n Part 3: Communication 93 n Chapter 8: Send and Receive 95 n Chapter 9: Communicating with the Host Application 123 n Chapter 10: Web Services 151 www.it-ebooks.info n CONTENTS AT A GLANCE vi n Part 4: Workflow Extensions 175 n Chapter 11: SQL Persistence 177 n Chapter 12: Custom Extensions 209 n Chapter 13: Tracking 229 n Chapter 14: Transactions 255 n Chapter 15: Transactions with Persistence 277 n Chapter 16: WorkflowServiceHost 289 n Part 5: Advanced Topics 317 n Chapter 17: Compensation, Confirmation, and Cancellation 319 n Chapter 18: Collections 345 n Chapter 19: Interoperability with Workflow 3.5 361 n Chapter 20: Policy 375 n Appendix: Sample Workflow Project 405 n Index: 439 www.it-ebooks.info vii Contents About the Author xix About the Technical Reviewer xx Acknowledgments xxi Introduction xxii n Part 1: Introduction 1 n Chapter 1: Building a Simple Workflow 3 A Simple Workflow 4 Exploring the IDE 4 Designing the Workflow 5 Reviewing Program.cs 6 Running the Application 7 Adding Procedural Elements 7 Using Variables 8 If 10 Assign 11 While 12 Sequence 13 Delay 13 More Embellishments 14 Running the Application 15 www.it-ebooks.info n CONTENTS viii Navigating the Designer 15 Looking a Bit Deeper 17 Differences from Previous Versions 21 n Chapter 2: Coded Workflows 23 Creating a Console Application 23 Defining the Workflow 24 Implementing Level 1 25 Implementing Level 2 26 Implementing Level 3 28 Running the Application 29 Review 32 n Chapter 3: Flowchart Workflow 33 Creating a Flowchart Workflow 33 Designing the Flowchart 34 Defining Connections 34 FlowDecision 35 Running the Application 37 Flow Switch 38 Adding a FlowSwitch Activity 38 Adding the FlowStep Activities 39 Running the Application 40 Parallel 40 Adding a Parallel Activity 40 Adding the Branches 41 Running the Application 42 n Part 2: Designing Workflows 43 n Chapter 4: Passing Arguments 45 Creating a New Solution 45 www.it-ebooks.info n CONTENTS ix Defining the Order Class 46 Implementing the Workflow 48 Defining the Arguments 49 Designing the Workflow 51 Switch Activity 51 Expression Activities 53 Invoking the Workflow 56 Running the Application 58 n Chapter 5: Replicated Activities 59 Reusing the Chapter 4 Project 59 Adding OrderItem Processing 61 ForEach Activity 61 Adding Order Items 65 Running the Application 66 ParallelForEach Activity 68 n Chapter 6: Exception Handling 69 Reusing the Chapter 5 Project 69 Adding the Check Stock Activity 70 TryCatch Activity 70 Defining an Exception 70 ForEach Activity 72 If Activity 72 Throw Activity 73 Catch Activity 74 Running the Application 76 Exceptions 77 n Chapter 7: Extending the Built-In Activities 79 Reusing the Chapter 6 Project 79 www.it-ebooks.info n CONTENTS x Using Custom Activities 80 Implementing a Custom Activity 80 Using the LookupItem Activity 82 Running the Application 85 InvokeMethod Activity 86 Creating a Discount Class 86 Using the InvokeMethod Activity 87 Adding the Discount 91 Running the Application 91 Summary 92 n Part 3: Communication 93 n Chapter 8: Send and Receive 95 Creating the Project 95 Define the Messages 96 Application Configuration 101 Defining the Workflows 102 Client–SendRequest 102 Server–ProcessRequest 107 Implementing the Application 114 WorkflowServiceHost 114 WorkflowInvoker 116 Running the Application 118 Configuring a Library Branch 118 Expected Results 120 n Chapter 9: Communicating with the Host Application 123 Creating a WPF Project 123 Reusing the Classes from Chapter 8 124 Defining the Window Form 125 www.it-ebooks.info [...]... Workflow Foundation (WF) I had a sense that there was something really useful there, but figuring out the right application of the technology seemed elusive The available code samples demonstrated some specific features, but there was no roadmap to help bring it all together So I started writing this book to help others who wanted to understand WF Along the way, the first beta release of WF 4.0 was made... which was a complete departure from the previous version So the first book based on version 3.5 was shelved, and I started writing a new book for WF 4.0 When the second Beta was released with significant changes, the book was once again rewritten Having watched WF evolve from version 3.5 to 4.0 B1 and then 4.0 B2, and finally 4.0 RC, I can confidently say that these improvements will make your job as a... to support collections of objects The project in Chapter 19 uses the Interop activity to execute workflows and activities that were created using previous versions of WF In Chapter 20, you’ll use the Policy activity from version 3.0 in a WF 4.0 workflow Appendix The Appendix describes a sample workflow that demonstrates many of the concepts presented in this book It is designed as a review of the key... Foundation included in Net 4.0 (referred to as WF 4.0) represents a whole new paradigm for building workflow-based applications It has been completely reengineered from the ground up In this section, you’ll design some simple workflows and learn the basic concepts In subsequent sections, you’ll develop more complex solutions as you explore the capabilities provided by WF 4.0 www.it-ebooks.info CHAPTER 1 ■■■... Procedural Elements WF 4.0 provides a number of procedural elements such as If, While, Assign, Sequence, and so on To demonstrate how they work, you’ll enhance this greeting First, like some old-fashioned clocks, you’ll sound a number of bells to indicate the time (one bell for each hour) Open the Workflow1.asmx file 7 www.it-ebooks.info CHAPTER 1 ■ BUILDING A SIMPLE WORKFLOW Using Variables With WF 4.0, you... the right The bottom window contains a number of tabs including the Error List and Output window Figure 1-2 Typical Visual Studio 2010 IDE 4 www.it-ebooks.info CHAPTER 1 ■ BUILDING A SIMPLE WORKFLOW The WF 4.0 designer is in the middle At the bottom right, there are controls for zooming Workflow designs in version 4.0 tend to be somewhat long, and this is a handy feature to see the “big picture” or to... workflow in your own solutions, the sample projects provided in this book make a handy reference guide A topical reference is provided to help you find the appropriate chapters to look at for each of the WF concepts Several of the projects require a SQL Server database Just about any version will work, including the Microsoft Data Engine (MSDE) provided with Visual Studio You will need to create the databases... Scope as Sequence For the Default property, click the ellipses, which will display the Expression editor, as shown in Figure 1-10 Figure 1-10 Expression editor ■ Tip One of the things you’ll notice about WF 4.0 is that it relies a lot on expressions Many properties can be defined using an expression However, the form doesn’t usually leave enough room to write complex expressions To solve this, the expression... example, for 2 PM, it will return 14 So you’ll need to adjust for this because you should ring 2 bells, not 14 In code, you would write this as follows: if (numberBells > 12) numberBells -= 12; However, in WF 4.0, you’ll need to use an If and an Assign activity to accomplish this Drag an If activity just below the Hello activity The diagram should look like the one shown in Figure 1-12 Figure 1-12 Adding . www.it-ebooks.info Beginning WF Windows Workflow in .NET 4.0 n n n Mark J. Collins www.it-ebooks.info Beginning WF: Windows Workflow in .NET 4.0

Ngày đăng: 24/04/2014, 14:42

Xem thêm: beginning wf

TỪ KHÓA LIÊN QUAN

Mục lục

    Contents at a Glance

    About the Technical Reviewer

    How to Use This Book

    CHAPTER 1 Building a Simple Workflow

    Looking a Bit Deeper

    Differences from Previous Versions

    Creating a Console Application

    Creating a Flowchart Workflow

    Adding a FlowSwitch Activity

    Adding the FlowStep Activities

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN