Ejemplo n.º 1
0
        /// <summary>
        /// Accepts the chat 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 static Pointel.Interactions.Chat.Core.General.OutputValues AcceptChatInteraction(int ticketID, string interactionID, int proxyID)
        {
            Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID");
            Pointel.Interactions.Chat.Core.General.OutputValues output = Pointel.Interactions.Chat.Core.General.OutputValues.GetInstance();
            try
            {
                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionDelivery.RequestAccept requestAccept = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionDelivery.RequestAccept.Create();
                requestAccept.TicketId      = ticketID;
                requestAccept.InteractionId = interactionID;
                requestAccept.ProxyClientId = Convert.ToInt32(proxyID);
                //added 27-02-2015
                requestAccept.InitialInFocusState = true;
                //end
                if (Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol != null && Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.State == Genesyslab.Platform.Commons.Protocols.ChannelState.Opened)
                {
                    Genesyslab.Platform.Commons.Protocols.IMessage message = Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.Request(requestAccept);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck.MessageId:
                            Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck eventAck = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck)message;
                            logger.Info("------------Accepted  Chat 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 Chat Interaction Successful";
                            break;

                        case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError.MessageId:
                            Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError eventError = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError)message;
                            logger.Info("------------Error on Chat 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     = "Chat Media Agent Not Ready UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("AcceptChatInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Accept the chat request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
        /// <summary>
        /// Transfers the chat session.
        /// </summary>
        /// <param name="interactionId">The interaction identifier.</param>
        /// <param name="agentId">The agent identifier.</param>
        /// <param name="placeId">The place identifier.</param>
        /// <param name="proxyId">The proxy identifier.</param>
        /// <param name="queueName">Name of the queue.</param>
        /// <returns></returns>
        public static Pointel.Interactions.Chat.Core.General.OutputValues TransferChatSession(string interactionId, string agentId, string placeId, int proxyId, string queueName, Genesyslab.Platform.Commons.Collections.KeyValueCollection userData)
        {
            Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID");
            Pointel.Interactions.Chat.Core.General.OutputValues output = Pointel.Interactions.Chat.Core.General.OutputValues.GetInstance();
            try
            {
                if (!string.IsNullOrEmpty(placeId) && !string.IsNullOrEmpty(agentId))
                {
                    Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestTransfer requestTransfer = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestTransfer.Create();
                    requestTransfer.Extension     = userData;
                    requestTransfer.InteractionId = interactionId;
                    requestTransfer.ProxyClientId = proxyId;
                    requestTransfer.PlaceId       = placeId;
                    requestTransfer.AgentId       = agentId;
                    if (Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol != null && Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.State == Genesyslab.Platform.Commons.Protocols.ChannelState.Opened)
                    {
                        Genesyslab.Platform.Commons.Protocols.IMessage message = Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.Request(requestTransfer);
                        if (message != null)
                        {
                            switch (message.Id)
                            {
                            case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck.MessageId:
                                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck eventack = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck)message;
                                logger.Info("------------TransferChatSession-------------");
                                logger.Info("InteractionId  :" + interactionId);
                                logger.Info("ProxyClientId    :" + proxyId);
                                logger.Info("AgentId    :" + agentId);
                                logger.Info("PlaceId    :" + placeId);
                                logger.Info("--------------------------------------------");
                                logger.Trace(eventack.ToString());
                                output.MessageCode = "200";
                                output.Message     = "Transfer Chat Session Successful";
                                break;

                            case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError.MessageId:
                                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError eventError = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError)message;
                                string LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                                string LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                                logger.Info("------------TransferChatSession-------------");
                                logger.Error(LoginErrorCode + ":" + LoginErrorDescription);
                                logger.Info("--------------------------------------------");
                                logger.Trace(eventError.ToString());
                                output.MessageCode = "2001";
                                output.Message     = LoginErrorDescription;
                                break;
                            }
                        }
                    }
                    else
                    {
                        logger.Warn("TransferChatSession() : Interaction Server protocol is Null..");
                    }
                }
                else if (!string.IsNullOrEmpty(queueName))
                {
                    Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestChangeProperties requestChangeProperties = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestChangeProperties.Create();
                    Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestPlaceInQueue     requestPlaceInQueue     = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestPlaceInQueue.Create();
                    Genesyslab.Platform.Commons.Collections.KeyValueCollection attachData = new Genesyslab.Platform.Commons.Collections.KeyValueCollection();
                    attachData.Add("ChatSkills", queueName);
                    requestChangeProperties.ChangedProperties = attachData;
                    requestChangeProperties.InteractionId     = interactionId;
                    requestChangeProperties.ProxyClientId     = proxyId;
                    requestPlaceInQueue.InteractionId         = interactionId;
                    requestPlaceInQueue.Queue           = queueName;
                    requestPlaceInQueue.ProxyClientId   = proxyId;
                    requestPlaceInQueue.AddedProperties = attachData;

                    if (Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol != null && Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.State == Genesyslab.Platform.Commons.Protocols.ChannelState.Opened)
                    {
                        Genesyslab.Platform.Commons.Protocols.IMessage message = Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.Request(requestPlaceInQueue);
                        if (message != null)
                        {
                            switch (message.Id)
                            {
                            case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck.MessageId:
                                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck eventAck = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck)message;
                                logger.Info("------------Chat Transfer Interaction By Queue-------------");
                                logger.Info("InteractionId  :" + interactionId);
                                logger.Info("ProxyClientId    :" + proxyId);
                                logger.Info("QueueName    :" + queueName);
                                logger.Info("----------------------------------------------------------");
                                logger.Trace(eventAck.ToString());
                                output.MessageCode = "200";
                                output.Message     = "Chat Transfer interaction Successful";
                                break;

                            case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError.MessageId:
                                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError eventError = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError)message;
                                logger.Info("------------Error on Chat Transfer Interaction By Queue-------------");
                                logger.Info("InteractionId  :" + interactionId);
                                logger.Info("ProxyClientId    :" + proxyId);
                                logger.Info("QueueName    :" + queueName);
                                logger.Info("-------------------------------------------------------------------");
                                logger.Trace(eventError.ToString());
                                output.MessageCode = "2001";
                                output.Message     = Convert.ToString(eventError.ErrorDescription);
                                logger.Error("Error occurred while chat transferring  interaction : " + Convert.ToString(eventError.ErrorDescription));
                                break;
                            }
                        }
                        else
                        {
                            output.MessageCode = "2001";
                            output.Message     = "Chat Transfer Interaction UnSuccessful";
                        }
                        logger.Info("------------TransferChatSession-------------");
                        logger.Info("InteractionId  :" + interactionId);
                        logger.Info("ProxyClientId    :" + proxyId);
                        logger.Info("QueueName    :" + queueName);
                        logger.Info("--------------------------------------------");
                        logger.Info(requestChangeProperties.ToString());
                        logger.Info(requestPlaceInQueue.ToString());
                    }
                    else
                    {
                        logger.Warn("TransferChatSession() : Interaction Server protocol is Null..");
                    }
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Transfer Chat Session request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
        /// <summary>
        /// Rejects the chat 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 static Pointel.Interactions.Chat.Core.General.OutputValues RejectChatInteraction(int ticketID, string interactionID, int proxyID, Genesyslab.Platform.Commons.Collections.KeyValueCollection data)
        {
            Pointel.Interactions.Chat.Core.General.OutputValues output = Pointel.Interactions.Chat.Core.General.OutputValues.GetInstance();
            Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID");
            try
            {
                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionDelivery.RequestReject requestReject = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionDelivery.RequestReject.Create();
                requestReject.TicketId      = ticketID;
                requestReject.InteractionId = interactionID;
                requestReject.ProxyClientId = proxyID;
                requestReject.Extension     = data;
                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.ReasonInfo reasonInfo = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.ReasonInfo.Create();
                reasonInfo.ReasonDescription = "Agent has reject this interaction";
                requestReject.Reason         = reasonInfo;
                if (Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol != null && Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.State == Genesyslab.Platform.Commons.Protocols.ChannelState.Opened)
                {
                    Genesyslab.Platform.Commons.Protocols.IMessage message = Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.Request(requestReject);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck.MessageId:
                            Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck eventInteractionReject = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck)message;
                            logger.Info("------------RejectChatInteraction-------------");
                            logger.Info("InteractionId  :" + interactionID);
                            logger.Info("ProxyClientId    :" + proxyID);
                            logger.Info("---------------------------------------------");
                            logger.Trace(eventInteractionReject.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Reject Chat Interaction Successful";
                            break;

                        case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError.MessageId:
                            Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError eventError = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError)message;
                            string LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = "RejectChatInteraction() : " + LoginErrorDescription;
                            break;
                        }
                    }
                    else
                    {
                        output.MessageCode = "2001";
                        output.Message     = "Chat Media Agent Reject Interaction UnSuccessful";
                    }
                }
                else
                {
                    logger.Warn("RejectChatInteraction() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Reject Chat Interaction request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }
        /// <summary>
        /// Consults the chat session.
        /// </summary>
        /// <param name="interactionId">The interaction unique identifier.</param>
        /// <param name="agentID">The agent unique identifier.</param>
        /// <param name="placeId">The place unique identifier.</param>
        /// <param name="proxyId">The proxy unique identifier.</param>
        /// <param name="userData">The user data.</param>
        /// <returns></returns>
        public static Pointel.Interactions.Chat.Core.General.OutputValues ConsultChatSession(string interactionId, string agentID, string placeId, int proxyId, Genesyslab.Platform.Commons.Collections.KeyValueCollection userData)
        {
            Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID");
            Pointel.Interactions.Chat.Core.General.OutputValues output = Pointel.Interactions.Chat.Core.General.OutputValues.GetInstance();
            try
            {
                Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestConference requestConference = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Requests.InteractionManagement.RequestConference.Create();
                requestConference.PlaceId       = placeId;
                requestConference.AgentId       = agentID;
                requestConference.InteractionId = interactionId;
                requestConference.ProxyClientId = proxyId;
                requestConference.Extension     = userData;
                requestConference.Extension.Add("ConsultUserData", "separate");
                requestConference.VisibilityMode = Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.VisibilityMode.Coach;
                if (Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol != null && Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.State == Genesyslab.Platform.Commons.Protocols.ChannelState.Opened)
                {
                    Genesyslab.Platform.Commons.Protocols.IMessage message = Pointel.Interactions.Chat.Core.Util.Settings.IxnServerProtocol.Request(requestConference);
                    if (message != null)
                    {
                        switch (message.Id)
                        {
                        case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck.MessageId:
                            Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck eventack = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventAck)message;
                            logger.Info("------------ConsultChatSession-------------");
                            logger.Info("InteractionId  :" + interactionId);
                            logger.Info("ProxyClientId    :" + proxyId);
                            logger.Info("AgentId    :" + agentID);
                            logger.Info("PlaceId    :" + placeId);
                            logger.Info("--------------------------------------------");
                            logger.Trace(eventack.ToString());
                            output.MessageCode = "200";
                            output.Message     = "Consult Chat Session Successful";
                            break;

                        case Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError.MessageId:
                            Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError eventError = (Genesyslab.Platform.OpenMedia.Protocols.InteractionServer.Events.EventError)message;
                            string LoginErrorCode        = Convert.ToString(eventError.ErrorCode);
                            string LoginErrorDescription = Convert.ToString(eventError.ErrorDescription);
                            logger.Info("------------ConsultChatSession-------------");
                            logger.Error(LoginErrorCode + ":" + LoginErrorDescription);
                            logger.Info("--------------------------------------------");
                            logger.Trace(eventError.ToString());
                            output.MessageCode = "2001";
                            output.Message     = LoginErrorDescription;
                            break;
                        }
                    }
                }
                else
                {
                    logger.Warn("ConferenceChatSession() : Interaction Server protocol is Null..");
                }
            }
            catch (Exception generalException)
            {
                logger.Error("Error occurred while Conference Chat Session request " + generalException.ToString());
                output.MessageCode = "2001";
                output.Message     = generalException.Message;
            }
            return(output);
        }