ebook img

Pro WF Windows Workflow in .NET 3.6 PDF

854 Pages·2008·17.68 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Pro WF Windows Workflow in .NET 3.6

cyan yelloW MaGenTa Black panTone 123 c Books for professionals By professionals® The eXperT’s Voice® in .neT Companion eBook Available Author of Pro WF: Windows Workflow in .NET 3.5 Pro WF: Windows Workflow P in .NET 3.0 .NET 2.0 Interoperability Dear Reader, Recipes: A Problem-Solution Since I began my career a few decades ago, I’ve looked for a better way to develop r Pro Approach software. I imagined that one day software would be developed visually instead o of with a text editor. I hoped that we would assemble complete applications from prebuilt components, just as my son assembles his exorbitantly priced plastic blocks. W Now the future is here with Microsoft’s Windows Workflow Foundation (WF). WF Why am I so excited about WF? Workflow-enabled applications use a declara- tive programming model rather than a procedural one, separating what to do from when to do it. And the WF designer is tightly integrated with Visual Studio, bringing workflow within reach of every .NET developer. In the future, I believe most nontrivial applications will be workflow-enabled, and WF is the de facto standard workflow framework for Windows. I wrote this book as a comprehensive tutorial on using WF. I start with the WF fundamentals to get you up and running quickly. After that, I provide coverage F of other WF topics, such as local services, event-driven activities, rules, work- flow persistence, tracking, transactions, compensation, dynamic updates, web services, ASP.NET, workflow markup, and hosting the workflow designers. I’ve updated the first edition of this book with coverage of the new WF features in .NET Framework 3.5, including a new chapter dedicated to workflow services. I also added a new chapter that explores the development of composite and WW long-running custom activities. As a working developer, I learn a new skill best through practical, hands-on examples. So when I wrote this book, I focused on demonstrating WF concepts oi Windows Workflow in .NET 3.5 instead of just talking about them. I truly believe that workflows are the next par- n adigm shift, and I hope this book helps you to use WF in your own applications. r Thank you, kd Bruce Bukovics fo l w Companion eBook o Use Windows Workflow Foundation to develop THE APRESS ROADMAP w next-generation, workflow-enabled applications Beginning C# 2008 Pro WF s Databases Pro C# 2008 Beginning C# 2008, Second Edition and the .NET 3.5 Beginning ASP.NET 3.5 in Platform, Fourth Edition Pro WPF in C# 2008, See last page for details C# 2008, Second Edition Second Edition in .NET on $10 eBook version Pro ASP.NET 3.5 Illustrated C# 2008 in C# 2008, Second Edition Beginning XML Pro LINQ 3.5 with C# 2008 Bruce Bukovics SOURCE CODE ONLINE www.apress.com ISBN 978-1-4302-0975-1 55299 Bukovics US $52.99 Shelve in Programming/Microsoft/.NET User level: 9 781430 209751 Intermediate–Advanced this print for content only—size & color not accurate spine = 1.6052" 856 page count Buckovics_975-1FRONT.fm Page i Wednesday, May 28, 2008 4:59 PM Pro WF Windows Workflow in .NET 3.5 ■ ■ ■ Bruce Bukovics Buckovics_975-1FRONT.fm Page ii Wednesday, May 28, 2008 4:59 PM Pro WF: Windows Workflow in .NET 3.5 Copyright © 2008 by Bruce Bukovics 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-0975-1 ISBN-13 (electronic): 978-1-4302-0976-8 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. Lead Editor: Matthew Moodie Technical Reviewers: Brian Robert Myers, Sylvain Groulx Editorial Board: Clay Andres, Steve Anglin, Ewan Buckingham, Tony Campbell, Gary Cornell, Jonathan Gennick, Matthew Moodie, Joseph Ottinger, Jeffrey Pepper, Frank Pohlmann, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Project Manager: Beth Christmas Copy Editor: Kim Wimpsett Associate Production Director: Kari Brooks-Copony Production Editor: Ellie Fountain Compositor: Susan Glinert Proofreader: Patrick Vincent Indexer: Julie Grady Artist: Kinetic Publishing Services, LLC Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski 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 [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http:// 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 http://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 http://www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. Buckovics_975-1FRONT.fm Page iii Wednesday, May 28, 2008 4:59 PM For Teresa and Brennen Buckovics_975-1FRONT.fm Page iv Wednesday, May 28, 2008 4:59 PM Buckovics_975-1FRONT.fm Page v Wednesday, May 28, 2008 4:59 PM Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxv Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii ■ CHAPTER 1 A Quick Tour of Windows Workflow Foundation . . . . . . . . . . . . . . . . . 1 ■ CHAPTER 2 Foundation Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 ■ CHAPTER 3 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 ■ CHAPTER 4 Hosting the Workflow Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 ■ CHAPTER 5 Flow Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 ■ CHAPTER 6 Local Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 ■ CHAPTER 7 Event-Driven Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 ■ CHAPTER 8 Workflow Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297 ■ CHAPTER 9 State Machine Workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333 ■ CHAPTER 10 Transactions and Compensation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369 ■ CHAPTER 11 Workflow Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 ■ CHAPTER 12 Exception and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 ■ CHAPTER 13 Advanced Custom Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 ■ CHAPTER 14 Dynamic Workflow Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519 ■ CHAPTER 15 Workflow Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549 ■ CHAPTER 16 Web Services and ASP.NET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595 ■ CHAPTER 17 Workflow Services and WCF Integration . . . . . . . . . . . . . . . . . . . . . . 625 ■ CHAPTER 18 Workflow Serialization and Markup . . . . . . . . . . . . . . . . . . . . . . . . . . 693 ■ CHAPTER 19 Hosting the Workflow Designers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 731 ■ INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .793 v Buckovics_975-1FRONT.fm Page vi Wednesday, May 28, 2008 4:59 PM Buckovics_975-1FRONT.fm Page vii Wednesday, May 28, 2008 4:59 PM Contents About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi About the Technical Reviewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxv Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii ■ CHAPTER 1 A Quick Tour of Windows Workflow Foundation . . . . . . . . . . 1 Why Workflow? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Workflows Are Different. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Why Windows Workflow Foundation? . . . . . . . . . . . . . . . . . . . . . . . . . 2 Your Development Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Hello Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Creating the Workflow Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Introducing the Workflow Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Using Workflow Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Entering Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Hosting the Workflow Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Running the Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Passing Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Declaring the Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Passing Values at Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Making Decisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Creating a Workflow Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Adding Workflow Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Adding IfElse Activities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Adding Calculation Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 Creating the Calculator Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Testing and Debugging the Calculator. . . . . . . . . . . . . . . . . . . . . . . . 26 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 vii Buckovics_975-1FRONT.fm Page viii Wednesday, May 28, 2008 4:59 PM viii ■ CONTENTS ■ CHAPTER 2 Foundation Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Workflow Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Sequential Workflows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 State Machine Workflows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Choosing a Workflow Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Foundation Deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Class Libraries and Framework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Runtime Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Runtime Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Design-Time Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 .NET 2.0 Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Runtime Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Application Host Process. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Runtime Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Registered Core Services. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Registered Local Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Workflow Instance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Design-Time Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Workflow Authoring Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Project Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Workflow Designer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Activity Designer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Rule Condition Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 RuleSet Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Workflow Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Command-Line Workflow Compiler . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Command-Line Communication Activity Generator . . . . . . . . . . . . . 62 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 ■ CHAPTER 3 Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Understanding Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 A Dual Audience for Activities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Class Hierarchy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Exploring Standard Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Custom Workflow Logic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Flow Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 State Management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Local Service Communication. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

Description:
Windows Workflow Foundation is a ground–breaking addition to the core of the .NET Framework that allows you to orchestrate human and system interactions as a series of workflows that can be easily mapped, analyzed, adjusted, and implemented. As business problems become more complex, the need for a
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.