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!