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.

50 lines
1.8 KiB

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