Ejemplo n.º 1
0
        public bool Enqueue(ChatSession session)
        {
            // TODO at the moment we are not handling the concept of office hours
            // since the requirements in the document are not clear for this part.
            // Apart from this there is a time constraint. This could easily be added
            // in the future
            if (IsFull())
            {
                return(false);
            }

            queue.AddOrUpdate(session.ChatSessionId, session, (key, oldValue) => session);
            return(true);
        }
Ejemplo n.º 2
0
        public void AssignChatToNextAvailableAgent(ChatSession chatSession)
        {
            var nextJuniorAvailable = team.Values.Where(x => x is JuniorSupportAgent && x.ChatSessionQ.Count() < x.Capacity * 10).OrderBy(m => m.ChatSessionQ.Count()).FirstOrDefault();

            if (nextJuniorAvailable != null)
            {
                nextJuniorAvailable.ChatSessionQ.AddOrUpdate(chatSession.ChatSessionId, chatSession, (key, oldValue) => chatSession);
                sessionAgents.AddOrUpdate(chatSession.ChatSessionId, nextJuniorAvailable.AgentId, (key, oldValue) => nextJuniorAvailable.AgentId);
                logProvider.Trace(MethodBase.GetCurrentMethod().Name, $"Assigned Chat Session ID: {chatSession.ChatSessionId} to Junior Agent ID: {nextJuniorAvailable.AgentId}");
                return;
            }

            var nextMidLevelAvailable = team.Values.Where(x => x is MidLevelSupportAgent && x.ChatSessionQ.Count() < x.Capacity * 10).OrderBy(m => m.ChatSessionQ.Count()).FirstOrDefault();;

            if (nextMidLevelAvailable != null)
            {
                nextMidLevelAvailable.ChatSessionQ.AddOrUpdate(chatSession.ChatSessionId, chatSession, (key, oldValue) => chatSession);
                sessionAgents.AddOrUpdate(chatSession.ChatSessionId, nextMidLevelAvailable.AgentId, (key, oldValue) => nextMidLevelAvailable.AgentId);
                logProvider.Trace(MethodBase.GetCurrentMethod().Name, $"Assigned Chat Session ID: {chatSession.ChatSessionId} to Mid Level Agent ID: {nextMidLevelAvailable.AgentId}");
                return;
            }

            var nextSeniorAvailable = team.Values.Where(x => x is SeniorSupportAgent && x.ChatSessionQ.Count() < x.Capacity * 10).OrderBy(m => m.ChatSessionQ.Count()).FirstOrDefault();;

            if (nextSeniorAvailable != null)
            {
                nextSeniorAvailable.ChatSessionQ.AddOrUpdate(chatSession.ChatSessionId, chatSession, (key, oldValue) => chatSession);
                sessionAgents.AddOrUpdate(chatSession.ChatSessionId, nextSeniorAvailable.AgentId, (key, oldValue) => nextSeniorAvailable.AgentId);
                logProvider.Trace(MethodBase.GetCurrentMethod().Name, $"Assigned Chat Session ID: {chatSession.ChatSessionId} to Senior Agent ID: {nextSeniorAvailable.AgentId}");
                return;
            }

            var nextTeamLeadAvailable = team.Values.Where(x => x is TeamLeadSupportAgent && x.ChatSessionQ.Count() < x.Capacity * 10).OrderBy(m => m.ChatSessionQ.Count()).FirstOrDefault();;

            if (nextTeamLeadAvailable != null)
            {
                nextTeamLeadAvailable.ChatSessionQ.AddOrUpdate(chatSession.ChatSessionId, chatSession, (key, oldValue) => chatSession);
                sessionAgents.AddOrUpdate(chatSession.ChatSessionId, nextTeamLeadAvailable.AgentId, (key, oldValue) => nextTeamLeadAvailable.AgentId);
                logProvider.Trace(MethodBase.GetCurrentMethod().Name, $"Assigned Chat Session ID: {chatSession.ChatSessionId} to Team Lead Agent ID: {nextTeamLeadAvailable.AgentId}");
                return;
            }
        }