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. <%@ WebHandler Language="C#" Class="GetImg" %>
  2. using System;
  3. using System.Web;
  4. using OT.Web.Ap_Code;
  5. public class GetImg : IHttpHandler
  6. {
  7. public void ProcessRequest(HttpContext context)
  8. {
  9. string gu_id = context.Request["F"];
  10. string strImgsrc = "";
  11. string subFileName = "";
  12. try
  13. {
  14. if (!string.IsNullOrEmpty(gu_id)) //不為空
  15. {
  16. OT.BLL.OTB_SYS_Document otb_document_bll = new OT.BLL.OTB_SYS_Document();
  17. OT.Model.OTB_SYS_Document otb_document_model = new OT.Model.OTB_SYS_Document();
  18. otb_document_model = otb_document_bll.GetImgSrc(gu_id); //代入GUID傳回Src
  19. strImgsrc = otb_document_model.FilePath == null ? "" : otb_document_model.FilePath;
  20. subFileName = otb_document_model.SubFileName == null ? "jpeg" : otb_document_model.SubFileName.Substring(1);
  21. }
  22. HttpResponse txt = context.Response;
  23. txt.ContentType = "image/" + subFileName;
  24. txt.WriteFile(strImgsrc);
  25. //context.Response.Write(strImgsrc);
  26. //context.Response.Write("Hello World");
  27. }
  28. catch (Exception ex)
  29. {
  30. BasePage.mo_Log.Error("TvlGetImg.ashx Error Message:" + ex.Message + "\nGUID:" + gu_id + "\nFilePath:" + strImgsrc);
  31. }
  32. }
  33. public bool IsReusable
  34. {
  35. get
  36. {
  37. return false;
  38. }
  39. }
  40. }