public ActionResult ManagePosts(string spaceKey, ManagePostsEditModel model, int pageIndex = 1) { long sectionId = GroupIdToGroupKeyDictionary.GetGroupId(spaceKey); BarSection section = barSectionService.Get(sectionId); if (!new Authorizer().BarSection_Manage(section)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = "您可能没有权限编辑此帖吧" }))); } var group = groupService.Get(spaceKey); pageResourceManager.InsertTitlePart(group.GroupName); pageResourceManager.InsertTitlePart("回帖管理"); BarPostQuery query = model.AsBarPostQuery(); query.SectionId = section.SectionId; model.SectionId = section.SectionId; ViewData["BarPosts"] = barPostService.Gets(TenantTypeIds.Instance().Group(), query, model.PageSize ?? 20, pageIndex); return(View(model)); }
/// <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); } }