Bonjour tout le monde,
J'ai un petit problème avec CallExternalActivity, celui-ci n'appèlle jamais sa fonction a appeller, il ne fait pas non plus son code invoking car juste avant il passe dans le handlerFault avec l'erreur suivante :
"Could not find service of type 'AnAssembly.IExecuteExternalCode' through the currently configured services. Consider adding the service to ExternalDataExchangeService."
Pourtant juste avant, ainsi que juste après je vérifie que ma classe ExecuteExternalCode se trouve bien dans les service de mon Runtime.
grâce aau code suivant.(et il fonctionne).
vous pouvez voir le design de mon Workflow ici :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 WorkflowRuntimeManager a = new WorkflowRuntimeManager(); IExecuteExternalCode b = (IExecuteExternalCode)(a.Runtime.GetService<ExternalDataExchangeService>().GetService(typeof(AnAssembly.ExecuteExternalCode))); b.execute(10, new AutomationQuery());
http://lh3.ggpht.com/TKanos/SH9qIZqq...JPG?imgmax=576
J'instancie mon Runtime ainsi :
Dans un autre fonction j'instancie le ManualWorkflowSchedulerService.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 public WorkflowRuntime Runtime { get { if (_workflowRuntime == null) { ExternalDataExchangeService edes = new ExternalDataExchangeService(); messagingService.ResultReceived += new EventHandler<WorkflowRuntimeMessagingService.MessageResultEventArgs>(OnMessageResultReceived); _workflowRuntime = new WorkflowRuntime("WorkflowRuntime"); _workflowRuntime.AddService(edes); edes.AddService(new AnAssembly.ExecuteExternalCode()); _workflowRuntime.StartRuntime(); this.AddWorkflowRuntimeAssembly(Assembly.GetExecutingAssembly()); } return _workflowRuntime; } }
Mon Interface :
Mon Code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 [ExternalDataExchange] [CorrelationParameter("id")] public interface IExecuteExternalCode { [CorrelationAlias("id", "e.Id")] event EventHandler<ExecuteExternalCodeEventArgs> ExternalCodeExtecutedComplete; [CorrelationInitializer] void Execute(string id, AutomationQuery request); }
Quand j'execute le WF, j'arrive dans le Replicator qui appelle l'evenement
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 public class ExecuteExternalCode : IExecuteExternalCode { #region IExecuteExternalCode Members public event EventHandler<ExecuteExternalCodeEventArgs> ExternalCodeExtecutedComplete; public void Execute(string id, AutomationQuery request) { // I NEVER ENTER IN THIS FUNCTION ThreadPool.QueueUserWorkItem(Execute, new ExecuteArgs(WorkflowEnvironment.WorkflowInstanceId, id, request)); } #endregion private void Execute(object state) { } //..... }
Replicator_ChildInitialized et juste après au lieu de rentrer dans le CallExternalMethod StartRun, il fait une erreur et va dans HandlerFault.
Tout les objet que j'utrilise sont instancier.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 private void StartRun_MethodInvoking(object sender, EventArgs e) { Console.WriteLine("NEVER the second"); } private void Replicator_ChildInitialized(object sender, ReplicatorChildEventArgs e) { Console.WriteLine("First"); } #endregion protected override ActivityExecutionStatus HandleFault(ActivityExecutionContext executionContext, Exception exception) { Console.WriteLine("Second"); ///////////////////////////////////////////////////////////////// // I Do this code to see if my class are in the Runtime WorkflowRuntimeManager a = new WorkflowRuntimeManager(); IExecuteExternalCode b = (IExecuteExternalCode)(a.Runtime.GetService<ExternalDataExchangeService>().GetService(typeof(AnAssembly.ExecuteExternalCode))); b.execute(10, new AutomationQuery()); // it works ///////////////////////////////////////////////////////////////// return base.HandleFault(executionContext, exception); //comme exception j'ai : "Could not find service of type 'AnAssembly.IExecuteExternalCode through the currently configured services. Consider adding the service to ExternalDataExchangeService" }
Merci
Partager