简体   繁体   中英

Persistence in Workflow Foundation 4.5

How can I use a persistent workflow instance in an ASP.NET MVC 5 app? (Things like accessing ViewBag or choosing a View or AJAXing comes to mind).

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. 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. Almost each operation on service contract was mapped to particular MVC widget. 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.

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.

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.

Based on that, MVC app would render available widgets.

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.

It is completely custom but I was not able to find any proper answer on how to do this without manual table scan.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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