示例#1
0
        public void GenerateEasiestCallqueue_Tester()
        {
            var callQueues         = _callQueueRepository.GetAll(false);
            var easy               = callQueues.Where(x => x.Id == 88).First();
            var callQueueCustomers = _easiestToConvertCallQueueService.GetCallQueueCustomers(easy.Id, easy.LastQueueGeneratedDate);

            if (callQueueCustomers != null && callQueueCustomers.Any())
            {
                _callQueueCustomerHelper.SaveCallQueueCustomer(callQueueCustomers);
            }
        }
示例#2
0
        public IEnumerable <CallQueueCategoryViewModel> GetCallQueueCategories()
        {
            var callqueues        = _callQueueRepository.GetAll(false);
            var callQueueCategory = new List <CallQueueCategoryViewModel>();

            if (callqueues != null)
            {
                callQueueCategory.AddRange(callqueues.Select(x => new CallQueueCategoryViewModel {
                    CallQueueId = x.Id, Name = x.Name, Category = x.Category, Description = x.Description
                }).OrderBy(s => s.CallQueueId));
            }

            return(callQueueCategory);
        }
        public IEnumerable <CallQueueCategoryViewModel> GetHealthPlanCallQueueDropDownList()
        {
            var callqueues        = _callQueueRepository.GetAll(false, true);
            var callQueueCategory = new List <CallQueueCategoryViewModel>();

            callQueueCategory.Add(new CallQueueCategoryViewModel
            {
                Name        = "--- Select ---",
                CallQueueId = -1
            });
            if (callqueues != null)
            {
                callQueueCategory.AddRange(callqueues.Select(x => new CallQueueCategoryViewModel {
                    CallQueueId = x.Id, Name = x.Name, Category = x.Category, Description = x.Description
                }).OrderBy(s => s.CallQueueId));
            }

            return(callQueueCategory);
        }
        public ListModelBase <CallSkippedReportViewModel, CallSkippedReportFilter> GetCallSkippedReport(int pageNumber, int pageSize, ModelFilterBase filter, out int totalRecords)
        {
            var callSkippedFilter = filter as CallSkippedReportFilter ?? new CallSkippedReportFilter();
            var model             = (IReadOnlyCollection <CallSkippedReportEditModel>)_customerCallQueueCallAttemptRepository.GetForCallSkippedReport(pageNumber, pageSize, callSkippedFilter, out totalRecords);

            List <long> orgRoleUserIds = model.Select(x => x.CustomerId).ToList();

            orgRoleUserIds.AddRange(model.Select(x => x.AgentId));

            var agentAndCustomerDetailsIdNamePair = (IReadOnlyCollection <OrderedPair <long, string> >)_organizationRoleUserRepository.GetNameIdPairofUsers(orgRoleUserIds.ToArray());
            var callQueues = (IReadOnlyCollection <CallQueue>)_callQueueRepository.GetAll(isManual: false, isHealthPlan: true);
            var accounts   = (IReadOnlyCollection <CorporateAccount>)_corporateAccountRepository.GetAllHealthPlan();

            var collection = _callSkippedReportFactory.Create(agentAndCustomerDetailsIdNamePair, callQueues, accounts, model);

            return(new CallSkippedReportListModel
            {
                Collection = collection,
                Filter = callSkippedFilter
            });
        }
