Пример #1
0
        private string GetCacheKey_GetChildren(SortBy_BarPost sortBy, long parentId)
        {
            StringBuilder cacheKey = new StringBuilder();

            cacheKey.Append(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.AreaVersion, "ParentId", parentId));
            cacheKey.AppendFormat("ChildBarPosts::SortBy-{0}:ParentId-{1}", (int)sortBy, parentId);
            return(cacheKey.ToString());
        }
Пример #2
0
        /// <summary>
        /// 获取主题帖下回帖列表缓存
        /// </summary>
        /// <param name="threadId"></param>
        /// <param name="onlyStarter"></param>
        /// <param name="sortBy"></param>
        /// <returns></returns>
        private string GetCacheKey_PostIdsOfThread(long threadId, bool onlyStarter, SortBy_BarPost sortBy)
        {
            StringBuilder cacheKey = new StringBuilder();

            cacheKey.Append(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.AreaVersion, "ThreadId", threadId));
            cacheKey.AppendFormat("BarPostsOfThread::SortBy-{0}:onlyLandlord-{1}", (int)sortBy, onlyStarter);
            return(cacheKey.ToString());
        }
 public string ThreadDetail(long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1, long? anchorPostId = null, bool isAnchorPostList = false, long? childPostIndex = null)
 {
     BarThread thread = new BarThreadService().Get(threadId);
     if (thread == null)
         return string.Empty;
     string spaceKey = TopicIdToTopicKeyDictionary.GetTopicKey(thread.SectionId);
     if (string.IsNullOrEmpty(spaceKey))
         return string.Empty;
     return SiteUrls.Instance().TopicThreadDetail(spaceKey, threadId, onlyLandlord, sortBy, pageIndex, anchorPostId, isAnchorPostList, childPostIndex);
 }
Пример #4
0
        /// <summary>
        /// 获取子级回帖列表
        /// </summary>
        /// <param name="parentId">父回帖Id</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="sortBy">排序字段</param>
        /// <returns></returns>
        public PagingDataSet <BarPost> GetChildren(long parentId, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1)
        {
            //排序:Id正序
            //缓存分区:ParentId
            //仅显示可公开对外显示的 PubliclyAuditStatus



            return(barPostRepository.GetChildren(parentId, pageIndex, sortBy));
        }
Пример #5
0
        /// <summary>
        /// 获取主题帖的回帖排行分页集合
        /// </summary>
        /// <param name="threadId">主题帖Id</param>
        /// <param name="onlyStarter">仅看楼主</param>
        /// <param name="sortBy">回帖排序依据(默认为按创建时间正序排序)</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>回复贴列表</returns>
        public PagingDataSet <BarPost> Gets(long threadId, bool onlyStarter = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1)
        {
            BarThread thread    = new BarThreadService().Get(threadId);
            long      starterId = 0;

            if (thread != null)
            {
                starterId = thread.UserId;
            }

            return(barPostRepository.Gets(threadId, onlyStarter, starterId, sortBy, pageIndex));
        }
        public ActionResult Detail(string spaceKey, long threadId, int pageIndex = 1, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, long? postId = null, long? childPostIndex = null)
        {
            BarThread barThread = barThreadService.Get(threadId);
            if (barThread == null)
                return HttpNotFound();

            TopicEntity topic = topicService.Get(spaceKey);
            if (topic == null)
                return HttpNotFound();
            BarSection section = barSectionService.Get(barThread.SectionId);
            if (section == null || section.TenantTypeId != TenantTypeIds.Instance().Topic())
                return HttpNotFound();

            //验证是否通过审核
            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);
            if (!authorizer.IsAdministrator(BarConfig.Instance().ApplicationId) && barThread.UserId != currentSpaceUserId
                && (int)barThread.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(BarConfig.Instance().ApplicationId)))
                return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前帖子尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                }));


            pageResourceManager.InsertTitlePart(section.Name);
            pageResourceManager.InsertTitlePart(barThread.Subject);

            Category category = categoryService.Get(barThread.CategoryId ?? 0);
            string keyWords = string.Join(",", barThread.TagNames);

            pageResourceManager.SetMetaOfKeywords(category != null ? category.CategoryName + "," + keyWords : keyWords);//设置Keyords类型的Meta
            pageResourceManager.SetMetaOfDescription(HtmlUtility.TrimHtml(barThread.GetResolvedBody(), 120));//设置Description类型的Meta

            ViewData["EnableRating"] = barSettings.EnableRating;

            //更新浏览计数
            CountService countService = new CountService(TenantTypeIds.Instance().BarThread());
            countService.ChangeCount(CountTypes.Instance().HitTimes(), barThread.ThreadId, barThread.UserId, 1, false);

            PagingDataSet<BarPost> barPosts = barPostService.Gets(threadId, onlyLandlord, sortBy, pageIndex);
            if (pageIndex > barPosts.PageCount && pageIndex > 1)
                return Detail(spaceKey, threadId, barPosts.PageCount);
            if (Request.IsAjaxRequest())
                return PartialView("~/Applications/Bar/Views/Bar/_ListPost.cshtml", barPosts);

            ViewData["barThread"] = barThread;
            ViewData["topic"] = topic;
            return View(barPosts);
        }
