private void ExportResultOnBcbsMnSftp(string fileName, string sourcePath, string eventSftpPdfDirectory) { _logger.Info("Destination Path: " + eventSftpPdfDirectory + "//" + fileName); _logger.Info("Source Path: " + sourcePath); var processFtp = new ProcessFtp(_logger, _bcbsMnSftpHost, _bcbsMnSftpUserName, _bcbsMnSftpPassword); processFtp.UploadSingleFile(sourcePath, eventSftpPdfDirectory, fileName); }
private void ExportResultInSftp(string fileName, string sourcePath, string eventSftpPdfDirectory) { _logger.Info("source Path: " + sourcePath); _logger.Info("destination Path: " + Path.Combine(eventSftpPdfDirectory, fileName)); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(sourcePath, eventSftpPdfDirectory, fileName); }
private void ExportResultOnWellCareSftp(string fileName, string sourcePath) { _logger.Info("Destination Path: " + _settings.WellCareSftpPath); _logger.Info("File Name Path: " + fileName); _logger.Info("Source Path: " + sourcePath); var processFtp = new ProcessFtp(_logger, _settings.WellCareSftpHost, _settings.WellCareSftpUserName, _settings.WellCareSftpPassword); processFtp.UploadSingleFile(sourcePath, _settings.WellCareSftpPath, fileName); }
private void ExportResultInSftp(string fileName, string sourcePath, SftpCridential sftpCridential) { _logger.Info("Destination Path: " + sftpCridential.SftpPath + "\\" + fileName); _logger.Info("Source Path: " + sourcePath); var processFtp = new ProcessFtp(_logger, sftpCridential.HostName, sftpCridential.UserName, sftpCridential.Password); processFtp.UploadSingleFile(sourcePath, sftpCridential.SftpPath, fileName); _logger.Info("Sending data to sftp succeded "); }
private bool UploadSingleFile(string sourcePath, string destination, string hostName, string userName, string password) { var processFtp = new ProcessFtp(_logger, hostName, userName, password); var fileName = Path.GetFileName(sourcePath); _logger.Info("Destination Path: " + destination); _logger.Info("File Name Path: " + fileName); _logger.Info("Source Path: " + sourcePath); return(processFtp.UploadSingleFile(sourcePath, destination, fileName)); }
public void UploadResultPdfFileTest() { var logger = new NLogLogManager().GetLogger("Upload"); var setting = new FakeSettings(); var strinname = Directory.GetParent("//download//Reports//pdf//09-08-2015"); var processFtp = new ProcessFtp(logger, setting.HcpNvSftpHost, setting.HcpNvSftpUserName, setting.HcpNvSftpPassword); var destinationPathOnSftp = (!string.IsNullOrEmpty(setting.HcpNvSftpResultReportDownloadPath) ? setting.HcpNvSftpResultReportDownloadPath + "/" : string.Empty) + "IncorrectPhoneNumber"; processFtp.UploadSingleFile(@"F:\test.pdf", destinationPathOnSftp, ("test_20170828" + ".pdf")); //processFtp.DownloadFiles(setting.HcpNvLockCorporateEventFolderLocation + "/HomeVisitRequest", @"F:\SFTP\HCP NV\HomeVisitRequest"); // processFtp.UploadSingleFile(@"D:\Projects\Falcon\branches\QA\src\UI\media.falcon.com\ResultPacket\39786\PremiumVersion\847108\PcpResultReport.pdf", @"download\Reports\pdf\09-08-2015", ("999988" + ".pdf")); }
private bool ExportReportOnMatrixSftp(string fileName, string sourcePath) { var destinationPathOnSftp = _settings.CustomerConsentDataReportSftpPath; destinationPathOnSftp = destinationPathOnSftp.Replace("/", "\\"); _logger.Info("Destination Path: " + destinationPathOnSftp); _logger.Info("File Name: " + fileName); _logger.Info("Source Path: " + sourcePath); var processFtp = new ProcessFtp(_logger, _settings.MatrixSftpHost, _settings.MatrixSftpUserName, _settings.MatrixSftpPassword); return(processFtp.UploadSingleFile(sourcePath, destinationPathOnSftp, fileName)); }
private void ExportResultInSftp(string fileName, string sourcePath) { _logger.Info("Destination Path: " + _sftpPath + "\\" + fileName); _logger.Info("Source Path: " + sourcePath); var sftpCridential = _sftpCridentialManager.Deserialize(_sftpCridentailPath + "MonarchWellmedPdfPath.xml"); if (sftpCridential != null) { var processFtp = new ProcessFtp(_logger, sftpCridential.HostName, sftpCridential.UserName, sftpCridential.Password); processFtp.UploadSingleFile(sourcePath, _sftpPath, fileName); } }
private bool ExportReportOnWellMedSftp(string fileName, string sourcePath) { var destinationPathOnSftp = _settings.WellmedMemberStatusReportSftpPath; destinationPathOnSftp = destinationPathOnSftp.Replace("/", "\\"); _logger.Info("Destination Path: " + destinationPathOnSftp); _logger.Info("File Name: " + fileName); _logger.Info("Source Path: " + sourcePath); var processFtp = new ProcessFtp(_logger, _settings.WellmedSftpHost, _settings.WellmedSftpUserName, _settings.WellmedSftpPassword); return(processFtp.UploadSingleFile(sourcePath, destinationPathOnSftp, fileName)); }
private bool ExportResultOnHcpNvSftp(string fileName, string sourcePath, long eventId, bool isPdf = true) { //var destinationPathOnSftp = string.Format("{0}/{1}/{2}", _settings.HcpNvSftpResultReportDownloadPath, "Completed Pt. Documentation", eventId); var destinationPathOnSftp = (!string.IsNullOrEmpty(_settings.HcpNvSftpResultReportDownloadPath) ? _settings.HcpNvSftpResultReportDownloadPath + "/" : string.Empty) + "Completed Pt. Documentation" + "/" + eventId; destinationPathOnSftp = destinationPathOnSftp.Replace("/", "\\"); _logger.Info("Destination Path: " + destinationPathOnSftp); _logger.Info("File Name Path: " + fileName); _logger.Info("Source Path: " + sourcePath); var processFtp = new ProcessFtp(_logger, _settings.HcpNvSftpHost, _settings.HcpNvSftpUserName, _settings.HcpNvSftpPassword); return(processFtp.UploadSingleFile(sourcePath, destinationPathOnSftp, fileName)); }
public void PollForEventScheduleReort() { try { _logger.Info("starting Event Schedule Report"); var accounts = _corporateAccountRepository.GetByIds(_settings.EventScheduleAccountIds); foreach (var account in accounts) { _logger.Info("Event Schedule Report for Account Tag" + account.Tag); if ((account.Id == _settings.ConnecticareAccountId || account.Id == _settings.ConnecticareMaAccountId) && DateTime.Today.DayOfWeek != _settings.ConnecticareEventScheduleExportDay) { _logger.Info("today is " + DateTime.Today.DayOfWeek + " while service is configured to run on " + _settings.ConnecticareEventScheduleExportDay); _logger.Info("Please set " + (int)DateTime.Today.DayOfWeek + " to run Service today"); continue; } var fromDate = new DateTime(DateTime.Today.Year, 1, 1); var toDate = new DateTime(DateTime.Today.Year, 12, 31); var filter = new EventScheduleListModelFilter { AccountId = account.Id, FromDate = fromDate, ToDate = toDate, }; var stateIds = _eventRepository.GetEventStateByAccountId(filter); if (stateIds.IsNullOrEmpty()) { _logger.Info("No State found for Account Tag " + account.Tag); continue; } var states = _stateRepository.GetStates(stateIds); foreach (var state in states) { try { _logger.Info("fetching records for State Name " + state.Name); filter.StateId = state.Id; var dataGen = new ExportableDataGenerator <EventScheduleModel, EventScheduleListModelFilter>(_eventReportingService.GetEventScheduleReport, _logger); var model = dataGen.GetData(filter); if (model != null && !model.Collection.IsNullOrEmpty()) { _logger.Info("Writing Event Schedule Report"); var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <EventScheduleModel>(); _logger.Info("Record count" + model.Collection.Count()); var eventScheduleReportPath = Path.Combine(_settings.EventScheduleReportPath, DateTime.Today.Year.ToString()); DirectoryOperationsHelper.CreateDirectoryIfNotExist(eventScheduleReportPath); var reportName = "EventScheduleReport_" + account.Tag + "_" + state.Name + "_" + DateTime.Today.ToString("yyyyMMdd") + ".csv"; var reportfilePath = Path.Combine(eventScheduleReportPath, reportName); if (account.Id == _settings.ConnecticareAccountId || account.Id == _settings.ConnecticareMaAccountId) { reportfilePath = Path.Combine(_settings.HealthPlanDownloadPath, account.FolderName); reportfilePath = Path.Combine(reportfilePath, reportName); } DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath); _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection); _logger.Info("Generated report of Event Schedule Report for Account " + account.Tag + " state " + state.Name); _logger.Info("Path: " + reportfilePath + " state " + state.Name); if (_sendReportToSftp) { _logger.Info("Sending file to sftp."); var eventScheduleReportSftpPath = string.Format(_eventScheduleReportSftpPath, fromDate.Year); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(reportfilePath, eventScheduleReportSftpPath, ""); _logger.Info("File sent on sftp."); } } } catch (Exception ex) { _logger.Error("some Error occurred while generating report of Event Schedule Report for Account " + account.Tag + " state " + state.Name); _logger.Error("ex: " + ex.Message); _logger.Error("stack Trace: " + ex.StackTrace); } } } } catch (Exception ex) { _logger.Error("some Error occurred while generating report of Event Schedule Report "); _logger.Error("ex: " + ex.Message); _logger.Error("stack Trace: " + ex.StackTrace); } }
public void PollForAppointmentBookExport() { try { _logger.Info("Day of the Week is " + _dayOfWeek); if (_accountId <= 0 || DateTime.Today.DayOfWeek != _dayOfWeek) { return; } var account = _corporateAccountRepository.GetById(_accountId); if (account == null) { _logger.Info("Account can't be null"); return; } _logger.Info(string.Format("Generating AppointmentBooked for accountId {0} and account tag {1}. ", account.Id, account.Tag)); var toDate = DateTime.Now; var fromDate = toDate.AddDays(-7); var destinationPath = string.Format(_destinationAppointmentBookedReportPath, fromDate.Year); try { var files = Directory.GetFiles(destinationPath); if (files.Any()) { foreach (var file in files) { File.Delete(file); if (_sendReportToSftp) { var sftpFolderAppointmentBookedReportDirectory = string.Format(_destinationSftpFolderAppointmentBookedReportPath, fromDate.Year); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.RemoveFile(sftpFolderAppointmentBookedReportDirectory, Path.GetFileName(file)); } } } } catch { } CreateDestinationDirectory(destinationPath); var sourcePath = destinationPath + string.Format(@"\{0}_{1}.csv", toDate.ToString("yyyyMMdd"), fromDate.ToString("yyyyMMdd")); AppointmentsBooked(new AppointmentsBookedListModelFilter { FromDate = fromDate, ToDate = toDate.Date, AccountId = account.Id, Tag = account.Tag }, sourcePath); if (File.Exists(sourcePath)) { sourcePath = _pgpFileEncryptionHelper.EncryptFile(account, sourcePath); } if (_sendReportToSftp) { var sftpFolderAppointmentBookedReportDirectory = string.Format(_destinationSftpFolderAppointmentBookedReportPath, fromDate.Year); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(sourcePath, sftpFolderAppointmentBookedReportDirectory, ""); } } catch (Exception ex) { _logger.Error(string.Format("Main App: \n Error {0} \n Trace: {1} \n\n\n", ex.Message, ex.StackTrace)); } }
public void PollForAppointmentBookExport() { try { if (_accountIds.IsNullOrEmpty()) { return; } var accounts = (_corporateAccountRepository).GetByIds(_accountIds); if (accounts.IsNullOrEmpty()) { _logger.Info("Accounts can't be null"); return; } foreach (var account in accounts) { _logger.Info("Running for account " + account.Tag); var list = new List <AppointmentsBookedModel>(); var toDate = DateTime.Today.GetLastDateOfYear(); var destinationPath = string.Format(_destinationAppointmentBookedReportPath, toDate.Year); destinationPath = Path.Combine(destinationPath, account.FolderName); var sourcePath = destinationPath + string.Format(@"\WCR_AppointmentBookedReport_{0}.csv", DateTime.Today.ToString("yyyyMMdd")); var appointmentSettings = string.Format(_appointmentSettings, "WellCareToWellmed"); var customSettings = _customSettingManager.Deserialize(appointmentSettings); customSettings = customSettings ?? new CustomSettings(); var fromDate = (customSettings.LastTransactionDate == null) ? _cutOfDate : DateTime.Today.GetFirstDateOfYear(); _logger.Info(string.Format("Generating AppointmentBooked for accountId {0} and account tag {1}. ", account.Id, account.Tag)); CreateDistinationDirectory(destinationPath); list.AddRange(AppointmentsBooked(new AppointmentsBookedListModelFilter { EventFrom = fromDate, EventTo = toDate.Date, AccountId = account.Id, Tag = account.Tag })); if (File.Exists(sourcePath)) { sourcePath = _pgpFileEncryptionHelper.EncryptFile(account, sourcePath); } customSettings.LastTransactionDate = toDate; _customSettingManager.SerializeandSave(appointmentSettings, customSettings); if (list.Any()) { _appointmentBookedExportCsvHelper.WriteCsv(list, sourcePath, _logger); if (_sendReportToSftp) { var sftpFolderAppointmentBookedReportDirectory = string.Format(_destinationSftpFolderAppointmentBookedReportPath, toDate.Year); sftpFolderAppointmentBookedReportDirectory = sftpFolderAppointmentBookedReportDirectory + "\\" + account.FolderName; _logger.Info("source path:" + sourcePath); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(sourcePath, sftpFolderAppointmentBookedReportDirectory, ""); _logger.Info("destination :" + sftpFolderAppointmentBookedReportDirectory); } } else { _logger.Info("No Records Found for account " + account.Tag); } _logger.Info("********** Completed for Account " + account.Tag + " *****************"); } } catch (Exception ex) { _logger.Error(string.Format("Main App: \n Error {0} \n Trace: {1} \n\n\n", ex.Message, ex.StackTrace)); } }
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 PollForBiWeeklyMicroAlbuminFobt() { try { var timeOfDay = DateTime.Now; _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss")); if (!_settings.IsDevEnvironment && _runningDates.All(x => x != DateTime.Today.Day)) { _logger.Info("Report is generated only on 1st and 15th of the month"); return; } if (_accountId <= 0) { _logger.Info("Account Id Not Provided"); return; } var account = _corporateAccountRepository.GetById(_accountId); if (account == null) { _logger.Info("Account not exists"); return; } _logger.Info(string.Format("Generating Report for BiWeekly MicroAlbumin and IFobt")); var lastMonthDate = (DateTime.Today).AddMonths(-1); var endDate = new DateTime(lastMonthDate.Year, lastMonthDate.Month, DateTime.DaysInMonth(lastMonthDate.Year, lastMonthDate.Month)); var filter = new BiWeeklyMicroAlbuminFobtReportModelFilter { StartDate = new DateTime(DateTime.Today.Year, 1, 1), EndDate = DateTime.Today, AccountId = _accountId, CutOffDate = _cutoffDate }; _logger.Info(string.Format("Generating Report for BiWeekly MicroAlbumin and IFobt")); if (lastMonthDate.Year < DateTime.Today.Year) { filter = new BiWeeklyMicroAlbuminFobtReportModelFilter { AccountId = _accountId, StartDate = new DateTime(lastMonthDate.Year, 1, 1), EndDate = endDate }; } _logger.Info("Start Date: " + filter.StartDate.ToShortDateString()); _logger.Info("End Date: " + filter.EndDate.ToShortDateString()); var dataGen = new ExportableDataGenerator <BiWeeklyMicroAlbuminFobtReportViewModel, BiWeeklyMicroAlbuminFobtReportModelFilter>(_biWeeklyMicroAlbuminFobtReportService.GetEventCustomerResultForReport, _logger); var model = dataGen.GetData(filter); if (model != null && !model.Collection.IsNullOrEmpty()) { var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <BiWeeklyMicroAlbuminFobtReportViewModel>(); var path = string.Format(_biWeeklyReportPath, account.FolderName); DirectoryOperationsHelper.CreateDirectoryIfNotExist(path); var reportfilePath = Path.Combine(path, string.Format("WellMed_Kit_Disbursement_{0}.csv", DateTime.Now.ToString("yyyyMMdd"))); _logger.Info("File path : " + reportfilePath); DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath); _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection); if (_sendReportToSftp && DirectoryOperationsHelper.IsFileExist(reportfilePath)) { var sftpResultExportDirectory = _sftpPathForBiWeeklyMicroAlbuminFobtReport; var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(reportfilePath, sftpResultExportDirectory, ""); } _logger.Info("BiWeeklyMicroAlbuminFobt Report generation completed"); } else { _logger.Info("No customer found for Report"); } } catch (Exception exception) { _logger.Error("Some error occurred "); _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } }
private void SendFilesToSftp(string sourceFilePath, string destinationPath, string fileName) { var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(sourceFilePath, destinationPath, fileName); }
public void ResultExport() { try { if (_accountIds.IsNullOrEmpty()) { return; } var accounts = _corporateAccountRepository.GetByIds(_accountIds); if (accounts.IsNullOrEmpty()) { _logger.Info("Account can't be null"); return; } foreach (var account in accounts) { try { var resultExportSettings = string.Format(_resultExportSettings, account.Tag); var customSettings = _customSettingManager.Deserialize(resultExportSettings); var fromDate = customSettings.LastTransactionDate ?? _cutOfDate; var toDate = DateTime.Now; var destinationPath = _wellmedResultExportDownloadPath; string[] customTags = null; if (account.Id == _settings.WellmedWellCareAccountId) { destinationPath = destinationPath + "\\" + account.FolderName; } if (account.Id == _settings.WellmedWellCareAccountId) { customTags = _settings.WellCareToWellMedCustomTags; } if (!Directory.Exists(destinationPath)) { Directory.CreateDirectory(destinationPath); } var fileName = string.Format(@"ResultExport_{0}.csv", DateTime.Now.Date.ToString("yyyyMMdd")); if (account.Id != _accountId) { fileName = string.Format(@"WCR_ResultExport_{0}.csv", DateTime.Now.Date.ToString("yyyyMMdd"));; } var sourceFileName = Path.Combine(destinationPath, fileName); DateTime?stopSendingPdftoHealthPlanDate = null; if (account != null && account.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate; } _pcpResultExportServiceHelper.ResultExport(fromDate, toDate, account.Id, destinationPath, account.Tag, customTags: customTags, resultExportFileName: fileName, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); if (DirectoryOperationsHelper.IsFileExist(sourceFileName)) { sourceFileName = _pgpFileEncryptionHelper.EncryptFile(account, sourceFileName); } if (_sendReportToSftp && File.Exists(sourceFileName)) { var sftpResultExportDirectory = _destinationSftpFolderResultExportPath; if (account.Id != _accountId) { sftpResultExportDirectory = sftpResultExportDirectory + "\\" + account.FolderName; } var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(sourceFileName, sftpResultExportDirectory, ""); } customSettings.LastTransactionDate = toDate; _customSettingManager.SerializeandSave(resultExportSettings, customSettings); } catch (Exception ex) { _logger.Error("some error occured for Account Id: " + account.Id + " tag: " + account.Tag); _logger.Info("Message:" + ex.Message); _logger.Info("Stack Trace:" + ex.StackTrace); } } } catch (Exception ex) { _logger.Error(string.Format("Message: {0} \n Stack Trace: {1} ", ex.Message, ex.StackTrace)); } }
private void ExportResultInSftp(string fileName, string sourcePath, string eventSftpPdfDirectory) { var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(sourcePath, eventSftpPdfDirectory, fileName); }
public void PollForEventList() { var timeOfDay = DateTime.Now; _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss")); var startTime = new TimeSpan(_settings.GmsEventStartTime, 0, 0); var endTime = new TimeSpan(_settings.GmsEventEndTime, 0, 0); if (timeOfDay.TimeOfDay < startTime || timeOfDay.TimeOfDay > endTime) { _logger.Info(string.Format("Report is generated only between {0} and {1}.", startTime.ToString(), endTime.ToString())); return; } _logger.Info(string.Format("Generating Event List for GMS.")); try { var filter = new EventListGmsModelFilter { FromDate = DateTime.Today, HealthPlanIds = _settings.GmsAccountIds }; var dataGen = new ExportableDataGenerator <EventListGmsModel, EventListGmsModelFilter>(_eventReportingService.GetEventListForGmsReport, _logger); var model = dataGen.GetData(filter); if (model != null && !model.Collection.IsNullOrEmpty()) { var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <EventListGmsModel>(); DirectoryOperationsHelper.CreateDirectoryIfNotExist(_settings.EventListGmsReportPath); var reportfilePath = Path.Combine(_settings.EventListGmsReportPath, string.Format("EventList_{0}.csv", DateTime.Now.ToString("yyyyMMdd_HH"))); _logger.Info("File path : " + reportfilePath); DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath); _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection); if (_settings.SendReportToGmsSftp) { _logger.Info("Sending Event List to GMS sftp."); var sftpFolderReportDirectory = _settings.GmsSftpPath; var processFtp = new ProcessFtp(_logger, _settings.GmsSftpHost, _settings.GmsSftpUserName, _settings.GmsSftpPassword); processFtp.UploadSingleFile(reportfilePath, sftpFolderReportDirectory, ""); _logger.Info("Sent Event List to GMS sftp."); } else { _logger.Info("Setting to send Event list to sftp is OFF."); } _logger.Info(string.Format("Event List generation for GMS completed.")); } else { _logger.Info("No future events found."); } } catch (Exception exception) { _logger.Error("Some error occurred "); _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } }
private void GenerateReport(EventScheduleListModelFilter eventScheduleModelFilter, PotentialPcpChangeReportModelFilter filter, CorporateAccount account) { var stateIds = (IReadOnlyCollection <long>)_eventRepository.GetEventStateByAccountId(eventScheduleModelFilter); if (stateIds.IsNullOrEmpty()) { _logger.Info("No State found for Wellmed"); //Do not return from here as we are updating last transaction date at last } var states = _stateRepository.GetStates(stateIds); foreach (var state in states) { try { _logger.Info("Generating Report for State: " + state.Name); var dataGen = new ExportableDataGenerator <PotentialPcpChangeReportViewModel, PotentialPcpChangeReportModelFilter>(_potentialPcpChangeReportService.GetPotentialPcpChangeData, _logger); filter.StateId = state.Id; var model = dataGen.GetData(filter); if (model != null && !model.Collection.IsNullOrEmpty()) { var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <PotentialPcpChangeReportViewModel>(); var path = string.Format(_pcpChangeReportPath, account.FolderName); var reportfilePath = Path.Combine(path, state.Name); DirectoryOperationsHelper.CreateDirectoryIfNotExist(reportfilePath); reportfilePath = Path.Combine(reportfilePath, string.Format("WellMed_PCP_Change_Report_{0}.csv", filter.StartDate.ToString("yyyyMM"))); _logger.Info("File path : " + reportfilePath); DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath); _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection); if (_sendReportToSftp && DirectoryOperationsHelper.IsFileExist(reportfilePath)) { _logger.Info("Starting to post Potential Pcp Change report on sftp for StateId: " + state.Id + " State: " + state.Name); var sftpResultExportDirectory = string.Format(_sftpPathForPcpChangeReport, state.Name); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(reportfilePath, sftpResultExportDirectory, ""); _logger.Info("Potential Pcp Change report posted on sftp for StateId: " + state.Id + " State: " + state.Name); } _logger.Info("Potential Pcp Change Report generation completed for StateId: " + state.Id + " State: " + state.Name); } else { _logger.Info("No data found for StateId: " + state.Id + " State: " + state.Name); } } catch (Exception exception) { _logger.Error("Error occurred during generation of report for StateId: " + state.Id); _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } } //update custom setting XML var customSetting = _customSettingManager.Deserialize(_pcpCustomSetting); customSetting.LastTransactionDate = filter.EndDate; _customSettingManager.SerializeandSave(_pcpCustomSetting, customSetting); }
public void PollForNonTargetableCustomer() { try { var timeOfDay = DateTime.Now; _logger.Info("Time of day : " + timeOfDay.ToString("HH:mm:ss")); if (!_settings.IsDevEnvironment && _runningDate != DateTime.Today.Day) { _logger.Info("Report is generated only in 1st week of the month"); return; } if (_accountId <= 0) { _logger.Info("Account Id Not Provided"); return; } var account = _corporateAccountRepository.GetById(_accountId); if (account == null) { _logger.Info("Account not exists"); return; } _logger.Info(string.Format("Generating Report for Non Target-able Report")); var lastMonthDate = (DateTime.Today).AddMonths(-1); var endDate = new DateTime(lastMonthDate.Year, lastMonthDate.Month, DateTime.DaysInMonth(lastMonthDate.Year, lastMonthDate.Month)); var filter = new NonTargetableReportModelFilter { AccountId = _accountId, StartDate = new DateTime(DateTime.Today.Year, 1, 1), EndDate = endDate }; if (lastMonthDate.Year < DateTime.Today.Year) { filter = new NonTargetableReportModelFilter { AccountId = _accountId, StartDate = new DateTime(lastMonthDate.Year, 1, 1), EndDate = endDate }; } var eventScheduleModelFilter = new EventScheduleListModelFilter { AccountId = _accountId, FromDate = filter.StartDate, ToDate = filter.EndDate }; var stateIds = _eventRepository.GetEventStateByAccountId(eventScheduleModelFilter); if (stateIds.IsNullOrEmpty()) { _logger.Info("No State found for Wellmed"); } var states = _stateRepository.GetStates(stateIds); foreach (var state in states) { try { _logger.Info("Generating Report for State: " + state.Name); var dataGen = new ExportableDataGenerator <NonTargetableReportModel, NonTargetableReportModelFilter>(_nonTargetableReportService.GetCustomersForNonTargetableService, _logger); filter.StateId = state.Id; var model = dataGen.GetData(filter); if (model != null && !model.Collection.IsNullOrEmpty()) { var exporter = ExportableDataGeneratorProcessManager <ViewModelBase, ModelFilterBase> .GetCsvExporter <NonTargetableReportModel>(); var path = string.Format(_nonTargetableReportPath, account.FolderName); var reportfilePath = Path.Combine(path, state.Name); DirectoryOperationsHelper.CreateDirectoryIfNotExist(reportfilePath); reportfilePath = Path.Combine(reportfilePath, string.Format("WellMed_NonTargetable_{0}.csv", DateTime.Now.ToString("yyyyMM"))); _logger.Info("File path : " + reportfilePath); DirectoryOperationsHelper.DeleteFileIfExist(reportfilePath); _baseExportableReportHelper.GenerateCsv(reportfilePath, exporter, model.Collection); if (_sendReportToSftp && DirectoryOperationsHelper.IsFileExist(reportfilePath)) { _logger.Info("Starting to post non targetable report on sftp for StateId: " + state.Id + " State: " + state.Name); var sftpResultExportDirectory = string.Format(_sftpPathForNonTargetableReport, state.Name); var processFtp = new ProcessFtp(_logger, _sftpHost, _sftpUserName, _sftpPassword); processFtp.UploadSingleFile(reportfilePath, sftpResultExportDirectory, ""); _logger.Info("Non targetable report posted on sftp for StateId: " + state.Id + " State: " + state.Name); } _logger.Info("Non targetable Report generation completed for StateId: " + state.Id + " State: " + state.Name); } else { _logger.Info("No customer found for StateId: " + state.Id + " State: " + state.Name); } } catch (Exception exception) { _logger.Error("Error occurred during generation of report for StateId: " + state.Id); _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } } } catch (Exception exception) { _logger.Error("Some error occurred "); _logger.Error("Message: " + exception.Message); _logger.Error("Stack Trace: " + exception.StackTrace); } }