Using Workflow Foundation in MVC3 to handle Page Flow (as in a Wizard)
I want to decouple the MVC web pages, and the order in which they are displayed. Generally speaking, I think these are the scenarios I need to address, but I'm lot locked into a particular way of thinking. I just want to find a pattern or an object that will assist in controlling the flow.
Sample Page Sequencing:
Forward only: The user can only progress forward though the workflow, until finished.
-- Special case: If a user navigates to, or manually enters in an invalid URL, then the system should respond accordingly (redirect to current step)Forward - Back (read only): The user may progress through the wizard, but the back button allows for read only view of previous data.
Forward - Back (read write): The user may go back and update data in previous entries. This may cause the workflow to reset to the prior state.
For those times when a user may enter into more than one "valid state", the forward concept above should accomodate that (such as in a State Machine)
Question:
How would I implement this page control flow in a MVC3 / WF4 application?
开发者_如何转开发We're ourselves considering an architecture similar to your proposal. The MVC part is mainly auto-generated code with Llblgen Pro + custom ASP.Net templates, therefore, we want to control the business logic (and page workflow) from somewhere else.
We're still studing the final decision, and WF 4.0 is one candidate (as it's quite easy to create a reusable activities' library), but Stateless state-machine seems an really simpler approach and easier to maintain. We already have an ORM-generated persistence layer, therefore, it's not a big deal to resume the state of a paused workflow any time in the future. Have a look at Stateless and let us know if it fits.
An example explained: http://blogs.msdn.com/b/nblumhardt/archive/2009/04/16/state-machines-in-domain-models.aspx
Actualized VS 2010 code with examples: https://github.com/haf/Stateless
I explored this idea. In my opinion, Workflow Foundation would only be worth it if your process takes a long time (like days).
Otherwise, you'll find that writing some kind of custom code (like a State Machine) is a much easier solution than trying to incorporate Workflow Foundation.
However, if you're looking for examples, here's one: http://code.msdn.microsoft.com/Windows-Workflow-233b5e3c/sourcecode?fileId=22211&pathId=1790082120
精彩评论