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 PollForOutreachReport() { try { _logger.Info("Polling for Out reach report started"); var healthPlans = _corporateAccountRepository.GetAllHealthPlan().Where(hp => _healthPlanIds.Contains(hp.Id)); foreach (var healthPlan in healthPlans) { _logger.Info(string.Format("Polling for Out reach report started for Account Id {0} ", healthPlan.Id)); try { var outreachSettings = string.Format(_outreachSettings, healthPlan.Tag); var customSettings = _customSettingManager.Deserialize(outreachSettings); var fromDate = customSettings.LastTransactionDate == null ? _cutOfDate : customSettings.LastTransactionDate.Value.AddDays(1); var toDate = DateTime.Today.AddDays(-1); _logger.Info(string.Format("Generating report for From Date : {0} To Date : {1}", fromDate, toDate)); var filter = new OutreachCallReportModelFilter { HealthPlanId = healthPlan.Id, DateFrom = fromDate, DateTo = toDate, CallAttemptFilter = CallAttemptFilterStatus.All, }; var filePath = GetOutreachFilePath(healthPlan, fromDate.Year, toDate); //_callCenterExportableReportHelper.HousecallOutreachCallReportExport(filter, filePath, _logger); HousecallOutreachCallReport(filter, filePath); customSettings.LastTransactionDate = toDate; _customSettingManager.SerializeandSave(outreachSettings, customSettings); _logger.Info(string.Format("Completed Out reach report for Account Id {0} ", healthPlan.Id)); } catch (Exception exception) { _logger.Error(string.Format("Exception occured while polling for outreach report for Account Id {0}. Exception Message : {1}, Stack Trace {2}", healthPlan.Id, exception.Message, exception.StackTrace)); } } } catch (Exception ex) { _logger.Error(string.Format("Exception occured while polling for outreach report. Exception Message : {0}, Stack Trace {1}", ex.Message, ex.StackTrace)); } }
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 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 }); }
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 void SaveHealthPlanEventZip(ILogger logger) { try { logger.Info("Starting Healthplan Event Zip Service."); var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); if (!healthPlans.IsNullOrEmpty()) { foreach (var healthPlan in healthPlans) { InsertHealthplanEventZipCode(healthPlan.Id, healthPlan.Tag, logger); } logger.Info("Successfully completed Healthplan Event Zip Service."); } logger.Info("Starting Healthplan Event Zip Service."); } catch (Exception ex) { logger.Error(string.Format("Error Occured While Processing The Healthplan Event Zip Service. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } }
private void ParseLockedEventFilesExceptWellmed() { try { var lockCorporateEventFolderLocation = string.Empty; var corporateAccounts = _corporateAccountRepository.GetAllHealthPlan(); var sourcePath = _settings.LockCorporateEventFolderLocation; foreach (var corporateAccount in corporateAccounts) { _logger.Info("Getting events for Account : " + corporateAccount.Tag); if (corporateAccount != null && (corporateAccount.Id == _settings.WellmedAccountId || corporateAccount.Id == _settings.WellmedTxAccountId)) { continue; } var eventIds = _eventRepository.GetEventIdsByAccountIdAndDate(corporateAccount.Id, DateTime.Today, DateTime.Today.AddDays(1)); if (eventIds.IsNullOrEmpty()) { _logger.Info("No events found for Account : " + corporateAccount.Tag); continue; } if (corporateAccount != null && string.IsNullOrWhiteSpace(corporateAccount.AcesClientShortName)) { _logger.Info("AcesClient Short Name not specified for Account : " + corporateAccount.Tag); continue; } lockCorporateEventFolderLocation = Path.Combine(sourcePath, corporateAccount.AcesClientShortName); if (!DirectoryOperationsHelper.IsDirectoryExist(lockCorporateEventFolderLocation)) { _logger.Info("Path does not exist for Account :" + corporateAccount.Tag + " Path @" + lockCorporateEventFolderLocation); continue; } foreach (var eventId in eventIds) { _logger.Info("Importing for EventId " + eventId); try { var location = _mediaRepository.GetUnlockEventsParseLocation(eventId, true); var eventCustomers = _eventCustomerRepository.GetEventCustomersbyEventId(eventId); if (!eventCustomers.IsNullOrEmpty()) { var customerIds = eventCustomers.Select(x => x.CustomerId).ToArray(); if (!customerIds.IsNullOrEmpty()) { ParseFileFromBPShare(customerIds, lockCorporateEventFolderLocation, location.PhysicalPath); } } _logger.Info("Import completed for EventId " + eventId); } catch (Exception exception) { _logger.Error("some error occurred while parsing event id " + eventId); _logger.Error(string.Format("Message: " + exception.Message + "\n stack trace: " + exception.StackTrace)); } } } } catch (Exception exception) { _logger.Error(string.Format("Message: " + exception.Message + "\n stack trace: " + exception.StackTrace)); } }
public void HealthPlanIncorrectPhoneCustomerExport(DateTime cutOffDate, string destinationFileFormate, ILogger logger) { var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); if (healthPlans.IsNullOrEmpty()) { logger.Info("No Healthplan exists"); return; } if (!_settings.DoNotSendHomeVistIncorrectPhoneNumberAccountIds.IsNullOrEmpty()) { healthPlans = healthPlans.Where(hp => !_settings.DoNotSendHomeVistIncorrectPhoneNumberAccountIds.Contains(hp.Id)); } logger.Info("Starting Corporate Customer Export for Incorrect Phone Number"); foreach (var corporateAccount in healthPlans) { if ((corporateAccount.Id == _settings.WellmedAccountId || corporateAccount.Id == _settings.WellmedTxAccountId)) { if (DateTime.Today.DayOfWeek != _settings.WellmedIncorrectPhoneNumberDayOfWeek) { logger.Info("Day of the week is " + ((long)DateTime.Today.DayOfWeek) + " Account Id: " + corporateAccount.Id); continue; } } //else if (corporateAccount.Id == _settings.HcpNvAccountId) //{ // if ((long)DateTime.Today.DayOfWeek != _settings.HcpNvIncorrectPhoneNumberDayOfWeek) // { // logger.Info("Today is Day of Week is " + DateTime.Today.DayOfWeek); // logger.Info("Service will run on Day of Week " + // (DayOfWeek)_settings.HcpNvIncorrectPhoneNumberDayOfWeek); // continue; // } //} else if (DateTime.Today.DayOfWeek != _dayOfWeek) { logger.Info("Day of the week is " + ((long)DateTime.Today.DayOfWeek) + " Account Id: " + corporateAccount.Id); continue; } var filter = new HealthPlanCustomerIncorrectPhoneExportFilter { CorporateTag = corporateAccount.Tag, StartDate = cutOffDate }; if (corporateAccount.Id == _settings.HealthNowAccountId) { filter.CustomTags = _settings.HealthNowCustomTags; } else if (corporateAccount.Id == _settings.ExcellusAccountId) { filter.CustomTags = _settings.ExcellusCustomTags; } logger.Info(string.Format("Starting for Corporate Tag: {0} StartDate: {1}", filter.CorporateTag, filter.StartDate.ToShortDateString())); var list = IncorrectPhoneNumberExportReport(filter, logger); if (!list.Any()) { continue; } var destinationFolderPath = string.Format(destinationFileFormate, corporateAccount.FolderName, DateTime.Today.Year); var fileName = "IncorrectPhoneNumber.csv"; if (_settings.OptumIncorrectPhoneNumberAccountIds.Contains(corporateAccount.Id)) { destinationFolderPath = string.Format(_settings.OptumIncorrectPhoneNumberDownloadPath, corporateAccount.FolderName); fileName = "IncorrectPhoneNumber" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; } else if (corporateAccount.Id == _martinsPointExclusiveAccountId) { fileName = "Exclusive_IncorrectPhoneNumber.csv"; } else if (corporateAccount.Id == _settings.ExcellusAccountId) { destinationFolderPath = Directory.GetParent(destinationFolderPath).FullName; fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; } else if (corporateAccount.Id == _settings.HealthNowAccountId) { destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName); fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "IncorrectPhoneNumber*.csv"); } else if (corporateAccount.Id == _settings.MedMutualAccountId) { destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName); fileName = "IncorrectPhoneNumbers_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "IncorrectPhoneNumbers*.csv"); } else if (corporateAccount.Id == _settings.WellmedWellCareAccountId) { var wellmedAccount = healthPlans.FirstOrDefault(x => x.Id == _settings.WellmedAccountId); if (wellmedAccount != null) { destinationFolderPath = string.Format(destinationFileFormate, wellmedAccount.FolderName, DateTime.Today.Year); fileName = "WCR_IncorrectPhoneNumbers_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; } DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "WCR_IncorrectPhoneNumbers*.csv"); } else if (corporateAccount.Id == _settings.ConnecticareAccountId) { destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName); fileName = "Comm Incorrect Phone Number " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv"; } else if (corporateAccount.Id == _settings.ConnecticareMaAccountId) { destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName); fileName = "MCR Incorrect Phone Number " + DateTime.Today.ToString("yyyy-MM-dd") + ".csv"; } else if (corporateAccount.Id == _settings.BcbsScAccountId || corporateAccount.Id == _settings.BcbsScAssessmentAccountId) { destinationFolderPath = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName); } else if (corporateAccount.Id == _settings.FloridaBlueFepAccountId) { destinationFolderPath = Path.Combine(string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName), "Reports"); fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; DirectoryOperationsHelper.DeleteFiles(destinationFolderPath, "IncorrectPhoneNumber*.csv"); } else if (corporateAccount.Id == _settings.PPAccountId) { logger.Info("PP Account"); destinationFolderPath = string.Format(_settings.HealthPlanDownloadPath, corporateAccount.FolderName); fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; } else if (corporateAccount.Id == _settings.NammAccountId) { logger.Info("Namm Account Id"); destinationFolderPath = string.Format(_settings.HealthPlanExportRootPath, corporateAccount.FolderName); fileName = "IncorrectPhoneNumber_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; } //else if (corporateAccount.Id == _settings.HcpNvAccountId) //{ // logger.Info("HCP NV"); // var folderName = _settings.HcpNvFolder; // destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "IncorrectPhone"); // fileName = string.Format("IncorrectPhoneNumber_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy")); //} else if (corporateAccount.Id == _settings.WellmedAccountId) { logger.Info("Wellmed FL"); var folderName = _settings.WellmedFlFolder; destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "IncorrectPhone"); fileName = string.Format("IncorrectPhoneNumber_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy")); } else if (corporateAccount.Id == _settings.WellmedTxAccountId) { logger.Info("Wellmed TX"); var folderName = _settings.WellmedTxFolder; destinationFolderPath = Path.Combine(string.Format(_settings.OutTakeReportPath, folderName), "IncorrectPhone"); fileName = string.Format("IncorrectPhoneNumber_{0}_{1}_{2}.csv", corporateAccount.AcesClientShortName, folderName, DateTime.Today.ToString("MMddyyyy")); } if (_settings.OptumAccountIds.Contains(corporateAccount.Id)) { try { DirectoryOperationsHelper.DeleteDirectory(destinationFolderPath, true); } catch (Exception ex) { logger.Error("Some error occurred while deleting directory at path: " + destinationFolderPath); logger.Error("Message: " + ex.Message); logger.Error("Stack Trace: " + ex.StackTrace); } } if (!Directory.Exists(destinationFolderPath)) { Directory.CreateDirectory(destinationFolderPath); } var destinationFileName = Path.Combine(destinationFolderPath, fileName); if (File.Exists(destinationFileName)) { File.Delete(destinationFileName); } logger.Info(string.Format("Corporate Tag: {0} StartDate: {1} Create CSV at Path: {2} ", filter.CorporateTag, filter.StartDate.ToShortDateString(), destinationFileName)); WriteCsv(destinationFileName, list, logger); //if (File.Exists(destinationFileName)) //{ // if (corporateAccount.Id == _settings.FloridaBlueFepAccountId && _settings.SendReportToFloridaBlueSftp) // { // var destinationSftpPath = _settings.FloridaBlueSftpPath + "\\" + corporateAccount.FolderName + "\\Download\\Reports"; // PostFile(destinationFileName, destinationSftpPath, _settings.FloridaBlueSftpHost, _settings.FloridaBlueSftpUserName, _settings.FloridaBlueSftpPassword, fileName, logger); // } // else // { // SendIncorrectPhoneNumberClientSftp(corporateAccount, destinationFileName, logger); // } //} } }
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 void PollForTestNotPerformed() { try { if (DateTime.Today.DayOfWeek != _dayOfWeek) { _logger.Info(string.Format("todays day : {0}, export set to run on {1}", DateTime.Today.DayOfWeek, _dayOfWeek)); return; } var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); _logger.Info("Test Not Performed Report Started"); foreach (var healthPlan in healthPlans) { try { _logger.Info(string.Format("Report Generation Started for {0} ", healthPlan.Tag)); var toDate = DateTime.Today.Date; var fromDate = DateTime.Today.AddDays(-7); if (fromDate.Year == toDate.Year) { fromDate = new DateTime(fromDate.Year, 1, 1); var filter = new TestNotPerformedListModelFilter { EventDateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, EventDateTo = toDate, HealthPlanId = healthPlan.Id, }; GenerateTestNotPerformedCsvByFilter(filter, healthPlan); } else { //for Previous Year fromDate = new DateTime(fromDate.Year, 1, 1); var filter = new TestNotPerformedListModelFilter { EventDateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, EventDateTo = new DateTime(fromDate.Year, 12, 31), HealthPlanId = healthPlan.Id, }; GenerateTestNotPerformedCsvByFilter(filter, healthPlan); //for current Year fromDate = new DateTime(toDate.Year, 1, 1); filter = new TestNotPerformedListModelFilter { EventDateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, EventDateTo = toDate, HealthPlanId = healthPlan.Id, }; GenerateTestNotPerformedCsvByFilter(filter, healthPlan); } _logger.Info(string.Format("Report Generation Completed for {0} ", healthPlan.Tag)); } catch (Exception ex) { _logger.Info(string.Format("Some Error Exception Occured while Generating Report for Tag: {0} Message: {1} Stack Trace {2}", healthPlan.Tag, ex.Message, ex.StackTrace)); _logger.Info(string.Format("Report Generation Completed for {0} ", healthPlan.Tag)); } } } catch (Exception ex) { _logger.Info(string.Format("Some Error Exception Occured Message: {0} Stack Trace {1}", ex.Message, ex.StackTrace)); } }
public CampaignListModel GetCampaignDetails(int pageNumber, int pageSize, CampaignListModelFilter filter, out int totalRecords) { var campaigns = _campaignRepository.GetCampaignDetails(pageNumber, pageSize, filter, out totalRecords); if (campaigns == null || !campaigns.Any()) { return(null); } var campaignIds = campaigns.Select(x => x.Id).ToArray(); //IEnumerable<CampaignAssignment> campaignAssignment = null; //if (campaignIds != null && campaignIds.Any()) //{ // campaignAssignment = _campaignAssignmentRepository.GetByCampaignIds(campaignIds); //} var campaignCreatedByIds = campaigns.Select(cg => cg.DataRecorderMetaData.DataRecorderCreator.Id).ToArray(); var campaignModifiedByIds = campaigns.Select(cg => cg.DataRecorderMetaData.DataRecorderModifier.Id).ToArray(); if (campaignCreatedByIds != null && campaignCreatedByIds.Any()) { campaignCreatedByIds = campaignCreatedByIds.Concat(campaignModifiedByIds).ToArray(); } var campaignActivity = _campaignActivityRepository.GetByCampaignIds(campaignIds); IEnumerable <CampaignActivityAssignment> campaignActivityAssignment = null; if (campaignActivity != null && campaignActivity.Any()) { var campaignActivityIds = campaignActivity.Select(x => x.Id).ToArray(); if (campaignActivityIds != null && campaignActivityIds.Any()) { campaignActivityAssignment = _campaignActivityAssignmentRepository.GetByCampaignActivityIds(campaignActivityIds).ToArray(); if (campaignActivityAssignment != null && campaignActivityAssignment.Any()) { var activityAssignmentOrgRoleIds = campaignActivityAssignment.Select(x => x.AssignedToOrgRoleUserId).Distinct().ToArray(); campaignCreatedByIds = campaignCreatedByIds.Concat(activityAssignmentOrgRoleIds).ToArray(); } } } IEnumerable <OrderedPair <long, string> > campaignCreatedByAgentNameIdPair = null; if (campaignCreatedByIds != null && campaignCreatedByIds.Any()) { campaignCreatedByAgentNameIdPair = _organizationRoleUserRepository.GetNameIdPairofUsers(campaignCreatedByIds).ToArray(); } var directMailTypes = _directMailTypeRepository.GetAll(); var corporateAccounts = _corporateAccountRepository.GetAllHealthPlan(); return(_campaignListModelFactory.Create(campaigns, campaignCreatedByAgentNameIdPair, corporateAccounts, campaignActivity, campaignActivityAssignment, directMailTypes)); }
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 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)); } }
public void PollForRegeneration() { try { if (!_settings.RegenerateAccountEventZip) { _logger.Info("Unable to start the service as Regeneration is set to false."); return; } var timeOfDay = DateTime.Now; _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss")); var startTime = new TimeSpan(_settings.AccountZipSubstituteStartTime, 0, 0); var endTime = new TimeSpan(_settings.AccountZipSubstituteEndTime, 0, 0); if (_settings.IsDevEnvironment == false && (timeOfDay.TimeOfDay < startTime || timeOfDay.TimeOfDay > endTime)) { _logger.Info(string.Format("Account Event Zip is generated only between {0} and {1}.", startTime.ToString(), endTime.ToString())); return; } _logger.Info("Starting Account Event Zip Regeneration Service."); var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); if (healthPlans.IsNullOrEmpty()) { _logger.Info("No Healthplans found for regeeration."); return; } var settingFilePath = Path.Combine(_settingFilePath, "AccountEventZipRegeneration.xml"); var generationSetting = Deserialize(settingFilePath); if (generationSetting.LastGeneratedTable == AccountEventZipGenerationType.AccountEventZipSubstitute.ToString()) { _logger.Info("Regenerating for table : " + AccountEventZipGenerationType.AccountEventZip); } else { _logger.Info("Regenerating for table : " + AccountEventZipGenerationType.AccountEventZipSubstitute); } try { foreach (var healthPlan in healthPlans) { _logger.Info(string.Format("Regenerating Account Event Zip for AccountID : {0} and Tag : {1}", healthPlan.Id, healthPlan.Tag)); InsertAccountEventZip(healthPlan.Id, healthPlan.Tag, generationSetting); } foreach (var healthPlan in healthPlans) { _logger.Info(string.Format("Deleting for AccountID : {0} and Tag : {1}", healthPlan.Id, healthPlan.Tag)); if (generationSetting.LastGeneratedTable == AccountEventZipGenerationType.AccountEventZipSubstitute.ToString()) { _accountEventZipReposiory.DeleteFromSubstitute(healthPlan.Id); } else { _accountEventZipReposiory.Delete(healthPlan.Id); } } if (generationSetting.LastGeneratedTable == AccountEventZipGenerationType.AccountEventZipSubstitute.ToString()) { generationSetting.LastGeneratedTable = AccountEventZipGenerationType.AccountEventZip.ToString(); } else { generationSetting.LastGeneratedTable = AccountEventZipGenerationType.AccountEventZipSubstitute.ToString(); } generationSetting.LastGenerationDateTime = timeOfDay; SerializeandSave(settingFilePath, generationSetting); _logger.Info("Completed Account Event Zip Regeneration Service."); } catch (Exception ex) { _logger.Error(string.Format("Error Occured While Regenerating Account Event Zip. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } } catch (Exception ex) { _logger.Error(string.Format("Error Occured While Regenerating Account Event Zip. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } }
public void PollForOutreachReport() { try { var today = DateTime.Today; if (today.DayOfWeek != _dayOfWeek) { _logger.Info(string.Format("todays day : {0}, export set to run on {1}", today.DayOfWeek, _dayOfWeek)); return; } _logger.Info("Polling for Out reach report started"); var healthPlans = _corporateAccountRepository.GetAllHealthPlan().Where(hp => _healthPlanIds.Contains(hp.Id)); foreach (var healthPlan in healthPlans) { _logger.Info(string.Format("Polling for Out reach report started for Account Id {0} ", healthPlan.Id)); try { var fromDate = DateTime.Today.AddDays(-7); if (fromDate.Year == today.Year) { fromDate = new DateTime(fromDate.Year, 1, 1); var filter = new OutreachCallReportModelFilter { Tag = healthPlan.Tag, DateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, DateTo = today, CallAttemptFilter = CallAttemptFilterStatus.All, }; var filePath = GetOutreachFilePath(healthPlan, today.Year); _callCenterExportableReportHelper.OutreachCallReportExport(filter, filePath, _logger); } else { //for Previous Year fromDate = new DateTime(fromDate.Year, 1, 1); var filter = new OutreachCallReportModelFilter { DateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, DateTo = new DateTime(fromDate.Year, 12, 31), CallAttemptFilter = CallAttemptFilterStatus.All, }; var filePath = GetOutreachFilePath(healthPlan, fromDate.Year); _callCenterExportableReportHelper.OutreachCallReportExport(filter, filePath, _logger); //for current Year fromDate = new DateTime(today.Year, 1, 1); filter = new OutreachCallReportModelFilter { DateFrom = _cutOfDate > fromDate ? _cutOfDate : fromDate, DateTo = today, CallAttemptFilter = CallAttemptFilterStatus.All, }; filePath = GetOutreachFilePath(healthPlan, fromDate.Year); _callCenterExportableReportHelper.OutreachCallReportExport(filter, filePath, _logger); } } catch (Exception exception) { _logger.Error(string.Format("Exception occured while polling for outreach report for Account Id {0}. Exception Message : {1}, Stack Trace {2}", healthPlan.Id, exception.Message, exception.StackTrace)); } _logger.Info(string.Format("Polling for Outreach report completed for Account Id {0} ", healthPlan.Id)); } } catch (Exception ex) { _logger.Error(string.Format("Exception occured while polling for outreach report. Exception Message : {0}, Stack Trace {1}", ex.Message, ex.StackTrace)); } }
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)); } }
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 PollForTestPerformedReports() { try { if (_dayOfMonth != DateTime.Today.Day) { _logger.Info(string.Format("Report will not be generated today as it set to {0} of every month", _dayOfMonth)); return; } var healthPlans = _corporateAccountRepository.GetAllHealthPlan(); _logger.Info(string.Format("health plan count " + healthPlans.Count())); if (!healthPlans.Any()) { return; } _logger.Info(string.Format("destination Path for All Reports {0}", _reportDestinationPath)); foreach (var healthPlan in healthPlans) { try { var directoryPath = string.Format(_reportDestinationPath, healthPlan.Tag); CreateDistinationDirectory(directoryPath); var reportingMonth = DateTime.Today.AddMonths(-1); var dateFrom = reportingMonth.GetFirstDayOfMonth(); var dateTo = reportingMonth.GetLastDayOfMonth(); var fileName = string.Format("{0}_{1}_{2}.csv", healthPlan.Tag, dateFrom.ToString("MMMM"), dateFrom.ToString("yyyy")); var filter = new TestPerformedListModelFilter { EventDateFrom = dateFrom, EventDateTo = dateTo, HealthPlanId = healthPlan.Id, Tag = healthPlan.Tag }; _logger.Info("generating Report for " + healthPlan.Tag); var dataGen = new ExportableDataGenerator <TestPerformedViewModel, TestPerformedListModelFilter>(_testResultService.GetTestPerformed, _logger); var model = dataGen.GetData(filter); if (model != null && !model.Collection.IsNullOrEmpty()) { var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <TestPerformedViewModel>(); _logger.Info("Record count" + model.Collection.Count()); if (File.Exists(directoryPath + fileName)) { File.Delete(directoryPath + fileName); } //_baseExportableReportHelper.GenerateCsv(directoryPath + fileName, exporter, model.Collection); _testPerformedCsvExportHelper.WriteCsvTestPerformed(directoryPath, fileName, model.Collection); } else { _logger.Info("No Record Found for Tag" + healthPlan.Tag); } } catch (Exception ex) { _logger.Error("Some Error occurred for Tag" + healthPlan.Tag); _logger.Error("Message: " + ex.Message); _logger.Error("Stack Trace: " + ex.StackTrace); } } } catch (Exception exception) { _logger.Error("Some Error occurred "); _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } }