public byte[] GetInstLogoBytesByCode(string code) { using (var db = new ResearchReportEntities()) { INSTITUTIONINFO institutionInfo = db.INSTITUTIONINFOes.FirstOrDefault(i => i.CODE == code); if (institutionInfo != null) { var cmaFile = FileService.GetFileById((long)institutionInfo.ID_C, "LOGO"); if (cmaFile != null) { return(cmaFile.Content); } } return(null); } }
private string GetLogoImagePath(INSTITUTIONINFO inst) { if (string.IsNullOrEmpty(inst.EXTENSION)) { return(""); } var path = string.Format("{0}logo-{1}-{2}.{3}", "~/Cache/", inst.CODE, inst.MTIME.Value.ToFileTime(), inst.EXTENSION); var realPath = HttpContext.Current.Server.MapPath(path); if (!File.Exists(realPath)) { byte[] buffer = _repository.GetInstLogoBytesByCode(inst.CODE); if (buffer == null) { return(""); } using (var fs = new FileStream(realPath, FileMode.Create)) { fs.Write(buffer, 0, buffer.Length); } } return(VirtualPathUtility.ToAbsolute(path)); }