Using WWF to develop ASP.net programs

Source: Internet
Author: User
Tags ticket visual studio
Asp.net| Program Brief Introduction

By using WWF, you can create workflows based on processor flow and deploy them in any type of. NET application. In addition, this article discusses some of the specific issues that asp.net developers face-problems that can be addressed by using workflows such as Maintenance status and page navigation.

In September 2005, Microsoft exposed the Windows Workflow Foundation (wwf,windows Workflow Foundation) at its two-year professional developer meeting. As one of the pillars of the WinFX API, WWF provides developers with a common framework for developing process-driven and workflow-centric applications on them.

At present, some organizations are trying to automate the entire business process; Their standard answer is to assemble a team of developers to develop the appropriate code. While this approach has a good effect on these organizations, there are some inherent problems. To get a deeper understanding of the problem, you need to understand the basic characteristics of a workflow.

A workflow essence is a way to archive activities that are included in the work of completing a unit. Typically, in the process of processing, the work "flow" flows through one or more activities. These activities can be done by machine or manual, and may be as simple as defining the page order in an Internet application, and may be as complex as managing files or products that must be seen, changed, and agreed to by any number of people.

Because so many workflows have to take into account human parameters, it may take a long time to complete, possibly for hours to months or longer. For example, a person who is in the process may not be able to find it, is not local, or is busy with another task; Therefore, the workflow must be able to store itself continuously during all inactive periods. Furthermore, the process of implementing independently by encoding may be difficult for non-technical people to understand and difficult for developers to change. This and other factors are the goal of common workflow frameworks such as windowswf-the goal is to make creating, changing, and managing workflows easier-by providing them with a visual interface or by defining a common set of APIs.

You can place the WWF workflow in any type of. NET application-including Windows Forms programs, console applications, Windows Services, and ASP.net Web applications. Each type requires special consideration. Although some of the existing examples are sufficient to show you how to host workflows into Windows Forms and console applications, this article will focus on ASP.net developers-they want to integrate workflows into their applications.

   Author Note: The code provided in this article was created with Windows WF Beta 1 and Visual Studio 2 as a tool. You can find information about installing Windows WF in Www.windowsworkflow.net. Although this article discusses some of the basics of Windows WF, there are other resources available for this. I assume that the reader knows at least a little about Windows WF. The purpose of this article is to analyze Windows WF and asp.net in depth, rather than discussing Windows WF from a high-level.

   Windows wf and MVC patterns

One of the common ways you might use the WWF when developing a ASP.net application is to implement a model-view-Controller (MVC) approach. Essentially, the goal of MVC is to separate the description layer, the application logic, and the application flow logic.

Figuring out this will be very beneficial to the development of a asp.net application, consider a place to help the desktop ticket workflow. Suppose a business user starts the workflow by filling out a asp.net Web form and clicking on a Submit button. Next, the server notifies an employee who uses a Windows Form application and a help desk-"a new ticket is available." The help desk employee will then work on this issue and close the ticket at the end. If you use Windows WF to develop this workflow scenario, all processing logic and processes can be included in the workflow itself, and the ASP.net application will not need to understand this logic at all.

This place provides some solid evidence that separating the description from the logic is a good thing. Because the process of processing help desk requests is very common, if you use C # or vb.net code to implement this logic in a number of different. NET applications, you will risk repetitive coding or even worse situations--with completely different code that results in different implementations of the same business process. But if you use WWF to implement this process, application developers who need this process will only need to modify these steps-the workflow itself-without having to worry about changing the application logic in one place. Code replication and where to implement this process can be mitigated by using Windows WF.

When using Windows WF to implement the MVC architecture in asp.net, developers should try to build a workflow that is separate from the application-and that workflow is still hosted in that application. This will help keep the logic separate from the description and maintain a high degree of independence between the order of work steps and the page flow in the Web application.

A new WWF developer might try to develop a workflow in some order with a fixed number of activities, and then develop a set of asp.net Web Forms that flow from one form to another in the same order. Unfortunately, although this may seem logical, it is actually very inefficient because you will be able to implement this workflow logic again. Web page x does not need to know whether it needs to go to page y or page Z to implement the workflow step correctly. Instead, the workflow (model) should tell ASP.net (the controller) what to do next, and then ASP.net should decide which page to display. In this way, each page has little need to understand the entire process; it only needs to know how to do a different activity and let the workflow care about how the page flows from one place to another. This separation provides a great deal of flexibility for developers to process page flows. For example, if you decide to change the order in which the page is displayed, you can easily implement this from the workflow without changing one line of code in the ASP.net application.

   Second Simple workflow MVC instance

To illustrate this idea, I'll show you a simple asp.net application and workflow. This overly simplified workflow describes a progress-gathering private information from an external application and then displaying it. The steps are as follows:

1. Calling a method-this means requesting a person's name; the workflow uses the InvokeMethod activity (see Figure 1).

2. Wait until an event is triggered-this means receiving a name; In this step, the workflow uses the EventSink activity.

3. Use a similar call to obtain an e-mail address from the host.

4. Waiting for an event means receiving an address.

5. After receiving the name and email, the workflow initiates a InvokeMethod activity to send personal data to the caller application. In a real-world situation, this last step is not very important. More likely, you will call a Web service to send data to another system, or put it into a database.


Figure 1. Sample Workflow: This workflow describes the process implied in the example asp.net application

[1] [2] Next page



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.