简体   繁体   English

加载工作流程实例

[英]Loading a Workflow Instance

Say I have a web application and in one page I need to upload a document. 假设我有一个Web应用程序,并且需要在一页中上传文档。 Then the document get's converted into something else and then the user can see the converted document. 然后将文档转换为其他文档,然后用户可以看到转换后的文档。

I want a workflow that will have 4 states. 我想要一个具有4种状态的工作流程。

  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. 参数是文档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. 到简单的WWF样本/示例站点的任何链接将不胜感激。

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/ 一种方法可以如本文所述: 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. 本质上,您将工作流状态保存到数据库表中(持久性由工作流管理),然后Web应用程序直接从数据库读取状态。 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. 另一种方法可能是使用诸如SqlWorkflowPersistenceService之类的持久性服务将工作流状态持久化到数据库中。 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). 您已使用工作流实例的Load方法获取已加载状态(并已卸载以进行保存)。 However all glue logic of calling these methods would sit in aspx page. 但是,调用这些方法的所有胶合逻辑都位于aspx页面中。 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. 我的方法问题是,您需要执行同步逻辑(如果需要),并且要读取状态信息,必须将其加载到工作流实例中。

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

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