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.

51 lines
1.7 KiB

4 years ago
  1. using Common.Helper;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Web;
  7. namespace JMEAgentSystem.WebPages
  8. {
  9. /// <summary>
  10. /// Summary description for GetFileView
  11. /// </summary>
  12. public class GetFileView : IHttpHandler
  13. {
  14. public void ProcessRequest(HttpContext context)
  15. {
  16. var imageName = context.Request.QueryString["imageName"];
  17. var imgPath = GetStatic.GetAppRoot() + @"\Images\na.gif";
  18. if (imageName == "" || imageName == null || imageName.Split('_').Length < 6)
  19. {
  20. context.Response.WriteFile(imgPath);
  21. }
  22. else
  23. {
  24. var customerId = context.Request.QueryString["customerId"];
  25. var dirLocation = imageName.Split('_')[3].ToString() + "\\" + imageName.Split('_')[4].ToString() + "\\" + imageName.Split('_')[5].Split('.')[0].ToString() + "\\";
  26. var fileType = context.Request.QueryString["fileType"];
  27. var file = GetStatic.GetCustomerFilePath() + "CustomerDocument\\" + dirLocation + customerId + "\\" + imageName;
  28. bool a = fileType.Contains("image");
  29. if (File.Exists(file) && a)
  30. {
  31. imgPath = file;
  32. context.Response.ContentType = fileType;
  33. }
  34. else
  35. {
  36. context.Response.ContentType = fileType;
  37. }
  38. }
  39. context.Response.WriteFile(imgPath);
  40. }
  41. public bool IsReusable
  42. {
  43. get
  44. {
  45. return false;
  46. }
  47. }
  48. }
  49. }