Пример #7
0
        public string ThreadDetail(long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1, long?anchorPostId = null, bool isAnchorPostList = false, long?childPostIndex = null)
        {
            BarThread thread = new BarThreadService().Get(threadId);

            if (thread == null)
            {
                return(string.Empty);
            }
            string spaceKey = GroupIdToGroupKeyDictionary.GetGroupKey(thread.SectionId);

            if (string.IsNullOrEmpty(spaceKey))
            {
                return(string.Empty);
            }
            return(SiteUrls.Instance().GroupThreadDetail(spaceKey, threadId, onlyLandlord, sortBy, pageIndex, anchorPostId, isAnchorPostList, childPostIndex));
        }
Пример #8
0
        /// <summary>
        /// 获取子级回帖列表
        /// </summary>
        /// <param name="parentId">父回帖Id</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="sortBy">排序字段</param>
        /// <returns></returns>
        public PagingDataSet <BarPost> GetChildren(long parentId, int pageIndex, SortBy_BarPost sortBy)
        {
            return(GetPagingEntities(childrenPageSize, pageIndex, CachingExpirationType.ObjectCollection,
                                     () =>
            {
                return GetCacheKey_GetChildren(sortBy, parentId);
            },
                                     () =>
            {
                var sql = Sql.Builder;
                sql.Select("*")
                .From("spb_BarPosts")
                .Where("ParentId = @0", parentId);

                switch (this.PubliclyAuditStatus)
                {
                case PubliclyAuditStatus.Again:
                case PubliclyAuditStatus.Fail:
                case PubliclyAuditStatus.Pending:
                case PubliclyAuditStatus.Success:
                    sql.Where("AuditStatus=@0", this.PubliclyAuditStatus);
                    break;

                case PubliclyAuditStatus.Again_GreaterThanOrEqual:
                case PubliclyAuditStatus.Pending_GreaterThanOrEqual:
                    sql.Where("AuditStatus>@0", this.PubliclyAuditStatus);
                    break;

                default:
                    break;
                }
                if (sortBy == SortBy_BarPost.DateCreated_Desc)
                {
                    sql.OrderBy("PostId desc");
                }
                return sql;
            }));
        }
Пример #9
0
        /// <summary>
        /// 获取主题帖的回帖列表的sql语句
        /// </summary>
        /// <param name="threadId">主题帖Id</param>
        /// <param name="sortBy">回帖排序依据(默认为按创建时间正序排序)</param>
        /// <param name="onlyStarter">仅看楼主</param>
        /// <param name="starterId">楼主Id</param>
        /// <returns></returns>
        private Sql GetSql_Posts(long threadId, bool onlyStarter, long starterId, SortBy_BarPost sortBy)
        {
            var sql = Sql.Builder;

            sql.Select("*")
            .From("spb_BarPosts")
            .Where("ParentId = 0")
            .Where("ThreadId = @0", threadId);

            if (onlyStarter)
            {
                sql.Where("UserId = @0", starterId);
            }

            switch (this.PubliclyAuditStatus)
            {
            case PubliclyAuditStatus.Again:
            case PubliclyAuditStatus.Fail:
            case PubliclyAuditStatus.Pending:
            case PubliclyAuditStatus.Success:
                sql.Where("AuditStatus=@0", this.PubliclyAuditStatus);
                break;

            case PubliclyAuditStatus.Again_GreaterThanOrEqual:
            case PubliclyAuditStatus.Pending_GreaterThanOrEqual:
                sql.Where("AuditStatus>@0", this.PubliclyAuditStatus);
                break;

            default:
                break;
            }
            if (sortBy == SortBy_BarPost.DateCreated_Desc)
            {
                sql.OrderBy("PostId desc");
            }
            return(sql);
        }
