fleet-contractor/Site/fic/ImageService.ashx
2023-04-28 12:22:26 +08:00

70 lines
2.0 KiB
Plaintext

<%@ WebHandler Language="C#" Class="ImageService" %>
using System;
using System.Collections.Generic;
using System.Web;
using FI.FIC;
public class ImageService : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string imgName = context.Request.QueryString["img"];
bool fullsize = (context.Request.QueryString["size"] == "o");
context.Response.Expires = -1;
byte[] imgData = null;
try
{
switch (imgName)
{
case "CustomerLogo":
List<string> names = new List<string>() {imgName};
Dictionary<string, byte[]> logoData = ResManager.GetSystemResourceData(names);
if (logoData.ContainsKey(imgName))
{
imgData = logoData[imgName];
if (!fullsize)
{
imgData = ResManager.MakeThumbnail(imgData, 0, 60, "H");
}
}
break;
case "LogoUrlIcon":
string luID = context.Request.QueryString["id"];
if (!string.IsNullOrWhiteSpace(luID))
{
FI.FIC.Models.LogoUrlManager lum = new FI.FIC.Models.LogoUrlManager();
imgData = lum.GetLogoUrlIcon(luID);
imgData = ResManager.MakeThumbnail(imgData, 0, 40, "H");
}
break;
}
}
catch
{
}
if (imgData != null)
{
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(imgData);
context.Response.End();
}
else
{
if (string.Compare("LogoUrlIcon", imgName, true) != 0)
context.Response.Redirect("image/logo.jpg");
}
}
public bool IsReusable
{
get
{
return false;
}
}
}