Please Help! Communication from App to Workflow and visa versa  
Author Message
oafc0000





PostPosted: Windows Workflow Foundation, Please Help! Communication from App to Workflow and visa versa Top

Hi All

I have been playing with Workflow for a while now and im still struggle with a major part of it all, communication between the host and the workflow.

Most the examples I find wont load properly (they seem to be aimed at the beta version). I have built some simple workflows that do stuff like this.

1, Work flow is started up and parameters passed across.

2, Workflow runs, does some tasks (sends emails, writes to database). Application sits there minding its own business.

3, Workflow waits for user action before starting second phase.

4, User kicks off second phase of the workflow. Button on form calls the even that the workflow needs to carry on.

5, Workflow runs and does more tasks.

6, Workflow finishes and i capture this in the application.

What I want to do Is when the workflow finishes the first phase and waits for the next event for there to be some communication that is has finished stage one and requires the user take some action. I have tried using CallExternalMethod but whats the code I need to put into the application to handle that event fireing

I hope this makes sense and any help would be great!! Im at my wits end with it all :(

Thanks



Software Development for Windows Vista13  
 
 
kushals





PostPosted: Windows Workflow Foundation, Please Help! Communication from App to Workflow and visa versa Top

Basically in your case it would be a method(the one configured for the activity) which would be executed as a part of executing the activity.

In this method you can then fire another event for your user(If it is a Console App - Saying - "The WF is in this particular state - Fire the necessary event").

In a WIndows Forms App or as ASP.NET app you will have to use some form of polling where CallExternalMethod raises some flag and the windows app or the ASP.NET page looks at that flag after particular intervals to know that the WF instance is in this state. OTherwise ofcourse you can use AJAX - to fire events from the server side to the client!!!

Hope this helps.

Thanks,

Kushall



 
 
Axel.C





PostPosted: Windows Workflow Foundation, Please Help! Communication from App to Workflow and visa versa Top

Hi, I face the same pb, but I want that my method who is called by CallExternalMethod raise an event for the upper layer, this would preserve the low coupling between layers,

Here is my code :

The method that is called by the CallExternalMethod activity which is part of ExternalDataExchange Implementation

public void CalculationResult(int result)

{

if (ResultSubmited != null)

ResultSubmited(this, new ResultSubmitedEventArg(result));

}

Here is the code that bind the event thrown me the external method

public void Add(int a, int b)

{

_myServ = this.Services.Get<IWorkflowService>();

_WorkFlowId = _myServ.StartWorkflow(typeof(CABWorkflows.Workflow1));

CalcExternalDataExchange ex = _myServ.GetExchangeService<CalcExternalDataExchange>();

ex.ResultSubmited += new EventHandler<ResultSubmitedEventArg>(ex_ResultSubmited); // this line make the exception to be thrown

ex.RaiseSubmitCalculation(a, b, 3, _WorkFlowId); //Other event that work fine

}

But as soon has I bind the event in the upper layer it throw an Exception that say that my upper classes are not Serialisable

How can I throw a custom event from the CallExternalMethode methode

Thx

Axel