Пример #10
0
        public ActionResult Detail(string spaceKey, long threadId, int pageIndex = 1, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, long?postId = null, long?childPostIndex = null)
        {
            BarThread barThread = barThreadService.Get(threadId);

            if (barThread == null)
            {
                return(HttpNotFound());
            }

            GroupEntity group = groupService.Get(spaceKey);

            if (group == null)
            {
                return(HttpNotFound());
            }
            BarSection section = barSectionService.Get(barThread.SectionId);

            if (section == null || section.TenantTypeId != TenantTypeIds.Instance().Group())
            {
                return(HttpNotFound());
            }

            //验证是否通过审核
            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (!authorizer.IsAdministrator(BarConfig.Instance().ApplicationId) && barThread.UserId != currentSpaceUserId &&
                (int)barThread.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(BarConfig.Instance().ApplicationId)))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前帖子尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }


            pageResourceManager.InsertTitlePart(section.Name);
            pageResourceManager.InsertTitlePart(barThread.Subject);

            Category category = categoryService.Get(barThread.CategoryId ?? 0);
            string   keyWords = string.Join(",", barThread.TagNames);

            pageResourceManager.SetMetaOfKeywords(category != null ? category.CategoryName + "," + keyWords : keyWords); //设置Keyords类型的Meta
            pageResourceManager.SetMetaOfDescription(HtmlUtility.TrimHtml(barThread.GetResolvedBody(), 120));            //设置Description类型的Meta

            ViewData["EnableRating"] = barSettings.EnableRating;

            //更新浏览计数
            CountService countService = new CountService(TenantTypeIds.Instance().BarThread());

            countService.ChangeCount(CountTypes.Instance().HitTimes(), barThread.ThreadId, barThread.UserId, 1, false);

            PagingDataSet <BarPost> barPosts = barPostService.Gets(threadId, onlyLandlord, sortBy, pageIndex);

            if (pageIndex > barPosts.PageCount && pageIndex > 1)
            {
                return(Detail(spaceKey, threadId, barPosts.PageCount));
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("~/Applications/Bar/Views/Bar/_ListPost.cshtml", barPosts));
            }

            ViewData["barThread"] = barThread;
            ViewData["group"]     = group;
            return(View(barPosts));
        }
        public ActionResult ThreadDetail(long threadId, int pageIndex = 1, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, long? postId = null, long? childPostIndex = null)
        {
            BarThread barThread = barThreadService.Get(threadId);
            if (barThread == null)
                return HttpNotFound();

            BarSection section = barSectionService.Get(barThread.SectionId);
            if (!authorizer.BarSection_View(section))
                return Redirect(SiteUrls.Instance().SystemMessage(TempData, SystemMessageViewModel.NoCompetence()));

            pageResourceManager.InsertTitlePart(section.Name);
            pageResourceManager.InsertTitlePart(barThread.Subject);



            Category category = categoryService.Get(barThread.CategoryId ?? 0);
            string keyWords = string.Join(",", barThread.TagNames);

            pageResourceManager.SetMetaOfKeywords(category != null ? category.CategoryName + "," + keyWords : keyWords);//设置Keyords类型的Meta
            pageResourceManager.SetMetaOfDescription(HtmlUtility.TrimHtml(barThread.GetResolvedBody(), 120));//设置Description类型的Meta



            ViewData["EnableRating"] = barSettings.EnableRating;

            //更新浏览计数
            CountService countService = new CountService(TenantTypeIds.Instance().BarThread());
            countService.ChangeCount(CountTypes.Instance().HitTimes(), barThread.ThreadId, barThread.UserId, 1, false);





            PagingDataSet<BarPost> barPosts = barPostService.Gets(threadId, onlyLandlord, sortBy, pageIndex);
            if (pageIndex > barPosts.PageCount && pageIndex > 1)
                return ThreadDetail(threadId, barPosts.PageCount);




            if (Request.IsAjaxRequest())
                return PartialView("_ListPost", barPosts);


            ViewData["barThread"] = barThread;






            return View(barPosts);
        }
