Doogal

Hi

I'm looking to drive a state machine workflow from an ASP.NET site. So if I have for instance a leave request that goes to the user's manager, the manager would have an 'Accept' and 'Reject' button which would send the workflow to two separate states. I can achieve this using the HandleExternalEvent activity but the problem I have with this is I need to define a new interface or new method on an existing interface for each HandleExternalEvent activity. I'd prefer to not have to add code for each possible event that will move the workflow on. Can this be achieved with the standard activities or do I need to develop a custom one And if I do need to develop my own activity can anybody show me an example of something similar




Re: Windows Workflow Foundation Driving a state machine workflow from an external source

Roman Kiss

Doogal,

- have a look at the following solutions:

Fire WorkflowEvents from WCF

Fire WorkflowEvents from Ajax (using the Orcas/B1 for Ajax binding)

The following code snippet shows an example of the inline plumbing between the Ajax driven browser and Workflow via the WCF service. Note, there is no necessary to implement a Workflow LocalService. The event message is sent to the HEEA based on the interface contract by OperationInvoker:

Code Snippet of the service1.svc

<%@ ServiceHost
Language=C#
Debug="true"
Service="ServiceTest1"
Factory="RKiss.WorkflowEventService.ServiceHostActivation,

WorkflowEventService" %>


// netfx3.0
using System.ServiceModel;
using System.Workflow.Activities;

// plumbing
using RKiss.WorkflowEventService;

// application (for test purpose)
using RKiss.WorkflowLibrary;


[ServiceContract]
public class ServiceTest1
{
[WorkflowFireEvent(EventType = typeof(IWorkflowSimpleEvents))]
[OperationContract(IsOneWay = true)]
public void Approve(object sender, ExternalDataEventArgs e) {}
}

Thanks

Roman






Re: Windows Workflow Foundation Driving a state machine workflow from an external source

Doogal

Hi

That looks useful thanks but I'm not sure it's exactly what I need. It looks like I still need to define an event or method on an interface for each event I want to handle Ideally I'd like my workflow to be pure XOML so I don't want to have to add C# plumbing behind the scenes if possible. Is there another way to move the workflow down a particular activity path without using the HandleExternalEvent activity






Re: Windows Workflow Foundation Driving a state machine workflow from an external source

Roman Kiss

Doogal,

The host application communicates with workflow via messaging based on the interface contract. The event driven activity implements interfaces such as IEventActivity and IActivityEventListener<QueueEventArgs> for handling an incoming message from the workflow queue. The name of the workflow queue is unique based on the interface contract with option of the correlation parameters. There are only two activities to receive an event message out of the box in the current version of the WF such as HEE and WebServiceInputActivity (note the Orcas/B1 added one more - ReceiveActivity).

Note, the event driven activity requires only metadata of the interface contract, not its implementation. This contract represents a plumbing between the host application and workflow.

The WF has built-in the tightly coupled communication layer (ExternalDataExchangeService ) to enable raising the event from the host application layer using the event/delegate pattern. This layer requires building a custom implementation based on the specific event.

Another option (like I pointed in this thread) is using a loosely coupled connectivity to the workflow based on the interface contract and fires an event direct to the workflow queue. Note, the xoml workflow requires only definitions of the interface contract and of course its assembly.

Thanks

Roman






Re: Windows Workflow Foundation Driving a state machine workflow from an external source

Doogal

Hi Roman

As you say none of the activities out of the box provide what I'm after. I've started putting together my own custom activity that implements IEventActivity. All it does is create a workflow queue named after the activity, then when I want to trigger that activity I post a message to its queue and that triggers it. It seems to work and makes life really simple for me, I just need to know the activity name and I don't need an interface at all.

Thanks for all your help.

Doogal