示例#5
0
        public void PollMailRoundCustomersReport()
        {
            try
            {
                _logger.Info("Entering Matrix Report Polling Agent");

                var healthPlans = _corporateAccountRepository.GetAllHealthPlan();
                var callQueues  = _callQueueRepository.GetAll(false, true);

                if (callQueues.IsNullOrEmpty())
                {
                    _logger.Info("No call queue found.");
                    return;
                }
                var mailRoundCallQueue       = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.MailRound);
                var fillEventCallQueue       = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.FillEventsHealthPlan);
                var languageBarrierCallQueue = callQueues.FirstOrDefault(x => x.Category == HealthPlanCallQueueCategory.LanguageBarrier);

                foreach (var healthPlan in healthPlans)
                {
                    try
                    {
                        _logger.Info(string.Format("Generating Matrix Report for accountId {0} and account tag {1}. ", healthPlan.Id, healthPlan.Tag));

                        var destinationPath = _settings.MailRoundCustomersReportDestinantionPath;

                        var filePath = Path.Combine(destinationPath, string.Format(@"MatrixReport_{0}_{1}.csv", healthPlan.Tag, DateTime.Now.ToString("MMddyyyy")));

                        DirectoryOperationsHelper.CreateDirectory(destinationPath);

                        var customers = new List <MailRoundCustomersReportViewModel>();

                        _logger.Info("Fetching customers for fill event call queue");
                        var fillEventCustomers = GetCustomersForMatrixReport(healthPlan.Id, fillEventCallQueue);
                        if (!fillEventCustomers.IsNullOrEmpty())
                        {
                            customers.AddRange(fillEventCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for fill event call queue");
                        }


                        _logger.Info("Fetching customers for mail round call queue");
                        var mailRoundCustomers = GetCustomersForMatrixReport(healthPlan.Id, mailRoundCallQueue);
                        if (!mailRoundCustomers.IsNullOrEmpty())
                        {
                            if (!customers.IsNullOrEmpty())
                            {
                                var existingCustomerIds = customers.Select(c => c.CustomerID);
                                mailRoundCustomers = mailRoundCustomers.Where(x => !existingCustomerIds.Contains(x.CustomerID)).ToList();
                            }
                            customers.AddRange(mailRoundCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for mail round call queue");
                        }


                        _logger.Info("Fetching customers for language barrier call queue");
                        var languageBarrierCustomers = GetCustomersForMatrixReport(healthPlan.Id, languageBarrierCallQueue);
                        if (!languageBarrierCustomers.IsNullOrEmpty())
                        {
                            if (!customers.IsNullOrEmpty())
                            {
                                var existingCustomerIds = customers.Select(c => c.CustomerID);
                                languageBarrierCustomers = languageBarrierCustomers.Where(x => !existingCustomerIds.Contains(x.CustomerID)).ToList();
                            }
                            customers.AddRange(languageBarrierCustomers);
                        }
                        else
                        {
                            _logger.Info("No customers found for language barrier call queue");
                        }


                        if (customers.Any())
                        {
                            var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <MailRoundCustomersReportViewModel>();

                            DirectoryOperationsHelper.DeleteFileIfExist(filePath);

                            _baseExportableReportHelper.GenerateCsv(filePath, exporter, customers);
                            _logger.Error(string.Format("Successfully Matrix Report Generated for AccountId {0} and Account Tag {1}.", healthPlan.Id, healthPlan.Tag));
                        }
                        else
                        {
                            _logger.Error(string.Format("No records found for AccountId {0} and Account Tag {1}. \n\n", healthPlan.Id, healthPlan.Tag));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error(string.Format("Error occured while generating Matrix Report for AccountId {0} and Account Tag {1} : \n Error {2} \n Trace: {3} ", healthPlan.Id, healthPlan.Tag, ex.Message, ex.StackTrace));
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error occured while generating Matrix Report : \n Error {0} \n Trace: {1} ", ex.Message, ex.StackTrace));
            }
        }
示例#6
0
        public void SendCustomersOnCallQueue()
        {
            try
            {
                var callQueues = _callQueueRepository.GetAll().Where(x => x.IsActive && (x.IsQueueGenerated == false || (DateTime.Now >= (x.LastQueueGeneratedDate.HasValue ? x.LastQueueGeneratedDate.Value.AddMinutes(x.QueueGenerationInterval.Value) : DateTime.Now))));

                foreach (CallQueue queue in callQueues)
                {
                    var callAssignMents = _callQueueAssignmentRepository.GetByCallQueueId(queue.Id);

                    _callQueueCustomerRepository.DeleteForInActiveCallQueueCriteria(queue.Id);

                    var customerList = _outboundCallQueueService.GetCallQueueCustomers(queue);

                    //int callsToInsert = customerList.Count > 1000 ? 1000 : customerList.Count;//only this number of calls to be inserted at a time
                    if (!queue.IsQueueGenerated)
                    {
                        //var shortList = customerList.Take(callsToInsert);
                        //customerList = shortList.ToList();
                        _outboundCallQueueService.ChangeAssignmentOfExistingQueue(queue, callAssignMents);
                    }
                    int totalRecords = customerList.Count;

                    //assigning each call centre user with number of customer based on percentage
                    var callDivision = (from ca in callAssignMents
                                        let count = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(totalRecords * ca.Percentage) / 100))
                                                    select new
                    {
                        AssignedTo = ca.AssignedOrgRoleUserId,
                        callCount = count > 0 ? count : 1
                    }).ToList();
                    int startCount = 0;
                    for (int i = 0; i < callDivision.Count; i++)
                    {
                        int endCount = callDivision[i].callCount;

                        int thresholdCount = customerList.Count < (startCount + endCount) ? customerList.Count : (startCount + endCount);

                        for (int j = startCount; j < thresholdCount; j++)
                        {
                            CallQueueCustomer callQueueCustomer = customerList[j];

                            if (_callQueueCustomerRepository.IsCallQueueExist(queue.Id, callQueueCustomer.ProspectCustomerId.HasValue ? callQueueCustomer.ProspectCustomerId.Value : 0, callQueueCustomer.CustomerId.HasValue ? callQueueCustomer.CustomerId.Value : 0, callQueueCustomer.EventId, _settings.NoOfDaysToIncludeRemovedFromQueue))
                            {
                                continue;
                            }

                            callQueueCustomer.CallQueueId = queue.Id;

                            callQueueCustomer.IsActive                = true;
                            callQueueCustomer.Attempts                = 0;
                            callQueueCustomer.DateCreated             = DateTime.Now;
                            callQueueCustomer.Status                  = CallQueueStatus.Initial;
                            callQueueCustomer.AssignedToOrgRoleUserId = callDivision[i].AssignedTo;
                            callQueueCustomer.CallDate                = DateTime.Now;
                            _callQueueCustomerRepository.Save(callQueueCustomer);
                        }
                        //Once the quota for 1 user is complete next user will start from that
                        startCount = startCount + endCount;
                    }

                    queue.IsQueueGenerated       = true;
                    queue.LastQueueGeneratedDate = DateTime.Now;
                    _callQueueRepository.Save(queue);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Message:{0} \nStackTrace: {1}", ex.Message, ex.StackTrace));
            }
        }
        public void PollForCallQueue()
        {
            try
            {
                var callQueues = _callQueueRepository.GetAll(false);
                if (callQueues != null && callQueues.Any())
                {
                    foreach (var callQueue in callQueues)
                    {
                        var criterias = _systemGeneratedCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteria(callQueue.Id);
                        criterias = criterias.Where(x => x.IsQueueGenerated);
                        try
                        {
                            IEnumerable <CallQueueCustomer> callQueueCustomers;
                            switch (callQueue.Category)
                            {
                            case CallQueueCategory.EasiestToConvertProspect:
                                callQueueCustomers = _easiestToConvertCallQueueService.GetCallQueueCustomers(callQueue.Id, callQueue.LastQueueGeneratedDate);
                                if (callQueueCustomers != null && callQueueCustomers.Any())
                                {
                                    _logger.Info(string.Format("{0} call queue customer found for {1}", callQueueCustomers.Count(), callQueue.Category));
                                    _callQueueCustomerHelper.SaveCallQueueCustomer(callQueueCustomers);
                                    _logger.Info(string.Format("{0} call queue customer saved for {1}", callQueueCustomers.Count(), callQueue.Category));
                                }
                                else
                                {
                                    _logger.Info(string.Format("No call queue customer found for {0}", callQueue.Category));
                                }
                                break;

                            case CallQueueCategory.Annual:
                                callQueueCustomers = _annualCallQueueService.GetCallQueueCustomers(callQueue.Id);
                                if (callQueueCustomers != null && callQueueCustomers.Any())
                                {
                                    _logger.Info(string.Format("{0} call queue customer found for {1}", callQueueCustomers.Count(), callQueue.Category));
                                    _callQueueCustomerHelper.SaveCallQueueCustomer(callQueueCustomers);
                                    _logger.Info(string.Format("{0} call queue customer saved for {1}", callQueueCustomers.Count(), callQueue.Category));
                                }
                                else
                                {
                                    _logger.Info(string.Format("No call queue customer found for {0}", callQueue.Category));
                                }
                                break;

                            case CallQueueCategory.CallBack:
                                callQueueCustomers = _callBackCallQueueService.GetCallQueueCustomers(callQueue.Id, callQueue.LastQueueGeneratedDate);
                                if (callQueueCustomers != null && callQueueCustomers.Any())
                                {
                                    _logger.Info(string.Format("{0} call queue customer found for {1}", callQueueCustomers.Count(), callQueue.Category));
                                    _callQueueCustomerHelper.SaveCallQueueCustomerForCallBack(callQueueCustomers);
                                    _logger.Info(string.Format("{0} call queue customer saved for {1}", callQueueCustomers.Count(), callQueue.Category));
                                }
                                else
                                {
                                    _logger.Info(string.Format("No call queue customer found for {0}", callQueue.Category));
                                }
                                break;

                            case CallQueueCategory.FillEvents:
                                foreach (var criteria in criterias)
                                {
                                    _systemGeneratedCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id);
                                    callQueueCustomers = _fillEventsCallQueueService.GetCallQueueCustomers(callQueue.Id, criteria);
                                    if (callQueueCustomers != null && callQueueCustomers.Any())
                                    {
                                        _logger.Info(string.Format("{0} call queue customer found for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId));
                                        _callQueueCustomerHelper.SaveCallQueueCustomerForFillEvent(callQueueCustomers, criteria.Id);
                                        _logger.Info(string.Format("{0} call queue customer saved for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId));
                                    }
                                    else
                                    {
                                        _logger.Info(string.Format("No call queue customer found for {0}", callQueue.Category));
                                    }

                                    criteria.IsQueueGenerated       = true;
                                    criteria.LastQueueGeneratedDate = DateTime.Now;
                                    _systemGeneratedCallQueueCriteriaService.Save(criteria);
                                }
                                break;

                            case CallQueueCategory.Upsell:
                                foreach (var criteria in criterias)
                                {
                                    _systemGeneratedCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id);
                                    callQueueCustomers = _upsellCallQueueService.GetCallQueueCustomers(callQueue.Id, criteria.Amount, criteria.NoOfDays);
                                    if (callQueueCustomers != null && callQueueCustomers.Any())
                                    {
                                        _logger.Info(string.Format("{0} call queue customer found for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId));
                                        _callQueueCustomerHelper.SaveCallQueueCustomerForFillEvent(callQueueCustomers, criteria.Id);
                                        _logger.Info(string.Format("{0} call queue customer saved for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId));
                                    }
                                    else
                                    {
                                        _logger.Info(string.Format("No call queue customer found for {0}", callQueue.Category));
                                    }

                                    criteria.IsQueueGenerated       = true;
                                    criteria.LastQueueGeneratedDate = DateTime.Now;
                                    _systemGeneratedCallQueueCriteriaService.Save(criteria);
                                }

                                break;

                            case CallQueueCategory.Confirmation:
                                foreach (var criteria in criterias)
                                {
                                    _systemGeneratedCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id);
                                    callQueueCustomers = _confirmationCallQueueService.GetCallQueueCustomers(callQueue.Id, criteria.NoOfDays);
                                    if (callQueueCustomers != null && callQueueCustomers.Any())
                                    {
                                        _logger.Info(string.Format("{0} call queue customer found for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId));
                                        _callQueueCustomerHelper.SaveCallQueueCustomerForFillEvent(callQueueCustomers, criteria.Id);
                                        _logger.Info(string.Format("{0} call queue customer saved for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId));
                                    }
                                    else
                                    {
                                        _logger.Info(string.Format("No call queue customer found for {0}", callQueue.Category));
                                    }

                                    criteria.IsQueueGenerated       = true;
                                    criteria.LastQueueGeneratedDate = DateTime.Now;
                                    _systemGeneratedCallQueueCriteriaService.Save(criteria);
                                }
                                break;
                            }

                            callQueue.IsQueueGenerated       = true;
                            callQueue.LastQueueGeneratedDate = DateTime.Now;
                            _callQueueRepository.Save(callQueue);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error(string.Format("Error while creating {0} call queue. Message {1} \n Stack Trace {2}", callQueue.Category, ex.Message, ex.StackTrace));
                        }
                    }
                }
                else
                {
                    _logger.Info("No System generated call queue exist.");
                }
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("Error while pulling System generated call queue. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace));
            }
        }
        public void PollForHealthPlanCallQueue()
        {
            try
            {
                _logger.Info("Entering Health Plan Polling Agent To Generate Call Queue For CallRound, NoShows and ZipRadius");

                var callQueues  = _callQueueRepository.GetAll(false, true);
                var healthPlans = _corporateAccountRepository.GetAllHealthPlan();

                if (!callQueues.IsNullOrEmpty())
                {
                    callQueues = callQueues.Where(x => x.Category != HealthPlanCallQueueCategory.FillEventsHealthPlan && x.Category != HealthPlanCallQueueCategory.UncontactedCustomers &&
                                                  x.Category != HealthPlanCallQueueCategory.MailRound);

                    foreach (var callQueue in callQueues)
                    {
                        try
                        {
                            var criteria = _healthPlanCallQueueCriteria.GetQueueCriteriasByQueueId(callQueue.Id);
                            criteria = criteria.Where(x => x.IsQueueGenerated);

                            switch (callQueue.Category)
                            {
                            case HealthPlanCallQueueCategory.CallRound:
                            {
                                foreach (var queueCriteria in criteria)
                                {
                                    try
                                    {
                                        _healthPlanCallQueueAssignment.DeleteByCriteriaId(queueCriteria.Id);

                                        if (queueCriteria.HealthPlanId.HasValue && !healthPlans.IsNullOrEmpty())
                                        {
                                            var corporateAccount = healthPlans.First(x => x.Id == queueCriteria.HealthPlanId.Value);
                                            _healthPlanCallRoundService.SaveCallRoundCallQueueCustomers(corporateAccount, queueCriteria, callQueue, _logger);
                                        }
                                        queueCriteria.IsQueueGenerated       = true;
                                        queueCriteria.LastQueueGeneratedDate = DateTime.Now;
                                        _healthPlanCallQueueCriteria.Save(queueCriteria);
                                    }
                                    catch (Exception exception)
                                    {
                                        _logger.Error("call Queue Id " + callQueue.Id);
                                        _logger.Error("criteria Id " + queueCriteria.Id);
                                        _logger.Error("Message " + exception.Message);
                                        _logger.Error("Stack Trace " + exception.StackTrace);
                                    }
                                }
                            }
                            break;

                                //case HealthPlanCallQueueCategory.NoShows:
                                //    {
                                //        foreach (var queueCriteria in criteria)
                                //        {
                                //            try
                                //            {
                                //                _healthPlanCallQueueAssignment.DeleteByCriteriaId(queueCriteria.Id);

                                //                if (queueCriteria.HealthPlanId.HasValue && !healthPlans.IsNullOrEmpty())
                                //                {
                                //                    var corporateAccount = healthPlans.First(x => x.Id == queueCriteria.HealthPlanId.Value);
                                //                    _healthPlanCallRoundService.SaveNoShowCallQueueCustomers(corporateAccount, queueCriteria, callQueue, _logger);
                                //                }
                                //                queueCriteria.IsQueueGenerated = true;
                                //                queueCriteria.LastQueueGeneratedDate = DateTime.Now;
                                //                _healthPlanCallQueueCriteria.Save(queueCriteria);
                                //            }
                                //            catch (Exception exception)
                                //            {
                                //                _logger.Error("call Queue Id " + callQueue.Id);
                                //                _logger.Error("criteira Id " + queueCriteria.Id);
                                //                _logger.Error("Message " + exception.Message);
                                //                _logger.Error("Stack Trace " + exception.StackTrace);
                                //            }

                                //        }
                                //    }
                                //    break;
                                //case HealthPlanCallQueueCategory.ZipRadius:
                                //    {
                                //        foreach (var queueCriteria in criteria)
                                //        {
                                //            _healthPlanCallQueueAssignment.DeleteByCriteriaId(queueCriteria.Id);

                                //            if (queueCriteria.IsDefault)
                                //            {
                                //                foreach (var corporateAccount in healthPlans)
                                //                {
                                //                    _healthPlanCallRoundService.SaveHealthPlanZipRadiusCallQueueCustomers(corporateAccount, queueCriteria, callQueue, _logger);
                                //                }
                                //            }
                                //            else if (queueCriteria.HealthPlanId.HasValue && !healthPlans.IsNullOrEmpty())
                                //            {
                                //                var corporateAccount = healthPlans.First(x => x.Id == queueCriteria.HealthPlanId.Value);
                                //                _healthPlanCallRoundService.SaveHealthPlanZipRadiusCallQueueCustomers(corporateAccount, queueCriteria, callQueue, _logger);
                                //            }
                                //            queueCriteria.IsQueueGenerated = true;
                                //            queueCriteria.LastQueueGeneratedDate = DateTime.Now;
                                //            _healthPlanCallQueueCriteria.Save(queueCriteria);
                                //        }
                                //    }
                                //    break;
                            }
                        }
                        catch (Exception exception)
                        {
                            _logger.Error(string.Format("error health plan call queue. callQueueId: {0} ", callQueue.Id));
                            _logger.Error(string.Format("Message {0} stack trace: {1} ", exception.Message, exception.StackTrace));
                        }
                        callQueue.IsQueueGenerated       = true;
                        callQueue.LastQueueGeneratedDate = DateTime.Now;
                        _callQueueRepository.Save(callQueue);
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("error health plan call queue."));
                _logger.Error(string.Format("Message {0} stack trace: {1} ", exception.Message, exception.StackTrace));
            }
        }