private void RemoveCacheByGroup(int userID, int groupID) { string cacheKey = string.Format(cacheKey_ByGroup, userID, groupID); CacheUtil.RemoveBySearch(string.Format(cacheKey_EmoticonPagedRoot, groupID));//清除已分页的本组缓存 CacheUtil.Remove(cacheKey); }
/// <summary> /// 高级删除 /// </summary> public bool DeleteTags(AdminTagFilter filter) { if (SafeMode) { if (!IsExecutorLogin) { ThrowError(new NotLoginError()); return(false); } } if (filter == null) { filter = new AdminTagFilter(); } if (SafeMode) { //TODO: } bool success = TagDao.Instance.DeleteTagsByFilter(filter); if (success) { CacheUtil.RemoveBySearch(CacheKey_TagPrefix); } return(true); }
public ClubMemberStatus?GetClubMemberStatus(int clubID, int userID) { if (userID <= 0) { return(null); } string cachekey = GetCacheKeyForClubMemberStatus(userID, clubID); ClubMemberStatus cache = ClubMemberStatus.Normal; if (CacheUtil.TryGetValue <ClubMemberStatus>(cachekey, out cache)) { return(cache); } ClubMemberStatus?result = ClubDao.Instance.GetClubMemberStatus(clubID, userID); if (result != null) { CacheUtil.Set <ClubMemberStatus>(cachekey, result.Value); } return(result); }
/// <summary> /// 删除标签 /// </summary> /// <param name="tagID">删除标签ID</param> public bool DeleteTag(int tagID) { if (SafeMode) { if (!IsExecutorLogin) { ThrowError(new NotLoginError()); return(false); } } if (tagID <= 0) { ThrowError(new InvalidParamError("tagID")); return(false); } if (SafeMode) { //TODO: } bool success = TagDao.Instance.DeleteTag(tagID); if (success) { CacheUtil.RemoveBySearch(CacheKey_TagPrefix); } return(true); }
/// <summary> /// 删除多个标签 /// </summary> public bool DeleteTags(IEnumerable <int> tagIDs) { if (SafeMode) { if (!IsExecutorLogin) { ThrowError(new NotLoginError()); return(false); } } if (tagIDs == null || ValidateUtil.HasItems <int>(tagIDs) == false) { ThrowError(new NotSelectedTagsError("tagIDs")); return(false); } if (SafeMode) { //TODO: } bool success = TagDao.Instance.DeleteTags(tagIDs); if (success) { CacheUtil.RemoveBySearch(CacheKey_TagPrefix); } return(true); }
public bool SaveTags(IEnumerable <string> tagNames, TagType type, int targetID, int operatorID) { if (tagNames != null) { TagCollection tags = new TagCollection(); foreach (string tagName in tagNames) { string t = tagName.Trim(); if (string.IsNullOrEmpty(t)) { continue; } Tag tag = new Tag(); tag.Name = t; tag.IsLock = false; tags.Add(tag); } string cacheKey = GetCacheKeyForUserTags(type, operatorID); CacheUtil.Remove(cacheKey); return(SaveTags(tags, type, targetID)); } return(false); }
/// <summary> /// 保存标签 /// </summary> /// <param name="tags">标签集</param> /// <param name="type">类型,如日志标签等</param> /// <param name="targetID">标签的对象ID</param> public bool SaveTags(TagCollection tags, TagType type, int targetID) { if (SafeMode) { if (!IsExecutorLogin) { ThrowError(new NotLoginError()); return(false); } } if (targetID <= 0) { ThrowError(new InvalidParamError("targetID")); return(false); } bool success = TagDao.Instance.SaveTags(tags, type, targetID); if (success) { CacheUtil.RemoveBySearch(CacheKey_TagPrefix); } return(true); }
/// <summary> /// 获取大家的记录包含当前页的记录的评论(通过记录的CommentList属性访问) /// </summary> /// <param name="visitorID">访问者ID</param> /// <param name="friendOwnerID">好友所有者ID</param> /// <param name="pageNumber">数据分页每页条数</param> /// <param name="pageSize">数据分页当前页码</param> /// <returns></returns> public DoingCollection GetEveryoneDoingsWithComments(int pageNumber, int pageSize) { pageNumber = pageNumber <= 0 ? 1 : pageNumber; pageSize = pageSize <= 0 ? Consts.DefaultPageSize : pageSize; DoingCollection doings = null; #region 获取Doings缓存 string doingsCacheKey = GetCacheKeyForEveryoneDoings(pageNumber, pageSize); bool doingsNeedCache = pageNumber <= Consts.ListCachePageCount; bool doingsCached = doingsNeedCache && CacheUtil.TryGetValue(doingsCacheKey, out doings); if (doingsCached) { return(doings); } #endregion #region 获取TotalCount缓存 int?totalCount = null; string totalCountCacheKey = GetCacheKeyForEveryoneDoingsTotalCount(); bool totalCountCached = CacheUtil.TryGetValue(totalCountCacheKey, out totalCount); #endregion doings = DoingDao.Instance.GetEveryoneDoingsWithComments(pageNumber, pageSize, ref totalCount); #region 设置TotalCount缓存 if (totalCountCached == false) { CacheUtil.Set(totalCountCacheKey, totalCount); } #endregion #region 设置Articles缓存 if (doingsNeedCache) { CacheUtil.Set(doingsCacheKey, doings); } #endregion ProcessKeyword(doings, ProcessKeywordMode.TryUpdateKeyword); return(doings); }
/// <summary> /// 缓存用户的表情分组 /// </summary> /// <param name="userID"></param> /// <param name="groups"></param> private void CacheUserEmoticonGroups(int userID, EmoticonGroupCollection groups) { string cacheKey = string.Format(cacheKey_EmoticonUserGroups, userID); CacheUtil.Set <EmoticonGroupCollection>(cacheKey, groups); foreach (EmoticonGroup group in groups) { CacheUtil.Set <EmoticonGroup>(string.Format(cacheKey_EmoticonGroup, group.GroupID), group); } }
private void RemoveCacheByType(int userID, int type) { if (type == 0) { CacheUtil.RemoveBySearch(string.Format(cacheKey_UserNotifyRoot, userID)); } else { CacheUtil.RemoveBySearch(string.Format(cacheKey_UserNotifyType, userID, type)); } }
/// <summary> /// 批量删除表情 /// </summary> /// <param name="userID">用户ID</param> /// <param name="groupID"></param> /// <param name="emoticonsIdentities">要删除的ID</param> /// <returns></returns> public void DeleteEmoticons(int userID, int groupID, IEnumerable <int> emoticonIds) { if (ValidateUtil.HasItems <int>(emoticonIds)) { List <string> canDeleteFiles = EmoticonDao.Instance.DeleteEmoticons(userID, groupID, emoticonIds); CacheUtil.RemoveBySearch(string.Format(cacheKey_EmoticonPagedRoot, groupID)); CacheUtil.Remove(string.Format(cacheKey_EmoticonUserGroups, userID)); DeleteEmoticonFiles(canDeleteFiles); } }
public bool SaveUploadedFile(AuthUser my, int directoryID, int tempFileID, bool replaceExistFile) { AuthUser user = my; if (my == User.Guest) { ThrowError(new NotLoginError()); return(false); } TempUploadFile tempUploadFile = FileManager.GetUserTempUploadFile(my.UserID, tempFileID); if (tempUploadFile == null) { ThrowError(new UnknownError()); return(false); } long diskSpace = GetDiskSpaceSize(my.UserID); long userRemnantDiskSpace = GetDiskSpaceSize(my.UserID) - user.UsedDiskSpaceSize; if (tempUploadFile.FileSize > GetMaxFileSize(my.UserID)) { ThrowError(new DiskFileSizeOverflowError(GetMaxFileSize(my.UserID))); return(false); } if (tempUploadFile.FileSize > userRemnantDiskSpace) { ThrowError(new InsufficientDiskSpaceError(diskSpace)); return(false); } if (DiskDao.Instance.SaveUploadFile(my.UserID, directoryID, tempUploadFile.FileID, tempUploadFile.FileName, tempUploadFile.FileSize, userRemnantDiskSpace, replaceExistFile)) { tempUploadFile.Save(); //string thumbPath = BuildThumb(tempUploadFile); //FileManager.DeleteFiles(canDeleteFileIds); CacheUtil.RemoveBySearch(string.Format(cacheKey_diskRoot, my.UserID)); return(true); } else { //if (!string.IsNullOrEmpty(thumbPath)) // IOUtil.DeleteFile(thumbPath); //saver.Cancel(); return(false); } }
/// <summary> /// ����ɾ��ָ���û���ָ��Ŀ¼�е��ļ��� /// </summary> /// <param name="userID">��ǰ�û�ID��</param> /// <param name="directoryID">��Ŀ¼ID��</param> /// <param name="diskFileIdentities">�ļ�ID�б��</param> /// <returns>����<see cref="DeleteStatus"/>��</returns> public DeleteStatus DeleteDiskFiles(int userID, int directoryID, IEnumerable <int> diskFileIds) { //List<string> needDeleteFileIds; DeleteStatus status = DiskDao.Instance.DeleteDiskFiles(userID, directoryID, diskFileIds); if (status == DeleteStatus.Success) { CacheUtil.Remove(string.Format(cacheKey_directory, userID, directoryID)); //FileManager.DeleteFiles(needDeleteFileIds); } return(status); }
/// <summary> /// 获取标签 /// </summary> public TagCollection GetUnlockTags(int pageNumber, int pageSize, ref int?count) { TagCollection tags = null; string cacheKey = string.Format(CacheKey_Tag_List_All, pageSize, pageNumber); if (!CacheUtil.TryGetValue <TagCollection>(cacheKey, out tags)) { tags = TagDao.Instance.GetMostTags(false, pageNumber, pageSize, ref count); CacheUtil.Set <TagCollection>(cacheKey, tags); } return(tags); }
public static ThreadCollectionV5 GetForumThreads(int forumID, ThreadOrderType orderType) { string cacheKey = string.Format(CacheKey_ForumThreadOrderType, orderType.ToString(), forumID, GetTotalCacheCount(orderType)); ThreadCollectionV5 threads; if (CacheUtil.TryGetValue <ThreadCollectionV5>(cacheKey, out threads)) { return(threads); } return(null); }
public bool IgnoreDenouncings(int operatorID, int[] denouncingIDs) { if (ManagePermission.Can(operatorID, BackendPermissions.Action.Manage_Report) == false) { ThrowError(new NoPermissionIgnoreDenouncingError()); return false; } DenouncingDao.Instance.IgnoreDenouncings(denouncingIDs); CacheUtil.Remove("Denouncing/Count"); return true; }
public DiskDirectory GetDiskDirectory(int userID, int directoryID) { string cacheKey = string.Format(cacheKey_directory, userID, directoryID); DiskDirectory Directory; if (!CacheUtil.TryGetValue <DiskDirectory>(cacheKey, out Directory)) { Directory = DiskDao.Instance.GetDiskDirectory(userID, directoryID); if (Directory != null) { CacheUtil.Set <DiskDirectory>(cacheKey, Directory); } } return(Directory); }
/// <summary> /// 移除用户的表情分组缓存 /// </summary> /// <param name="userID"></param> private void RemoveCachedUserEmoticonGroups(int userID) { string cacheKey = string.Format(cacheKey_EmoticonUserGroups, userID); EmoticonGroupCollection cachedGroups; if (CacheUtil.TryGetValue <EmoticonGroupCollection>(cacheKey, out cachedGroups)) { CacheUtil.Remove(cacheKey); foreach (EmoticonGroup group in cachedGroups) { CacheUtil.Remove(string.Format(cacheKey_EmoticonGroup, group.GroupID)); } } }
public PointShowUserCollection GetTopUserShows(int userID, int count) { PointShowUserCollection users; PointShowUserCollection result = new PointShowUserCollection(); if (CacheUtil.TryGetValue <PointShowUserCollection>(showUsersKey, out users)) { int i = 0; foreach (PointShowUser user in users) { result.Add(user); i++; if (i == count) { break; } } return(users); } Dictionary <int, int> points; Dictionary <int, string> contents; UserCollection temp = GetUserShows(userID, 1, count, out points, out contents); users = new PointShowUserCollection(); int m = 0; foreach (User u in temp) { PointShowUser pointShowUser = new PointShowUser(); pointShowUser.Content = contents[u.UserID]; pointShowUser.Price = points[u.UserID]; pointShowUser.UserID = u.UserID; users.Add(pointShowUser); if (m < count) { result.Add(pointShowUser); m++; } } CacheUtil.Set <PointShowUserCollection>(showUsersKey, users); return(result); }
public ClubCategoryCollection GetClubCategories() { string cacheKey = GetCacheKeyForClubCategories(); ClubCategoryCollection result = null; if (CacheUtil.TryGetValue <ClubCategoryCollection>(cacheKey, out result)) { return(result); } result = ClubDao.Instance.GetClubCategories(); CacheUtil.Set <ClubCategoryCollection>(cacheKey, result); return(result); }
/*----------------------3.0------------------------------*/ public bool RenameEmoticonShortcut(int userID, int groupID, List <int> emoticonIDs, List <string> newShortcuts) { //替换|为空 string sortcurString = StringUtil.Join(newShortcuts); if (sortcurString.IndexOf('"') > -1 || sortcurString.IndexOf('<') > -1 || sortcurString.IndexOf('>') > -1) { ThrowError(new InvalidEmoticonShortcutError()); return(false); } Dictionary <string, int> temp = new Dictionary <string, int>(new DictionaryIgnoreCase()); for (int i = 0; i < newShortcuts.Count; i++) { newShortcuts[i] = newShortcuts[i].Replace("|", ""); if (newShortcuts[i].Length > 15) { newShortcuts[i] = newShortcuts[i].Substring(0, 15); } if (!temp.ContainsKey(newShortcuts[i])) { temp.Add(newShortcuts[i], emoticonIDs[i]); } else { if (newShortcuts[i] != string.Empty) { return(false); } } } bool status = EmoticonDao.Instance.RenameEmoticonShortcut(userID, groupID, emoticonIDs, newShortcuts); //缓存更新 if (status) { foreach (int i in emoticonIDs) { CacheUtil.Remove(string.Format(cacheKey_Emoticon, i)); } RemoveCacheByGroup(userID, groupID); } return(status); }
/// <summary> /// 获取指定用户指定类型的所有通知 /// </summary> /// <param name="notifyType">指定类型</param> /// <returns>指定用户指定类型的所有通知集合</returns> public NotifyCollection GetNotifiesByType(int userID, int notifyType, int pageSize, int pageNumber, ref int?count) { if (userID <= 0) { ThrowError(new NotLoginError()); return(new NotifyCollection()); } pageNumber = pageNumber <= 0 ? 1 : pageNumber; pageSize = pageSize <= 0 ? Consts.DefaultPageSize : pageSize; if (HasUnCatchedError) { return(new NotifyCollection()); } #if !Passport PassportClientConfig settings = Globals.PassportClient; if (settings.EnablePassport) { NotifyProxy[] proxys = settings.PassportService.Notify_GetNotifiesByType(userID, notifyType, pageSize, pageNumber, ref count); NotifyCollection notifies = new NotifyCollection(); foreach (NotifyProxy proxy in proxys) { notifies.Add(GetNotify(proxy)); } return(notifies); } else #endif { NotifyCollection notifys; string cacheKey = string.Format(cacheKey_pagedNotify, userID, notifyType, pageSize, pageNumber); if (!CacheUtil.TryGetValue <NotifyCollection>(cacheKey, out notifys)) { notifys = NotifyDao.Instance.GetNotifiesByType(userID, notifyType, pageSize, pageNumber, ref count); CacheUtil.Set <NotifyCollection>(cacheKey, notifys); } count = notifys.TotalRecords; return(notifys); } }
public void GetDenouncingCount( out int? denouncingPhotoCount, out int? denouncingArticleCount, out int? denouncingShareCount, out int? denouncingUserCount, out int? denouncingTopicCount, out int? denouncingReplyCount) { string cacheKey = "Denouncing/Count"; int?[] cachedata = null; if (CacheUtil.TryGetValue<int?[]>(cacheKey, out cachedata) == false) { DenouncingDao.Instance.GetDenouncingCount( out denouncingPhotoCount, out denouncingArticleCount, out denouncingShareCount, out denouncingUserCount, out denouncingTopicCount, out denouncingReplyCount); cachedata = new int?[] { denouncingPhotoCount, denouncingArticleCount, denouncingShareCount, denouncingUserCount, denouncingTopicCount, denouncingReplyCount }; CacheUtil.Set<int?[]>(cacheKey, cachedata); } else { int i = 0; denouncingPhotoCount = cachedata[i ++]; denouncingArticleCount = cachedata[i ++]; denouncingShareCount = cachedata[i ++]; denouncingUserCount = cachedata[i ++]; denouncingTopicCount = cachedata[i ++]; denouncingReplyCount = cachedata[i++]; } }
public EmoticonCollection GetEmoticons(int userID, int groupID) { if (!CanUseEmoticon(userID)) { return(new EmoticonCollection()); } string cacheKey = string.Format(cacheKey_ByGroup, userID, groupID); EmoticonCollection emoticons; if (!CacheUtil.TryGetValue <EmoticonCollection>(cacheKey, out emoticons)) { emoticons = EmoticonDao.Instance.GetEmoticons(userID, groupID); CacheUtil.Set <EmoticonCollection>(cacheKey, emoticons); } return(emoticons); }
/// <summary> /// 返回表情列表 /// </summary> /// <param name="userID">用户ID</param> /// <param name="groupID">分组ID</param> /// <param name="emoticons"></param> /// <returns></returns> public EmoticonCollection GetEmoticons(int userID, int groupID, int pageNumber, int pageSize, bool IsDesc) { if (!CanUseEmoticon(userID)) { return(new EmoticonCollection()); } string cacheKey = string.Format(cacheKey_EmotiocnPaged, groupID, pageSize, pageNumber); EmoticonCollection emotes; if (!CacheUtil.TryGetValue <EmoticonCollection>(cacheKey, out emotes)) { int totalCount; emotes = EmoticonDao.Instance.GetEmoticons(userID, groupID, pageSize, pageNumber, IsDesc, out totalCount); CacheUtil.Set <EmoticonCollection>(cacheKey, emotes);//列表缓存 } return(emotes); }
/// <summary> /// ��ȡ��Ŀ¼ /// </summary> /// <param name="userID"></param> /// <returns></returns> public DiskDirectory GetDiskRootDirectory(int userID) { DiskDirectory rootDirectory = null; if (!CacheUtil.TryGetValue <DiskDirectory>(string.Format(chcheKey_userRootDirectory, userID), out rootDirectory)) { rootDirectory = DiskDao.Instance.GetDiskRootDirectory(userID); } if (rootDirectory == null) { rootDirectory = new DiskDirectory(0, 0, "\\"); } else { CacheUtil.Set <DiskDirectory>(string.Format(chcheKey_userRootDirectory, userID), rootDirectory); } return(rootDirectory); }
public static void ClearAllCache() { lock (s_AllCachedThreadsLocker) { CacheUtil.RemoveBySearch("Threads/"); //int count = CacheUtil.GetBySearch<ThreadCollectionV5>("Threads/").Count; //if (count > 0) //{ // MaxLabs.bbsMax.Common.LogHelper.CreateErrorLog2("ClearAllCache", count.ToString()); //} s_AllCachedThreads = null; s_AllForumTopThreads = null; s_ForumCacheKeys = null; //s_ForumLockers = null; InitForumLockers(); } }
private static void ClearForumThreadsCache(string cacheKey, int forumID) { List <string> cacheKeys = null; if (s_ForumCacheKeys != null && s_ForumCacheKeys.TryGetValue(forumID, out cacheKeys)) { if (cacheKeys.Contains(cacheKey)) { cacheKeys.Remove(cacheKey); } } ThreadCollectionV5 threads; if (CacheUtil.TryGetValue <ThreadCollectionV5>(cacheKey, out threads)) { CacheUtil.Remove(cacheKey); UpdateAllCachedThreadsRemoveThreads(threads, forumID, null); } }
public bool CreateDenouncing(int operatorID, int targetID, int targetUserID, DenouncingType type, string content, string createIP) { if (targetID <= 0) { ThrowError(new InvalidParamError("targetID")); return false; } if (StringUtil.GetByteCount("content") > Consts.Report_Length) { Context.ThrowError(new InvalidReportLengthError("content", content, Consts.Report_Length)); return false; } DenouncingDao.Instance.CreateDenouncing(operatorID, targetID, targetUserID, type, content, createIP); CacheUtil.Remove("Denouncing/Count"); return true; }
public ImpressionRecordCollection GetTargetUserImpressionRecords(int targetUserID, int pageNumber, int pageSize) { ImpressionRecordCollection result = null; string cacheKey = GetCacheKeyForTargetUserImpressionRecordsTotalCount(targetUserID); int?totalCount = null; bool totalCountCached = CacheUtil.TryGetValue <int?>(cacheKey, out totalCount); result = ImpressionDao.Instance.GetTargetUserImpressionRecords(targetUserID, pageNumber, pageSize, ref totalCount); if (totalCountCached == false) { CacheUtil.Set <int?>(cacheKey, totalCount); } ProcessKeyword(result, ProcessKeywordMode.TryUpdateKeyword); return(result); }