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.
52 lines
1.8 KiB
52 lines
1.8 KiB
<%@ WebHandler Language="C#" Class="GetImg" %>
|
|
|
|
using System;
|
|
using System.Web;
|
|
|
|
public class GetImg : IHttpHandler
|
|
{
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
string gu_id = context.Request["F"];
|
|
string strImgsrc = "";
|
|
string subFileName = "";
|
|
try
|
|
{
|
|
Guid OutPutGuId;
|
|
bool isValidGuId = Guid.TryParse(gu_id, out OutPutGuId);
|
|
if (!string.IsNullOrEmpty(gu_id) && gu_id != "0" && isValidGuId) //不為空
|
|
{
|
|
OT.BLL.OTB_SYS_Document otb_document_bll = new OT.BLL.OTB_SYS_Document();
|
|
OT.Model.OTB_SYS_Document otb_document_model = new OT.Model.OTB_SYS_Document();
|
|
otb_document_model = otb_document_bll.GetImgSrc(gu_id); //代入GUID傳回Src
|
|
strImgsrc = otb_document_model.FilePath;
|
|
if (!string.IsNullOrEmpty(strImgsrc))
|
|
{
|
|
//DB內找不到圖片
|
|
subFileName = otb_document_model.SubFileName == null ? "jpeg" : otb_document_model.SubFileName.Substring(1);
|
|
HttpResponse txt = context.Response;
|
|
txt.ContentType = "image/" + subFileName;
|
|
txt.WriteFile(strImgsrc);
|
|
}
|
|
else
|
|
{
|
|
OT.Web.Ap_Code.BasePage.mo_Log.Error("GUID:" + OutPutGuId.ToString() + ",DB內找不到該GUID");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
OT.Web.Ap_Code.BasePage.mo_Log.Error("OrigtekGetImg.ashx Error Message:" + ex.Message + "\nGUID:" + gu_id + "\nFilePath:" + strImgsrc);
|
|
}
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|