private void CorrectandSaveResultPosted(ResultPdfPostedXml resultPosted, CorporateAccount account) { if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + account.Tag); resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted); if (account.Id == _settings.AppleCareAccountId || account.Id == _settings.MedMutualAccountId) { var pdfLogfile = string.Format(_settings.PdfLogFilePath, account.FolderName); if (account.Id == _settings.MedMutualAccountId) { pdfLogfile = pdfLogfile.Replace(" ", ""); } pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, pdfLogfile, account.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } } _logger.Info("Result posted Log Completed for " + account.Tag); } var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", account.Tag)); _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted); }
private void CreateResultPostedLoger(CorporateAccount corporateAccount) { if (_resultPdfPostedXml != null && !_resultPdfPostedXml.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + corporateAccount.Tag); _resultPdfPostedXml = _resultPdfFileHelper.CorrectMissingRecords(_resultPdfPostedXml); var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName); pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { _resultPdfFileHelper.CreateCsvForFileShared(_resultPdfPostedXml.Customer, pdfLogfile, corporateAccount.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } _logger.Info("Result posted Log Completed for " + corporateAccount.Tag); } }
public void PollForPdfDownload() { try { if (_accountId <= 0) { return; } var corporateAccount = _corporateAccountRepository.GetById(_accountId); try { _logger.Info(string.Format("Genderating for accountId {0} and account tag {1}. ", corporateAccount.Id, corporateAccount.Tag)); var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag); var customSettings = _customSettingManager.Deserialize(customSettingFilePath); var exportToTime = DateTime.Now.AddHours(-1); var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate; DateTime?stopSendingPdftoHealthPlanDate = null; if (corporateAccount.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate; } var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, true, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray(); if (eventCustomerResults == null || !customerResults.Any()) { _logger.Info(string.Format("No event customer result list for {0} Result Pdf Download.", corporateAccount.Tag)); return; } _logger.Info(string.Format("Found {0} customers for {1} Result Pdf Download. ", eventCustomerResults.Count(), corporateAccount.Tag)); var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport(); var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport(); var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag)); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml { Customer = new List <CustomerInfo>() } : resultPosted; var sftpFailedRecordsFileName = Path.Combine(_resultPostedToPlanPath, string.Format("CustomerResultsFailedOnSftp_{0}.xml", corporateAccount.Tag + "_ToWellmed")); var sftpFailedCustomers = _customerResultsFailedOnSftpSerializer.Deserialize(sftpFailedRecordsFileName); sftpFailedCustomers = sftpFailedCustomers == null || sftpFailedCustomers.EventCustomerIds.IsNullOrEmpty() ? new CustomerResultsFailedOnSftp { EventCustomerIds = new List <long>() } : sftpFailedCustomers; var newSftpFailedCustomers = new CustomerResultsFailedOnSftp { EventCustomerIds = new List <long>() }; if (!sftpFailedCustomers.EventCustomerIds.IsNullOrEmpty()) { var failedEventCustomerIds = sftpFailedCustomers.EventCustomerIds.Where(x => !customerResults.Select(ecr => ecr.Id).Contains(x)); if (!failedEventCustomerIds.IsNullOrEmpty()) { int totalRecords = failedEventCustomerIds.Count(); int pageNumber = 0; int pagesize = 100; while (true) { if (totalRecords < 1) { break; } var totalItems = pageNumber * pagesize; var customerIds = failedEventCustomerIds.Skip(totalItems).Take(pagesize); var failedEventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsByIdsAndResultState(customerIds, (int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false); if (!failedEventCustomerResults.IsNullOrEmpty()) { customerResults.Concat(failedEventCustomerResults); } pageNumber++; if (totalItems >= totalRecords) { break; } } } } foreach (var ecr in customerResults) { var sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport; if (!File.Exists(sourcePath)) { sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport; } if (File.Exists(sourcePath)) { try { var customer = _customerRepository.GetCustomer(ecr.CustomerId); var eventData = _eventRepository.GetById(ecr.EventId); var host = _hostRepository.GetHostForEvent(ecr.EventId); if (!string.IsNullOrEmpty(customer.InsuranceId)) { var destinationFolderPdfPath = string.Empty; var destinationCatalystFolderPdfPath = string.Empty; //if (!string.IsNullOrEmpty(customer.GroupName) && _wellmedCustomerGroupName.Contains(customer.GroupName)) // destinationFolderPdfPath = _destinationCatalystFolderPdfPath + "\\" + host.Address.State + "\\" + eventData.EventDate.Year + "\\" + ecr.EventId; //else destinationFolderPdfPath = _destinationFolderPdfPath + "\\" + host.Address.State + "\\" + eventData.EventDate.Year + "\\" + ecr.EventId; var eventDirectoryPdf = GetDestinationFolderPath(destinationFolderPdfPath, customer, eventData.EventDate); var destinationFilename = ""; if (!string.IsNullOrEmpty(customer.GroupName)) { destinationFilename = RemoveIllegalFileChar(customer.GroupName) + "_" + RemoveIllegalFileChar(customer.InsuranceId); } else { destinationFilename = "NoGroup_" + RemoveIllegalFileChar(customer.InsuranceId); } if (corporateAccount.MarkPennedBack && ecr.IsPennedBack) { destinationFilename += "_" + corporateAccount.PennedBackText; } if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both) { var fileName = "UHC_" + _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.PDF); var resultPdfFile = eventDirectoryPdf + "/" + fileName + ".pdf"; _resultPdfDownloadHelper.ExportResultInPdfFormat(fileName + ".pdf", sourcePath, eventDirectoryPdf); if (File.Exists(resultPdfFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultPdfFile); } else { _logger.Info("File Not Found : " + resultPdfFile); } if (!string.IsNullOrEmpty(customer.GroupName) && _wellmedCustomerGroupName.Contains(customer.GroupName.ToLower())) { destinationCatalystFolderPdfPath = _destinationCatalystFolderPdfPath + "\\" + host.Address.State + "\\" + eventData.EventDate.Year + "\\" + ecr.EventId; var resultCatalystPdfFile = destinationCatalystFolderPdfPath + "/" + fileName + ".pdf"; _resultPdfDownloadHelper.ExportResultInPdfFormat(fileName + ".pdf", sourcePath, destinationCatalystFolderPdfPath); if (File.Exists(resultCatalystPdfFile)) { var pgpCatalystFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultCatalystPdfFile); } else { _logger.Info("File Not Found : " + resultCatalystPdfFile); } } if (_sendReportToSftp) { var destinationSftpfolderPath = _destinationSftpFolderPdfPath + "\\" + host.Address.State + "\\" + eventData.EventDate.Year + "\\" + ecr.EventId; var resultPostedToSftp = false; if (ExportResultInSftp(fileName + ".pdf", sourcePath, destinationSftpfolderPath)) //GetDestinationFolderPath(destinationSftpfolderPath, customer, eventData.EventDate) { _logger.Info(string.Format("File Moved to Wellmed Sftp location for customer Id {0} and eventId {1}", ecr.CustomerId, ecr.EventId)); resultPostedToSftp = true; } if (resultPostedToSftp && !string.IsNullOrEmpty(customer.GroupName) && _wellmedCustomerGroupName.Contains(customer.GroupName.ToLower())) { var destinationSftpCatalystfolderPath = _destinationSftpCatalystFolderPdfPath + "\\" + host.Address.State + "\\" + eventData.EventDate.Year + "\\" + ecr.EventId; if (ExportResultInSftp(fileName + ".pdf", sourcePath, destinationSftpCatalystfolderPath)) { _logger.Info(string.Format("File Moved to Wellmed Catalyst Sftp location for customer Id {0} and eventId {1}", ecr.CustomerId, ecr.EventId)); } else { resultPostedToSftp = false; } } if (resultPostedToSftp) { resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, fileName + ".pdf", (long)ResultFormatType.PDF, customer, ecr.Id)); } else { newSftpFailedCustomers.EventCustomerIds.Add(ecr.Id); } } } if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both) { var fileName = "UHC_" + _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.TIF); var resultTifFile = eventDirectoryPdf + "/" + fileName + ".tif"; _resultPdfDownloadHelper.ExportResultInTiffFormat(fileName + ".tif", sourcePath, eventDirectoryPdf); if (File.Exists(resultTifFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultTifFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customer, ecr.Id)); } else { _logger.Info(string.Format("File {0} not Exit for pgp Encryption ", resultTifFile)); } } } else { _logger.Info(string.Format("member id is not found for customer {0} and eventId {1}", ecr.CustomerId, ecr.EventId)); } } catch (Exception exception) { _logger.Error(string.Format("some error occured for the customerId {0}, {1},\n Messagen {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace)); } } else { _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId)); } } customSettings.LastTransactionDate = exportToTime; _customSettingManager.SerializeandSave(customSettingFilePath, customSettings); if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + corporateAccount.Tag); resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted); var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName); pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, pdfLogfile, corporateAccount.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } _logger.Info("Result posted Log Completed for " + corporateAccount.Tag); } _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted); _customerResultsFailedOnSftpSerializer.SerializeandSave(sftpFailedRecordsFileName, newSftpFailedCustomers); } catch (Exception ex) { _logger.Error(string.Format("some error occured for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace)); } } catch (Exception exception) { _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace)); } }
public void PollForPdfDownload() { try { if (_accountId < 1) { return; } var corporateAccount = _corporateAccountRepository.GetById(_accountId); try { _logger.Info(string.Format("Generating for accountId {0} and account tag {1}. ", corporateAccount.Id, corporateAccount.Tag)); var destinationFolderPdf = _settings.AnthemDownloadPath; var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag); var customSettings = _customSettingManager.Deserialize(customSettingFilePath); var exportToTime = DateTime.Now.AddHours(-1); var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate; DateTime?stopSendingPdftoHealthPlanDate = null; if (corporateAccount.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate; } var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, true, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray(); customerResults = customerResults ?? new EventCustomerResult[] { }; var resultNotPostedFileName = string.Format("ResultNotPostedto_{0}.xml", corporateAccount.Tag); var resultNotPostedToPlanFileName = Path.Combine(_settings.ResultNotPostedToPlanPath, resultNotPostedFileName); var resultNotPosted = _resultPdfNotPostedSerializer.Deserialize(resultNotPostedToPlanFileName); resultNotPosted = resultNotPosted == null || resultNotPosted.EventCustomer.IsNullOrEmpty() ? new ResultPdfNotPosted { EventCustomer = new List <EventCustomerInfo>() } : resultNotPosted; if (resultNotPosted.EventCustomer.Count > 0) { var eventCustomerIds = resultNotPosted.EventCustomer.Select(x => x.EventCustomerId); if (!customerResults.IsNullOrEmpty()) { var freshCustomerEventCustomerIds = customerResults.Select(x => x.Id); eventCustomerIds = (from q in eventCustomerIds where !freshCustomerEventCustomerIds.Contains(q) select q).ToList(); } int totalRecords = eventCustomerIds.Count(); int pageNumber = 0; int pagesize = 100; while (true) { if (totalRecords < 1) { break; } var totalItems = pageNumber * pagesize; var customerIds = eventCustomerIds.Skip(totalItems).Take(pagesize); var resultNotPostedEventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsByIdsAndResultState(customerIds, (int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false); if (!resultNotPostedEventCustomerResults.IsNullOrEmpty()) { var resultReports = resultNotPostedEventCustomerResults.ToArray(); if (customerResults.IsNullOrEmpty()) { customerResults = resultReports.ToArray(); } else { customerResults = customerResults.Concat(resultReports).ToArray(); } } pageNumber++; if (totalItems >= totalRecords) { break; } } } resultNotPosted.EventCustomer = !resultNotPosted.EventCustomer.IsNullOrEmpty() ? new List <EventCustomerInfo>() : resultNotPosted.EventCustomer; if (eventCustomerResults == null || !customerResults.Any()) { _logger.Info(string.Format("No event customer result list for {0} Result Pdf Download.", corporateAccount.Tag)); return; } _logger.Info(string.Format("Found {0} customers for {1} Result Pdf Download. ", eventCustomerResults.Count(), corporateAccount.Tag)); var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport(); var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport(); var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag)); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml { Customer = new List <CustomerInfo>() } : resultPosted; var eventsCollection = ((IUniqueItemRepository <Event>)_eventRepository).GetByIds(customerResults.Select(x => x.EventId).Distinct().ToArray()); foreach (var ecr in customerResults) { var customerData = _customerRepository.GetCustomer(ecr.CustomerId); if (string.IsNullOrEmpty(customerData.InsuranceId)) { _logger.Info("Customer Id: " + customerData.CustomerId + " does not contain Member Id"); } var eventData = eventsCollection.Single(x => x.Id == ecr.EventId); var sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport; if (!DirectoryOperationsHelper.IsFileExist(sourcePath)) { sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport; } if (DirectoryOperationsHelper.IsFileExist(sourcePath)) { try { var eventDirectoryPdf = destinationFolderPdf; if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF) { var patientMemerId = string.IsNullOrEmpty(customerData.InsuranceId) ? "No_MemberId_" + ecr.CustomerId + "_" : customerData.InsuranceId + "_"; var pdfFileName = RemoveIllegalFileChar("HLTHFAIR_" + patientMemerId + ecr.EventId); if (corporateAccount.MarkPennedBack && ecr.IsPennedBack) { pdfFileName += "_" + corporateAccount.PennedBackText; } pdfFileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, pdfFileName, (long)ResultFormatType.PDF); //var pdfResultFile = eventDirectoryPdf + "/" + pdfFileName + ".pdf"; var pdfResultFile = Path.Combine(eventDirectoryPdf, pdfFileName + ".pdf"); _resultPdfDownloaderHelper.ExportResultInPdfFormat(pdfFileName + ".pdf", sourcePath, eventDirectoryPdf); if (DirectoryOperationsHelper.IsFileExist(pdfResultFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, pdfResultFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.PDF, customerData, ecr.Id)); _logger.Info("Source: " + sourcePath); _logger.Info("destination: " + pdfResultFile); } else { resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "file not Moved on HIP SFTP." }); } } if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF) { var patientMemerId = string.IsNullOrEmpty(customerData.InsuranceId) ? "No_MemberId_" + ecr.CustomerId + "_" : customerData.InsuranceId + "_"; var fileName = RemoveIllegalFileChar("HLTHFAIR_" + patientMemerId + ecr.EventId); if (corporateAccount.MarkPennedBack && ecr.IsPennedBack) { fileName += "_" + corporateAccount.PennedBackText; } fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, fileName, (long)ResultFormatType.TIF); // var tipResultFile = eventDirectoryPdf + "/" + fileName + ".tif"; var tipResultFile = Path.Combine(eventDirectoryPdf, fileName + ".tif"); _resultPdfDownloaderHelper.ExportResultInTiffFormat(ecr.CustomerId + ".tif", sourcePath, eventDirectoryPdf); if (DirectoryOperationsHelper.IsFileExist(tipResultFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, tipResultFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customerData, ecr.Id)); _logger.Info("Source: " + sourcePath); _logger.Info("destination: " + tipResultFile); } else { resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "file not Moved on HIP SFTP." }); } } } catch (Exception exception) { resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "file not Moved on HIP SFTP." }); _logger.Error(string.Format("some error occurred for the customerId {0}, {1},\n Message {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace)); } } else { _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId)); resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "File not generated or removed." }); } } customSettings.LastTransactionDate = exportToTime; _customSettingManager.SerializeandSave(customSettingFilePath, customSettings); if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + corporateAccount.Tag); resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted); var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName); pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, pdfLogfile, corporateAccount.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } _logger.Info("Result posted Log Completed for " + corporateAccount.Tag); } _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted); _resultPdfNotPostedSerializer.SerializeandSave(resultNotPostedToPlanFileName, resultNotPosted); if (resultNotPosted.EventCustomer.Count > 0) { _resultPdfEmailNotificationHelper.SendEmailNotificationForFileNotPosted(corporateAccount.Tag, resultNotPosted.EventCustomer.Count, _logger); } } catch (Exception ex) { _logger.Error(string.Format("some error occured for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace)); } } catch (Exception exception) { _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace)); } }
public void PollForPdfDownload() { try { if (_accountIds.IsNullOrEmpty()) { return; } var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds); foreach (var corporateAccount in corporateAccounts) { try { _logger.Info(string.Format("Generating for accountId {0} and account tag {1}. ", corporateAccount.Id, corporateAccount.Tag)); var destinationFolderPdf = string.Format(_destinationFolderPdfSetting, corporateAccount.FolderName); var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag); var customSettings = _customSettingManager.Deserialize(customSettingFilePath); var exportToTime = DateTime.Now.AddHours(-1); var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate; DateTime?stopSendingPdftoHealthPlanDate = null; if (corporateAccount.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _stopSendingPdftoHealthPlanDate; } _logger.Info("exportToTime: " + exportToTime.ToString("MM/dd/yyyy")); _logger.Info("exportFromTime: " + exportFromTime.ToString("MM/dd/yyyy")); var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, true, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray(); if (eventCustomerResults == null || !customerResults.Any()) { _logger.Info(string.Format("No event customer result list for {0} Result Pdf Download.", corporateAccount.Tag)); continue; } if (_optumAccountIds.Contains(corporateAccount.Id)) { try { DirectoryOperationsHelper.DeleteDirectory(destinationFolderPdf, true); } catch (Exception ex) { _logger.Error("Some error occurred while deleting directory at path: " + destinationFolderPdf); _logger.Error("Message: " + ex.Message); _logger.Error("Stack Trace: " + ex.StackTrace); } } _logger.Info(string.Format("Found {0} customers for {1} Result Pdf Download. ", eventCustomerResults.Count(), corporateAccount.Tag)); var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport(); var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport(); var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag)); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml { Customer = new List <CustomerInfo>() } : resultPosted; _logger.Info(string.Format("Result Pdf file Transfer started for {0} ", corporateAccount.Tag)); var customersWithNoMrn = new List <long>(); var newCustomersWithNoMrn = new List <long>(); foreach (var ecr in customerResults) { var sourceUrl = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport; if (!File.Exists(sourceUrl)) { sourceUrl = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport; } if (File.Exists(sourceUrl)) { try { SetReusltPdfNameing(ecr, corporateAccount, destinationFolderPdf, sourceUrl, resultPosted, newCustomersWithNoMrn); } catch (Exception exception) { _logger.Error(string.Format("some error occured for the customerId {0}, {1},\n Messagen {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace)); } } else { _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId)); } } if (corporateAccount.Id == _settings.OptumNvAccountId || corporateAccount.Id == _settings.OptumNvMedicareAccountId) { _logger.Info("Sending Old Files to SFTP"); PostCustomerWithNoMrn(corporateAccount, destinationFolderPdf, resultPosted, customersWithNoMrn); _logger.Info("Sending Old Files to SFTP Completed"); if (!customersWithNoMrn.IsNullOrEmpty()) { newCustomersWithNoMrn.AddRange(customersWithNoMrn); } newCustomersWithNoMrn = newCustomersWithNoMrn.Distinct().ToList(); SaveCustomersWithNoMrn(corporateAccount, newCustomersWithNoMrn); } customSettings.LastTransactionDate = exportToTime; _customSettingManager.SerializeandSave(customSettingFilePath, customSettings); if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + corporateAccount.Tag); resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted); var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName); pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { DirectoryOperationsHelper.CreateDirectoryIfNotExist(pdfLogfile); if (DirectoryOperationsHelper.IsDirectoryExist(pdfLogfile)) { var filesTobedeleted = DirectoryOperationsHelper.GetFiles(pdfLogfile, "*" + corporateAccount.Tag + "_PdfLogFile*"); foreach (var logFile in filesTobedeleted) { DirectoryOperationsHelper.DeleteFileIfExist(logFile); } } var resultPostedCustomers = resultPosted.Customer.Where(x => x.EventDate.HasValue && x.EventDate.Value.Year >= _cutOfDate.Year); _resultPdfFileHelper.CreateCsvForFileShared(resultPostedCustomers, pdfLogfile, corporateAccount.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } _logger.Info("Result posted Log Completed for " + corporateAccount.Tag); } _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted); _logger.Info(string.Format("Result Pdf file Transfer completed for {0} ", corporateAccount.Tag)); _logger.Info(""); _logger.Info(""); _logger.Info("================================================================================"); } catch (Exception ex) { _logger.Error(string.Format("some error occured for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace)); } } } catch (Exception exception) { _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace)); } }
private void PostResultPdfOnSftp(DateTime exportToTime, DateTime exportFromTime, CorporateAccount corporateAccount, string destinationFolderPdfPath, bool includeCustomerWithTag, string[] customTags) { var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultDelivered(exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, _settings.PPEventCutOfDate, includeCustomerWithTag, customTags, stopSendingPdftoHealthPlanDate: _stopSendingPdftoHealthPlanDate); var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray(); customerResults = customerResults ?? new EventCustomerResult[] { }; var resultNotPostedFileName = string.Format("ResultNotPostedto_{0}.xml", corporateAccount.Tag); var resultNotPostedToPlanFileName = Path.Combine(_settings.ResultNotPostedToPlanPath, resultNotPostedFileName); var resultNotPosted = _resultPdfNotPostedSerializer.Deserialize(resultNotPostedToPlanFileName); resultNotPosted = resultNotPosted == null || resultNotPosted.EventCustomer.IsNullOrEmpty() ? new ResultPdfNotPosted { EventCustomer = new List <EventCustomerInfo>() } : resultNotPosted; if (resultNotPosted.EventCustomer.Count > 0) { var eventCustomerIds = resultNotPosted.EventCustomer.Select(x => x.EventCustomerId); if (!customerResults.IsNullOrEmpty()) { var freshCustomerEventCustomerIds = customerResults.Select(x => x.Id); eventCustomerIds = (from q in eventCustomerIds where !freshCustomerEventCustomerIds.Contains(q) select q).ToList(); } int totalRecords = eventCustomerIds.Count(); int pageNumber = 0; int pagesize = 100; while (true) { if (totalRecords < 1) { break; } var totalItems = pageNumber * pagesize; var customerIds = eventCustomerIds.Skip(totalItems).Take(pagesize); var resultNotPostedEventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsByIdsAndResultState(customerIds, (int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false); if (!resultNotPostedEventCustomerResults.IsNullOrEmpty()) { var resultReports = resultNotPostedEventCustomerResults.ToArray(); if (customerResults.IsNullOrEmpty()) { customerResults = resultReports.ToArray(); } else { customerResults = customerResults.Concat(resultReports).ToArray(); } } pageNumber++; if (totalItems >= totalRecords) { break; } } } resultNotPosted.EventCustomer = !resultNotPosted.EventCustomer.IsNullOrEmpty() ? new List <EventCustomerInfo>() : resultNotPosted.EventCustomer; if (eventCustomerResults == null || !customerResults.Any()) { _logger.Info(string.Format("No event customer result list found for {0}.", corporateAccount.Tag)); } _logger.Info(string.Format("Found {0} customers for {1} Result. ", eventCustomerResults.Count(), corporateAccount.Tag)); var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport(); var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport(); var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag)); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml { Customer = new List <CustomerInfo>() } : resultPosted; foreach (var ecr in customerResults) { var sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport; if (!DirectoryOperationsHelper.IsFileExist(sourcePath)) { sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport; } if (DirectoryOperationsHelper.IsFileExist(sourcePath)) { try { var customer = _customerRepository.GetCustomer(ecr.CustomerId); var eventData = _eventRepository.GetById(ecr.EventId); var destinationFilename = string.IsNullOrEmpty(customer.InsuranceId) ? "No MemberId_" + customer.CustomerId + "_" + eventData.EventDate.ToString("MM-dd-yyyy") : customer.InsuranceId + "_" + eventData.EventDate.ToString("MM-dd-yyyy"); destinationFilename = RemoveIllegalFileChar(destinationFilename); if (corporateAccount.MarkPennedBack && ecr.IsPennedBack) { destinationFilename += "_" + corporateAccount.PennedBackText; } //var destinationFolderPdfPathWithYear = Path.Combine(destinationFolderPdfPath, eventData.EventDate.Year.ToString()); if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both) { var pdfFileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.PDF); var resultPdfFile = Path.Combine(destinationFolderPdfPath, pdfFileName + ".pdf"); _logger.Info("destination file : " + destinationFolderPdfPath + "\\" + pdfFileName + ".pdf"); _logger.Info("source file : " + sourcePath); _resultPdfDownloadHelper.ExportResultInPdfFormat(pdfFileName + ".pdf", sourcePath, destinationFolderPdfPath); if (DirectoryOperationsHelper.IsFileExist(resultPdfFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultPdfFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.PDF, customer, ecr.Id)); } else { _logger.Info("File Not Found : " + resultPdfFile); resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "file not Moved on HIP SFTP." }); } } if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both) { var tifFileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFilename, (long)ResultFormatType.TIF); var resultTifFile = destinationFolderPdfPath + "/" + tifFileName + ".tif"; _resultPdfDownloadHelper.ExportResultInTiffFormat(tifFileName + ".tif", sourcePath, destinationFolderPdfPath); if (DirectoryOperationsHelper.IsFileExist(resultTifFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, resultTifFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customer, ecr.Id)); } else { _logger.Info(string.Format("File {0} not Exit for pgp Encryption ", resultTifFile)); resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "file not Moved on HIP SFTP." }); } } } catch (Exception exception) { resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "file not Moved on HIP SFTP." }); _logger.Error(string.Format("some error occurred for the customerId {0}, Event Id {1},\n Message {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace)); } } else { _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId)); resultNotPosted.EventCustomer.Add(new EventCustomerInfo { EventCustomerId = ecr.Id, EventId = ecr.EventId, CustomerId = ecr.CustomerId, Error = "File not generated or removed." }); } } if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + corporateAccount.Tag); resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted); var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName); pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, pdfLogfile, corporateAccount.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } _logger.Info("Result posted Log Completed for " + corporateAccount.Tag); } _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted); }
public void PollForPdfDownload() { try { if (!_sendPdfToWellmed) { _logger.Info("Service has been stopped. "); return; } if (_accountIds.IsNullOrEmpty()) { return; } var corporateAccounts = _corporateAccountRepository.GetByIds(_accountIds); try { foreach (var corporateAccount in corporateAccounts) { try { _logger.Info(string.Format("Generating for accountId {0} and account tag {1}. ", corporateAccount.Id, corporateAccount.Tag)); var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag + "_MonarchWellmedPdfPath"); var customSettings = _customSettingManager.Deserialize(customSettingFilePath); var exportToTime = DateTime.Now.AddHours(-1); var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate; _logger.Info("Sending Fresh Files to SFTP"); DateTime?stopSendingPdftoHealthPlanDate = null; if (corporateAccount.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _stopSendingPdftoHealthPlanDate; } var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax((int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, true, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); var newCustomerListWithNoGmpi = new List <long>(); var customersGmpiNoUpdated = new List <long>(); PostResultPdfToSftp(eventCustomerResults, corporateAccount, newCustomerListWithNoGmpi); _logger.Info("Sending Fresh Files to SFTP Completed"); _logger.Info("Sending Old File to SFTP"); PostCustomerWithNoGmpi(corporateAccount, customersGmpiNoUpdated); _logger.Info("Sending Old File to SFTP Completed"); if (!customersGmpiNoUpdated.IsNullOrEmpty()) { newCustomerListWithNoGmpi.AddRange(customersGmpiNoUpdated); } newCustomerListWithNoGmpi = newCustomerListWithNoGmpi.Distinct().ToList(); SaveCustomersWithNoGmpi(corporateAccount, newCustomerListWithNoGmpi); customSettings.LastTransactionDate = exportToTime; _customSettingManager.SerializeandSave(customSettingFilePath, customSettings); } catch (Exception ex) { _logger.Error(string.Format("some error occurred: \n Message {0} \n Stack Trace {1}", ex.Message, ex.StackTrace)); } } var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, "resultPostedMonarchToWellmed.xml"); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml { Customer = new List <CustomerInfo>() } : resultPosted; if (!resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log"); CorrectMissingRecords(resultPosted); resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, _destinationFolderPdfPath, "resultPostedMonarchToWellmed"); _logger.Info("Result posted Log Completed"); } ZipResultPdfFiles(); } catch (Exception ex) { _logger.Error(string.Format("some error occurred: Exception Message: \n{0}, \n stack Trace: \n\t {1} ", ex.Message, ex.StackTrace)); } } catch (Exception exception) { _logger.Error(string.Format("some error occurred Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace)); } }
public void PollForPdfDownload() { try { if (_accountId <= 0) { return; } var corporateAccount = _corporateAccountRepository.GetById(_accountId); try { _logger.Info(string.Format("Genderating for accountId {0} and account tag {1}. ", corporateAccount.Id, corporateAccount.Tag)); var destinationFolderPdfPath = string.Format(_destinationFolderPdfPath, corporateAccount.FolderName); var customSettingFilePath = string.Format(_customSettingFile, corporateAccount.Tag); var customSettings = _customSettingManager.Deserialize(customSettingFilePath); var exportToTime = DateTime.Now.AddHours(-1); var exportFromTime = customSettings.LastTransactionDate ?? _cutOfDate; DateTime?stopSendingPdftoHealthPlanDate = null; if (corporateAccount.IsHealthPlan) { stopSendingPdftoHealthPlanDate = _settings.StopSendingPdftoHealthPlanDate; } var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultsToFax( (int)TestResultStateNumber.ResultDelivered, (int)NewTestResultStateNumber.ResultDelivered, false, exportToTime, exportFromTime, corporateAccount.Id, corporateAccount.Tag, true, stopSendingPdftoHealthPlanDate: stopSendingPdftoHealthPlanDate); var customerResults = eventCustomerResults as EventCustomerResult[] ?? eventCustomerResults.ToArray(); if (eventCustomerResults == null || !customerResults.Any()) { _logger.Info(string.Format("No event customer result list for {0} Result Pdf Download.", corporateAccount.Tag)); return; } _logger.Info(string.Format("Found {0} customers for {1} Result Pdf Download. ", eventCustomerResults.Count(), corporateAccount.Tag)); var pcpResultReport = _mediaRepository.GetPdfFileNameForPcpResultReport(); var healthPlanResultReport = _mediaRepository.GetPdfFileNameForHealthPlanResultReport(); var resultPostedToPlanFileName = Path.Combine(_resultPostedToPlanPath, string.Format("ResultPostedto_{0}.xml", corporateAccount.Tag)); var resultPosted = _resultPdfPostedSerializer.Deserialize(resultPostedToPlanFileName); resultPosted = resultPosted == null || resultPosted.Customer.IsNullOrEmpty() ? new ResultPdfPostedXml { Customer = new List <CustomerInfo>() } : resultPosted; foreach (var ecr in customerResults) { var sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + healthPlanResultReport; if (!File.Exists(sourcePath)) { sourcePath = _mediaRepository.GetPremiumVersionResultPdfLocation(ecr.EventId, ecr.CustomerId).PhysicalPath + pcpResultReport; } if (File.Exists(sourcePath)) { try { var customer = _customerRepository.GetCustomer(ecr.CustomerId); var eventData = _eventRepository.GetById(ecr.EventId); var destinationFileName = string.Empty; //if (!string.IsNullOrEmpty(customer.Mrn)) //{ // destinationFileName = customer.Mrn + "_" + eventData.EventDate.ToString("yyyyMMdd") + "_258_Outside Diagnostics_HF"; //} //else if (!string.IsNullOrEmpty(customer.Lpi)) //{ // destinationFileName = "XID" + customer.Lpi + "_" + eventData.EventDate.ToString("yyyyMMdd") + "_258_Outside Diagnostics_HF"; //} if (!string.IsNullOrEmpty(customer.Lpi)) { destinationFileName = "XID" + customer.Lpi + "_" + eventData.EventDate.ToString("yyyyMMdd") + "_258_Outside Diagnostics_HF"; } else if (!string.IsNullOrEmpty(customer.Mrn)) { destinationFileName = customer.Mrn + "_" + eventData.EventDate.ToString("yyyyMMdd") + "_258_Outside Diagnostics_HF"; } else { destinationFileName = customer.CustomerId + "_" + eventData.EventDate.ToString("yyyyMMdd") + "_258_Outside Diagnostics_HF"; } if (corporateAccount.MarkPennedBack && ecr.IsPennedBack) { destinationFileName += "_" + corporateAccount.PennedBackText; } if (!string.IsNullOrEmpty(destinationFileName)) { if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.PDF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both) { var fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFileName, (long)ResultFormatType.PDF); var pdfResultFile = destinationFolderPdfPath + "/pdf/" + fileName + ".pdf"; _resultPdfDownloaderHelper.ExportResultInPdfFormat(fileName + ".pdf", sourcePath, destinationFolderPdfPath + "/pdf"); if (File.Exists(pdfResultFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, pdfResultFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.PDF, customer, ecr.Id)); } } if (corporateAccount.ResultFormatTypeId == (long)ResultFormatType.TIF || corporateAccount.ResultFormatTypeId == (long)ResultFormatType.Both) { var fileName = _resultPdfFileHelper.GetFileName(resultPosted.Customer, ecr, destinationFileName, (long)ResultFormatType.TIF); var tifResultFile = destinationFolderPdfPath + "/tif/" + fileName + ".tif"; _resultPdfDownloaderHelper.ExportResultInTiffFormat(fileName + ".tif", sourcePath, destinationFolderPdfPath + "/tif"); if (File.Exists(tifResultFile)) { var pgpFilePath = _pgpFileEncryptionHelper.EncryptFile(corporateAccount, tifResultFile); resultPosted.Customer.Add(_resultPdfFileHelper.GetCustomerInfo(eventData, Path.GetFileName(pgpFilePath), (long)ResultFormatType.TIF, customer, ecr.Id)); } if (_sendReportToSftp) { ExportResultInSftp(fileName + ".tif", tifResultFile, ""); _logger.Info(string.Format("File Moved to HCP CA Sftp location for customer Id {0} and eventId {1}", ecr.CustomerId, ecr.EventId)); } } } else { _logger.Info("customer info does nither contain LPI nor MRN info customer Id: " + customer.CustomerId + " Event Id: " + eventData.Id); } } catch (Exception exception) { _logger.Error(string.Format("some error occured for the customerId {0}, {1},\n Messagen {2} \n Stack Trace {3}", ecr.CustomerId, ecr.EventId, exception.Message, exception.StackTrace)); } } else { _logger.Info(string.Format("File not generated or removed for the customerId {0}, {1}", ecr.CustomerId, ecr.EventId)); } } customSettings.LastTransactionDate = exportToTime; _customSettingManager.SerializeandSave(customSettingFilePath, customSettings); if (resultPosted != null && !resultPosted.Customer.IsNullOrEmpty()) { _logger.Info("Result posted Log for " + corporateAccount.Tag); resultPosted = _resultPdfFileHelper.CorrectMissingRecords(resultPosted); var pdfLogfile = string.Format(_settings.PdfLogFilePath, corporateAccount.FolderName); pdfLogfile = Path.Combine(pdfLogfile, "Download"); try { _resultPdfFileHelper.CreateCsvForFileShared(resultPosted.Customer, pdfLogfile, corporateAccount.Tag + "_PdfLogFile"); } catch (Exception ex) { _logger.Error("some error occurred"); _logger.Error("exception: " + ex.Message); _logger.Error("stack trace: " + ex.StackTrace); } _logger.Info("Result posted Log Completed for " + corporateAccount.Tag); } _resultPdfPostedSerializer.SerializeandSave(resultPostedToPlanFileName, resultPosted); } catch (Exception ex) { _logger.Error(string.Format("some error occured for AccountId: {0} and account tag: {1} Exception Message: \n{2}, \n stack Trace: \n\t {3} ", corporateAccount.Id, corporateAccount.Tag, ex.Message, ex.StackTrace)); } } catch (Exception exception) { _logger.Error(string.Format("some error occured Exception Message: \n{0}, \n stack Trace: \n\t {1} ", exception.Message, exception.StackTrace)); } }