You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.1 KiB

  1. using Swift.web.Library;
  2. using System;
  3. using System.IO;
  4. using System.Web;
  5. namespace Swift.web
  6. {
  7. /// <summary>
  8. /// Summary description for img
  9. /// </summary>
  10. public class img : IHttpHandler
  11. {
  12. public void ProcessRequest(HttpContext context)
  13. {
  14. try
  15. {
  16. var id = context.Request.QueryString["id"];
  17. var functionId = context.Request.QueryString["functionId"];
  18. var imgPath = GetStatic.GetAppRoot() + @"\Images\na.gif";
  19. var primaryFilePath = GetStatic.GetAppRoot() + @"\doc\" + id;
  20. var defaultDocPath = GetStatic.GetDefaultDocPath() + @"\doc\" + id;
  21. var docFolder = context.Request.QueryString["df"];
  22. var doctype = (null != context.Request.QueryString["type"]) ? context.Request.QueryString["type"] : "";
  23. if (doctype.ToLower() == "txn")
  24. {
  25. if (docFolder == "")
  26. primaryFilePath = GetStatic.GetFilePath() + "TxnDocUpload\\" + id;
  27. else
  28. primaryFilePath = GetStatic.GetFilePath() + "TxnDocUpload\\" + docFolder + "\\" + id;
  29. }
  30. if (doctype.ToLower() == "txntmp")
  31. primaryFilePath = GetStatic.GetFilePath() + "TxnDocUploadTmp\\" + id;
  32. var secondaryFilePath = "";
  33. if (functionId == "20181400")
  34. secondaryFilePath = GetStatic.GetFilePath() + @"\doc\CreditSecurity\" + id;
  35. else if (functionId == "20182130")
  36. secondaryFilePath = GetStatic.GetFilePath() + @"\ReconcilationDoc\" + id;
  37. else if (functionId == "10111100")
  38. secondaryFilePath = GetStatic.GetFilePath() + @"\PopupMessage\" + id;
  39. else if (functionId == "vdoc")
  40. {
  41. id = id.Replace("../", "");
  42. id = id.Replace("doc", "");
  43. secondaryFilePath = GetStatic.GetFilePath() + id;
  44. }
  45. else
  46. secondaryFilePath = GetStatic.GetFilePath() + @"\doc\" + id;
  47. if (File.Exists(primaryFilePath) || File.Exists(secondaryFilePath) || File.Exists(defaultDocPath))
  48. {
  49. imgPath = (File.Exists(primaryFilePath)) ? primaryFilePath : secondaryFilePath;
  50. if (!File.Exists(imgPath))
  51. {
  52. imgPath = defaultDocPath;
  53. }
  54. }
  55. if (imgPath.ToLower().EndsWith(".pdf"))
  56. {
  57. context.Response.ContentType = "application/pdf";
  58. }
  59. else
  60. {
  61. context.Response.ContentType = "image/png";
  62. }
  63. context.Response.WriteFile(imgPath);
  64. }
  65. catch (Exception ex)
  66. {
  67. }
  68. }
  69. public bool IsReusable
  70. {
  71. get
  72. {
  73. return false;
  74. }
  75. }
  76. }
  77. }