Esempio n. 1
0
        /// <summary>
        /// 获取群组管理员
        /// </summary>
        /// <param name="groupId">群组Id</param>
        /// <returns>若没有找到,则返回空集合</returns>
        public IEnumerable <long> GetGroupManagers(long groupId)
        {
            string      cacheKey   = "GroupManagers" + groupId + "-" + RealTimeCacheHelper.GetAreaVersion("GroupId", groupId);
            List <long> managerIds = cacheService.Get <List <long> >(cacheKey);

            if (managerIds == null)
            {
                Sql sql = Sql.Builder;
                sql.Select("UserId")
                .From("spb_GroupMembers")
                .Where("GroupId = @0 and IsManager = 1", groupId);
                managerIds = CreateDAO().Fetch <long>(sql);

                //已修改
                cacheService.Add(cacheKey, managerIds, CachingExpirationType.UsualObjectCollection);
            }
            return(managerIds);
        }
Esempio n. 2
0
        /// <summary>
        /// 获取全部标签分组
        /// </summary>
        /// <param name="tenantTypeId">租户类型Id</param>
        public IEnumerable <TagGroup> GetGroups(string tenantTypeId)
        {
            string      cacheKey    = RealTimeCacheHelper.GetAreaVersion("TenantTypeId", tenantTypeId) + "::AllTagGroups";
            List <long> tagGroupIds = cacheService.Get <List <long> >(cacheKey);

            if (tagGroupIds == null)
            {
                var sql = PetaPoco.Sql.Builder;
                sql.Select("GroupId")
                .From("tn_TagGroups");

                if (!string.IsNullOrEmpty(tenantTypeId))
                {
                    sql.Where("TenantTypeId = @0", tenantTypeId);
                }

                tagGroupIds = CreateDAO().Fetch <long>(sql);
                cacheService.Add(cacheKey, tagGroupIds, CachingExpirationType.ObjectCollection);
            }
            return(PopulateEntitiesByEntityIds(tagGroupIds));
        }
Esempio n. 3
0
        /// <summary>
        /// 获取用户申请过的帖吧列表(仅适用于租户类型Id为帖吧应用的情况)
        /// </summary>
        /// <param name="tenantTypeId">租户类型Id</param>
        /// <param name="userId">创建者Id</param>
        /// <returns>帖吧列表</returns>
        public IEnumerable <BarSection> GetsByUserId(long userId)
        {
            string cacheKey = RealTimeCacheHelper.GetAreaVersion("UserId", userId) + userId + "SectionsOfUser";

            List <long> sectionIds = cacheService.Get <List <long> >(cacheKey);

            if (sectionIds == null)
            {
                var sql = PetaPoco.Sql.Builder;
                sql.Select("SectionId")
                .From("spb_BarSections")
                .Where("TenantTypeId=@0", TenantTypeIds.Instance().Bar())
                .Where("UserId=@0", userId);
                sectionIds = CreateDAO().Fetch <long>(sql);
                if (sectionIds != null)
                {
                    cacheService.Add(cacheKey, sectionIds, CachingExpirationType.UsualObjectCollection);
                }
            }
            return(PopulateEntitiesByEntityIds <long>(sectionIds));
        }
Esempio n. 4
0
        /// <summary>
        /// 获取成员请求书
        /// </summary>
        /// <param name="topicId">专题Id</param>
        /// <returns></returns>
        public int GetMemberApplyCount(long topicId)
        {
            int    version  = RealTimeCacheHelper.GetAreaVersion("TopicId", topicId);
            string cacheKey = string.Format("MemberApplyCount:{0}::TopicId:{1}", version, topicId);

            int?count = cacheService.Get(cacheKey) as int?;

            if (count == null)
            {
                var sql = Sql.Builder;

                sql.Select("Count(Id)")
                .From("spt_TopicMemberApplies")
                .Where("TopicId = @0", topicId)
                .Where("ApplyStatus=@0", TopicMemberApplyStatus.Pending);
                count = CreateDAO().ExecuteScalar <int>(sql);

                cacheService.Add(cacheKey, count, CachingExpirationType.UsualSingleObject);
            }

            return(count == null ? 0 : count.Value);
        }
Esempio n. 5
0
        /// <summary>
        /// 获取星级评价信息的CacheKey
        /// </summary>
        /// <param name="tenantTypeId">租户类型Id</param>
        /// <param name="objectId">操作对象</param>
        private string GetCacheKey_Rating(string tenantTypeId, long objectId)
        {
            int areaVersion = RealTimeCacheHelper.GetAreaVersion("ObjectId", objectId);

            return(string.Format("ObjectRating{0}::TenantTypeId:{1}", areaVersion, tenantTypeId));
        }
Esempio n. 6
0
 /// <summary>
 /// 获取主题帖最新的一条回复的CacheKey
 /// </summary>
 /// <returns></returns>
 private string GetCacheKey_NewestPost(long threadId)
 {
     return(string.Format("NewestPost::V-{0}:ThreadId-{1}", RealTimeCacheHelper.GetAreaVersion("ThreadId", threadId), threadId));
 }
Esempio n. 7
0
        /// <summary>
        /// 获取cachekey
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <param name="objectType">保存数据类型</param>
        /// <returns></returns>
        private string GetCacheKey_BlockedObjects(long userId, int objectType)
        {
            int version = RealTimeCacheHelper.GetAreaVersion("UserId", userId);

            return(string.Format("BlockedObjects-list;userId-{0};objectType-{1};Version-{2}", userId, objectType, version));
        }
Esempio n. 8
0
 /// <summary>
 /// 获取全部提到用户名CacheKey
 /// </summary>
 /// <param name="associateId">关联项Id</param>
 /// <param name="tenantTypeId">租户类型Id</param>
 /// <returns></returns>
 public string GetCacheKey_AllAtUserIds(long associateId, string tenantTypeId)
 {
     return(string.Format("AllAtUserIds{2}:AssociateId-{0}:TenantTypeId-{1}", associateId, tenantTypeId, RealTimeCacheHelper.GetAreaVersion("AssociateId", tenantTypeId + "_" + associateId)));
 }
Esempio n. 9
0
        /// <summary>
        /// 获取全部收藏CacheKey
        /// </summary>
        /// <param name="userId">收藏用户Id</param>
        /// <param name="tenantTypeId">租户类型Id</param>
        /// <returns></returns>
        public string GetCacheKey_PaingObjectIds(long userId, string tenantTypeId)
        {
            int areaVersion = RealTimeCacheHelper.GetAreaVersion("UserId", userId);

            return(string.Format("PaingFavoriteObjectIds:UserId{0}::TenantTypeId-{1}", areaVersion, tenantTypeId));
        }
Esempio n. 10
0
        /// <summary>
        /// 获取用户今天评分的cachekey
        /// </summary>
        /// <returns>用户今天评分的cachekey</returns>
        private string GetCacheKey_UserTodayRatingSum(long userId)
        {
            int userIdAreaVersion = RealTimeCacheHelper.GetAreaVersion("UserId", userId);

            return(string.Format("UserTodayRatingSum::UserId-{0};UserIdAreaVersion-{1};", userId, userIdAreaVersion));
        }
Esempio n. 11
0
        /// <summary>
        /// 获取我的邀请码列表的cachekey
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <returns>cachekey</returns>
        private string GetCacheKey_MyInvitationCodes(long userId)
        {
            int areaVersion = RealTimeCacheHelper.GetAreaVersion("UserId", userId);

            return(string.Format("MyInvitationCodes::UserId-{0};AreaVersion-{1}", userId, areaVersion));
        }