Пример #12
0
 /// <summary>
 /// 帖子的详细显示页
 /// </summary>
 /// <param name="siteUrls"></param>
 /// <param name="threadId">帖子的id</param>
 /// <param name="pageIndex">回复内容的id</param>
 /// <param name="onlyLandlord">是否只看楼主</param>
 /// <param name="sortBy">回帖的排序方式</param>
 /// <param name="anchorPostId">回帖Id锚点</param>
 /// <param name="isAnchorPostList">是否定位到回帖列表</param>
 /// <param name="childPostIndex">自己回复的列表页码</param>
 /// <returns>帖子的详细显示链接</returns>
 public static string ThreadDetail(this SiteUrls siteUrls, long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int? pageIndex = 1, long? anchorPostId = null, bool isAnchorPostList = false, long? childPostIndex = null)
 {
     RouteValueDictionary routeValueDictionary = new RouteValueDictionary();
     routeValueDictionary.Add("threadId", threadId);
     if (pageIndex.HasValue && pageIndex != 1)
         routeValueDictionary.Add("pageIndex", pageIndex);
     if (onlyLandlord)
         routeValueDictionary.Add("onlyLandlord", onlyLandlord);
     if (sortBy == SortBy_BarPost.DateCreated_Desc)
         routeValueDictionary.Add("sortBy", sortBy);
     string anchor = string.Empty;
     if (childPostIndex.HasValue && childPostIndex > 1)
     {
         BarPost post = new BarPostService().Get(anchorPostId ?? 0);
         if (post.ParentId > 0)
             routeValueDictionary.Add("postId", post.ParentId);
         else
             routeValueDictionary.Add("postId", anchorPostId);
         routeValueDictionary.Add("childPostIndex", childPostIndex);
     }
     if (anchorPostId.HasValue && anchorPostId.Value > 0)
         anchor = "#" + anchorPostId;
     else if (isAnchorPostList == true)
         anchor = "#reply";
     return CachedUrlHelper.RouteUrl("Channel_Bar_ThreadDetail", routeValueDictionary) + anchor;
 }
Пример #13
0
 /// <summary>
 /// 获取主题帖的回帖排行分页集合
 /// </summary>
 /// <param name="threadId">主题帖Id</param>
 /// <param name="sortBy">回帖排序依据(默认为按创建时间正序排序)</param>
 /// <param name="onlyStarter">仅看楼主</param>
 /// <param name="starterId">楼主Id</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>回复贴列表</returns>
 public PagingDataSet <BarPost> Gets(long threadId, bool onlyStarter, long starterId, SortBy_BarPost sortBy, int pageIndex)
 {
     //只获取可对外显示审核状态的回复贴
     //缓存周期:对象集合,需要维护即时性
     //排序:发布时间(倒序)
     return(GetPagingEntities(pageSize, pageIndex, CachingExpirationType.ObjectCollection,
                              () =>
     {
         return GetCacheKey_PostIdsOfThread(threadId, onlyStarter, sortBy);
     },
                              () =>
     {
         return GetSql_Posts(threadId, onlyStarter, starterId, sortBy);
     }));
 }
Пример #14
0
 /// <summary>
 /// 获取子级回帖列表
 /// </summary>
 /// <param name="parentId">父回帖Id</param>
 /// <param name="pageIndex">当前页码</param>
 /// <param name="sortBy">排序字段</param>
 /// <returns></returns>
 public PagingDataSet <BarPost> GetChildrenForMobile(long parentId, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1)
 {
     return(barPostRepository.GetChildrenForMobile(parentId, pageIndex, sortBy));
 }
Пример #15
0
 /// <summary>
 /// ������ϸ��ʾҳ��
 /// </summary>
 /// <param name="threadId">����id</param>
 /// <param name="onlyLandlord">ֻ��¥��</param>
 /// <param name="sortBy">����ʽ</param>
 /// <param name="pageIndex">ҳ��</param>
 /// <returns>������ϸ��ʾҳ��</returns>
 public string ThreadDetail(long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1, long? anchorPostId = null, bool isAnchorPostList = false, long? childPostIndex = null)
 {
     return SiteUrls.Instance().ThreadDetail(threadId, onlyLandlord, sortBy, pageIndex, anchorPostId, isAnchorPostList, childPostIndex);
 }
Пример #16
0
        /// <summary>
        /// 获取子级回帖列表
        /// </summary>
        /// <param name="parentId">父回帖Id</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="sortBy">排序字段</param>
        /// <returns></returns>
        public PagingDataSet <BarPost> GetChildrenForMobile(long parentId, int pageIndex, SortBy_BarPost sortBy)
        {
            var sql = Sql.Builder;

            sql.Select("*")
            .From("spb_BarPosts")
            .Where("ParentId = @0", parentId);
            if (sortBy == SortBy_BarPost.DateCreated_Desc)
            {
                sql.OrderBy("PostId desc");
            }
            return(GetPagingEntities(100, pageIndex, sql));
        }
Пример #17
0
 /// <summary>
 /// 帖子详细显示页面
 /// </summary>
 /// <param name="threadId">帖子id</param>
 /// <param name="onlyLandlord">只看楼主</param>
 /// <param name="sortBy">排序方式</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>帖子详细显示页面</returns>
 public string ThreadDetail(long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1, long?anchorPostId = null, bool isAnchorPostList = false, long?childPostIndex = null)
 {
     return(SiteUrls.Instance().ThreadDetail(threadId, onlyLandlord, sortBy, pageIndex, anchorPostId, isAnchorPostList, childPostIndex));
 }