/// <summary> /// 获取用户具有的权限 /// </summary> /// <param name="user"></param> /// <returns></returns> public DataTable GetPermissionsNameByUseridModouleid(string userid, string moduleid) { string cacheStrphold = string.Format("CommonSearch_GetPermissionsNameByUseridModouleid_{0}_{1}", userid, moduleid); if ((WebCache.GetCache(cacheStrphold) == null)) { lock (lockHelp) { if ((WebCache.GetCache(cacheStrphold) == null)) { DataTable dt = commonSearch.GetPermissionsNameByUseridModouleid(userid, moduleid); WebCache.SetCache(cacheStrphold, dt, 60); } } } return((DataTable)WebCache.GetCache(cacheStrphold)); }
/// <summary> /// 获取用户所具有的平台列表 /// </summary> /// <param name="user"></param> /// <returns></returns> public DataTable GetPlatformTableByUserid(string userid) { string cacheStrphold = string.Format("CommonSearch_GetPlatformTableByUserid_{0}", userid); if ((WebCache.GetCache(cacheStrphold) == null)) { lock (lockHelp) { if ((WebCache.GetCache(cacheStrphold) == null)) { DataTable dt = commonSearch.GetPlatformTableByUserid(userid); WebCache.SetCache(cacheStrphold, dt, 60); } } } return((DataTable)WebCache.GetCache(cacheStrphold)); }
/// <summary> /// 获取用户具有的权限 /// </summary> /// <param name="user"></param> /// <returns></returns> public DataTable GetGameListByRoleId(string roleid, int channelid) { string cacheStrphold = string.Format("CommonSearch_GetGameListByRoleId_{0}_{1}", roleid, channelid); if ((WebCache.GetCache(cacheStrphold) == null)) { lock (lockHelp) { if ((WebCache.GetCache(cacheStrphold) == null)) { DataTable dt = commonSearch.GetGameListByRoleId(roleid); WebCache.SetCache(cacheStrphold, dt, 60); } } } return((DataTable)WebCache.GetCache(cacheStrphold)); }
/// <summary> /// 获得天气的信息(json格式) /// </summary> /// <returns></returns> private string GetResponseStr() { string cacheTodayDay = string.Format("TodayDay_{0}", DateTime.Now.ToString("yyyy-MM-dd hh:00:00")); if ((WebCache.GetCache(cacheTodayDay) == null)) { lock (lockHelp) { if ((WebCache.GetCache(cacheTodayDay) == null)) { string str = "http://m.weather.com.cn/data/101010100.html"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(str); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream();//获得回应的数据流 //将数据流转成 String string result = new StreamReader(stream, System.Text.Encoding.UTF8).ReadToEnd(); WebCache.SetCache(cacheTodayDay, result, 3600); } } } return((string)WebCache.GetCache(cacheTodayDay)); }
/// <summary> /// 设置缓存(时间) /// </summary> /// <param name="key"></param> /// <param name="data"></param> /// <param name="d"></param> public static void SetCache(string key, object data, DateTime d) { WebCache.SetCache(key, data, d); }
/// <summary> /// 设置缓存 /// </summary> /// <param name="key"></param> /// <param name="data"></param> /// <param name="d"></param> public static void SetCache(string key, object data) { WebCache.SetCache(key, data); }