ASPNET 的工作流程 4:并发和状态检查

发布于 2024-10-23 16:00:29 字数 872 浏览 5 评论 0原文

我正在尝试对请求提交/批准/完成场景进行建模。我正在使用 WorkflowServiceHost 作为控制台应用程序中的服务托管的流程图工作流。该工作流具有对 IIS 中托管的 WCF 服务的服务引用,该第二个服务与应用程序数据库进行交互。我有一个 aspnet 前端,其中包含对托管工作流服务的服务引用,并从代理客户端调用其方法。

该工作流程使用我使用提供的脚本创建的持久性数据库。

该场景是用户发出服务请求。该请求必须由特定人员批准一次(我在一个分支中使用带有延迟的选择来提醒该人,如果没有决定到达,则另一个分支正在收到决定)。对于某些服务,请求必须经过第二次批准,可由一组批准者中的任何一个来完成。全部批准完成后,请求将转交给不同的人员来完成。

我可以正常工作,但有 3 个问题:

  1. 在 aspnet 主页中,我有一个请求列表,其中包含指向适当批准/完成的页面的链接,并在代理上调用方法,然后它们重定向回来,但因为它都是异步的,所以我必须手动刷新主页即可看到更改的列表。我是否坚持强制页面每 x 秒刷新一次以解决此问题,或者是否有办法使其同步/检查工作流程状态/等待返回消息?只是按下按钮而不知道操作是否成功,交互性不是很好。
  2. 有没有办法在池中的其他人批准请求后阻止某人批准请求?目前,当第二个人按下按钮时,没有任何反应(这很好)。在工作流持久性数据库中,我可以看到阻止书签是下一个活动(大概是由第一个到达那里的人设置的),因此看起来好像第二个接收没有发生。我在 WCF 数据服务中有并发检查代码,但这永远不会触发,因为没有尝试更新数据库。我希望能够警告第二个人,另一个用户先到达那里。
  3. 我的 Web 应用程序中的主页列表是通过查询应用程序数据库构建的,但是是否可以查询工作流程以查找每个项目的状态,并传递项目的 id(我使用 id 作为相关句柄)?这样做是正常的还是人们通常只是查询应用程序数据库?

I'm trying to model a request submission/ approval /completion scenario. I'm using a flowchart workflow hosted as a service in a console app using WorkflowServiceHost. The workflow has a service reference to a WCF Service hosted in IIS this second service interacts with the application database. I have an aspnet front end with a service reference to the hosted workflow service and call its methods from a proxy client.

The workflow is using a persistence database that I have created using the scripts provided.

The scenario is that a request for a service is made by a user. The request must be approved once by a specific person (I'm using a pick with a delay in one branch to remind the person if no decision arrives, the other branch is receive decision). For some services the request must have a second approval which can be done by any one of a pool of approvers. Once approval is all finished the request goes to a different pool of people for completion.

I have it working but 3 questions:

  1. In the aspnet home page I have a list of requests with links to pages to approve/complete as appropriate and call methods on the proxy after which they redirect back but because it's all asynchronous I am having to manually refresh the home page to see the changed list. Am I stuck with forcing the page to refresh itself every x seconds to get around this or is there a way to make it synchronous/check state of workflow/wait for a message back? It's not terribly interactive just hitting a button and not knowing whether the action succeeded or not.
  2. Is there a way to stop someone approving a request just after someone else in the pool has approved it? At the moment nothing happens for the second person when they hit the button (which is good). In the workflow persistence database I can see that the blocking bookmark is the next activity along (presumably set by the person who got there first) so it looks as though the second receive just doesn't happen. I have concurrency checking code in the WCF data service but this never fires because there is no attempt to update the database. I would like to be able to warn the second person that another user got there first.
  3. My homepage list in the web app is built by querying the application database, but is it possible to query the workflow to find the status of each item, passing the item's id (I'm using the id as the correlation handle)? Is it normal to do this or do people usually just query the application database?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦在深巷 2024-10-30 16:00:29
  1. 我想您可以创建一个 Ajax 调用来检查是否发生任何状态更改,并且仅在发生这种情况时刷新页面。
  2. 如果您发送的 WCF 请求不再有效,您应该会收到错误,除非您使用单向消息传递,因为没有消息可以发回错误。请注意,由于 WF4 中的错误,消息可能会在 60 秒后超时。没有真正的方法可以避免该问题,因为您正在检查工作流程状态是否持续,并让用户根据该状态执行操作。即使您查询状态,工作流程也可能已恢复但尚未保存。
  3. 两者都可以工作,但我通常会查询工作流实例存储,因为它最接近实际的工作流状态。
  1. I guess you could create an Ajax call that would check if any state change occurs and only refresh the page when that is the case.
  2. If you send a WCF request for an operation that is no longer valid you should receive an error, unless you are using one way messaging because there is no message to send the error back. Mind you that due to a bug in WF4 the message could be a timeout after 60 seconds. There is no real way to avoid the problem because you are checking the workflow state as persisted and letting the user do an action based on that. Even when you query the state the workflow could have been resumes but not saved yet.
  3. Either can work but I normally query the workflow instance store as that is the closest to the actual workflow state.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文