ReportHelper.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using Core.Mes.Client.Comm.Server;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Net;
  6. using System.Text;
  7. namespace Core.Mes.Client.Comm.Tool
  8. {
  9. public class ReportHelper
  10. {
  11. /// <summary>
  12. /// 把报表转换为PDF并上传到FTP服务器
  13. /// </summary>
  14. /// <param name="url">报表地址</param>
  15. /// <param name="ftpPath">FTP服务器相对路径 Qcm/Craft/</param>
  16. /// <param name="pdfName">PDF名称</param>
  17. /// <returns></returns>
  18. public static bool CreatePdfToFtp(string url, string ftpPath, string pdfName)
  19. {
  20. WebClient webClient = new WebClient();
  21. List<FileBean> listPdf = new List<FileBean>();
  22. byte[] pdf = webClient.DownloadData(url + "&format=pdf");
  23. FileBean fileBean = new FileBean();
  24. fileBean.setFile(pdf);
  25. fileBean.setFileName(pdfName + ".pdf");
  26. fileBean.setPathName(ftpPath);
  27. listPdf.Add(fileBean);
  28. webClient.Dispose();
  29. return FileHelper.Upload(listPdf);
  30. }
  31. }
  32. }