开发者

Listing Currently Running Workflows in .Net 4.0

开发者 https://www.devze.com 2023-01-13 12:37 出处:网络
I\'ve got a .Net 4.0 Workflow application hosted in WCF that takes a request to process some information.This information is passed to a secondary system via a web service and returns a bool indicatin

I've got a .Net 4.0 Workflow application hosted in WCF that takes a request to process some information. This information is passed to a secondary system via a web service and returns a bool indicating that its going to process that information.

My workflow then loops, sleeping for 5 minutes and then querying the secondary system to see if processing of the information is complete.

When i开发者_如何转开发ts complete the workflow finishes.

I have this persisting in SQL, and it works perfectly.

My question is how do I retrieve a list of the persisted workflows in such a way that I can tie them back to the original request? I'd like my UI to be able to list the running workflows in a grid with the elapsed time that they've been run.

I've thought about storing the workflow GUID in my primary DB and generating the list that way, but what I'd really like is to be able to reconcile what I think is running, and what the persistant store thinks is running.

I'd also like to be able to select a running workflow and kill it off or completely restart it if the user determines that its gone screwy.


You can promote data from the workflow using the SqlWorkflowInstanceStore. The result is they are stored alongside the workflow data in the InstancesTable using the InstancePromotedPropertiesTable. Using the InstancePromotedProperties view is the easiest way of querying you data.

This blog post will show you the code you need.


Another option, use the WorkflowRuntime GetAllServices(). Then you can loop through each one to pull out the data you need. I would cache the results, given this may be an expensive operation. If you have only 100 or less running workflows, and only a few users on your page, don't bother caching.

This way you don't have to create a DAL or Repo layer. Especially if you are using sql for persistence.

http://msdn.microsoft.com/en-us/library/ms594874(v=vs.100).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消