捕获 ASP.NET 站点上工作流的 Web 表单事件

发布于 2024-07-18 05:52:55 字数 1346 浏览 3 评论 0原文

基本想法是我有一个网站和一个工作流程。 我需要在工作流程中捕获来自 aspx 页面的按钮点击。

我有一个包含 worflow 项目和网站项目的解决方案,并且 web.config 和 global.asax 已设置为与 WF 一起使用。 还设置了持久性服务。

我创建了一个 StateMachine 工作流程。 有几个状态(StateActivity)包含EventDrivenActivity实例,其中包含HandleExternalEventActivity实例。 为了正确设置后者以便应用程序可以编译,我创建了一个用ExternalDataExchange 属性装饰的接口,并公开了必要的事件。 然后我创建了一个实现该接口的类。

据我所知。 现在我需要将类连接到我的 aspx 页面; 页面上的事件需要触发类中的事件。

我的代码看起来像这样:

<ExternalDataExchange()> _
Public Interface ICatWorkflow
            Property RequestId() As Guid
            ...
            Sub requestInfoEmail()
        ...
        Event onReception(ByVal sender As Object, ByVal e As ExternalDataEventArgs) 
End Interface

Class MyObject
   Implements ICatWorkflow
        Public Property RequestId() As Guid Implements ICatWorkflow.RequestId
            ...
        End Property
        Public Sub requestInfoEmail() Implements ICatWorkflow.onReception
            ...
        End Sub
        Event onReception(ByVal sender As Object, ByVal e As ExternalDataEventArgs)
end class

在我的 form.aspx âge 上,有一个按钮,在 form.aspx.vb 页面上,有一个相应的事件处理程序:

Protected Sub btnReception_Click(ByVal sender As Object, ByVal e As System.EventArgs)             
      Handles btnReception.Click
        ...
End Sub

从这里去哪里?

The basic idea is that I have a website and a workflow. I need to capture button clicks from aspx pages in my workflow.

I have a solution with a worflow project and a website project, and the web.config and global.asax have been set up to work with WF. Persistence services are also set up.

I have created a StateMachine workflow. There are several states (StateActivity) containing EventDrivenActivity instances, inside of which are HandleExternalEventActivity instances. To set up the latter correctly so the application could compile, I created an interface decorated with the ExternalDataExchange attribute, and exposing the necessary events. I then created a class that implemented this interface.

That's as far as I got. Now I need to connect the class to my aspx page; events on the page need to trigger the events in the class.

My code looks something like this:

<ExternalDataExchange()> _
Public Interface ICatWorkflow
            Property RequestId() As Guid
            ...
            Sub requestInfoEmail()
        ...
        Event onReception(ByVal sender As Object, ByVal e As ExternalDataEventArgs) 
End Interface

Class MyObject
   Implements ICatWorkflow
        Public Property RequestId() As Guid Implements ICatWorkflow.RequestId
            ...
        End Property
        Public Sub requestInfoEmail() Implements ICatWorkflow.onReception
            ...
        End Sub
        Event onReception(ByVal sender As Object, ByVal e As ExternalDataEventArgs)
end class

On my form.aspx âge, there is a button, and on form.aspx.vb page, there is a corresponding event handler:

Protected Sub btnReception_Click(ByVal sender As Object, ByVal e As System.EventArgs)             
      Handles btnReception.Click
        ...
End Sub

Where to go from here?

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

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

发布评论

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

评论(1

三寸金莲 2024-07-25 05:52:55

我假设您正在为每个用户会话运行一个工作流程。 如果是这样,您需要将工作流实例 iId 存储在您可以访问的地方。 因此要么将其放入 cookie 中,要么放入 Session 对象中。 我更喜欢 cookie,因为即使会话超时或 AppDomain 被 IIS 回收,它仍然可以工作。

接下来,您需要获取对ExternalDataExchange 服务的引用。 如果您有工作流运行时的引用,那就很容易了。 您所需要的只是workflowRuntime.GetService()。 接下来,您使用该服务来引发将消息发送到您的工作流程的事件。

I presume you are running a workflow per user session. If so you need to store the workflow instanceiId somewhere you can get to it. So either put it in a cookie or in the Session object. I prefer the cookie because it works even when the session times out or the AppDomain is recycled by IIS.

Next you need to get a reference to the ExternalDataExchange service. That is easy if you have a reference to the worklfow runtime. All you need is workflowRuntime.GetService(). Next you use the service to raise the event that sends the message to your workflow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文