CorrelationInitializer question

Hi, I'm new to wwf, and I have the following question,

In all the available application samples I browsed the CorrelationInitializer is always attributed to a method, and not to an event. Is there a reason for this?

The usual is something like:

[ExternalDataExchange]
[CorrelationParameter("nextStage")]
public interface ISMConnector
{
[CorrelationAlias("nextStage", "e.Command")]
event EventHandler<RegEventArgs> OwnerInfoSubmitted;

[CorrelationInitializer()]
void SMSnapshot( string nextStage);
}


I had originally thought of doing something more like:

[CorrelationParameter("WorkflowInstanceId")]
[ExternalDataExchange]
public interface ICaseManagementLocalService
{
[CorrelationInitializer]
[CorrelationAlias("WorkflowInstanceId", "e.Case.WorkflowInstanceId")]
event EventHandler<CaseEventArgs> CaseCreated;

[CorrelationAlias("WorkflowInstanceId", "e.Case.WorkflowInstanceId")]
event EventHandler<CaseEventArgs> CaseUpdated;
}


Is there a problem with defining the CorrelationInitializer as an event? (I'm having problems with this approach).

thanks,
GLR

[1488 byte] By [gabo_uy] at [2007-12-22]
# 1
I've made an event the correlationinitializer - this is definately legal. You don't need the CorrelationAlias attribute on the CaseCreated event. I am not sure about the property of a property syntax howerver (it may work - but I've never done it).
JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 2

Jon,

In your case, were you working with a state machine workflow? was persistence enabled?

thanks,

GLR

gabo_uy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 3

Yes to state machine - dont' remember if I was using persistence.

Are you getting exceptions?

JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 4
Yeah, I'm getting EventDeliveryFailedException: Event "CaseUpdated"....System.InvalidOperationException: Workflow with id "d9c3f57b-2<BR>834-47a7-8403-649cc7bfd175" not found in state persistence store.

This happens when I execute this piece of code to test the wf:

CaseData cd = GetDummyCaseData();
CaseManager manager = new CaseManager();
//raises CaseCreated event
string instanceid = manager.OpenNewCase(caseData);
caseData
.WorkflowInstanceId = instanceid;
caseData.CaseStatus = "Assigned";
caseData.AssignedTo = "technician";
//raises CaseUpdated event
manager.UpdateCase(caseData, "dispatcher");

But I'm not paying much attention to the exception because I know things are already inconsistent before I get the exception.The state machine defined looks like this, and the initial state is something like this.

When I raise the CaseCreated event, I know the handleExternalEventActivity1_Invoked handler gets invoked, because it writes in the EventLog, but the second activity (PersistCaseData, the code activity) never gets executed.

Persistence service is enabled, if I look at the persistence database, each time I run the test code, a new row appears in the WorkflowInstance table. So I guess It's just unloading on idle somewhere, but I don't get why, and why it just doesn't run the code activity and continue to the next state.

Any hint will be appreciated,

thanks,
GLR

gabo_uy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 5
Are you handling the WorkflowRuntime.WorkflowTerminated event? My guess based on that exception is that your workflow is terminated before you are expecting it to.
JonFlanders at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...
# 6
that was it!

THANKS!!

gabo_uy at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Windows Workflow Foundation...

Software Development for Windows Vista

Site Classified