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"); } }