开发者

Loading a Workflow Instance

Say I have a web application and in one page I need to upload a document. Then the document get's conve开发者_运维知识库rted into something else and then the user can see the converted document.

I want a workflow that will have 4 states.

  1. New
  2. Uploaded
  3. Converting
  4. Converted

So now the user comes in and creates a document record and uploads the file.

At this point they will need to be taken to a dashboard which tells them the document is being converted. They may log off and come back later.

Once the document is converted they will be allowed to progress to the next step of viewing the document.

I can easily create a workflow that has these states and does all the checking and setting of states depending on flags against the document record.

What I am missing I think, is that if the user logs off and comes back, how do I grab the workflow for that uploaded document and check it's state in the workflow?

All I have is this;

WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowProject1.Workflow1), parms);

instance.Start();

Where params is the document id. When I come back into my application how do I get the workflow instance for this document and check it's current step?

Any links to simple WWF sample/example sites would be greatly appreciated.

Is there in fact a better way of doing this?

Also, once I have the workflow loaded, how can I then check its current step or activity?


One of the way could be as described in this article: http://ajdotnet.wordpress.com/2007/09/30/workflow-instance-state-management/

Essentially, you persist workflow state into a database table (the persistence is managed by the workflow) and web application reads the status from database directly. This is actually simpler approach that I would prefer because state information is available outside workflow instance.

Another approach could be to use persistence service such as SqlWorkflowPersistenceService to persist the workflow state into the database. The persistence is managed by the persistence service and workflow is oblivious of the fact. You have use Load method of workflow instance to get the state loaded (and Unload for saving). However all glue logic of calling these methods would sit in aspx page. My issue with approach is that you have do synchronization logic (if needed) and for reading the state information, you have to load that into a workflow instance.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