public void PollForAppointmentBookedReport() { try { foreach (var customTag in _customTags) { try { _logger.Info("Running report for CustomTag: " + customTag); var corporateTag = _corporateTagRepository.GetByTag(customTag); if (corporateTag == null) { _logger.Info("No Corporate Tag Found: " + customTag); continue; } var account = ((IUniqueItemRepository <CorporateAccount>)_corporateAccountRepository).GetById(corporateTag.CorporateId); _logger.Info(string.Format("Generating AppointmentBooked for accountId {0} and account tag {1}. ", account.Id, account.Tag)); DateTime fromDate; if (DateTime.Now.Year > _cutOfDate.Date.Year) { fromDate = DateTime.Today.GetFirstDateOfYear(); } else { fromDate = _cutOfDate; } var folderStateCode = string.Empty; if (_settings.AnthemAccountId == account.Id) { folderStateCode = "CA"; } else { foreach (var stateCode in _settings.AnthemCustomTagStates) { if (customTag.Contains(stateCode)) { folderStateCode = stateCode.Substring(stateCode.Length - 2); break; } } } if (folderStateCode == string.Empty) { continue; } var toDate = DateTime.Today.GetLastDateOfYear(); var destinationPath = string.Format(_settings.AnthemDownloadPath, folderStateCode); destinationPath = Path.Combine(destinationPath, "Appointments"); CreateDistinationDirectory(destinationPath); try { var files = Directory.GetFiles(destinationPath); var fileNottoDeleted = Directory.GetFiles("HLTHFAIR_" + "*.csv"); if (files.Any()) { foreach (var file in files) { if (!fileNottoDeleted.Contains(file)) { File.Delete(file); } } } } catch { } var appointmentFileName = "HLTHFAIR_appointmentsbooked_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; var appointmentSettings = string.Format(_appointmentSettings, account.Tag); var customSettings = _customSettingManager.Deserialize(appointmentSettings); _logger.Info(string.Format("Generating AppointmentBooked Date From. {0} To Date {1}", fromDate.Date.ToShortDateString(), toDate.ToShortDateString())); var customTags = new[] { customTag }; AppointmentsBooked(new AppointmentsBookedListModelFilter { EventFrom = fromDate, EventTo = toDate.Date, AccountId = account.Id, CustomTags = customTags, Tag = account.Tag }, destinationPath, appointmentFileName); var fileName = Path.Combine(destinationPath, appointmentFileName); _logger.Info(string.Format("Completed AppointmentBooked Date From. {0} To Date {1}", fromDate.Date.ToShortDateString(), toDate.ToShortDateString())); if (File.Exists(fileName)) { _pgpFileEncryptionHelper.EncryptFile(account, fileName); } else { _logger.Info("file Not found " + fileName); } customSettings.LastTransactionDate = toDate; _customSettingManager.SerializeandSave(appointmentSettings, customSettings); } catch (Exception ex) { _logger.Error(string.Format("Exception For custom Tag {0} : \n Error {1} \n Trace: {2} \n\n\n", customTag, ex.Message, ex.StackTrace)); } } } catch (Exception ex) { _logger.Error("Message " + ex.Message); _logger.Error("Stack Trace " + ex.StackTrace); } }
public void PollForCustomerExport() { try { _logger.Info("Stated Corporate Customer Export for Anthem Home Visit Requested."); if (DateTime.Today.DayOfWeek != _dayOfWeek) { _logger.Info("Day of the week is " + ((long)DateTime.Today.DayOfWeek)); return; } foreach (var customTag in _settings.AnthemCustomTags) { try { var corporateTag = _corporateTagRepository.GetByTag(customTag); if (corporateTag == null) { _logger.Info("No Corporate Account Found for the Tag: " + customTag); continue; } var corporateAccount = _corporateAccountReporsitory.GetById(corporateTag.CorporateId); if (corporateAccount == null) { _logger.Info("No Corporate Account Found for the Tag: " + customTag); continue; } _logger.Info("running for Custom Tag: " + customTag); var filter = new HealthPlanCustomerExportFilter { CallStatus = CallStatus.Attended, CorporateTag = corporateAccount.Tag, StartDate = new DateTime(DateTime.Today.Year, 1, 1), Tag = ProspectCustomerTag.HomeVisitRequested, CustomTags = new[] { customTag } }; var folderStateCode = string.Empty; foreach (var stateCode in _settings.AnthemCustomTagStates) { if (customTag.Contains(stateCode)) { folderStateCode = stateCode.Substring(stateCode.Length - 2); break; } } if (folderStateCode == string.Empty) { continue; } var destinationPath = string.Format(_settings.AnthemDownloadPath, folderStateCode); destinationPath = Path.Combine(destinationPath, "HomeVisitRequest"); var fileName = string.Format("HLTHFAIR_HomeVisitRequest_{0}.csv", DateTime.Today.ToString("yyyyMMdd")); _healthPlanCustomerExportService.AnthemHomeVisitRequestedCustomerExport(filter, destinationPath, fileName, _logger); _logger.Info("completed for Custom Tag: " + customTag); } catch (Exception exception) { _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } } } catch (Exception ex) { _logger.Error(string.Format("Error while Creating Csv Home Visit Requested list. Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } _logger.Info("Completed Corporate Customer Export for Anthem Home Visit Requested."); }
public void ResultExport() { try { string[] showAdditionalFields = null; if (!string.IsNullOrEmpty(_settings.AnthemAdditionalFieldValues)) { showAdditionalFields = _settings.AnthemAdditionalFieldValues.Split(new char[','], StringSplitOptions.RemoveEmptyEntries); } foreach (var customTag in _customTags) { try { _logger.Info("Running report for CustomTag: " + customTag); var corporateTag = _corporateTagRepository.GetByTag(customTag); if (corporateTag == null) { _logger.Info("No Corporate Tag Found: " + customTag); continue; } var account = (_corporateAccountRepository).GetById(corporateTag.CorporateId); _logger.Info(string.Format("Generating AppointmentBooked for accountId {0} and account tag {1}. ", account.Id, account.Tag)); var folderStateCode = string.Empty; if (account.Id == _anthemAccountId) { folderStateCode = "CA"; } else { foreach (var stateCode in _settings.AnthemCustomTagStates) { if (customTag.Contains(stateCode)) { folderStateCode = stateCode.Substring(stateCode.Length - 2); break; } } } if (folderStateCode == string.Empty) { continue; } var destinationPath = string.Format(_settings.AnthemDownloadPath, folderStateCode); destinationPath = Path.Combine(destinationPath, "results"); var resultExportSettings = string.Format(_resultExportSettings, account.Tag); var customSettings = _customSettingManager.Deserialize(resultExportSettings); var fromDate = customSettings.LastTransactionDate ?? DateTime.Today.GetFirstDateOfYear(); var toDate = DateTime.Now; CreateDistinationDirectory(destinationPath); CreateDistinationDirectory(_accumulativeResultExportsPath); CreateDistinationDirectory(_incrementalResultExportsPath); var customTags = new[] { customTag }; var finalFilename = string.Format("HLTHFAIR_ResultsExport_{0}.csv", DateTime.Today.ToString("yyyyMMdd")); var incrementalFile = string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, Guid.NewGuid()); var cumulativeFilePath = Path.Combine(_accumulativeResultExportsPath, string.Format(@"ResultExport_{0}_{1}.csv", account.Tag, DateTime.Today.Year)); var incrementalFilePath = Path.Combine(_incrementalResultExportsPath, incrementalFile); var finalFilePath = Path.Combine(destinationPath, finalFilename); DateTime?stopSendingPdftoHealthPlanDate = null; if (account != null && account.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate; } _pcpResultExportServiceHelper.ResultExport(fromDate, toDate, account.Id, _incrementalResultExportsPath, account.Tag, customTags, resultExportFileName: incrementalFile, considerEventDate: true, eventStartDate: fromDate.GetFirstDateOfYear(), eventEndDate: fromDate.GetLastDateOfYear(), showHiddenAdditionalFields: showAdditionalFields, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); _pcpResultExportServiceHelper.CreateCumulativeFileAndPost(incrementalFilePath, cumulativeFilePath, finalFilePath); if (DirectoryOperationsHelper.IsFileExist(finalFilePath)) { _pgpFileEncryptionHelper.EncryptFile(account, finalFilePath); } customSettings.LastTransactionDate = toDate; _customSettingManager.SerializeandSave(resultExportSettings, customSettings); } catch (Exception ex) { _logger.Error(string.Format("Custom Tag {0} Message: {1} \n Stack Trace: {2} ", customTag, ex.Message, ex.StackTrace)); } } } catch (Exception ex) { _logger.Error(string.Format("Message: {0} \n Stack Trace: {1} ", ex.Message, ex.StackTrace)); } }