Ejemplo n.º 1
0
        internal static void SendTaskRequestToTaskExecutionNode(List <STaskInfo> staskInfos)
        {
            if (staskInfos.Count() == 0)
            {
                return;
            }

            var channel = new DuplexChannelFactory <ITaskExecutionNode>(
                new InstanceContext(new CallbackHandler()),
                new WSDualHttpBinding(), new EndpointAddress("http://localhost:5283/TaskExecutionNodeService.svc"))
                          .CreateChannel();

            try
            {
                var requestId = Guid.NewGuid().ToString();
                var reqs      = staskInfos.Select(s => AddRequestToTracker(requestId, s, channel)).Where(s => s != null);
                ((IClientChannel)channel).Open();
                channel.Start(reqs.ToList <STask>());
            }
            catch (CommunicationException ex)
            {
                foreach (var stask in staskInfos)
                {
                    HandleClientUpdate(stask.ClientRequest.Id, STaskStatus.Faulted, ex);
                }
            }
        }