Improvements to the LocalService service class in Workflow Foundation

Source: Internet
Author: User
Recently, Workflow Foundation was used in the project to implement workflows in Asp.net using state machines. The sample shown in samples is that various events are added to the LocalService Service Project to trigger status change. However, in actual projects, I think this method is not universal for three reasons: first, LocalService needs to be updated every time the process changes; second, general custom activities cannot be implemented; third, on the Asp.net page Code You need to trigger different events according to the current status, but the ideal situation is that the page Code only needs to notify the State Machine to change, the page code is not concerned about how the Page code changes or the status. configure the ing between the status and the event in config ).
The following are my ideas for improving the LocalService service.
In fact, what I want to achieve is that the outside world only notifies the state machine that the state machine needs to change the state and can pass parameters to the state machine. How to change the state and why the state change is handled by the state machine itself.
We all know that the LocalService changes with the state machine workflow because the sample in samples tells us to write a trigger for each State, the trigger is triggered externally based on the current state of the state machine to change the state machine. My idea is to only make one wfeventtrigger and set the eventname in handleexternal in each state to a uniform wfeventtrigger. Add an ifelsebranchactivity to handleexternal in each state. The condition is callme. Private   Bool Callme ()
{
Return This. Tuserdata ["Currentstate"]. Tostring ()= This. Currentstatename;
}

This. tuserdata ["currentstate"]. tostring () is a parameter sent in the page code. The content is the current state of the state machine obtained from the outside.
In this way, common code can be used externally to trigger state changes. LocalService does not need to change as the state machine changes.

I hope to share with you the advantages and disadvantages of doing so. Thank you!

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.