示例#1
0
        //接收
        public void Accept(int ticketId, string interactionId)
        {
            try
            {
                RequestAccept request = RequestAccept.Create(ticketId, interactionId);

                LogRequest(request.ToString());
                protocolManagementService[ISERVER_IDENTIFIER].Send(request);
            }
            catch (Exception e)
            {
                LogException(e);
            }
        }
        public void Execute(int ticketId, string interactionId)
        {
            RequestAccept requestAccept =
                RequestAccept.Create(
                    ticketId,
                    interactionId);

            BaseAction action = new OpenMediaAcceptAction(Protocol);

            action.Request = requestAccept;

            base.CloneSubscription(ref action);

            action.Execute();
        }
        /// <summary>
        /// Accepts the interaction.
        /// </summary>
        /// <param name="ticketID">The ticket identifier.</param>
        /// <param name="interactionID">The interaction identifier.</param>
        /// <param name="proxyID">The proxy identifier.</param>
        /// <returns></returns>
        public OutputValues AcceptInteraction(int ticketID, string interactionID, int proxyID)
        {
            OutputValues output = OutputValues.GetInstance();

            output.Message     = string.Empty;
            output.MessageCode = string.Empty;
            output.ErrorCode   = 0;
            try
            {
                RequestAccept requestAccept = RequestAccept.Create();
                requestAccept.TicketId      = ticketID;
                requestAccept.InteractionId = interactionID;
                requestAccept.ProxyClientId = Convert.ToInt32(proxyID);
                //added 27-02-2015
                requestAccept.InitialInFocusState = true;
                //end
                if (Settings.InteractionProtocol != null && Settings.InteractionProtocol.State == ChannelState.Opened)
                {
                    IMessage message = Settings.InteractionProtocol.Request(requestAccept);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case EventAck.MessageId:
                            EventAck eventAck = (EventAck)message;
                            logger.Info("------------Accepted  Interaction-------------");
                            logger.Info("TicketID  :" + ticketID);
                            logger.Info("InteractionID  :" + interactionID);
                            logger.Info("ProxyID        :" + proxyID);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventAck.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Accept Interaction Successful";
                            break;

                        case EventError.MessageId:
                            EventError eventError = (EventError)message;
                            logger.Info("------------Error on Email Interaction-------------");
                            logger.Info("TicketID  :" + ticketID);
                            logger.Info("InteractionID  :" + interactionID);
                            logger.Info("ProxyID        :" + proxyID);
                            logger.Info("----------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = Convert.ToString(eventError.ErrorDescription);
                            logger.Error("Error occurred while accepting the interaction : " + Convert.ToString(eventError.ErrorDescription));
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Agent Not Ready UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AcceptChatInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Accept the request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
示例#4
0
 public void Accept()
 {
     RequestAccept.Invoke(Value);
 }
示例#5
0
        /// <summary>
        /// Get the serialization format for the response based on the value of the HTTP Accept header.
        ///
        /// If $format is not specified then the format comes from the accept header.
        ///
        /// The order in which a response content-type is chosen is based on the
        /// incoming "Accept" header and the types that the service supports.
        /// According to the HTTP/1.1 Header Field Definitions RFC
        /// (http:///www.w3.org/Protocols/rfc2616/rfc2616-sec14.html), an absence of the
        /// Accept header means that the client accepts all response types.
        ///
        /// Media ranges can be overridden by more specific media ranges, for example:
        /// both application/json and application/atom+xml would override */*.
        ///
        /// Depending on the service configuration application/atom+xml would override application/json
        /// if application/atom+xml if the default serialization format, and application/json would
        /// override application/atom+xml if the default serialization format is application/json.
        ///
        /// A client can also send a media range of the following type: application/*, which can be
        /// substituted for application/atom+xml or application/json depending on the service configuration.
        ///
        /// A. If the default configured serialization format is "application/atom+xml"
        ///
        ///  The formats in order of priority are:
        ///     1. application/atom+xml
        ///     2. application/json
        ///     3. application/* or */* substituted with application/atom+xml
        ///
        ///  Examples (order of accept headers doesn't matter):
        ///     "application/*" -> ATOM+XML
        ///     "application/*,application/JSON" -> JSON
        ///     "application/*,application/ATOM+XML" -> ATOM+XML
        ///     "application/*,application/ATOM+XML,application/JSON" -> ATOM+XML
        ///     "application/JSON" -> JSON
        ///     "application/ATOM+XML" -> ATOM+XML
        ///     "application/JSON,application/ATOM+XML" -> ATOM+XML
        ///
        /// B. If the default configured serialization format is "application/json"
        ///
        ///  The formats in order of priority are:
        ///     1. application/json
        ///     2. application/atom+xml
        ///     3. application/* or */* substituted with application/json
        ///
        ///  Examples (order of accept headers doesn't matter):
        ///     "application/*" -> JSON
        ///     "application/*,application/JSON" -> JSON
        ///     "application/*,application/ATOM+XML" -> ATOM+XML
        ///     "application/*,application/ATOM+XML,application/JSON" -> JSON
        ///     "application/JSON" -> JSON
        ///     "application/ATOM+XML" -> ATOM+XML
        ///     "application/JSON,application/ATOM+XML" -> JSON
        ///
        /// Note: headers from firefox need to be trimmed before we make a comparison.In other words the media range
        /// parameter as specified in the above RFC are ignored.
        /// </summary>
        /// <returns>Response serialization format</returns>
        internal SyncSerializationFormat GetOutputSerializationFormat(SyncSerializationFormat defaultSerializationFormat)
        {
            // Read $format from querystring first
            string formatQueryString = QueryStringCollection[SYNC_FORMAT_QUERYKEY];

            if (!String.IsNullOrEmpty(formatQueryString))
            {
                if (0 == String.Compare(formatQueryString.ToLowerInvariant(), "atom", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(SyncSerializationFormat.ODataAtom);
                }

                if (0 == String.Compare(formatQueryString.ToLowerInvariant(), "json", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(SyncSerializationFormat.ODataJson);
                }
            }
            else if (!String.IsNullOrEmpty(RequestAccept))
            {
                var header =
                    RequestAccept.ToLowerInvariant().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(h => h.Trim());

                SyncSerializationFormat?outputSerializationFormat = null;

                foreach (string headerString in header)
                {
                    // Media range followed by optional semi-column and accept-params ,
                    string[] headerStringParts = headerString.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

                    if (0 == headerStringParts.Length)
                    {
                        continue;
                    }

                    // Is this header application/atom+xml
                    if (headerStringParts[0].Equals(CONTENT_TYPE_APPLICATION_ATOM, StringComparison.OrdinalIgnoreCase))
                    {
                        outputSerializationFormat = SyncSerializationFormat.ODataAtom;
                    }

                    // Is this header application/json
                    if (headerStringParts[0].Equals(CONTENT_TYPE_APPLICATION_JSON, StringComparison.OrdinalIgnoreCase))
                    {
                        outputSerializationFormat = SyncSerializationFormat.ODataJson;
                    }

                    // If the default header has been set explicitly then no need to read other headers
                    if (outputSerializationFormat == defaultSerializationFormat)
                    {
                        break;
                    }

                    // Is this header application/* or */*
                    if ((null == outputSerializationFormat) &&
                        (headerStringParts[0].Equals(CONTENT_TYPE_APPLICATION_ANY) || headerStringParts[0].Equals(CONTENT_TYPE_ANY)))
                    {
                        // Do not exit the loop as this can be overwritten by an explicit json or atnm+xml header
                        outputSerializationFormat = defaultSerializationFormat;
                    }
                }

                if (null == outputSerializationFormat)
                {
                    throw SyncServiceException.CreateNotAcceptable(Strings.UnsupportedAcceptHeaderValue);
                }

                return(outputSerializationFormat.Value);
            }

            // return the default serialization format.
            return(defaultSerializationFormat);
        }