/// <summary> /// 检查某用户是否在某个板块被屏蔽 /// </summary> /// <param name="userID"></param> /// <param name="forumID"></param> /// <returns></returns> public static bool IsBanned(int userID, int forumID) { string cachekey = "IsBanned_{0}_{1}"; cachekey = string.Format(cachekey, userID, forumID); bool isBanned; if (false == PageCacheUtil.TryGetValue <bool>(cachekey, out isBanned)) { isBanned = false; long key = GetKey(userID, forumID); isBanned = AllBannedUsers.Limited.ContainsKey(userID) || AllBannedUsers.Limited.ContainsKey(key); PageCacheUtil.Set(cachekey, isBanned); } return(isBanned); }
/// <summary> /// 根据类型编号、目标,返回 符合条件的广告列表 /// </summary> /// <param name="categoryID"></param> /// <param name="target"></param> /// <returns></returns> private AdvertCollection SearchAdverts(int categoryID, string target, ADPosition position, int?Floor, bool?isLastFloor) { if (AllSettings.Current.AdvertSettings.EnableAdverts == false) { return(new AdvertCollection()); } if (!ADCategory.SystemADCategoryes.ContainsKey(categoryID)) { return(new AdvertCollection()); } AdvertCollection ads = ADCategory.SystemADCategoryes.GetValue(categoryID).AdvertList.Limited; AdvertCollection adResults; string cacheKey = string.Concat(categoryID, ",", target, position, Floor, isLastFloor); if (PageCacheUtil.TryGetValue <AdvertCollection>(cacheKey, out adResults) == false) { adResults = new AdvertCollection(); foreach (Advert ad in ads) { if (ad.Targets.Contains(",all,") || ad.Targets.IndexOf(string.Concat(",", target, ","), StringComparison.OrdinalIgnoreCase) > -1) //投放目标选择 { if (position == ADPosition.None || ad.Position == position) //投放位置选中(左边还是右边还是上边) { if (Floor == null || //忽略 ad.Floor.IndexOf(",-1,") > -1 || //全部楼层 ad.Floor.IndexOf("," + Floor + ",") > -1 || //匹配特定楼层 (ad.Floor.IndexOf(",-2,") > -1 && (isLastFloor != null && isLastFloor.Value)) //最后一楼 ) { adResults.Add(ad); } } } } PageCacheUtil.Set(cacheKey, adResults); } return(adResults); }