简体   繁体   English

在Workflow Foundation 4.5中的持久性

[英]Persistence in Workflow Foundation 4.5

How can I use a persistent workflow instance in an ASP.NET MVC 5 app? 如何在ASP.NET MVC 5应用程序中使用持久性工作流实例? (Things like accessing ViewBag or choosing a View or AJAXing comes to mind). (诸如访问ViewBag或选择View或AJAXing之类的想法)。

Notes: I tried two books (full of errors with code samples that does not work; so gave up after some chapters) and a dozen of online materials (blog posts, etc) and yet far from being satisfied by what I got of this WF thing. 注意:我尝试了两本书(充满了代码示例的错误,导致无法正常工作;因此在几章之后就放弃了)和十二本在线资料(博客文章等),但我对这本WF的知识并不满意事情。 Of-course it's far easier without employing persistence; 当然,不采用持久性就容易得多。 but what good is that? 但是那有什么好处?

So I think I am missing an essential piece or maybe the whole picture. 所以我想我缺少了必不可少的部分或整个画面。

We have built Workflow Service that exposes WCF endpoints/contracts that MVC app talks to. 我们已经构建了工作流服务,该服务公开了与MVC应用程序交谈的WCF终结点/合同。 Almost each operation on service contract was mapped to particular MVC widget. 服务合同上的几乎每个操作都映射到特定的MVC小部件。 When I say widget, I mean some form of partial view that would only be visible when specific service operation is available at specific state of state machine. 当我说小部件时,我指的是某种形式的局部视图,只有当特定服务操作在状态机的特定状态下可用时才可见。

Ie "Accept" service/widget is available only when process in Submitted state. 即“接受”服务/小工具仅在进程处于“已提交”状态时可用。 Processes were built to be long-running meaning persistence was used together with timers, etc. but all that required us to use AppFabric integration with IIS. 进程被构建为可以长时间运行,这意味着持久性与计时器等一起使用,但是所有这些都要求我们使用AppFabric与IIS的集成。

That is all out-of-the-box. 这就是开箱即用的。 Problem was how to detect state of the workflow and how to get possible transitions to other states, which would then dictate available widgets on the UI. 问题在于如何检测工作流程的状态以及如何转换为其他状态,这将决定UI上的可用小部件。

For that purpose, we had to build custom logic. 为此,我们必须构建自定义逻辑。

When Workflow is persisted, in default tables generated for persistence, you can find information about available Bookmarks . 当持久化工作流时,在为持久性生成的默认表中,您可以找到有关可用书签的信息。 If service call can trigger state transition, then bookmark has the service/operation name. 如果服务调用可以触发状态转换,则书签具有服务/操作名称。

So we have built custom probing service that would scan persistence tables and return list of bookmarks to MVC app, for specific workflow instance. 因此,我们针对特定的工作流实例构建了自定义的探测服务,该服务将扫描持久性表并将书签列表返回给MVC应用。

Based on that, MVC app would render available widgets. 基于此,MVC应用程序将呈现可用的小部件。

Once the widget is used, service call is made to Workflow Service, state is changed, instance is persisted, new Bookmarks are stored to persistence tables, and we refresh the UI based on those. 使用小部件后,将对Workflow Service进行服务调用,更改状态,保留实例,将新的书签存储到持久性表中,然后我们基于这些刷新UI。

It is completely custom but I was not able to find any proper answer on how to do this without manual table scan. 它是完全自定义的,但是如果没有手动表扫描,我将找不到如何执行此操作的任何正确答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM