Beispiel #1
0
        public string GetTwilioStatsForWallboard()
        {
            var stats = new WallboardStats
            {
                QueueStats = new QueueStats(),
                AgentStats = new List<AgentStat>()
            };

            //TODO: Hardcoded until we have more than 1 team
            var queue = _queueService.ResolveByTeamId(6);

            stats.QueueStats.AverageWait = queue.AverageWaitTime.ToString();
            stats.QueueStats.CallCount = queue.Size.ToString();
            stats.QueueStats.AbandonRate = _queueService.GetQueueAbandonRateForDay(queue.Sid);

            var agents = _agentService.GetAgentsForTeamByTeamId("6");
            foreach (var agent in agents)
            {
                //var agentName =
                    //agent.CallsTaken = _agentService.GetCallsTakenByAgentOverPeriod(agent.Id);
            }

            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Serialize(stats);
        }
        public WallboardStats GetWallboardStatsForTeam(string teamId)
        {
            var stats = new WallboardStats()
            {
                QueueStats = new QueueStats(),
                AgentStats = new List<AgentStat>()
            };

            var queue = _queueService.ResolveByTeamId(Convert.ToInt32(teamId));
            var twilioQueue = _queueProvider.GetQueue(queue.Sid);

            if (twilioQueue == null)
                return null;

            stats.QueueStats.AverageWait = twilioQueue.AverageWaitTime.ToString();
            stats.QueueStats.CallCount = twilioQueue.Size.ToString();
            stats.QueueStats.AbandonRate = _queueService.GetQueueAbandonRateForDay(queue.Sid);

            var agents = _agentService.GetAgentsForTeamByTeamId("6");

            foreach (var agent in agents)
            {
                var today = DateTime.Today;
                var tomorrow = today.AddDays(1);
                var clientName = agent.Email.Split('@')[0];
                clientName = clientName.Replace('.', '_');

                var callsTaken = _agentService.GetCallsTakenByAgentOverPeriod(clientName, today, tomorrow);
                var callsDialled = _agentService.GetCallsDialledByAgentOverPeriod(clientName, today, tomorrow);
                stats.AgentStats.Add(new AgentStat
                {
                    AgentIdentifier = agent.Email,
                    AnsweredCalls = Convert.ToInt32(string.IsNullOrEmpty(callsTaken) ? "0" : callsTaken),
                    DialledCalls = Convert.ToInt32(string.IsNullOrEmpty(callsDialled) ? "0" : callsDialled)
                });

            }
            stats.AgentStats = stats.AgentStats.OrderByDescending(l => l.AnsweredCalls).ToList();

            return stats;
        }