在 MVC3 中使用 Workflow Foundation 处理页面流(如在向导中)
我想要解耦 MVC 网页以及它们的显示顺序。一般来说,我认为这些是我需要解决的场景,但我很受困于一种特定的思维方式。我只是想找到一个有助于控制流程的模式或对象。
示例页面排序:
仅前进:用户只能在工作流程中前进,直到完成。
-- 特殊情况:如果用户导航到或手动输入无效 URL,则系统应做出相应响应(重定向到当前步骤)前进 - 后退(只读):用户可以通过向导进行操作,但后退按钮允许只读查看以前的数据。
前进-后退(读写):用户可以返回并更新先前条目中的数据。这可能会导致工作流程重置为之前的状态。
对于用户可能进入多个“有效状态”的情况,上面的前向概念应该适应这种情况(例如在状态机中)
问题:
我将如何实现此页面控制流MVC3/WF4 应用程序?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们自己正在考虑与您的提案类似的架构。
MVC部分主要是使用Llblgen Pro +自定义ASP.Net模板自动生成的代码,
因此,我们希望从其他地方控制业务逻辑(和页面工作流程)。
我们仍在研究最终决定,WF 4.0 是一个候选者(因为创建可重用活动库非常容易),但无状态状态机似乎是一种非常简单的方法并且更易于维护。
我们已经有了一个 ORM 生成的持久层,因此,将来随时恢复暂停的工作流程的状态并不是什么大问题。
看看无状态并让我们知道它是否合适。
一个示例解释: http ://blogs.msdn.com/b/nblumhardt/archive/2009/04/16/state-machines-in-domain-models.aspx
实际VS 2010 代码示例:https://github.com/haf/Stateless
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
我探索了这个想法。在我看来,只有当您的流程需要很长时间(例如几天)时,Workflow Foundation 才值得。
否则,您会发现编写某种自定义代码(如状态机)比尝试合并 Workflow Foundation 更容易。
但是,如果您正在寻找示例,这里有一个:
http://code.msdn.microsoft.com/Windows-Workflow-233b5e3c/sourcecode?fileId=22211&pathId=1790082120
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