Пример #1
0
        public OutboundCallQueueListModel GetOutboundCallQueue([FromUri] OutboundCallQueueFilter filter)
        {
            int  totalRecords;
            var  callQueue  = _callQueueRepository.GetById(filter.CallQueueId);
            var  criteria   = _systemGeneratedCallQueueCritairaService.GetSystemGeneratedCallQueueCriteria(filter.CallQueueId, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId);
            long criteriaId = criteria != null ? criteria.Id : 0;
            OutboundCallQueueListModel model = null;

            if (callQueue.Category == CallQueueCategory.Upsell || callQueue.Category == CallQueueCategory.Confirmation)
            {
                if (criteria != null && criteria.IsQueueGenerated == false)
                {
                    model = new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = false
                    };
                    totalRecords = 0;
                }
                else
                {
                    model = _outboundCallQueueService.GetOutboundCallQueueUpsellAndConfirmation(filter, callQueue, PageSize, criteriaId, out totalRecords) ??
                            new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = true
                    };
                }
            }
            else
            {
                if (criteria != null && criteria.IsQueueGenerated == false)
                {
                    model = new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = false
                    };
                    totalRecords = 0;
                }
                else
                {
                    model = _outboundCallQueueService.GetOutboundCallQueueListModel(filter, callQueue, PageSize, criteriaId, out totalRecords) ?? new OutboundCallQueueListModel()
                    {
                        IsQueueGenerated = true
                    };
                }
            }

            model.PagingModel = new PagingModel(filter.PageNumber, PageSize, totalRecords, null);

            return(model);
        }
Пример #2
0
        public void GenerateUpsellCallqueue_Tester()
        {
            var upsellId  = 140;
            var criterias = _systemGeneratedCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteria(upsellId);

            criterias = criterias.Where(x => x.IsQueueGenerated == false);
            foreach (var criteria in criterias)
            {
                _systemGeneratedCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id);
                var callQueueCustomers = _upsellCallQueueService.GetCallQueueCustomers(upsellId, criteria.Amount, criteria.NoOfDays);
                if (callQueueCustomers != null && callQueueCustomers.Any())
                {
                    _callQueueCustomerHelper.SaveCallQueueCustomerForFillEvent(callQueueCustomers, criteria.Id);
                }

                criteria.IsQueueGenerated       = true;
                criteria.LastQueueGeneratedDate = DateTime.Now;
                _systemGeneratedCallQueueCriteriaService.Save(criteria);
            }
        }
        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));
            }
        }