} // Disable public ActionResult DownloadCompanyFile(int fileId) { var file = m_oServiceClient.Instance.GetCompanyFile(_context.UserId, fileId); var fileMetaData = _companyFiles.Get(fileId); if (file != null && fileMetaData != null) { var document = file; var cd = new System.Net.Mime.ContentDisposition { FileName = fileMetaData.FileName, Inline = true, }; Response.AppendHeader("Content-Disposition", cd.ToString()); if (fileMetaData.FileContentType.Contains("image") || fileMetaData.FileContentType.Contains("pdf") || fileMetaData.FileContentType.Contains("html") || fileMetaData.FileContentType.Contains("text")) { return(File(document, fileMetaData.FileContentType)); } var pdfDocument = AgreementRenderer.ConvertToPdf(document); return(pdfDocument == null?File(document, fileMetaData.FileContentType) : File(pdfDocument, "application/pdf")); } return(null); } // DownloadCompanyFile
public AgreementsController(IEzbobWorkplaceContext context, ILoanAgreementRepository agreements, AgreementRenderer agreementRenderer, ServiceClient serviceClient) { this.agreementRenderer = agreementRenderer; this.serviceClient = serviceClient; this.context = context; this.agreements = agreements; }
public ActionResult Download() { AgreementRenderer agreementRenderer = new AgreementRenderer(); string template = (string)Session["Template"]; JavaScriptSerializer jss = new JavaScriptSerializer(); AgreementModel model = jss.Deserialize <AgreementModel>(GetDummyAgreementModel()); var pdf = agreementRenderer.RenderAgreementToPdf(template, model); return(File(pdf, "application/pdf", "test" + " Summary_" + DateTime.Now + ".pdf")); } // Download
public AgreementController( AgreementRenderer agreementRenderer, IEzbobWorkplaceContext context, AgreementsModelBuilder builder, LoanBuilder loanBuilder ) { this.agreementRenderer = agreementRenderer; this.context = context; this.builder = builder; this.customer = this.context.Customer; this.loanBuilder = loanBuilder; this.serviceClient = new ServiceClient(); } // constructor
//----------------------------------------------------------------------------------- public ActionResult File(int id) { var f = _docRepo.Get(id); if (f != null) { var document = f.BinaryBody; var cd = new System.Net.Mime.ContentDisposition { FileName = f.DocName, Inline = true, }; Response.AppendHeader("Content-Disposition", cd.ToString()); var mtr = new MimeTypeResolver(); MimeType oExtMimeType = mtr.Get(f.DocName); FileResult fs = new FileContentResult(f.BinaryBody, oExtMimeType.PrimaryMimeType); Log.Debug("fs {1} mime type {0}", oExtMimeType, f.DocName); if (fs.ContentType.Contains("image") || fs.ContentType.Contains("pdf") || fs.ContentType.Contains("html") || fs.ContentType.Contains("text")) { return(fs); } var pdfDocument = AgreementRenderer.ConvertToPdf(document); if (pdfDocument != null) { return(File(pdfDocument, "application/pdf")); } return(fs); } return(null); }
} // Index public ActionResult DownloadMessagesDocument(string id, bool download = false) { Guid guid; FileResult fs = null; string fileName; if (Guid.TryParse(id, out guid)) { var askville = _askvilleRepository.GetAskvilleByGuid(id); var askvilleData = ConvertFormat(string.IsNullOrEmpty(askville.MessageBody) ? "" : askville.MessageBody, SaveFormat.Pdf, "text"); fs = File(askvilleData, "application/pdf"); fileName = string.Format("Askville({0}).pdf", FormattingUtils.FormatDateTimeToStringWithoutSpaces(askville.CreationDate)); } else { var f = _exportResultRepository.Get(Convert.ToInt32(id)); if (f == null) { throw new Exception(String.Format("File id={0} not found", id)); } fileName = f.FileName.Replace(",", "").Replace("£", ""); if (f.FileType == 1) { fs = File(f.BinaryBody, "application/pdf"); } else { if (f.FileName.EndsWith("html")) { fs = File(f.BinaryBody, "text/html"); } else { if (download) { fs = File(f.BinaryBody, "application/msoffice"); } else { var pdfDocument = AgreementRenderer.ConvertToPdf(f.BinaryBody, LoadFormat.Docx); fs = File(pdfDocument, "application/pdf"); fileName.Replace("docx", "pdf"); } } } } if (download) { fs.FileDownloadName = fileName; } else { var cd = new System.Net.Mime.ContentDisposition { FileName = fileName, Inline = true, }; Response.AppendHeader("Content-Disposition", cd.ToString()); } return(fs); }