Ejemplo n.º 1
0
        public Message CreatePullRequest(RequestPull request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (request.EnumerationContext == null)
            {
                throw new InvalidOperationException("EnumerationContext must be set in order to call Pull");
            }

            Message pullRequest;

            lock (request)
            {
                pullRequest = Message.CreateMessage(MessageVersion.Soap12WSAddressing10, Constants.WsEnumeration.PullAction, request, new ClientSerializer(typeof(RequestPull)));
            }

            return(pullRequest);
        }
Ejemplo n.º 2
0
        public bool MoveNext()
        {
            lock (this.client)
            {
                if (resultIndex < results.Count)
                {
                    this.current = results[resultIndex++];
                    return(true);
                }
                else
                {
                    ResponsePull response;
                    if (this.context == null)
                    {
                        if (resultIndex > 0)
                        {
                            // case: previous pull returned an invalid context
                            return(false);
                        }
                        RequestEnumeration request = new RequestEnumeration(filter);
                        if (attributes != null)
                        {
                            request.Selection = new List <string>();
                            request.Selection.AddRange(this.attributes);
                        }

                        Message msgRequest  = requestFactory.CreateEnumerationRequest(request);
                        Message msgResponse = client.Enumerate(msgRequest);
                        if (msgResponse.IsFault)
                        {
                            ClientHelper.HandleFault(msgResponse);
                        }

                        response           = responseFactory.CreateEnumerationResponse(msgResponse);
                        this.endOfSequence = response.EndOfSequence != null;
                    }
                    else
                    {
                        if (this.endOfSequence == true)
                        {
                            // case: previous pull returned an end of sequence flag
                            this.current = null;
                            return(false);
                        }

                        RequestPull request = new RequestPull();
                        request.EnumerationContext = this.context;

                        Message msgRequest  = requestFactory.CreatePullRequest(request);
                        Message msgResponse = client.Pull(msgRequest);
                        if (msgResponse.IsFault)
                        {
                            ClientHelper.HandleFault(msgResponse);
                        }

                        response = responseFactory.CreatePullResponse(msgResponse);
                    }

                    if (response == null)
                    {
                        return(false);
                    }

                    resultIndex        = 0;
                    this.results       = resourceFactory.CreateResource(response, false).ConvertAll <RmResource>(x => x as RmResource);
                    this.context       = response.EnumerationContext;
                    this.endOfSequence = response.IsEndOfSequence;

                    if (this.results.Count > 0)
                    {
                        this.current = results[resultIndex++];
                        return(true);
                    }
                    else
                    {
                        this.current = null;
                        return(false);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public OutputValues PullInteraction(int tenantId, int proxyClientId, KeyValueCollection interactionIDs)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestPull requestPull = RequestPull.Create();
                requestPull.ViewId         = "_system_";
                requestPull.TenantId       = tenantId;
                requestPull.ProxyClientId  = proxyClientId;
                requestPull.PullParameters = interactionIDs;


                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestPull);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventPulledInteractions.MessageId:
                            logger.Info("------------Pull Interaction-------------");
                            logger.Info("ViewId  :" + requestPull.ViewId);
                            logger.Info("TenantID  :" + requestPull.TenantId);
                            logger.Info("ProxyClientId  :" + requestPull.ProxyClientId);
                            logger.Info("InteractionIds  :" + requestPull.PullParameters.ToString());
                            logger.Info("----------------------------------------------");
                            output.MessageCode = "200";
                            output.IMessage    = message;
                            output.Message     = "Pull interaction Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Pull Interaction-------------");
                            logger.Info("ViewId  :" + requestPull.ViewId);
                            logger.Info("TenantID  :" + requestPull.TenantId);
                            logger.Info("ProxyClientId  :" + requestPull.ProxyClientId);
                            logger.Info("InteractionIds  :" + requestPull.PullParameters.ToString());
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Error("Error occurred while pull the  interaction : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Pull Interaction UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("TransferInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while pull the interaction" + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }