public ActionResult GenerateRoster(long eventId) { var mediaLocation = IoC.Resolve <IMediaRepository>().GetTempMediaFileLocation(); string newpdfpath = _settings.AppUrl + "/App/Franchisee/Technician/PrintRosterNew.aspx?EventId=" + eventId; var fileName = Guid.NewGuid() + ".pdf"; _pdfGenerator.GeneratePdf(newpdfpath, mediaLocation.PhysicalPath + fileName); Response.RedirectUser(mediaLocation.Url + fileName); return(null); }
public ActionResult Print(long eventId, long customerId, long testId) { var mediaLocation = _mediaRepository.GetTempMediaFileLocation(); var fileName = "Pdf_" + DateTime.Now.ToFileTimeUtc() + ".pdf"; //var url = Request.Url.OriginalString.Replace(Request.Url.Query, ""); // string newpdfpath = url.Replace(Request.Url.AbsolutePath, string.Concat("/Medical/CustomerEventCriticalData/View?eventId=", eventId, "&customerId=", customerId, "&testId=", testId)); string newpdfpath = _settings.AppUrl + "/Medical/CustomerEventCriticalData/View?eventId=" + eventId + "&customerId=" + customerId + "&testId=" + testId; _pdfGenerator.GeneratePdf(newpdfpath, mediaLocation.PhysicalPath + fileName); if (mediaLocation.PhysicalPath.IndexOfAny(Path.GetInvalidPathChars()) != -1) { throw new InvalidDirectoryPathException(); } if (fileName.IndexOfAny(Path.GetInvalidFileNameChars()) != -1) { throw new InvalidFileNameException(); } Response.Clear(); Response.ContentType = "application/octet-stream"; Response.AddHeader("content-disposition", "attachment;filename=\"" + HttpUtility.HtmlEncode(Path.GetFileName(mediaLocation.PhysicalPath + fileName).Replace(Environment.NewLine, "")) + "\""); Response.AddHeader("content-length", new FileInfo(mediaLocation.PhysicalPath + fileName).Length.ToString()); Response.TransmitFile(mediaLocation.PhysicalPath + fileName); Response.Flush(); Response.Close(); return(Content("")); }
private void GeneratePdf(HtmlDocument doc, MediaLocation ipResultPdfMediaLocation, Event eventData, Customer customer, TestType testType, string testSourceHtmlPath, IEnumerable <CustomerScreeningEvaluatinPhysicianViewModel> physicians, TestResult testResult, List <ResultMedia> resultMedia) { string testName = testType.ToString(); var testHtmlPath = Path.Combine(ipResultPdfMediaLocation.PhysicalPath, testName + ".html"); var testHtmlUrl = Path.Combine(ipResultPdfMediaLocation.Url, testName + ".html"); var appentAcesIdOrCustomerId = string.IsNullOrEmpty(customer.AcesId) ? "NoAcesId_" + customer.CustomerId : customer.AcesId; var testPdfLocation = ipResultPdfMediaLocation.PhysicalPath + testName + "_" + appentAcesIdOrCustomerId + "_" + customer.Name.LastName + "_" + customer.Name.FirstName + "_" + eventData.EventDate.Year + ".pdf"; _copyMediaResultPdfHelper.CopyOverSupportDirectorytotheDestination(testHtmlPath, testSourceHtmlPath, physicians, copySupportMediaOtherThanPhysician: true); _copyMediaResultPdfHelper.CopyOverMedia(eventData.Id, customer.CustomerId, testHtmlPath, resultMedia); if (testType == TestType.AwvEkg) { _copyMediaResultPdfHelper.CopyOverAwvEkgGraph(eventData.Id, customer.CustomerId, testHtmlPath, testResult as AwvEkgTestResult); } _copyMediaResultPdfHelper.UpdateHTMLWithImages(doc); doc.Save(testHtmlPath); var dob = string.Empty; if (customer.DateOfBirth.HasValue) { dob = " DOB:" + customer.DateOfBirth.Value.ToString("MM/dd/yyyy"); } _pdfGenerator.GeneratePdf(testHtmlUrl, testPdfLocation, true, customer.NameAsString + " [" + customer.CustomerId + "]" + dob + " Testing Date:" + eventData.EventDate.ToShortDateString()); }
/// <summary> /// generate pdf file for profile information of the passed criminal /// </summary> /// <param name="criminal"></param> public static bool GeneratorPdf(CriminalProxy criminal) { if (_pdfGenerator == null) { _pdfGenerator = new TextSharpGenerator(); } return(_pdfGenerator.GeneratePdf(criminal)); }
public MediaLocation PrintEventCustomerPcpAppointmentForm(long eventId, long customerId, string fileName) { var mediaLocation = _mediaRepository.GetTempMediaFileLocation(); var url = _settings.AppUrl + "/Scheduling/EventCustomerList/ViewPcpAppointment?eventId=" + eventId + "&customerId=" + customerId + "&print=true"; _pdfGenerator.GeneratePdf(url, mediaLocation.PhysicalPath + fileName); return(mediaLocation); }
public string PrintAttestationPdf(long accountId, long customerId, long eventId) { try { if (accountId == _settings.MolinaAccountId || accountId == _settings.WellmedAccountId) { var focAttestationPdfUrl = string.Empty; var eventCustomerResult = _eventCustomerResultRepository.GetByCustomerIdAndEventId(customerId, eventId); var fileName = "Attestation_" + Guid.NewGuid() + ".pdf"; _logger.Info(string.Format("generating AttestationFormPdf: CustomerId {0} EventId {1} AccountId {2}", customerId, eventId, accountId)); var mediaLocation = _mediaRepository.GetTempMediaFileLocation(); if (accountId == _settings.WellmedAccountId && eventCustomerResult != null) { focAttestationPdfUrl = _settings.AppUrl + "/Medical/Attestation/WellMedView?eventCustomerResultId=" + eventCustomerResult.Id + "&accountId=" + accountId + "&customerId=" + customerId + "&eventId=" + eventId + "&print=true"; } else if (accountId == _settings.MolinaAccountId && eventCustomerResult != null) { focAttestationPdfUrl = _settings.AppUrl + "/Medical/Attestation/MolinaView?eventCustomerResultId=" + eventCustomerResult.Id + "&accountId=" + accountId + "&customerId=" + customerId + "&eventId=" + eventId + "&print=true"; } if (string.IsNullOrEmpty(focAttestationPdfUrl)) { return(string.Empty); } _pdfGenerator.GeneratePdf(focAttestationPdfUrl, mediaLocation.PhysicalPath + fileName); return(mediaLocation.PhysicalPath + fileName); } } catch (Exception exception) { _logger.Error(string.Format("Some Error occured: Exception: {0} Stack Trace: {1}", exception.Message, exception.StackTrace)); } return(string.Empty); }
private string GenerateMammoConsent(MammoConsentEditModel model) { var mediaLocation = _mediaRepository.GetTempMediaFileLocation(); var fileName = "MammoConsent_" + model.EventId + "_" + model.CustomerId + ".pdf"; var url = _settings.AppUrl + "/Medical/Results/MammoConsent?customerId=" + model.CustomerId + "&eventId=" + model.EventId + "&print=" + model.Print; _pdfGenerator.GeneratePdf(url, mediaLocation.PhysicalPath + fileName); return(mediaLocation.Url + fileName); }
public void GenerateHafAssessment(long eventId) { try { var eventLogger = _logManager.GetLogger("HealthAssessmentFormGenerator_" + eventId); eventLogger.Info("Generating HAF for Event Id: " + eventId); _pdfGenerator.PaperSize = _configurationSettingRepository.GetConfigurationValue(ConfigurationSettingName.PaperSize); try { var eventCustomers = _eventCustomerRepository.GetbyEventId(eventId); if (eventCustomers != null && eventCustomers.Any()) { eventCustomers = eventCustomers.Where(ec => ec.AppointmentId.HasValue).ToArray(); if (eventCustomers != null && eventCustomers.Any()) { eventLogger.Info("found EventCustomers Count: " + eventCustomers.Count()); var mediaLocation = _mediaRepository.GetMedicalHistoryMediaLocation(eventId); DirectoryOperationsHelper.CreateDirectoryIfNotExist(mediaLocation.PhysicalPath); DirectoryOperationsHelper.DeleteFiles(mediaLocation.PhysicalPath); var eventData = _eventRepository.GetById(eventId); var account = _corporateAccountRepository.GetbyEventId(eventId); var corporateSurveyPdf = ""; if (account != null && account.CaptureSurvey) { if (account.SurveyPdfFileId > 0) { var surveyPdf = _fileRepository.GetById(account.SurveyPdfFileId); if (surveyPdf != null) { corporateSurveyPdf = _mediaRepository.GetCorporateSurveyPdfFolderLocation().PhysicalPath + surveyPdf.Path; } } } var corporateCheckListPdf = ""; if (account != null && account.PrintCheckList && account.CheckListFileId > 0 && eventData.EventDate >= _settings.ChecklistChangeDate) { var checkListFilePdf = _fileRepository.GetById(account.CheckListFileId); if (checkListFilePdf != null) { corporateCheckListPdf = _mediaRepository.GetCorporateCheckListPdfFolderLocation().PhysicalPath + checkListFilePdf.Path; } } var filesFocAttestation = new[] { "" }; var mediaLocFocAttestation = _mediaRepository.GetUnlockEventsParseLocation(eventId); if (account != null && account.Id == _settings.HcpNvAccountId) { if (DirectoryOperationsHelper.IsDirectoryExist(mediaLocFocAttestation.PhysicalPath)) { filesFocAttestation = Directory.GetFiles(mediaLocFocAttestation.PhysicalPath, "*.*"); filesFocAttestation = filesFocAttestation.Where(fsd => !string.IsNullOrEmpty(fsd)).ToArray(); } } else { if (DirectoryOperationsHelper.IsDirectoryExist(mediaLocFocAttestation.PhysicalPath)) { filesFocAttestation = Directory.GetFiles(mediaLocFocAttestation.PhysicalPath, "*.pdf"); filesFocAttestation = filesFocAttestation.Where(fsd => !string.IsNullOrEmpty(fsd)).ToArray(); } } var tempMediaLocation = _mediaRepository.GetTempMediaFileLocation(); var customers = _customerRepository.GetCustomers(eventCustomers.Select(ec => ec.CustomerId).ToArray()); int index = 0; foreach (var eventCustomer in eventCustomers) { eventLogger.Info(string.Format("Generating HAF for Event Id: {0} and Customer Id : {1} ", eventId, eventCustomer.CustomerId)); string url = _settings.HealthAssessmentFormUrl + string.Format("?eventId={0}&customerId={1}&LoadLayout=false&showKynEditModel=true&bulkPrint=true&removeChache={2}", eventCustomer.EventId, eventCustomer.CustomerId, Guid.NewGuid()); var customer = customers.First(c => c.CustomerId == eventCustomer.CustomerId); var focAttestationFile = string.Empty; if (account != null) { var questFile = Path.Combine(_mediaRepository.GetQuestUploadMediaFileLocation().PhysicalPath, account.Tag + "_Quest.pdf"); if (account.Id == _settings.WellmedAccountId || account.Id == _settings.WellmedTxAccountId) { var memberId = string.IsNullOrEmpty(customer.InsuranceId) ? "" : customer.InsuranceId.ToLower().Trim(); focAttestationFile = filesFocAttestation.FirstOrDefault(fsd => !string.IsNullOrEmpty(fsd) && Path.GetFileNameWithoutExtension(fsd).ToLower().Trim() == memberId); eventLogger.Info(string.Format("focAttestationFile : {0}", focAttestationFile)); var _files = new List <string>(); if (!string.IsNullOrEmpty(focAttestationFile) && DirectoryOperationsHelper.IsFileExist(focAttestationFile)) { eventLogger.Info(string.Format("focAttestationFile : First if {0}", focAttestationFile)); _files.Add(focAttestationFile); } if (DirectoryOperationsHelper.IsFileExist(questFile)) { eventLogger.Info(string.Format("focAttestationFile : 2nd if {0}", questFile)); _files.Add(questFile); } if (!_files.IsNullOrEmpty()) { if (_files.Count() > 1) { eventLogger.Info(string.Format("focAttestationFile : File Count {0}", _files.Count())); focAttestationFile = GetFocAttestationFileMerge(_files, focAttestationFile, eventLogger); } else { eventLogger.Info(string.Format("focAttestationFile : File[0] {0}", _files[0])); focAttestationFile = _files[0]; eventLogger.Info(string.Format("focAttestationFile : Last {0}", focAttestationFile)); } } } else { focAttestationFile = GetFocAttestationFileForMht(filesFocAttestation, customer.CustomerId.ToString(), eventLogger); } //else if (account.Id == _settings.MolinaAccountId) //{ // var hicn = string.IsNullOrEmpty(customer.Hicn) ? "" : customer.Hicn.ToLower().Trim(); // focAttestationFile = filesFocAttestation.FirstOrDefault(fsd => !string.IsNullOrEmpty(fsd) && Path.GetFileNameWithoutExtension(fsd).ToLower().Trim() == hicn); //} //else if (account.Id == _settings.HcpNvAccountId) //{ //} //else if (_settings.MonarchAccountIds.Contains(account.Id)) //{ // var gmpi = string.IsNullOrEmpty(customer.AdditionalField4) ? "" : customer.AdditionalField4.ToLower().Trim(); // if (!string.IsNullOrEmpty(gmpi)) // { // focAttestationFile = GetFocAttestationFile(filesFocAttestation, "_" + gmpi.ToLower(), focAttestationFile, eventLogger); // } //} //else if (account.Id == _settings.AppleCareAccountId) //{ // focAttestationFile = GetFocAttestationFile(filesFocAttestation, customer.CustomerId.ToString(), focAttestationFile, eventLogger); //} //else if (account.Id == _settings.NammAccountId) //{ // focAttestationFile = GetFocAttestationFile(filesFocAttestation, customer.CustomerId.ToString(), focAttestationFile, eventLogger); //} } var focAttestationFilePath = string.Empty; eventLogger.Info("focAttestationFile: " + focAttestationFile); if (!string.IsNullOrEmpty(focAttestationFile)) { focAttestationFilePath = focAttestationFile; } var annualComprehensiveExamPdf = string.Empty; var memberInformationProfilePdf = string.Empty; if (!string.IsNullOrEmpty(customer.Hicn)) { var fileNamePattern = customer.Hicn + (customer.Name != null ? "_" + customer.Name.LastName + "_" + customer.Name.FirstName : ""); if (account != null && account.PrintAceForm) { try { var mediaLocationForAce = _mediaRepository.GetAceMipLocation(account.FolderName, fileNamePattern, "ACE"); var aceFiles = DirectoryOperationsHelper.GetFiles(mediaLocationForAce.PhysicalPath, fileNamePattern + "*_ACE.pdf"); if (aceFiles.Any()) { annualComprehensiveExamPdf = _pdfGenerator.ExtractPdfPagesFromEnd(aceFiles.First(), tempMediaLocation.PhysicalPath + "Ripped_" + customer.Hicn + "_ACE.pdf", NumberOfPagesToExtractFromAcePdf); } } catch (Exception ex) { eventLogger.Error(string.Format("Unable to attach ACE form to the bulk HAF for CustomerID : {0}\nMessage : {1}", customer.CustomerId, ex.Message)); } } if (account != null && account.PrintMipForm) { try { var mediaLocationForMip = _mediaRepository.GetAceMipLocation(account.FolderName, fileNamePattern, "MIP"); var mipFiles = DirectoryOperationsHelper.GetFiles(mediaLocationForMip.PhysicalPath, fileNamePattern + "*_MIP.pdf"); if (mipFiles.Any()) { memberInformationProfilePdf = mipFiles.First(); } } catch (Exception ex) { eventLogger.Error(string.Format("Unable to attach MIP to the bulk HAF for CustomerID : {0}\nMessage : {1}", customer.CustomerId, ex.Message)); } } } var consentHeaderWithChecklistpdf = string.Empty; if (!string.IsNullOrWhiteSpace(corporateCheckListPdf) && DirectoryOperationsHelper.IsFileExist(corporateCheckListPdf)) { var tempPath = _mediaRepository.GetTempMediaFileLocation(); var consentHeader = Path.Combine(tempPath.PhysicalPath, Guid.NewGuid() + ".pdf"); string consentHeaderUrl = _settings.ConsentHeaderFormUrl + string.Format("?eventId={0}&customerId={1}&removeChache={2}", eventCustomer.EventId, eventCustomer.CustomerId, Guid.NewGuid()); _pdfGenerator.GeneratePdf(consentHeaderUrl, consentHeader); consentHeaderWithChecklistpdf = Path.Combine(tempPath.PhysicalPath, Guid.NewGuid() + ".pdf"); var consentHeaderWithChecklistpdfArray = new string[] { consentHeader, corporateCheckListPdf }; _pdfGenerator.Merge(consentHeaderWithChecklistpdf, consentHeaderWithChecklistpdfArray); } _pdfGenerator.GeneratePdfForHaf(url, mediaLocation.PhysicalPath + (++index).ToString("000.") + eventCustomer.CustomerId + ".pdf", corporateSurveyPdf, "", focAttestationFilePath, consentHeaderWithChecklistpdf, annualComprehensiveExamPdf, memberInformationProfilePdf); } eventLogger.Info("Merging HAF for Event Id: " + eventId); _pdfGenerator.GetPdffilesfromLocationandMergeintoOne(mediaLocation.PhysicalPath, mediaLocation.PhysicalPath + "Event_" + eventId + ".pdf"); _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, false, (long)GenerateHealthAssesmentFormStatus.Completed); index = 0; foreach (var eventCustomer in eventCustomers) { DirectoryOperationsHelper.Delete(mediaLocation.PhysicalPath + (++index).ToString("000.") + eventCustomer.CustomerId + ".pdf"); } } else { eventLogger.Info("No customer found with appointment attached with this event. Merging HAF for Event Id: " + eventId); _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, false, (long)GenerateHealthAssesmentFormStatus.Completed); } } else { eventLogger.Info("No customer found attached with this event. Merging HAF for Event Id: " + eventId); _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, false, (long)GenerateHealthAssesmentFormStatus.Completed); } } catch (Exception ex) { _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, true, (long)GenerateHealthAssesmentFormStatus.Pending); eventLogger.Error("\n" + ex.Message + "\n\t Stack Trace: " + ex.StackTrace); } } catch (Exception ex) { _eventRepository.SetGenrateHealthAssesmentFormStatus(eventId, true, (long)GenerateHealthAssesmentFormStatus.Pending); _logger.Error("\n" + ex.Message + "\n\t Stack Trace: " + ex.StackTrace); } }
public async Task <IActionResult> DescargarFactura(int id) { var factura = await _facturasServices.FindFacturaByIdForEditAsync(id); return(File(await _pdfGenerator.GeneratePdf(factura), "application/pdf", $"{factura.Codigo}.pdf")); }
public void GeneratePdf_usingAbcPdf() { _pdfGenerator.GeneratePdf("http://localhost/config/content/ResultPacket/coverletter.htm", @"D:\CoverLetter.pdf"); }