protected bool IsStickForum(int forumID) { if (ThreadList.Count > 1) { return(false); } else if (ThreadList.Count == 1) { if (stickThreadsInForums == null) { stickThreadsInForums = PostBOV5.Instance.GetAllStickThreadInForums(); } return(stickThreadsInForums.GetValue(ThreadList[0].ThreadID, forumID) != null); } else { return(false); } }
protected bool IsStickForum(int forumID) { if (ThreadList.Count > 1) return false; else if (ThreadList.Count == 1) { if (stickThreadsInForums == null) stickThreadsInForums = PostBOV5.Instance.GetAllStickThreadInForums(); return stickThreadsInForums.GetValue(ThreadList[0].ThreadID, forumID) != null; } else return false; }
/// <summary> /// 移除AllCachedThreads里的缓存 /// </summary> /// <param name="threads"></param> /// <param name="forumID"></param> /// <param name="excludeCacheKeys">这些缓存将不去检查(这样就会去移除AllCachedThreads)</param> private static void UpdateAllCachedThreadsRemoveThreads(ThreadCollectionV5 threads, int?forumID, ThreadOrderType?excludeOrderType, params string[] excludeCacheKeys) { if (s_AllCachedThreads == null) { return; } if (threads == null || threads.Count == 0) { return; } List <string> cacheKeys = null; if (/*forumID != null &&*/ s_ForumCacheKeys != null) { List <int> checkForumIDs = new List <int>(); StickThreadCollection stickThreads = null; foreach (BasicThread thread in threads) { if (thread.ThreadStatus == Enums.ThreadStatus.Sticky || thread.ThreadStatus == Enums.ThreadStatus.GlobalSticky) { if (stickThreads == null) { stickThreads = PostBOV5.Instance.GetAllStickThreadInForums(); } foreach (StickThread stick in stickThreads) { if (stick.ThreadID == thread.ThreadID && checkForumIDs.Contains(stick.ForumID) == false) { checkForumIDs.Add(stick.ForumID); } } } if (forumID == null) { if (checkForumIDs.Contains(thread.ForumID) == false) { checkForumIDs.Add(thread.ForumID); } } } if (forumID != null) { checkForumIDs.Add(forumID.Value); if (forumID.Value != 0)//还要从MovedThreads里检查 { checkForumIDs.Add(0); } else//MovedThreads { foreach (BasicThread thread in threads) { if (checkForumIDs.Contains(thread.ForumID)) { continue; } checkForumIDs.Add(thread.ForumID); } } } else { checkForumIDs.Add(0); } foreach (int tempForumID in checkForumIDs) { List <string> tempKeys = null; s_ForumCacheKeys.TryGetValue(tempForumID, out tempKeys); if (tempKeys != null) { if (cacheKeys == null) { cacheKeys = new List <string>(tempKeys); } else { cacheKeys.AddRange(tempKeys); } } } /* * List<string> tempCacheKeys = null; * s_ForumCacheKeys.TryGetValue(forumID.Value, out tempCacheKeys); * * if (tempCacheKeys != null) * cacheKeys = new List<string>(tempCacheKeys); * //cacheKeys = s_ForumCacheKeys[forumID.Value]; * * if (forumID.Value != 0)// 还要从MovedThreads里检查 * { * List<string> tempKeys = null; * s_ForumCacheKeys.TryGetValue(0, out tempKeys); * if (tempKeys != null) * { * if (cacheKeys == null) * cacheKeys = new List<string>(tempKeys); * else * cacheKeys.AddRange(tempKeys); * } * } * else//MovedThreads * { * List<int> tempForumIDs = new List<int>(); * foreach (BasicThread thread in threads) * { * if (tempForumIDs.Contains(thread.ForumID)) * continue; * tempForumIDs.Add(thread.ForumID); * * List<string> tempKeys = null; * s_ForumCacheKeys.TryGetValue(thread.ForumID, out tempKeys); * * if (tempKeys != null) * { * if (cacheKeys == null) * cacheKeys = new List<string>(tempKeys); * else * cacheKeys.AddRange(tempKeys); * } * } * } */ } lock (s_AllCachedThreadsLocker) { if (s_AllCachedThreads == null) { return; } foreach (BasicThread thread in threads) { //检查其他所有缓存 如果有该主题的缓存 就不从AllCachedThreads中移除 否则移除 if (s_AllCachedThreads != null && s_AllCachedThreads.ContainsKey(thread.ThreadID)) { bool remove = true; if (cacheKeys != null) { //检查当前版块中的所有缓存的主题 foreach (string key in cacheKeys) { if (excludeCacheKeys != null) { bool exclude = false; foreach (string eck in excludeCacheKeys) { if (string.Compare(eck, key, true) == 0) { exclude = true; break; } } if (exclude) { continue; } } ThreadCollectionV5 tempThreads; if (CacheUtil.TryGetValue <ThreadCollectionV5>(key, out tempThreads)) { if (tempThreads.ContainsKey(thread.ThreadID)) { remove = false; break; } } } } if (remove == true && s_AllForumTopThreads != null) { //检查所有版块中的所有缓存的主题 foreach (KeyValuePair <ThreadOrderType, ThreadCollectionV5> pair in s_AllForumTopThreads) { if (excludeOrderType != null && excludeOrderType.Value == pair.Key) { continue; } if (pair.Value.ContainsKey(thread.ThreadID)) { remove = false; break; } } } if (remove && s_AllCachedThreads != null) { s_AllCachedThreads.Remove(thread.ThreadID); } } } } }