Examples of WF Voting

Source: Internet
Author: User
First look at the sketch of the basic process

The concept of using WF
1. design the Activity of [Comments by the voting person]. This is a notification and reply process. Therefore, use a group of CallExternalMethod and HandleExternalEvent to implement notification and wait for a reply.
2. because the number of participants is not specific, but the process for participation of all participants is the same, multiple copies of the [Comments by the vote] Activity are created using a replicatoracti.pdf container.
3. The voting is concurrent, so the ReplicatorActivity container should be set to concurrent
4. Because HandleExternalEvent of the Activity with multiple [Comments by the voting person] is waiting at the same time, CorrelationToken must be used to associate CallExternalMethod with HandleExternalEvent.
5. Due to the uncertainty of the number of participants, the InitialChildData set of ReplicatorActivit must be imported after the user-defined user when the process is started.

 

Data item class public class DataItem
{
Public DataItem (string partakeName)
{
This. PartakeName = partakeName;
}
Public string PartakeName;
Public string Result;
}

AllExternalMethod and HandleExternalEvent binding class
Use
System. Workflow. Activities. CorrelationParameter
System. Workflow. Activities. CorrelationInitializer
System. Workflow. Activities. CorrelationAlias
Associate CallExternalMethod with HandleExternalEvent // Interface
[System. Workflow. Activities. ExternalDataExchange]
[System. Workflow. Activities. CorrelationParameter ("PartakeName")]
Public interface IExternalEvent
{
[System. Workflow. Activities. CorrelationInitializer]
Void CreateBallot (string PartakeName, object value );

// Associate Parameters
// Corresponds to the event attributes
[System. Workflow. Activities. CorrelationAlias ("PartakeName", "e. PartakeName")]
Event EventHandler <EventArgs> WxdEvent;
}

// Event parameters
[Serializable]
Public class EventArgs: System. Workflow. Activities. ExternalDataEventArgs
{
Public string Result;
Private string _ PartakeName;
Public string PartakeName
{
Get {return _ PartakeName ;}
Set {_ PartakeName = value ;}
}

Public EventArgs (Guid instanceId, string PartakeName)
: Base (instanceId)
{
_ PartakeName = PartakeName;
}
}

// Interface implementation class
Public class WxdExternalEvent: IExternalEvent
{
// Implement interface events
Public event EventHandler <EventArgs> WxdEvent;
// Interface Implementation Method
Public void CreateBallot (string PartakeName, object value)
{
System. Console. WriteLine ("Notification {0} voting", PartakeName );
}

// Trigger the event
Public void OnWxdEvent (Guid instanceId, string PartakeName, string Result)
{
EventArgs e = new EventArgs (instanceId, PartakeName );
E. Result = Result;
WxdEvent (null, e );
}
}


Custom voting Activity

WorkFlow Design

Alert trigger

Code download
Http://files.cnblogs.com/foundation/WorkflowLibrary3.rar

Add
The above example is to demonstrate the use of ReplicatorActivity and to associate CallExternalMethod and HandleExternalEvent with CorrelationToken.
In actual application, the Activity of [Comments by the voting person] can be designed as follows:

If the Participant does not vote within the specified period, the system will handle the request as a timeout. This will prevent a user from disvoting and keep the entire process suspended. In instance applications, delay is generally not directly used as a business node, but an independent time engine. This allows you to handle work days, holidays, and application delays.

In addition, if you do not need all participants to complete the voting process before continuing to run down, you can join the rules to judge. When a certain number of votes is agreed or disagree, the results will be displayed directly, of course, this depends on whether the actual business has such requirements.

It is easier to add the above functions, so no code is provided here.
After the test is passed, the engine and client are respectively encapsulated,
The engine can select the Win service, and the Application of COM + and IIS as the host.
The client can select WinForm or WEB
Of course, you also need to select a communication method, which can be WebService, Remoting, WCF, or TCP.
All the examples of the above combinations have been written, so we will not provide them here

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.