views:

145

answers:

1

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?

A: 

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.

Maurice