DOC

COMHOL01 - Getting Started with Windows Workflow Foundation

By Tiffany Mason,2014-09-09 15:46
21 views 0
COMHOL01 - Getting Started with Windows Workflow Foundation

Hands-On Lab

    Lab Manual

    Lab 01 Getting Started with Windows Workflow Foundation

    Please do not remove this manual from the lab

     ;

    Information in this document, including URL and other Internet Web site references, is subject to change without notice. This document supports a preliminary release of software that may be changed substantially prior to final commercial release, and is the proprietary information of Microsoft Corporation.

    This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EITHER EXPRESS OR IMPLIED, AS TO THE INFORMATION IN THIS DOCUMENT.

    The entire risk of the use or the results from the use of this document remains with the user. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation.

    Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property.

    Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, email address, logo, person, place or event is intended or should be inferred.

? 2005 Microsoft Corporation. All rights reserved.

    Microsoft, MS-DOS, Windows, Windows NT, Windows Server, Visual C# and Visual Studio are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

    The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

     ;

Contents

    LAB 01: GETTING STARTED WITH WINDOWS WORKFLOW FOUNDATION .................................................. 1 Lab Objective .................................................................................................................................................. 1 Exercise 1 Create a Hello World Workflow .................................................................................................... 2 Task 1 Create a new Workflow Project...................................................................................................... 2 Task 2 Add a code activity ........................................................................................................................ 4 Task 3 Run the new workflow with Debugging .......................................................................................... 6 Exercise 2 Receiving Data into the Workflow using Parameters .................................................................. 10 Task 1 Define parameters for the workflow ............................................................................................. 10 Task 2 Modify the Code Activity .............................................................................................................. 12 Task 3 Execute the modified workflow .................................................................................................... 13 Exercise 3 Using the If/Else activity, declarative conditions, and custom activities ....................................... 17 Task 1 Create a new Workflow Project.................................................................................................... 17 Task 2 Add the Expense Reporting Interface to the Project ..................................................................... 19 Task 3 Add the ExpenseReportSubmitted activity ................................................................................... 20 Task 4 Add a Rule Condition to the workflow .......................................................................................... 22 Task 5 Add the logic to approve or reject the expense report .................................................................. 25 Task 6 Configure the ExpenseWorkflows project for debugging .............................................................. 27 Task 7 Test the Expense Reporting Workflow ......................................................................................... 28 Exercise 4 Using Listen, Delay, and event-based custom activities ............................................................. 33 Task 1 Add activities for requesting manager approval ............................................................................ 33 Task 2 Add a Listen activity for waiting for the Expense Report Review................................................... 36 Task 3 Approve or Reject the Expense Report ........................................................................................ 39 Task 4 Test the Expense Reporting Workflow ......................................................................................... 46 Lab Summary ................................................................................................................................................ 50

    Page i

Page ii

    Lab 01: Getting Started with Windows Workflow Foundation Estimated time to complete this lab: 60 minutes

    The project files for this lab are in the c:\Windows Workflow Foundation\Labs\Lab01 folder. Completed

    solutions for each exercise can be found in the Completed subdirectory. Resource files referenced in these labs can be found in the Resources subdirectory. All code snippets in this lab manual that are longer than two lines are available on the lab machine as Microsoft Visual Studio 2005 Code Snippets. To access these you can right click your mouse in the code editor and choose Insert Snippet… The

    code snippets associated with this lab are accessed in My Code Snippets | Lab01.

    More information about Windows Workflow Foundation can be found at

    http://msdn.microsoft.com/workflow

    Lab Objective

    The objective of this lab is to introduce the key Windows Workflow Foundation workflow concepts. After completing this lab, you will be able to:

     Author Sequential Workflows using the Visual Studio 2005 designer for Windows Workflow

    Foundation

     Configure and use the Visual Studio 2005 debugger to debug your workflows

     Receive parameters into a workflow

     Receive an event to activate a new instance of a workflow

     Define conditions

     Configure basic activities including If/Else, Delay, Listen, and Code

     Utilize custom activities for receiving events into a workflow

    A workflow is a model of a human or system process which is defined as a map of

    activities. An activity is a step in a workflow and is the unit of execution, re-use and

    composition for a workflow. A workflow is designed by laying out activities is compiled to

    a .NET assembly and is executed on the workflow runtime and the Common Language

    Runtime (CLR).

    Page 1

Exercise 1 Create a Hello World Workflow

    In this exercise, you will create a very simple “Hello World” workflow using the Visual Studio 2005

    designer for Windows Workflow Foundation, referred to as the Visual Studio workflow designer in the remainder of this document. The Hello World workflow will be a sequential workflow that includes a single code activity. The code activity will be used to write the phrase “Hello, World!” to the console at

    runtime. You will explore the workflow definition and the code-beside for the workflow. Finally, you will see how to execute your workflow using a simple host and debug your workflow using Visual Studio 2005.

Task 1 Create a new Workflow Project

    1. Open Visual Studio 2005 by going to the Start Menu | Programs | Microsoft Visual Studio

    2005 Beta | Microsoft Visual Studio 2005 Beta 2

    2. In Visual Studio 2005, select the File | New | Project menu command.

    3. Visual Studio 2005 will display the New Project dialog window.

    4. In the New Project dialog window, expand Visual C# | Workflow in the Project Types tree on

    the left side.

    5. Select the template named Sequential Workflow Console Application and enter the

    following values:

    Name: HelloWorldWorkflow

    Location: C:\Windows Workflow Foundation\Labs\Lab01

    Page 2

6. You should now have a new solution and workflow project.

    7. The project template has a Workflow1.cs which we will remove as we will be using a simpler

    kind of workflow for this lab. Click on Workflow1.cs and press the DEL key. Click the okay

    button to confirm.

    8. Right click on the HelloWorldWorkflow project in Solution Explorer and select Add | New Item

    from the context menu.

    9. In the Add New Item dialog window, select the item template named Sequential Workflow

    (with code separation) and click the Add button to add the new workflow to the

    HelloWorldWorkflow project.