Example #1
0
 /// <summary>
 /// Gets Instance of the class ChatSessionEnded
 /// </summary>
 /// <returns></returns>
 public static ChatSessionEnded GetInstance()
 {
     if (InviteObject == null)
     {
         InviteObject = new ChatSessionEnded();
     }
     return(InviteObject);
 }
Example #2
0
        public void InteractionEventChat(IXNCustomData chatData)
        {
            try
            {
                this._logger.Info("Chat Event Received : " + chatData.EventName);
                switch (chatData.EventName)
                {
                case "InteractionChatAcceptChat":
                    GetChatData(chatData.InteractionId, chatData);
                    ChatSessionConnected.GetInstance().PopupRecords(chatData, SFDCCallType.InboundChat);
                    return;

                case "InteractionChatDeclineChat":
                    GetChatData(chatData.InteractionId, chatData);
                    ChatRejected.GetInstance().UpdateRecords(chatData, chatData.InteractionType);
                    return;

                case "InteractionChatCloseInteraction":

                case "InteractionChatDisconnectChat":

                case "InteractionChatAutoCloseInteraction":

                case "InteractionChatAutoDisconnect":
                    GetChatData(chatData.InteractionId, chatData);
                    ChatSessionEnded.GetInstance().PopupRecords(chatData, chatData.InteractionType);
                    return;

                case "InteractionMarkDone":
                    GetChatData(chatData.InteractionId, chatData);
                    ChatMarkDone.GetInstance().UpdateRecords(chatData, chatData.InteractionType);
                    break;

                default:

                    return;
                }
            }
            catch (Exception generalException)
            {
                this._logger.Error("Error occurred while processing chat event, exception : " + generalException.ToString());
            }
        }
        /// <summary>
        ///  Receives Chat Events
        /// </summary>
        /// <param name="events"></param>
        public void ReceiveChatEvents(IMessage events)
        {
            try
            {
                if (Settings.SFDCOptions.SFDCPopupPages != null)
                {
                    if (events != null)
                    {
                        logger.Info("Agent Chat Event : " + events.Name);
                        switch (events.Id)
                        {
                        case EventInvite.MessageId:
                            eventInvite = (EventInvite)events;
                            if (eventInvite.Interaction.InteractionType == "Inbound")
                            {
                                if (eventInvite.VisibilityMode.ToString() != "Coach" && eventInvite.VisibilityMode.ToString() != "Conference")
                                {
                                    IsConsultReceived = false;
                                    InboundChatInvite.GetInstance().PopupRecords(eventInvite, SFDCCallType.InboundChat);
                                }
                                else
                                {
                                    IsConsultReceived = true;
                                    InboundChatInvite.GetInstance().PopupRecords(eventInvite, SFDCCallType.ConsultChatReceived);
                                }
                            }
                            else if (eventInvite.Interaction.InteractionType == "Consult")
                            {
                                IsConsultReceived = true;
                                InboundChatInvite.GetInstance().PopupRecords(eventInvite, SFDCCallType.ConsultChatReceived);
                            }
                            break;

                        case EventSessionInfo.MessageId:
                            sessionInfo = (EventSessionInfo)events;
                            try
                            {
                                if (LastSessionId != eventInvite.Interaction.InteractionId)
                                {
                                    LastSessionId = eventInvite.Interaction.InteractionId;

                                    if (!ChatIXNCollection.ContainsKey(eventInvite.Interaction.InteractionId))
                                    {
                                        ChatIXNCollection.Add(eventInvite.Interaction.InteractionId, eventInvite);
                                    }

                                    if (!CallDurationData.ContainsKey(eventInvite.Interaction.InteractionId))
                                    {
                                        CallDurationData.Add(eventInvite.Interaction.InteractionId, System.DateTime.Now);
                                    }
                                    ChatSessionConnected.GetInstance().PopupRecords(eventInvite, SFDCCallType.InboundChat);
                                }
                                if (sessionInfo.SessionStatus == SessionStatus.Over)
                                {
                                    if (CallDurationData.ContainsKey(sessionInfo.ChatTranscript.SessionId))
                                    {
                                        TimeSpan ts = System.DateTime.Now.Subtract(CallDurationData[sessionInfo.ChatTranscript.SessionId]);
                                        callDuration = ts.Hours + "Hr " + ts.Minutes + " mins " + ts.Seconds + "secs";
                                        if (!FinishedCallDuration.ContainsKey(sessionInfo.ChatTranscript.SessionId))
                                        {
                                            FinishedCallDuration.Add(sessionInfo.ChatTranscript.SessionId, callDuration);
                                        }
                                        else
                                        {
                                            FinishedCallDuration[sessionInfo.ChatTranscript.SessionId] = callDuration;
                                        }
                                    }
                                    if (IsConsultReceived)
                                    {
                                        ChatSessionEnded.GetInstance().PopupRecords(eventInvite, SFDCCallType.ConsultChatReceived, callDuration, GetChatInteractionContent(sessionInfo.ChatTranscript.SessionId).Replace('&', ' '));
                                    }
                                    else
                                    {
                                        ChatSessionEnded.GetInstance().PopupRecords(eventInvite, SFDCCallType.InboundChat, callDuration, GetChatInteractionContent(sessionInfo.ChatTranscript.SessionId).Replace('&', ' '));
                                    }
                                }
                            }
                            catch (Exception generalException)
                            {
                                this.logger.Error(generalException.ToString());
                            }
                            break;

                        default:
                            logger.Info("Unhandled Event " + events.Name);
                            break;
                        }
                    }
                }
            }
            catch (Exception generalException)
            {
                logger.Error("ReceiveChatEvents : Error occured while receiving Chat events " + generalException.ToString());
            }
        }