<%@ WebHandler Language="C#" Class="titlelogo" %> using System; using System.Web; using IronIntel.Contractor.Users; using IronIntel.Contractor.iisitebase; using System.IO; using IronIntel.Contractor; public class titlelogo : IHttpHandler { const string CONTENTTYPE = "image/png"; public void ProcessRequest(HttpContext context) { context.Response.ContentType = CONTENTTYPE; string cmpid = context.Request.Params["cmpid"]; string tp = context.Request.Params["tp"]; byte[] buffer = null; if (string.Compare(tp, "loc", true) == 0) { int locid = -1; if (!int.TryParse(context.Request.Params["locid"], out locid)) locid = -1; buffer = IronIntel.Contractor.Site.CommonHttpRequestHandler.GetCustomerLocationLOGO(locid); if (buffer == null || buffer.Length == 0)//user { var sessionid = IronIntelBasePage.GetLoginSessionID(context.Request); int styleid = UserManagement.GetUserSiteTitleStyleID(sessionid); if (styleid > 0) buffer = UserManagement.GetSiteHederStyleLogo(styleid, 3); } if (buffer == null || buffer.Length == 0) buffer = IronIntel.Contractor.Site.CommonHttpRequestHandler.GetCompanyLocationLOGO(cmpid); } else if (string.Compare(tp, "location", true) == 0) { int locationid = -1; if (!int.TryParse(cmpid, out locationid)) locationid = -1; buffer = IronIntel.Contractor.Site.CommonHttpRequestHandler.GetCustomerLocationLOGO(locationid); } else if (string.Compare(tp, "dealer", true) == 0) { string styid = context.Request.Params["styid"]; int styleid = -1; if (!Int32.TryParse(styid, out styleid)) styleid = -1; if (styleid > 0) { buffer = UserManagement.GetSiteHederStyleLogo(styleid, 2); } else { buffer = IronIntel.Contractor.Site.CommonHttpRequestHandler.GetCompanyLocationLOGO(cmpid); } } else if (string.Compare(tp, "avatar", true) == 0) { string uid = context.Request.Params["uid"]; if (string.IsNullOrEmpty(uid)) { IronIntelHttpHandlerBase hh = new IronIntelHttpHandlerBase(context); var session = hh.GetCurrentLoginSession(); if (session != null) { buffer = UserManagement.GetUserAvatar(session.SessionID, session.User.UID); } } else { buffer = UserManagement.GetUserAvatar("", uid); } if (buffer == null) { string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "img\\user.png"); if (File.Exists(path)) buffer = File.ReadAllBytes(path); } } else { if ("foresight".Equals(cmpid, StringComparison.OrdinalIgnoreCase)) { buffer = IronIntel.Contractor.Site.CommonHttpRequestHandler.GetForesightLOGOInMainStyle(); } if (buffer == null || buffer.Length == 0) { string cmptype = context.Request.Params["cmpty"]; if (!string.IsNullOrEmpty(cmptype))//user { string styid = context.Request.Params["styid"]; int styleid = -1; if (!Int32.TryParse(styid, out styleid)) styleid = -1; if (styleid > 0) { if (string.Compare(cmptype, "contractor", true) == 0) { buffer = UserManagement.GetSiteHederStyleLogo(styleid, 1); } else if (string.Compare(cmptype, "dealer", true) == 0) { buffer = UserManagement.GetSiteHederStyleLogo(styleid, 2); } } } else { buffer = IronIntel.Contractor.Site.CommonHttpRequestHandler.GetCompanyLOGO(cmpid); } } } if (buffer != null) { context.Response.OutputStream.Write(buffer, 0, buffer.Length); context.Response.OutputStream.Flush(); } else context.Response.StatusCode = 404; context.Response.End(); } public bool IsReusable { get { return false; } } }