WF from Getting started to proficient (fourth chapter): Introduction to activities and workflow types

Source: Internet
Author: User
Tags visual studio

After completing this chapter, you will learn:

How the 1.workflow activity is formed

2. The difference between sequential workflow and state machine workflow

3. Create a sequential workflow

4. Create a State machine workflow

Activity is the basic unit of workflow processing in WF, and if you break down a business process (or workflow Task), you'll find that it's made up of smaller, finer tasks. If you need to design such a large task, it needs to send information to a series of data processing system for processing, then the subtasks may include things: read data from the database, use the data to generate a file, by using FTP or XML Web service to upload files to a remote server, Tag information has been processed (e.g. by writing to the database and entering the audit steps), and so on. These subtasks focus on a specific task: reading the database, uploading files, and auditing. In other words, they are activities.

When you create workflow, you bundle these individual activities together and move the activity from one to the other. Some activities can be used as containers for other activities. Some activities perform a single task, which we have talked about. Container based activities are used to accommodate other activities, and the root activity we talked about in the previous chapter is this activity. Root activity is both a sequential activity and a state machine activity, and we will describe the types of these activities in this chapter.

How does the activity know what to do next after this step is completed? The main focus of this chapter is on this. Perhaps the activity will be executed in the order specified when you create a root activity, or it may be only after a specific event has occurred that a specified activity is executed. To give us a better understanding of the activities, we first have to look at the WF activities object and then see how the activity is linked together.

Activity Introduction: Basic work Unit

WF provides you with an Activity object. The activity implements a base class that looks very simple. It does not do many intelligent tasks, but it can interact with each other workflow (this is not easy). The active object derives from "activity" and provides a powerful feature. You can freely create your own activities, the topic will be introduced in the 13th chapter (custom activities). In fact, the second part of the book is in the introductory event (chapters 7th through 13th). Table 4-1 lists many of the properties of the activity that we are usually interested in, and table 4-2 lists the methods that you will often use. In the 13th chapter, you will also see more methods and properties related to custom activities.

Table 4-1 Properties of activities (activity)

Property Function
Description Gets or sets a user-defined description of the activity.
Enable Gets or sets a value that indicates whether the instance can be executed and validated.
ExecutionResult Gets the result of the last run of the instance (Activityexecutionresult). (There are canceled, compensated, Faulted, none and succeeded).
ExecutionStatus Gets the state of the workflow, which is one of the activityexecutionstatus enumerated values (canceling, Closed, compensating, executing, faulting, and initialized).
Name Gets or sets the name of the active instance.
Parent Gets the parent activity that contains this activity.
Workflowinstanceid Gets the identifier for the workflow instance that is associated with the activity.

Table 4-2 Methods of activities (activity)

Property Function
Cancel Cancels the execution of the activity.
Clone Returns a deep copy of the activity.
Execute Runs the activity in a synchronized fashion.
Getactivitybyname If executed on a composite activity, this method returns the activity of the specified name contained in the combined activity.
Load Loads an active instance from a stream.
RaiseEvent Triggers an event related to the specified dependency property.
Raisegenericevent<t> Triggers the events associated with the referenced dependency property. The role of RaiseEvent and Raisegenericevent is the same--the first event RaiseEvent directly indicates Dependencypropenty, and raisegenericevent is a generic version.
Save Save the activity to the stream.

Active methods usually have virtual and protected properties. The point is that you can cover them to provide an implementation that meets your own needs for the activity. So far, the most critical approach is execute. When this method is invoked by the workflow runtime, your activity begins to execute.

Activities can be grouped into two broad categories: portfolio activities and basic activities. The group activity contains other activities. An excellent example is the sequential activity that we have so far run through the book: it is a vector of all the activities in a sequential workflow, and Visual Studio was created for us to see in the View Designer when creating a sequential workflow. All program instances so far perform workflow instances in the form of sequential activities that contain other activities, such as itself, delay activity, and code activity.

Basic activities, like the delay activities and code activities I just talked about, are a single task based activity that I talked about earlier in this chapter. Ultimately, you need basic activities to actually host a particular task. Combined activities may command the flow of tasks and data, but basic activities can do more.

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: 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.