捕获 ASP.NET 站点上工作流的 Web 表单事件
基本想法是我有一个网站和一个工作流程。 我需要在工作流程中捕获来自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在为每个用户会话运行一个工作流程。 如果是这样,您需要将工作流实例 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.