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.

45 lines
1.4 KiB

  1. using Swift.web.Library;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Web;
  5. namespace Swift.web.AgentPanel.OnlineAgent.CustomerSetup
  6. {
  7. /// <summary>
  8. /// Summary description for VerifyDocuments
  9. /// </summary>
  10. public class GetDocumentView : IHttpHandler
  11. {
  12. public void ProcessRequest(HttpContext context)
  13. {
  14. var imageName = context.Request.QueryString["imageName"];
  15. var idNumber = context.Request.QueryString["idNumber"];
  16. var imgPath = GetStatic.GetAppRoot() + @"Images\na.gif";
  17. var file = GetStatic.GetFilePath() + "CustomerDocument\\" + idNumber + "\\" + imageName;
  18. string type = imageName.Split('.')[1];
  19. string[] imageExtensions = { ".jpg", ".tif", ".gif", ".png", ".tiff", ".bmp", ".jpg", ".jpeg" };
  20. if (File.Exists(file))
  21. {
  22. imgPath = file;
  23. }
  24. if (imgPath.ToLower().EndsWith(".pdf"))
  25. {
  26. context.Response.ContentType = "application/pdf";
  27. }
  28. else if (imageExtensions.Contains("." + type))
  29. {
  30. context.Response.ContentType = "image/png";
  31. }
  32. context.Response.WriteFile(imgPath);
  33. }
  34. public bool IsReusable
  35. {
  36. get
  37. {
  38. return false;
  39. }
  40. }
  41. }
  42. }