Bonjour,
j'ai un StateMachine workflow d'approbation d'une demande de droits.
Cette demande peut avoir les états suivants (ce sont des "State" du workflow) : InProgress, Validated, Cancelled, Processed, etc.
Quand je souhaite par exemple valider une demande, c a d la faire passer de "Inprogress" à "Validated", je déclenche un évènement "eventValidated".
Le problème est que parfois l'eventHandler associé à cet évènement est null.
Quand je crée moi-même la demande sur mon poste, tout se passe bien, quand cette demande a été créée sur un autre poste (on travaille à deux sur ce projet), l'eventHandler est null.
Voici le code associé dans ma classe Service :
public event EventHandler<WrapperEventArgs> eventValidated;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| public bool ValidateDemand(Demand pDemand)
{
Check.ArgumentIsNotNull(pDemand, "demand");
bool eventResult = RaiseEvent(eventValidated, pDemand, pDemand.WorkflowId);
if (eventResult == true)
{
WorkflowResults workflowResults =
WorkflowMediator.Instance.RunWorkflow(pDemand.WorkflowId);
Check.IsNotNull(workflowResults, "Could not harvest workflow results");
VerifyResults(workflowResults, WorkflowStatus.Running);
}
return eventResult;
} |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| private bool RaiseEvent(EventHandler<WrapperEventArgs> ev,
Demand pDemand, Guid instanceId)
{
bool result = true;
try
{
if (ev != null)
{
WrapperEventArgs e = new WrapperEventArgs(instanceId, pDemand);
ev(null, e);
}
else
result = false;
}
catch (EventDeliveryFailedException)
{
result = false;
}
return result;
} |
Donc c'est le "ev" (= EventHandler<WrapperEventArgs> eventValidated), paramètre de la dernière méthode "RaiseEvent" qui est parfois null.
Une idée d'où pourrait venir ce problème ?
Merci,
Partager