public void PollForCallQueue() { try { _logger.Info("Starting single call queue customer for Upsell"); var callQueue = _callQueueRepository.GetCallQueueByCategory(CallQueueCategory.Upsell); var criterias = _systemGeneratedCallQueueCriteriaService.GetSystemGeneratedCallQueueCriteriaNotGenerated(callQueue.Id); foreach (var criteria in criterias) { _systemGeneratedCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id); var callQueueCustomers = _upsellCallQueueService.GetCallQueueCustomers(callQueue.Id, criteria.Amount, criteria.NoOfDays); if (callQueueCustomers != null && callQueueCustomers.Any()) { _logger.Info(string.Format("{0} single 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} single call queue customer saved for {1} for Agent Id : {2}", callQueueCustomers.Count(), callQueue.Category, criteria.AssignedToOrgRoleUserId)); } else { _logger.Info(string.Format("No single call queue customer found for {0} for Agent Id : {1}", callQueue.Category, criteria.AssignedToOrgRoleUserId)); } criteria.IsQueueGenerated = true; criteria.LastQueueGeneratedDate = DateTime.Now; _systemGeneratedCallQueueCriteriaService.Save(criteria); } callQueue.IsQueueGenerated = true; callQueue.LastQueueGeneratedDate = DateTime.Now; _callQueueRepository.Save(callQueue); } catch (Exception ex) { _logger.Error(string.Format("Error while pulling single Upsell Event call queue. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } }
public void PollForHealthPlanUncontactedCustomer() { try { _logger.Info("Entering Health Plan Uncontacted Customers Polling Agent For 24 hrs"); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.UncontactedCustomers); var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); if (callQueue != null) { // _callQueueCustomerRepository.DeleteCallQueueCustomersHasNotBeenCalled(callQueue.Id); var criteria = _healthPlanCallQueueCriteria.GetQueueCriteriasByQueueId(callQueue.Id); criteria = criteria.Where(x => x.IsQueueGenerated); foreach (var queueCriteria in criteria) { try { _healthPlanCallQueueAssignmentRepository.DeleteByCriteriaId(queueCriteria.Id); //if (queueCriteria.IsDefault) //{ // foreach (var corporateAccount in healthPlans) // { // _healthPlanCallRoundService.SaveHealthPlanUncontactedCustomerCallQueue(corporateAccount, queueCriteria, callQueue, _logger); // } //} //else if (queueCriteria.HealthPlanId.HasValue && !healthPlans.IsNullOrEmpty()) { var corporateAccount = healthPlans.First(x => x.Id == queueCriteria.HealthPlanId.Value); _healthPlanCallRoundService.SaveHealthPlanUncontactedCustomerCallQueue(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); } } } } catch (Exception exception) { _logger.Error(string.Format("Message {0} stack trace: {1} ", exception.Message, exception.StackTrace)); } }
public void PollForCallQueue() { try { _logger.Info("Entering Single Health Plan NoShows Polling Agent"); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.NoShows); var criterias = _healthPlanCallQueueCriteriaService.GetHealthPlanCallQueueCriteriaNotGenerated(callQueue.Id); var healthPlanIds = criterias.Where(x => x.HealthPlanId != null).Select(x => x.HealthPlanId.Value).ToArray(); var healthPlans = _corporateAccountRepository.GetByIds(healthPlanIds); foreach (var criteria in criterias) { try { _logger.Info(string.Format("Generating single No Show call queue.")); _healthPlanCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id); if (criteria.HealthPlanId.HasValue) { var healthPlan = healthPlans.First(x => x.Id == criteria.HealthPlanId.Value); _healthPlanCallRoundService.SaveNoShowCallQueueCustomers(healthPlan, criteria, callQueue, _logger); } _logger.Info(string.Format("Completed single No Show call queue.")); criteria.IsQueueGenerated = true; criteria.LastQueueGeneratedDate = DateTime.Now; _healthPlanCallQueueCriteriaService.Save(criteria); } catch (Exception exception) { _logger.Error(string.Format("Error while generating call queue No show customer data for Criteria Id: {0} \n message: {1} stack trace {2}", criteria.Id, exception.Message, exception.StackTrace)); } } callQueue.IsQueueGenerated = true; callQueue.LastQueueGeneratedDate = DateTime.Now; _callQueueRepository.Save(callQueue); } catch (Exception ex) { _logger.Error(string.Format("Error while pulling single call round call queue. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } }
public void DoNoShowCallQueueCustomerChanges(long eventCustomerId, bool isNoShow, DateTime?noShowDateTime) { var appointmentCallQueueId = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.AppointmentConfirmation).Id; var eventCustomer = _eventCustomerRepository.GetById(eventCustomerId); if (eventCustomer == null) //if wrong eventcustomerId provided { return; } var appointmentDate = _eventCustomerRepository.GetFutureMostAppointmentDateForEventCustomerByCustomerId(eventCustomer.CustomerId); if (appointmentDate != null) { noShowDateTime = null; } _callQueueCustomerRepository.UpdateCallQueueCustomerForNoShow(eventCustomer.CustomerId, appointmentDate, noShowDateTime, appointmentCallQueueId); }
public void PollForQueueGeneration() { try { _logger.Info("Entering Health Plan Confirmation Queue Polling Agent For 24 hrs."); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.AppointmentConfirmation); var criterias = _healthPlanCallQueueCriteriaRepository.GetQueueCriteriasByQueueId(callQueue.Id); var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); foreach (var criteria in criterias) { try { _healthPlanCallQueueAssignmentRepository.DeleteByCriteriaId(criteria.Id); if (criteria.HealthPlanId.HasValue) { var healthPlan = healthPlans.FirstOrDefault(x => x.Id == criteria.HealthPlanId); if (healthPlan != null) { _healthPlanCallRoundService.SaveHealthPlanConfirmationCustomerCallQueue(healthPlan, criteria, callQueue, _logger); } criteria.IsQueueGenerated = true; criteria.LastQueueGeneratedDate = DateTime.Now; _healthPlanCallQueueCriteriaRepository.Save(criteria); } } catch (Exception ex) { _logger.Error(string.Format("Error generating confirmation queue for HealthPlanId: {0} CallQueueId: {1} CriteriaId : {2}", criteria.HealthPlanId, callQueue.Id, criteria.Id)); _logger.Error(string.Format("Message : {0} \nStack Trace : {1}", ex.Message, ex.StackTrace)); } } _logger.Info("Completed Health Plan Confirmation Queue Polling Agent For 24 hrs."); } catch (Exception ex) { _logger.Error(string.Format("Message {0} stack trace: {1} ", ex.Message, ex.StackTrace)); } }
public void PollforRegenerateLanguageBarrierCallQueue() { try { _logger.Info("Entering Single Health Plan Language Barrier Polling Agent"); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.LanguageBarrier); var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); if (callQueue != null) { var criteria = _healthPlanCallQueueCriteria.GetQueueCriteriasByQueueId(callQueue.Id); criteria = criteria.Where(x => !x.IsQueueGenerated && !x.IsDefault); foreach (var queueCriteria in criteria) { _healthPlanCallQueueAssignmentRepository.DeleteByCriteriaId(queueCriteria.Id); if (queueCriteria.HealthPlanId.HasValue && !healthPlans.IsNullOrEmpty()) { var corporateAccount = healthPlans.First(x => x.Id == queueCriteria.HealthPlanId.Value); _healthPlanCallRoundService.SaveHealthPlanLanguageBarrierCustomerCallQueue(corporateAccount, queueCriteria, callQueue, _logger); } queueCriteria.IsQueueGenerated = true; queueCriteria.LastQueueGeneratedDate = DateTime.Now; _healthPlanCallQueueCriteria.Save(queueCriteria); } } _logger.Info("Completing Single Health Plan Language Barrier Polling Agent"); } catch (Exception exception) { _logger.Error("Error while regenration"); _logger.Error(string.Format("Message {0} stack trace: {1} ", exception.Message, exception.StackTrace)); } }
public HealthPlanCallQueueCriteriaEditModel SaveHealthPlanCallQueueCriteria(HealthPlanCallQueueCriteriaEditModel model, long orgRoleId, bool isCriteriaSameAsPervious) { var callQueue = _callQueueRepository.GetCallQueueByCategory(model.CallQueue); model.CallQueueId = callQueue.Id; model.IsCriteriaSameAsPervious = isCriteriaSameAsPervious; if (model.CallQueue == HealthPlanCallQueueCategory.MailRound) { model.IsCriteriaSameAsPervious = true; var healthPlanCallQueueCriterias = new List <HealthPlanCallQueueCriteria>(); HealthPlanCallQueueCriteria existingCriteria = model.Id > 0 ? _healthPlanCallQueueCriteriaRepository.GetById(model.Id) : null; foreach (var campaign in model.CampaignDirectMailDates) { var criteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForMailRound(model, campaign.CampaignId, orgRoleId); if (existingCriteria != null) { if (existingCriteria.CampaignId.HasValue && model.CampaignDirectMailDates.Any(x => x.CampaignId == existingCriteria.CampaignId.Value)) { if (campaign.CampaignId == existingCriteria.CampaignId.Value) { criteria.Id = model.Id; criteria.IsQueueGenerated = existingCriteria.IsQueueGenerated; } } else { if (campaign.CampaignId == model.CampaignDirectMailDates.First().CampaignId) { criteria.Id = model.Id; } } } if (criteria.Id > 0) { var directmailActivities = _healthPlanCriteriaDirectMailRepository.GetByCriteriaId(criteria.Id); if (directmailActivities.IsNullOrEmpty() && !campaign.DirectMailDateActivities.IsNullOrEmpty()) { criteria.IsQueueGenerated = false; model.IsCriteriaSameAsPervious = false; } else if (!directmailActivities.IsNullOrEmpty() && campaign.DirectMailDateActivities.IsNullOrEmpty()) { criteria.IsQueueGenerated = false; model.IsCriteriaSameAsPervious = false; } else if (!directmailActivities.IsNullOrEmpty() && !campaign.DirectMailDateActivities.IsNullOrEmpty()) { if (directmailActivities.Count() != campaign.DirectMailDateActivities.Count()) { criteria.IsQueueGenerated = false; model.IsCriteriaSameAsPervious = false; } else { var activtyIdsInDB = directmailActivities.Select(x => x.CampaignActivityId); var activityIdsInModel = campaign.DirectMailDateActivities.Select(x => x.ActivityId); if (!(activtyIdsInDB.All(activityIdsInModel.Contains) && activityIdsInModel.All(activtyIdsInDB.Contains))) { criteria.IsQueueGenerated = false; model.IsCriteriaSameAsPervious = false; } } } } else { criteria.IsQueueGenerated = false; model.IsCriteriaSameAsPervious = false; } criteria = _healthPlanCallQueueCriteriaRepository.Save(criteria); if (!campaign.DirectMailDateActivities.IsNullOrEmpty()) { var activityIds = campaign.DirectMailDateActivities.Select(x => x.ActivityId); _healthPlanCriteriaDirectMailRepository.Save(activityIds, criteria.Id); } healthPlanCallQueueCriterias.Add(criteria); } if (!model.IsTeamAssignment) { foreach (var healthPlanCallQueueCriteria in healthPlanCallQueueCriterias) { SaveFileInfoForCsvUpload(model, healthPlanCallQueueCriteria); } if (!model.Assignments.IsNullOrEmpty()) { var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaAssignmentForMailRound(model.Assignments, healthPlanCallQueueCriterias, orgRoleId); _healthPlanCriteriaAssignmentRepository.Save(model.HealthPlanId, model.CallQueueId, model.Id, assignments); } } else { if (!model.CallCenterTeamAssignments.IsNullOrEmpty()) { var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaTeamAssignmentForMailRound(model.CallCenterTeamAssignments, healthPlanCallQueueCriterias, orgRoleId); _healthPlanCriteriaTeamAssignmentRepository.Save(assignments); } } } else if (model.CallQueue == HealthPlanCallQueueCategory.LanguageBarrier) { var healthPlanCallQueueCriteria = _healthPlanCallQueueCriteriaRepository.GetQueueCriteriaForQueue(model.CallQueueId, model.HealthPlanId); if (!model.IsTeamAssignment) { if (!model.Assignments.IsNullOrEmpty()) { SaveFileInfoForCsvUpload(model, healthPlanCallQueueCriteria); var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaAssignment(model.Assignments, healthPlanCallQueueCriteria.Id, orgRoleId); _healthPlanCriteriaAssignmentRepository.Save(model.HealthPlanId, model.CallQueueId, model.Id, assignments); } } else { if (!model.CallCenterTeamAssignments.IsNullOrEmpty()) { var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaTeamAssignment(model.CallCenterTeamAssignments, healthPlanCallQueueCriteria, orgRoleId); _healthPlanCriteriaTeamAssignmentRepository.Save(assignments); } } } else if (model.CallQueue == HealthPlanCallQueueCategory.AppointmentConfirmation) { var healthPlanCallQueueCriteria = model.Id > 0 ? _healthPlanCallQueueCriteriaRepository.GetById(model.Id) : _healthPlanCallQueueCriteriaRepository.GetQueueCriteriaForQueueByLanguage(model.CallQueue, model.HealthPlanId, model.LanguageId); var organization = _organizationRepository.GetOrganizationbyId(model.HealthPlanId); var language = model.LanguageId.HasValue ? _languageRepository.GetById(model.LanguageId.Value) : null; model.CriteriaName = organization.Name + " Confirmation" + (language != null ? " for " + language.Name : ""); if (healthPlanCallQueueCriteria == null) { healthPlanCallQueueCriteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForConfirmation(model, orgRoleId); healthPlanCallQueueCriteria = _healthPlanCallQueueCriteriaRepository.Save(healthPlanCallQueueCriteria); } else { /*if (healthPlanCallQueueCriteria.LanguageId != model.LanguageId) * healthPlanCallQueueCriteria.IsQueueGenerated = false;*/ healthPlanCallQueueCriteria.LanguageId = model.LanguageId; healthPlanCallQueueCriteria.CriteriaName = model.CriteriaName; healthPlanCallQueueCriteria = _healthPlanCallQueueCriteriaRepository.Save(healthPlanCallQueueCriteria); } if (!model.IsTeamAssignment) { if (!model.Assignments.IsNullOrEmpty()) { SaveFileInfoForCsvUpload(model, healthPlanCallQueueCriteria); var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaAssignment(model.Assignments, healthPlanCallQueueCriteria.Id, orgRoleId); _healthPlanCriteriaAssignmentRepository.Save(model.HealthPlanId, model.CallQueueId, model.Id, assignments); } } else { if (!model.CallCenterTeamAssignments.IsNullOrEmpty()) { var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaTeamAssignment(model.CallCenterTeamAssignments, healthPlanCallQueueCriteria, orgRoleId); _healthPlanCriteriaTeamAssignmentRepository.Save(assignments); } } } else { HealthPlanCallQueueCriteria criteria = null; if (!isCriteriaSameAsPervious) { if (model.CallQueue == HealthPlanCallQueueCategory.FillEventsHealthPlan) { criteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForFillEvent(model, orgRoleId); } #region not in use //switch (model.CallQueue) //{ // //case HealthPlanCallQueueCategory.CallRound: // // criteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForCallRound(model, orgRoleId); // // break; // case HealthPlanCallQueueCategory.FillEventsHealthPlan: // criteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForFillEvent(model, orgRoleId); // break; // //case HealthPlanCallQueueCategory.NoShows: // // criteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForNoShow(model, orgRoleId); // // break; // //case HealthPlanCallQueueCategory.ZipRadius: // // criteria = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCallQueueCriteriaForZipRadius(model, orgRoleId); // // break; //} #endregion _healthPlanCallQueueCriteriaRepository.MarkForDelete(model.Id, true); criteria = _healthPlanCallQueueCriteriaRepository.Save(criteria); model.Id = criteria.Id; } else if (model.Id > 0) { criteria = _healthPlanCallQueueCriteriaRepository.GetById(model.Id); criteria.DataRecorderMetaData.DateModified = DateTime.Now; criteria.DataRecorderMetaData.DataRecorderModifier = new OrganizationRoleUser(orgRoleId); criteria.CriteriaName = model.CriteriaName; criteria = _healthPlanCallQueueCriteriaRepository.Save(criteria); } if (!model.IsTeamAssignment) { SaveFileInfoForCsvUpload(model, criteria); if (!model.Assignments.IsNullOrEmpty()) { var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaAssignment(model.Assignments, model.Id, orgRoleId); _healthPlanCriteriaAssignmentRepository.Save(model.HealthPlanId, model.CallQueueId, model.Id, assignments); } } else { if (!model.CallCenterTeamAssignments.IsNullOrEmpty()) { var assignments = _healthPlanCallQueueCriteriaEditModelFactory.GetHealthPlanCriteriaTeamAssignment(model.CallCenterTeamAssignments, criteria, orgRoleId); _healthPlanCriteriaTeamAssignmentRepository.Save(assignments); } } } if (!model.IsTeamAssignment) { if (model.Assignments != null && model.Assignments.Any()) { var list = new List <CallQueueAssignmentEditModel>(); foreach (var assignment in model.Assignments) { assignment.IsExistInOtherCriteria = false; list.Add(assignment); } model.Assignments = list; } return(model); } else { model.IsTeamAssignment = true; model.Assignments = null; return(model); } }
public void PollForHealthPlanMailRoundCallQueue() { try { var callDate = DateTime.Now; var campaigns = new List <Campaign>(); var campaignByCallDate = _campaignRepository.GeCotporateCampaignForCallQueue(callDate); if (!campaignByCallDate.IsNullOrEmpty()) { campaigns.AddRange(campaignByCallDate); } var campaignsNotGenerated = _campaignRepository.GetCotporateCampaignForNotGenerated(); if (!campaignsNotGenerated.IsNullOrEmpty()) { var campaigIds = campaigns.Select(x => x.Id).ToArray(); if (!campaigIds.IsNullOrEmpty()) { campaignsNotGenerated = campaignsNotGenerated.Where(x => !campaigIds.Contains(x.Id)).ToArray(); if (!campaignsNotGenerated.IsNullOrEmpty()) { campaigns.AddRange(campaignsNotGenerated); } } else { campaigns.AddRange(campaignsNotGenerated); } } if (campaigns.IsNullOrEmpty()) { _logger.Info("No Campaigns found for call queue generation."); return; } var healthPlanIds = campaigns.Select(x => x.AccountId).ToArray(); var healthPlans = _corporateAccountRepository.GetByIds(healthPlanIds); foreach (var campaign in campaigns) { try { _logger.Info("Started creating Mail Round call queue for campaign: " + campaign.Name); var campaignActivites = _campaignActivityRepository.GetByCampaignId(campaign.Id); var outboundCallAcivity = campaignActivites.FirstOrDefault(ca => ca.TypeId == (long)CampaignActivityType.OutboundCall && ca.ActivityDate.Date == callDate.Date); if (outboundCallAcivity == null) { outboundCallAcivity = campaignActivites.Where(ca => ca.TypeId == (long)CampaignActivityType.OutboundCall).OrderByDescending(x => x.ActivityDate).FirstOrDefault(); } if (outboundCallAcivity == null) { continue; } var firstDirectMailActivity = campaignActivites.Where(ca => ca.TypeId == (long)CampaignActivityType.DirectMail && ca.ActivityDate <= outboundCallAcivity.ActivityDate).OrderBy(ca => ca.ActivityDate).FirstOrDefault(); if (firstDirectMailActivity == null) { _logger.Info("No Direct mail activity before outbound call."); _logger.Info("Completed creating Mail Round call queue for campaign: " + campaign.Name); continue; } var criterias = _healthPlanCallQueueCriteriaRepository.GetByCampaignId(campaign.Id); if (criterias.IsNullOrEmpty()) { _logger.Info("No Criteria has been created."); _logger.Info("Completed creating Mail Round call queue for campaign: " + campaign.Name); continue; } foreach (var campaingnCriteria in criterias) { try { if (campaingnCriteria.IsQueueGenerated && campaingnCriteria.LastQueueGeneratedDate.HasValue && campaingnCriteria.LastQueueGeneratedDate.Value.Date == callDate.Date) { _logger.Info("Call queue has been already generated for the campaign."); _logger.Info("Completed creating Mail Round call queue for campaign: " + campaign.Name); continue; } _healthPlanCallQueueAssignmentRepository.DeleteByCriteriaId(campaingnCriteria.Id); var healthPlan = healthPlans.Single(x => x.Id == campaign.AccountId); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); _healthPlanCallRoundService.SaveMailRoundCallQueueCustomers(healthPlan, campaingnCriteria, callQueue, _logger, campaign); campaingnCriteria.IsQueueGenerated = true; campaingnCriteria.LastQueueGeneratedDate = DateTime.Now; _healthPlanCallQueueCriteriaRepository.Save(campaingnCriteria); } catch (Exception ex) { _logger.Error("Some Error Occurred While Generating Campaign Criteria Data: " + campaign.Name); _logger.Error("Message: " + ex.Message); _logger.Error("Stack Trace: " + ex.StackTrace); } } _logger.Info("Completed creating Mail Round call queue for campaign: " + campaign.Name); } catch (Exception ex) { _logger.Error("Error while Creating Mail Round call queue for campaign: " + campaign.Name); _logger.Error("Message : " + ex.Message); _logger.Error("Stack Trace : " + ex.StackTrace); } } } catch (Exception ex) { _logger.Error("Error while Polling Mail Round call queue"); _logger.Error("Message : " + ex.Message); _logger.Error("Stack Trace : " + ex.StackTrace); } }
public void PollForHealthPlanCallQueue() { try { var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.FillEventsHealthPlan); var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); _logger.Info("Started Healthfair Fill Event call Queue For Generated Call Queues For 24 hrs"); if (callQueue != null) { try { var criteria = _healthPlanCallQueueCriteria.GetQueueCriteriasByQueueId(callQueue.Id); criteria = criteria.Where(x => x.IsQueueGenerated).OrderByDescending(x => x.Id); foreach (var queueCriteria in criteria) { try { _healthPlanCallQueueAssignment.DeleteByCriteriaId(queueCriteria.Id); _healthPlanFillEventCallQueueRepository.DeleteByCriteriaId(queueCriteria.Id); //if (queueCriteria.IsDefault) //{ // foreach (var corporateAccount in healthPlans) // { // _healthPlanCallRoundService.SaveHealthPlanFillEventCallQueueCustomers(corporateAccount, queueCriteria, callQueue, _logger); // } //} //else if (queueCriteria.HealthPlanId.HasValue && !healthPlans.IsNullOrEmpty()) { var corporateAccount = healthPlans.First(x => x.Id == queueCriteria.HealthPlanId.Value); _healthPlanCallRoundService.SaveHealthPlanFillEventCallQueueCustomers(corporateAccount, queueCriteria, callQueue, _logger); } queueCriteria.IsQueueGenerated = true; queueCriteria.LastQueueGeneratedDate = DateTime.Now; _healthPlanCallQueueCriteria.Save(queueCriteria); } catch (Exception ex) { _logger.Error(string.Format("error health plan call queue. callQueueId: {0} CriteriaId {1} ", callQueue.Id, queueCriteria.Id)); _logger.Error(string.Format("Message {0} stack trace: {1} ", ex.Message, ex.StackTrace)); } } } 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)); } }
public long SaveGmsDialerCall(GmsDialerCallModel model, long orgRoleUserId, ILogger logger) { var callDateTime = Convert.ToDateTime(model.CallDate + " " + model.CallTime); long status = 0; var disposition = string.Empty; if (model.CallDisposition.ToUpper() == "ANS.MACH")//Left Voice mail { status = (long)CallStatus.VoiceMessage; } else if (model.CallDisposition.ToUpper() == "NO.ANS") //No Answer/Busy/Mail Full { status = (long)CallStatus.NoAnswer; } else if (model.CallDisposition.ToUpper() == "BUSY") //No Answer/Busy/Mail Full { status = (long)CallStatus.NoAnswer; } else if (model.CallDisposition.ToUpper() == "DEAD") { //Incorrect Phone number status = (long)CallStatus.TalkedtoOtherPerson; disposition = ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString(); } var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); long customerId = Convert.ToInt64(model.CustomerId); var customer = _customerRepository.GetCustomer(customerId); var healthPlanId = _corporateAccountRepository.GetHealthPlanIdByAccountName(model.HealthPlan); if (healthPlanId == 0) { logger.Info(string.Format("Unable to parse for Customer Id : {0}. Healthplan not found by Name : {1}", model.CustomerId, model.HealthPlan)); return(0); } var calledNumber = !string.IsNullOrEmpty(model.PhoneHome) ? model.PhoneHome : !string.IsNullOrEmpty(model.PhoneOffice) ? model.PhoneOffice : model.PhoneCell; var callQueueCustomer = _callQueueCustomerRepository.GetCallQueueCustomerByCustomerIdAndHealthPlanId(customerId, healthPlanId, HealthPlanCallQueueCategory.MailRound); if (callQueueCustomer == null) { logger.Info(string.Format("Unable to parse for Customer Id : {0}. Call Queue Customer not found.", model.CustomerId)); return(0); } bool?isContacted = false; if (callQueue.Category == HealthPlanCallQueueCategory.AppointmentConfirmation) { isContacted = null; } else { isContacted = (status == (long)CallStatus.Attended || status == (long)CallStatus.VoiceMessage || status == (long)CallStatus.LeftMessageWithOther); } var call = new Call() { CallDateTime = callDateTime, StartTime = callDateTime, EndTime = callDateTime, CallStatus = CallType.Existing_Customer.GetDescription(), IsIncoming = false, CalledCustomerId = customerId, Status = status, CreatedByOrgRoleUserId = orgRoleUserId, IsNewCustomer = false, DateCreated = callDateTime, DateModified = callDateTime, ReadAndUnderstood = true, HealthPlanId = healthPlanId, CallQueueId = callQueue.Id, DialerType = (long)DialerType.Gms, CalledInNumber = model.CallerId, CallerNumber = calledNumber, CallBackNumber = calledNumber, IsContacted = isContacted, Disposition = disposition, ProductTypeId = customer.ProductTypeId }; call = _callCenterCallRepository.Save(call); if (status == (long)CallStatus.TalkedtoOtherPerson && disposition == ProspectCustomerTag.IncorrectPhoneNumber_TalkedToOthers.ToString()) { _customerService.UpdateIsIncorrectPhoneNumber(customerId, true, orgRoleUserId); } var callQueueCustomerCall = new CallQueueCustomerCall { CallQueueCustomerId = callQueueCustomer.Id, CallId = call.Id }; _callQueueCustomerCallRepository.Save(callQueueCustomerCall); var customerAccountGlocomNumber = new CustomerAccountGlocomNumber { CallId = call.Id, CustomerId = customerId, GlocomNumber = PhoneNumber.ToNumber(model.CallerId), CreatedDate = callDateTime, IsActive = true }; _customerAccountGlocomNumberService.SaveAccountCheckoutPhoneNumber(customerAccountGlocomNumber); bool removeFromCallQueue = status == (long)CallStatus.TalkedtoOtherPerson; var callQueueStatus = CallQueueStatus.Initial; if (removeFromCallQueue) { callQueueStatus = CallQueueStatus.Removed; } callQueueCustomer.Disposition = disposition; _callQueueCustomerContactService.SetCallQueueCustomerStatus(callQueueCustomer, callQueueStatus, orgRoleUserId, false, status, callDateTime); var prospectCustomerId = callQueueCustomer.ProspectCustomerId ?? 0; if (prospectCustomerId == 0) { var prospectCustomer = _prospectCustomerRepository.GetProspectCustomerByCustomerId(customerId); if (prospectCustomer != null) { prospectCustomerId = prospectCustomer.Id; } } _callQueueCustomerRepository.UpdateOtherCustomerAttempt(callQueueCustomer.Id, customerId, prospectCustomerId, orgRoleUserId, callQueueCustomer.CallDate, removeFromCallQueue, callQueueCustomer.CallQueueId, status, callDateTime, isForParsing: true, disposition: disposition); return(call.Id); }
private void ParseCallUploadedCalls(IEnumerable <DataRow> rows, List <CallUploadLog> failedCustomerList, List <CallUploadLog> successCustomerList, long callUploadId) { var callUploadLogs = rows.Select(row => _callUploadHelper.GetUploadLog(row, callUploadId)); if (callUploadLogs.IsNullOrEmpty()) { _logger.Info("No Record Found For Parsing in file"); return; } SaveFailedCustomers(failedCustomerList, callUploadLogs); callUploadLogs = callUploadLogs.Where(x => x.IsSuccessfull); if (callUploadLogs.IsNullOrEmpty()) { _logger.Info("No Successfull Customer Found For Parsing in file"); return; } var customerIds = callUploadLogs.Select(x => x.CustomerId).Distinct(); var outboundCustomerIds = callUploadLogs.Where(x => !x.IsDirectMail).Select(x => x.CustomerId).ToArray(); IEnumerable <Customer> customers = null; try { customers = _customerRepository.GetCustomers(customerIds.ToArray()); } catch (Exception ex) { _logger.Error(" Exception : " + ex.Message + " \n Stack Trace: " + ex.StackTrace); } if (customers != null && customers.Any()) { var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); var events = ((IUniqueItemRepository <Event>)_eventRepository).GetByIds(callUploadLogs.Where(x => x.EventId > 0).Select(x => x.EventId).ToArray()); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.CallRound); var callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomersBuCustomerIds(outboundCustomerIds, callQueue.Id).ToList(); var prospectCustomers = _prospectCustomerRepository.GetProspectCustomersByCustomerIds(outboundCustomerIds); var calls = _callCenterCallRepository.GetCallDetails(outboundCustomerIds); var emailIds = callUploadLogs.Select(x => x.Email).Distinct().ToList(); var userNames = callUploadLogs.Where(x => !string.IsNullOrEmpty(x.UserName)).Select(x => x.UserName).Distinct().ToList(); var organizationRoleUserEmail = _organizationRoleUserRepository.GetNameIdPairofOrgRoleIdByEmail(emailIds, (long)Roles.CallCenterRep); var organizationRoleUserUserName = _organizationRoleUserRepository.GetNameIdPairofOrgRoleIdByUserNames(userNames, (long)Roles.CallCenterRep); var directMailTypes = _directMailTypeRepository.GetAll(); foreach (var callUploadLog in callUploadLogs) { try { var customer = customers.SingleOrDefault(x => x.CustomerId == callUploadLog.CustomerId); if (customer == null) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Customer ID is not valid."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } if (string.IsNullOrEmpty(customer.Tag)) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Customer does not belong to any HealthPlan."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } var healthPlan = healthPlans.SingleOrDefault(x => x.Tag == customer.Tag); if (healthPlan == null) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "HealthPlan " + customer.Tag + " not found."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } var orgRoleId = _callUploadHelper.GetOrganizationRoleId(callUploadLog, organizationRoleUserEmail, organizationRoleUserUserName); if (orgRoleId <= 0) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Created By Information does not found."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } long?directMailTypeId = null; if (callUploadLog.IsDirectMail) { var campaign = _campaignRepository.GetCampaignByName(callUploadLog.CampaignName); if (campaign == null) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = " Please provide a valid campaign name."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } if (!string.IsNullOrEmpty(callUploadLog.DirectMailType)) { var directMailType = directMailTypes.SingleOrDefault(s => s.Name.ToLower() == callUploadLog.DirectMailType.ToLower()); if (directMailType == null) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = " Please provide a valid Direct Mail Type."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } directMailTypeId = directMailType.Id; } var isInvalidAddress = false; if (callUploadLog.IsInvalidAddress != null) { isInvalidAddress = callUploadLog.IsInvalidAddress.ToLower().Trim() == "yes" ? true : false; } var directMail = new DirectMail { CustomerId = callUploadLog.CustomerId, MailDate = callUploadLog.OutreachDateTime.Value.Date, CallUploadId = callUploadLog.CallUploadId, CampaignId = campaign.Id, DirectMailTypeId = directMailTypeId, Mailedby = orgRoleId, IsInvalidAddress = isInvalidAddress, Notes = isInvalidAddress ? "Direct Mail returned because of invalid address." : string.Empty, }; _directMailRepository.Save(directMail); } else { Event theEventData = null; if (callUploadLog.EventId > 0) { theEventData = events.SingleOrDefault(x => x.Id == callUploadLog.EventId); if (theEventData == null) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Event Id provide is not valid."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } } if (callUploadLog.EventId > 0) { var isValidEventForAccount = _eventRepository.ValidateEventForAccount(callUploadLog.EventId, healthPlan.Id); if (!isValidEventForAccount) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Event Id provide is not valid for customer HealthPlan."; _callUploadLogRepository.SaveCallUploadLog(callUploadLog); failedCustomerList.Add(callUploadLog); continue; } } var prospectCustomer = prospectCustomers.FirstOrDefault(x => x.CustomerId == customer.CustomerId); if (prospectCustomer == null && customer != null) { prospectCustomer = _prospectCustomerFactory.CreateProspectCustomerFromCustomer(customer, false); prospectCustomer = ((IUniqueItemRepository <ProspectCustomer>)_prospectCustomerRepository).Save(prospectCustomer); } var callQueueCustomer = SaveCallQueueCustomer(callQueue.Id, callUploadLog, healthPlan.Id, callQueueCustomers); var call = SaveCall(callUploadLog, theEventData != null ? theEventData.Id : 0, orgRoleId, healthPlan.Id); if (prospectCustomer != null) { UpdateContactedInfo(prospectCustomer.Id, call.Id, orgRoleId); } SaveCallQueueCustomerCall(callQueueCustomer, call); SaveCallNotes(callUploadLog, call.Id, orgRoleId); var customerCalls = calls.Where(x => x.CalledCustomerId == callUploadLog.CustomerId); bool isRemovedFromCallQueue; var isRuleApplied = _callUploadRuleEngine.ApplyRuleEngine(callUploadLog, customerCalls, prospectCustomer, orgRoleId, callQueueCustomer.Id, callQueueCustomer.CallQueueId, out isRemovedFromCallQueue, _logger); if (isRemovedFromCallQueue) { callQueueCustomer.Status = CallQueueStatus.Removed; _callQueueCustomerRepository.Save(callQueueCustomer); } callUploadLog.IsRuleApplied = isRuleApplied; } successCustomerList.Add(callUploadLog); _callUploadLogRepository.SaveCallUploadLog(callUploadLog); } catch (Exception ex) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Message: " + ex.Message + "\n stack Trace: " + ex.StackTrace; failedCustomerList.Add(callUploadLog); _logger.Error("Message: " + ex.Message + "\n stack Trace: " + ex.StackTrace); } } } else { foreach (var callUploadLog in callUploadLogs) { callUploadLog.IsSuccessfull = false; callUploadLog.ErrorMessage = "Please Provide a valid CustomerId"; failedCustomerList.Add(callUploadLog); } } SaveFailedCustomers(failedCustomerList, callUploadLogs); }
public void PollForApplyRule() { try { var timeOfDay = DateTime.Now; _logger.Info("Entering In Apply Rules On Locked Customers PollingAgent"); if (_isDevEnvironment || timeOfDay.TimeOfDay > new TimeSpan(4, 0, 0)) { var callUploadLogs = _callUploadLogRepository.GetCustomerForApplyRule(OutReachType); if (callUploadLogs.IsNullOrEmpty()) { _logger.Info("No Record Found"); return; } var customerIds = callUploadLogs.Select(x => x.CustomerId); var callcenterCalls = _callCenterCallRepository.GetCallDetails(customerIds); var prospectCustomers = _prospectCustomerRepository.GetProspectCustomersByCustomerIds(customerIds.ToArray()); var emailIds = callUploadLogs.Select(x => x.Email).Distinct().ToList(); var userNames = callUploadLogs.Select(x => x.UserName).Distinct().ToList(); var organizationRoleUserEmail = _organizationRoleUserRepository.GetNameIdPairofOrgRoleIdByEmail(emailIds, (long)Roles.CallCenterRep); var organizationRoleUserUserName = _organizationRoleUserRepository.GetNameIdPairofOrgRoleIdByUserNames(userNames, (long)Roles.CallCenterRep); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.CallRound); var callQueueCustomers = _callQueueCustomerRepository.GetCallQueueCustomersBuCustomerIds(customerIds, callQueue.Id).ToList(); foreach (var uploadLog in callUploadLogs) { try { var customerCalls = callcenterCalls.Where(x => x.CalledCustomerId == uploadLog.CustomerId); var prospectCustomer = prospectCustomers.Single(x => x.CustomerId == uploadLog.CustomerId); var orgRoleId = _callUploadHelper.GetOrganizationRoleId(uploadLog, organizationRoleUserEmail, organizationRoleUserUserName); var callQueueCustomer = callQueueCustomers.FirstOrDefault(x => x.CustomerId.HasValue && x.CustomerId.Value == uploadLog.CustomerId); bool isRemovedFromCallQueue; var isRuleApplied = _callUploadRuleEngine.ApplyRuleEngine(uploadLog, customerCalls, prospectCustomer, orgRoleId, callQueueCustomer.Id, callQueueCustomer.CallQueueId, out isRemovedFromCallQueue, _logger); if (isRuleApplied) { if (isRemovedFromCallQueue) { callQueueCustomer.Status = CallQueueStatus.Removed; _callQueueCustomerRepository.Save(callQueueCustomer); } uploadLog.IsRuleApplied = isRuleApplied; _callUploadLogRepository.SaveCallUploadLog(uploadLog); } } catch (Exception exception) { _logger.Error("Error on Apply Rule on Locked Customer For CallUploadLogId: " + uploadLog.Id + " Exception: " + exception + "\n Stack Trace:" + exception.StackTrace); } } } else { _logger.Info(string.Format("Apply Rule on Locked Customer can not be called as time of day is {0}", timeOfDay.TimeOfDay)); } } catch (Exception exception) { _logger.Error("Error on Apply Rule on Locked Customer Exception: " + exception + "\n Stack Trace:" + exception.StackTrace); } }
public JsonResult MassAssignment(MassAgentAssignmentEditModel data) { var model = new MassAgentAssignmentViewModel(); var healthPlanId = data.HealthPlanId; var callQueueCategory = data.CallQueueCategory; var criteriaId = data.CriteriaId; var callQueue = new CallQueue(); if (healthPlanId == null || (healthPlanId.HasValue && healthPlanId.Value == 0)) { return(Json(model.ErrorMessage = "Select healthplan first", JsonRequestBehavior.AllowGet)); } if (!(callQueueCategory == HealthPlanCallQueueCategory.FillEventsHealthPlan || callQueueCategory == HealthPlanCallQueueCategory.MailRound || callQueueCategory == HealthPlanCallQueueCategory.LanguageBarrier || callQueueCategory == HealthPlanCallQueueCategory.AppointmentConfirmation)) { return(Json(model.ErrorMessage = "Select call queue first", JsonRequestBehavior.AllowGet)); } if (Request != null && Request.Files != null && Request.Files.Count > 0 && data.MassAssignmentFile != null) { HttpPostedFileBase file = Request.Files[0]; var uploadDateTime = DateTime.Now; var fileUploadName = @"MassAgentAssignment_" + uploadDateTime.ToString("yyyyMMddHHmmss") + "_" + _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId + ".csv"; var tempMediaFileLocation = _mediaRepository.GetTempMediaFileLocation(); var tempPhysicalPath = tempMediaFileLocation.PhysicalPath; var tempFullpath = tempPhysicalPath + fileUploadName; var logFileName = "Failure_" + fileUploadName; var logFilePath = tempPhysicalPath + logFileName; var fileExtension = file.FileName.Split('.'); if ((fileExtension.Length >= 2 && fileExtension[fileExtension.Length - 1].ToLower() != "csv") || fileExtension.Length < 2) { return(Json(model.ErrorMessage = "File format is not CSV", JsonRequestBehavior.AllowGet)); } try { file.SaveAs(tempFullpath); //save in Temp model.UploadedCsvFileName = fileUploadName; } catch (Exception) { return(Json(model.ErrorMessage = "Internal error occurred", JsonRequestBehavior.AllowGet)); } var massAssignmentTable = _csvReader.ReadWithTextQualifier(tempFullpath); if (massAssignmentTable.Rows.Count == 0) { return(Json(model.ErrorMessage = "File contains no data", JsonRequestBehavior.AllowGet)); } var columns = massAssignmentTable.Columns.Cast <DataColumn>().Select(x => x.ColumnName).ToArray(); var missingColumnNames = CheckAllColumnExist(columns); if (!string.IsNullOrEmpty(missingColumnNames)) { var customString = missingColumnNames .Replace(MassAgentAssignmentColumns.AgentName, "Agent name") .Replace(MassAgentAssignmentColumns.EmailId, "Email id") .Replace(MassAgentAssignmentColumns.StartDate, "Start date") .Replace(MassAgentAssignmentColumns.EndDate, "End date"); return(Json(model.ErrorMessage = "Missing Column Name(s):" + customString, JsonRequestBehavior.AllowGet)); } //parsing HealthPlanId and CallQueueCategory if (healthPlanId == null || string.IsNullOrEmpty(callQueueCategory)) { return(Json(model.ErrorMessage = "Please select healthplan/call queue first", JsonRequestBehavior.AllowGet)); } callQueue = _callQueueRepository.GetCallQueueByCategory(data.CallQueueCategory); if (callQueue == null) { return(Json(model.ErrorMessage = "Invalid call queue selected", JsonRequestBehavior.AllowGet)); } var agentDataCollection = new List <CallQueueAssignmentEditModel>(); DataTable table = _csvReader.CsvToDataTable(tempMediaFileLocation.PhysicalPath + fileUploadName, true); if (table.Rows.Count <= 0) { return(Json(model.ErrorMessage = "File contains no data", JsonRequestBehavior.AllowGet)); } var failedToParseRecords = new StringBuilder(); failedToParseRecords.Append(MassAgentAssignmentColumns.AgentName + "," + MassAgentAssignmentColumns.EmailId + "," + MassAgentAssignmentColumns.StartDate + "," + MassAgentAssignmentColumns.EndDate + "," + "Error Message" + Environment.NewLine); foreach (DataRow row in table.Rows) { var agentData = new CallQueueAssignmentEditModel(); var rowData = GetMassAssignmentCsvRow(row); var errorRow = rowData.AgentName + "," + rowData.EmailId + "," + rowData.StartDate + "," + rowData.EndDate; //Email Id if (string.IsNullOrEmpty(rowData.EmailId)) { failedToParseRecords.Append(errorRow + "," + "No Email Provided" + Environment.NewLine); continue; } //StartDate empty if (string.IsNullOrEmpty(rowData.StartDate)) { failedToParseRecords.Append(errorRow + "," + "Start date not provided" + Environment.NewLine); continue; } //Start Date Convert try { var startDate = Convert.ToDateTime(rowData.StartDate); if (!(startDate >= DateTime.Today)) { failedToParseRecords.Append(errorRow + "," + "Start date must be greater than or equal to current date" + Environment.NewLine); continue; } agentData.StartDate = startDate; } catch (Exception) { failedToParseRecords.Append(errorRow + "," + "Start date invalid format" + Environment.NewLine); continue; } //EndDate if (!string.IsNullOrEmpty(rowData.EndDate)) { try { var endDate = Convert.ToDateTime(rowData.EndDate); if (!(endDate >= agentData.StartDate)) { failedToParseRecords.Append(errorRow + "," + "End date should be greater than or equal to start date." + Environment.NewLine); continue; } agentData.EndDate = endDate; } catch (Exception) { failedToParseRecords.Append(errorRow + "," + "End date invalid format" + Environment.NewLine); continue; } } else { agentData.EndDate = null; } var oruId = _userRepository.SearchUserByEmailAndRole(rowData.EmailId); if (oruId == null) { failedToParseRecords.Append(errorRow + "," + "Agent not found in our records" + Environment.NewLine); continue; } if (!data.AssignmentsfromUi.IsNullOrEmpty()) { if (data.AssignmentsfromUi.Any(x => x.AssignedOrgRoleUserId == oruId)) { failedToParseRecords.Append(errorRow + "," + "Agent already added manually" + Environment.NewLine); continue; } } if (agentDataCollection.Any(x => x.AssignedOrgRoleUserId == oruId)) { failedToParseRecords.Append(errorRow + "," + "Failed, as record is already present in CSV" + Environment.NewLine); continue; } agentData.AssignedOrgRoleUserId = oruId.Value; agentData.Name = rowData.AgentName; if (criteriaId == null) { criteriaId = 0; } if (callQueueCategory == HealthPlanCallQueueCategory.FillEventsHealthPlan) { agentData.IsExistInOtherCriteria = _healthPlanCallQueueCriteriaRepository.CheckHealthPlanAssignment(healthPlanId.Value, callQueueCategory, criteriaId.Value, agentData.AssignedOrgRoleUserId, agentData.StartDate.Value, agentData.EndDate); if (agentData.IsExistInOtherCriteria) { failedToParseRecords.Append(errorRow + "," + "Start date is overlapping with already assigned date for same health plan and same call queue." + Environment.NewLine); continue; } } else { agentData.IsExistInOtherCriteria = false; } agentData.IsEdited = true; agentDataCollection.Add(agentData); } if (agentDataCollection.Count < table.Rows.Count) //Some records have failed { System.IO.File.AppendAllText(logFilePath, failedToParseRecords.ToString()); model.IsRecordsFailed = true; model.LogFileName = logFileName; } else { model.LogFileName = null; } model.SuccessAssignments = agentDataCollection; model.ErrorMessage = ""; return(Json(model, JsonRequestBehavior.AllowGet)); } else { return(Json(model.ErrorMessage = "No file has been uploaded. Please upload a csv file.", JsonRequestBehavior.AllowGet)); } }
public void PollForReportGeneration() { var healthPlans = !_healthPlanIds.IsNullOrEmpty() ? _corporateAccountRepository.GetByIds(_healthPlanIds) : _corporateAccountRepository.GetAllHealthPlan(); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); var collection = new List <GmsCallQueueCustomerViewModel>(); foreach (var healthPlan in healthPlans) { if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount) { break; } _logger.Info(string.Format("Getting call queue customers for Account ID : {0} and Tag : {1}", healthPlan.Id, healthPlan.Tag)); var criterias = _healthPlanCallQueueCriteriaRepository.GetCriteriaByHealthPlanCallQueue(healthPlan.Id, HealthPlanCallQueueCategory.MailRound); if (!_settings.GmsCampaignIds.IsNullOrEmpty()) { criterias = _healthPlanCallQueueCriteriaRepository.GetByCampaignIds(_settings.GmsCampaignIds, healthPlan.Id); _logger.Info(string.Format("Found {0} criterias for Campaign IDs : ", criterias.Count(), string.Join(",", _settings.GmsCampaignIds))); } foreach (var criteria in criterias) { if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount) { break; } _logger.Info(string.Format("Criteria ID : {0}", criteria.Id)); try { var filter = new OutboundCallQueueFilter { CallQueueId = callQueue.Id, CriteriaId = criteria.Id, CampaignId = criteria.CampaignId, Tag = healthPlan.Tag, HealthPlanId = healthPlan.Id, UseCustomTagExclusively = false }; if (filter.HealthPlanId == _settings.OptumUtAccountId) { filter.CustomCorporateTag = _settings.OptumUtCustomTagsForGms; } else if (filter.HealthPlanId == 1083) { filter.CustomCorporateTag = "UHC-TX_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1066) { filter.CustomCorporateTag = "Excellus_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1061) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-1_GMS,Optum-NV_Assessments_2018_List-2_GMS,Optum-NV_Assessments_2018_List-3_GMS,Optum-NV_Mammo_2018_List-2_GMS"; } else if (filter.HealthPlanId == 1111) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-4_GMS"; } else if (filter.HealthPlanId == 1087) { filter.CustomCorporateTag = "UHC-AZ_Assessments_2018_List-1_GMS"; } else if (filter.HealthPlanId == 1093) { filter.CustomCorporateTag = "UHC-CT_Assessments_2018_List-1_GMS"; } _healthPlanOutboundCallQueueService.GetAccountCallQueueSettingForCallQueue(filter); var dataGen = new ExportableDataGenerator <GmsCallQueueCustomerViewModel, OutboundCallQueueFilter>(_callQueueCustomerReportService.GetGmsCallQueueCustomersReport, _logger); var model = dataGen.GetData(filter); var distinctCustomers = model.Collection.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId)); collection.AddRange(distinctCustomers); } catch (Exception ex) { _logger.Error("Error getting call queue customers for Account ID : " + healthPlan.Id + " Criteria ID : " + criteria.Id); _logger.Error(ex); } } } if (!collection.Any()) { _logger.Info("No records found."); return; } if (_settings.GmsMaxCustomerCount > 0 && collection.Count() >= _settings.GmsMaxCustomerCount) { collection = collection.Take(_settings.GmsMaxCustomerCount).ToList(); } if (!Directory.Exists(_settings.GmsCustomerReportPath)) { Directory.CreateDirectory(_settings.GmsCustomerReportPath); } var fileName = _settings.GmsCustomerReportPath + @"\" + string.Format("PatientList_{0}.csv", DateTime.Today.ToString("yyyyMMdd")); WriteCsv(collection, fileName); if (_settings.SendReportToGmsSftp) { _logger.Info("Sending Customer List to GMS sftp."); var sftpFolderReportDirectory = _settings.GmsSftpPath; var processFtp = new ProcessFtp(_logger, _settings.GmsSftpHost, _settings.GmsSftpUserName, _settings.GmsSftpPassword); processFtp.UploadSingleFile(fileName, sftpFolderReportDirectory, ""); _logger.Info("Sent Customer List to GMS sftp."); } else { _logger.Info("Setting to send Customer list to sftp is OFF."); } }
public void PollForReport() { if (_healthPlanIds.IsNullOrEmpty()) { _logger.Info("No Health Plan IDs found."); return; } var healthPlans = _corporateAccountRepository.GetByIds(_healthPlanIds); var callQueue = _callQueueRepository.GetCallQueueByCategory(HealthPlanCallQueueCategory.MailRound); var collection = new List <GmsExcludedCustomerViewModel>(); foreach (var healthPlan in healthPlans) { _logger.Info("Getting excluded customers for Account ID : " + healthPlan.Id); var criterias = _healthPlanCallQueueCriteriaRepository.GetCriteriaForMailRoundGms(healthPlan.Id); if (!_settings.GmsCampaignIds.IsNullOrEmpty()) { criterias = _healthPlanCallQueueCriteriaRepository.GetByCampaignIds(_settings.GmsCampaignIds, healthPlan.Id); _logger.Info(string.Format("Found {0} criterias for Campaign IDs : ", criterias.Count(), string.Join(",", _settings.GmsCampaignIds))); } foreach (var criteria in criterias) { _logger.Info("Criteria ID : " + criteria.Id); try { var filter = new OutboundCallQueueFilter { CallQueueId = callQueue.Id, CriteriaId = criteria.Id, CampaignId = criteria.CampaignId, Tag = healthPlan.Tag, HealthPlanId = healthPlan.Id, UseCustomTagExclusively = false }; if (filter.HealthPlanId == _settings.OptumUtAccountId) { filter.CustomCorporateTag = _settings.OptumUtCustomTagsForGms; } else if (filter.HealthPlanId == 1083) { filter.CustomCorporateTag = "UHC-TX_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1066) { filter.CustomCorporateTag = "Excellus_GMS_2018_List-1"; } else if (filter.HealthPlanId == 1061) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-1_GMS,Optum-NV_Assessments_2018_List-2_GMS,Optum-NV_Assessments_2018_List-3_GMS,Optum-NV_Mammo_2018_List-2_GMS"; } else if (filter.HealthPlanId == 1111) { filter.CustomCorporateTag = "Optum-NV_Assessments_2018_List-4_GMS"; } else if (filter.HealthPlanId == 1087) { filter.CustomCorporateTag = "UHC-AZ_Assessments_2018_List-1_GMS"; } else if (filter.HealthPlanId == 1093) { filter.CustomCorporateTag = "UHC-CT_Assessments_2018_List-1_GMS"; } var excludedCustomerCollection = _gmsExcludedCustomerService.GetGmsExcludedCustomers(filter, callQueue); var distinctCustomers = excludedCustomerCollection.Where(x => !collection.Select(c => c.CustomerId).Contains(x.CustomerId)); collection.AddRange(distinctCustomers); } catch (Exception ex) { _logger.Error("Error getting excluded customers for Account ID : " + healthPlan.Id + " Criteria ID : " + criteria.Id); _logger.Error(ex); } } _logger.Info("Completed for Account ID : " + healthPlan.Id); } var excludedPath = _settings.GmsExcludeReportDownloadCustomerPath; if (DirectoryOperationsHelper.CreateDirectoryIfNotExist(excludedPath)) { var fileName = Path.Combine(excludedPath, string.Format("ExcludedPatientList_{0}.csv", DateTime.Today.ToString("yyyyMMdd"))); WriteCsv(collection, fileName); } else { _logger.Error("Folder can not be created"); } }