views:

137

answers:

4

I have two customers that have the same workflow (Create file ->transport file -> wait for response -> send response to internal team); however the implementation of each step is different for each customer. For example, one customer requires a flat file to be sent via SFTP, while the other customer requires an XML file to be sent via FTP.

I'd like to create a sequential workflow, using Microsoft Workflow Foundation (WF) and reuse this workflow for multiple vendors. Each action's call to an external module can use the same interface, but a different concrete implementation.

However, I'm unfamiliar with WF and I'm not sure how to implement this. Can someone point me to the proper way to use this pattern? Will it make a difference whether I choose WF 3.5 or WF 4.0?

Thank you.

A: 

You can create activities that orchestrate the main work and defer implementation details to external objects. Both WF3 and WF4 have a similar mechanism, WorkflowRuntimeService in WF3 and Extensions in WF4, where you can add addons to activities to the runtime environment. In your activity you are passed a context you can use to retrieve the actual extension to use and call it do do the required work.

Maurice
A: 

From what you have described, it's apparent that you are dealing with files of different types (xml, raw, etc). I would write interfaces in this scenario for sure, as you have the same process but with different code details in each case. For example, you have the TransportFile "thing" that either sends using the SFTP port or the FTP. You can specify the port in a constructor or by any other means. "WaitForResponse" can be best implemented by having your "GetResponseActvity" implement the AsynchCodeActivity provided by WF4.0. For each specific task, you might need a helper class for your "general purpose" actvities. The nice thing about WF's is that you can do all of the customization for the differnt customers in the designer by dragging and dropping these activites and configuring them with these helper objects.

Derar
A: 

I'm wondering whether this would be better implemented by having the workflow just invoke a WCF service and the different communication paths would be abstracted into WCF channel classes...

Rich
A: 

You could look at the strategy pattern, where a specific implementation is settable at runtime.

Tim Lovell-Smith