public ActionResult ImagePreview(string guid) { guid = "preview-" + guid; if (CacheUtil.ExistCache(guid)) { byte[] imageBuffer = CacheUtil.Get <byte[]>(guid); return(File(imageBuffer, "image/Jpeg")); } else { return(Content("图片不存在!" + guid)); } }
public static string GetAuth(string account) { if (CacheUtil.ExistCache("Auth")) { var data = CacheUtil.Get <IDictionary <string, string> >("Auth"); if (data.ContainsKey(account)) { return(data[account]); } } string auth = SQL.QueryValue <string>("select Auth from Account where AccountName=@p0", account); SetAuth(account, auth); return(auth); }
public static void SetAuth(string account, string auth) { IDictionary <string, string> data; if (CacheUtil.ExistCache("Auth")) { data = CacheUtil.Get <IDictionary <string, string> >("Auth"); data[account] = auth; } else { data = new Dictionary <string, string> { { account, auth } }; CacheUtil.Set("Auth", data); } }
public static int GetAccountID(string account) { IDictionary <string, int> data; if (CacheUtil.ExistCache("AccountID")) { data = CacheUtil.Get <IDictionary <string, int> >("AccountID"); if (data.ContainsKey(account)) { return(data[account]); } } else { data = new Dictionary <string, int>(); CacheUtil.Set("AccountID", data); } int userId = SQL.QueryValue <int>("select AccountID from Account where AccountName=@p0", account); data[account] = userId; return(userId); }