Ejemplo n.º 1
0
        public ActionResult ManagePosts(ManagePostsEditModel model, int pageIndex = 1, string tenantTypeId = null)
        {
            if (string.IsNullOrEmpty(tenantTypeId))
            {
                tenantTypeId = TenantTypeIds.Instance().Bar();
            }

            ViewData["TenantType"] = tenantTypeService.Get(tenantTypeId);

            pageResourceManager.InsertTitlePart("回帖管理");



            ViewData["BarPosts"] = barPostService.Gets(tenantTypeId, model.AsBarPostQuery(), model.PageSize ?? 20, pageIndex);
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult _CreateBarThread(long ActivityId)
        {
            Activity activity = activityService.Get(ActivityId);

            if (activity == null)
            {
                return(Content(string.Empty));
            }
            BarThread thread = barThreadService.Get(activity.SourceId);

            if (thread == null)
            {
                return(Content(string.Empty));
            }
            PagingDataSet <BarPost> barPosts = barPostService.Gets(thread.ThreadId, false, SortBy_BarPost.DateCreated_Desc);


            ViewData["BarPosts"] = barPosts.Take(3);
            IEnumerable <Attachment> attachments = attachementService.GetsByAssociateId(thread.ThreadId);

            if (attachments != null && attachments.Count() > 0)
            {
                IEnumerable <Attachment> attachmentImages = attachments.Where(n => n.MediaType == MediaType.Image);
                if (attachmentImages != null && attachmentImages.Count() > 0)
                {
                    ViewData["Attachments"] = attachmentImages;
                }
            }
            ViewData["ActivityId"] = ActivityId;
            if (thread.BarSection.TenantTypeId != TenantTypeIds.Instance().Bar())
            {
                var    tenantType     = new TenantTypeService().Get(thread.BarSection.TenantTypeId);
                string tenantTypeName = string.Empty;
                if (tenantType != null)
                {
                    tenantTypeName = tenantType.Name;
                }
                ViewData["tenantTypeName"] = tenantTypeName;
            }
            return(View(thread));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 重建索引
        /// </summary>
        public void RebuildIndex()
        {
            bool hasData = false;

            //pageSize参数决定了每次批量取多少条数据进行索引。要注意的是,如果是分布式搜索,客户端会将这部分数据通过WCF传递给服务器端,而WCF默认的最大传输数据量是65535B,pageSize较大时这个设置显然是不够用的,WCF会报400错误;系统现在将最大传输量放宽了,但仍要注意一次不要传输过多,如遇异常,可适当调小pageSize的值
            int            pageSizeBarThread     = 100;
            int            pageIndexBarThread    = 1;
            long           totalRecordsBarThread = 0;
            bool           isBeginningBarThread  = true;
            bool           isEnddingBarThread    = false;
            BarThreadQuery barThreadQuery        = new BarThreadQuery();

            do
            {
                //分页获取帖子列表
                PagingDataSet <BarThread> barThreads = barThreadService.Gets(null, barThreadQuery, pageSizeBarThread, pageIndexBarThread);
                totalRecordsBarThread = barThreads.TotalRecords;
                if (totalRecordsBarThread > 0)
                {
                    hasData = true;
                }
                isEnddingBarThread = (pageSizeBarThread * pageIndexBarThread < totalRecordsBarThread) ? false : true;

                //重建索引
                List <BarThread> barThreadList = barThreads.ToList <BarThread>();

                IEnumerable <Document> docs = BarIndexDocument.Convert(barThreadList);

                searchEngine.RebuildIndex(docs, isBeginningBarThread, false);

                isBeginningBarThread = false;
                pageIndexBarThread++;
            }while (!isEnddingBarThread);

            int          pageSizeBarPost     = 100;
            int          pageIndexBarPost    = 1;
            long         totalRecordsBarPost = 0;
            bool         isEnddingBarPost    = false;
            BarPostQuery barPostQuery        = new BarPostQuery();

            do
            {
                //分页获取帖子列表
                PagingDataSet <BarPost> barPosts = barPostService.Gets(null, barPostQuery, pageSizeBarPost, pageIndexBarPost);
                totalRecordsBarPost = barPosts.TotalRecords;
                if (totalRecordsBarPost > 0)
                {
                    hasData = true;
                }
                isEnddingBarPost = (pageSizeBarPost * pageIndexBarPost < totalRecordsBarPost) ? false : true;

                //重建索引
                List <BarPost> barPostList = barPosts.ToList <BarPost>();

                IEnumerable <Document> docs = BarIndexDocument.Convert(barPostList);

                searchEngine.RebuildIndex(docs, false, false);

                pageIndexBarPost++;
            }while (!isEnddingBarPost);

            if (hasData)
            {
                searchEngine.RebuildIndex(null, false, true);
            }
        }