Come collegare gli eventi WF4 WorkflowRuntime quando si utilizza un servizio di XAMLX
-
04-10-2019 - |
Domanda
Attualmente sto usando un BehaviorExtensionElement per caricare un ServiceBehavior in cui il metodo ApplyDispatchBehavior è impostato come:
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
WorkflowServiceHost host = serviceHostBase as WorkflowServiceHost;
if (host != null)
{
UnityService.CreateContainer();
host.WorkflowExtensions.Add<IUnityContainer>(delegate { return UnityService.CreateChildContainer(); });
System.Diagnostics.Debug.WriteLine("NotificationService : Adding extension");
WorkflowRuntimeBehavior wfbehavior = serviceDescription.Behaviors.Find<WorkflowRuntimeBehavior>();
WorkflowRuntime runtime = wfbehavior.WorkflowRuntime;
runtime.WorkflowStarted += runtime_WorkflowStarted;
runtime.WorkflowCreated += runtime_WorkflowCreated;
runtime.WorkflowUnloaded += runtime_WorkflowUnloaded;
runtime.WorkflowSuspended += runtime_WorkflowSuspended;
runtime.WorkflowCompleted += runtime_WorkflowCompleted;
runtime.WorkflowAborted += runtime_WorkflowAborted;
runtime.WorkflowTerminated += runtime_WorkflowTerminated;
}
}
Nessuno degli eventi sono attivati, che va solo a dire che il modo in cui sto riferimento l'istanza di esecuzione in questo scenario particolare è sbagliato.
Qualcuno sa di un modo per fare questo? Grazie in anticipo.
Soluzione
Il WorkflowRuntime e WorkflowRuntimeBehavior sono artefatti WF3 ma la tua domanda è etichettato come WF4 quindi presumo che si sta utilizzando WF4.
In WF4 il modo per farlo è quello di utilizzare un TrackingParticipant personalizzato e aggiungendo che alla raccolta WorkflowExtensions del WorkflowServiceHost.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow