public bool Invoke(IMessage obj) { EventSessionInfo sessionInfo = obj as EventSessionInfo; bool br = false; if (sessionInfo == null) { return(false); } try { MessageInfo messageInfo = sessionInfo.ChatTranscript.ChatEventList.GetAsMessageInfo( sessionInfo.ChatTranscript.ChatEventList.Count - 1); if (messageInfo != null) { br = true; } } catch (Exception ex) { ChatLog.GetInstance().LogException(ex); } return(br); }
// 聊天事件 protected void ChatEventsHandler(IMessage response) { switch (response.Id) { case EventSessionInfo.MessageId: { EventSessionInfo info = (EventSessionInfo)response; this.RoomID = info.ChatTranscript.SessionId; if (this.Room != null) { this.Room.RoomID = this.RoomID; } foreach (var item in info.ChatTranscript.ChatEventList) { try { var StartAt = info.ChatTranscript.StartAt; AddMessage(item, StartAt); } catch (Exception ex) { ChatLog.GetInstance().LogException(ex); } } } break; } }
public bool Invoke(IMessage obj) { EventSessionInfo sessionInfo = obj as EventSessionInfo; bool br = false; if (sessionInfo == null) { return(false); } NoticeInfo noticeInfo = sessionInfo.ChatTranscript.ChatEventList.GetAsNoticeInfo( sessionInfo.ChatTranscript.ChatEventList.Count - 1); if (noticeInfo != null) { br = true; } return(br); }
/// <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()); } }
/// <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; Settings.ChatProxyClientId = _eventInvite.ProxyClientId; IXNCustomData ixnData = new IXNCustomData(); ixnData.InteractionId = _eventInvite.Interaction.InteractionId; ixnData.InteractionEvent = _eventInvite; if (!_chatIXNCollection.ContainsKey(_eventInvite.Interaction.InteractionId)) { _chatIXNCollection.Add(_eventInvite.Interaction.InteractionId, _eventInvite); } GetChatData(_eventInvite.Interaction.InteractionId, ixnData); if (_eventInvite.Interaction.InteractionType == "Inbound") { if (_eventInvite.VisibilityMode.ToString() != "Coach" && _eventInvite.VisibilityMode.ToString() != "Conference") { ChatInvite.GetInstance().PopupRecords(ixnData, SFDCCallType.InboundChat); } else { ChatInvite.GetInstance().PopupRecords(ixnData, SFDCCallType.ConsultChatReceived); } } else if (_eventInvite.Interaction.InteractionType == "Consult") { ChatInvite.GetInstance().PopupRecords(ixnData, SFDCCallType.ConsultChatReceived); } break; case EventSessionInfo.MessageId: _sessionInfo = (EventSessionInfo)events; try { if (Settings.SFDCOptions.ChatAttachActivityId && Settings.SFDCListener.ChatActivityIdCollection.Keys.Contains(_sessionInfo.ChatTranscript.SessionId.ToString()) && _sessionInfo.SessionStatus == SessionStatus.Alive) { Settings.SFDCListener.SetAttachedData(_sessionInfo.ChatTranscript.SessionId.ToString(), Settings.SFDCOptions.ChatAttachActivityIdKeyname, Settings.SFDCListener.ChatActivityIdCollection[_sessionInfo.ChatTranscript.SessionId.ToString()], Settings.ChatProxyClientId); Settings.SFDCListener.ChatActivityIdCollection.Remove(_sessionInfo.ChatTranscript.SessionId.ToString()); } if (_lastSessionId != _eventInvite.Interaction.InteractionId) { _lastSessionId = _eventInvite.Interaction.InteractionId; if (!_callDurationData.ContainsKey(_eventInvite.Interaction.InteractionId)) { _callDurationData.Add(_eventInvite.Interaction.InteractionId, System.DateTime.Now); } } 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; } } } } 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()); } }