Esempio n. 1
0
        /// <summary>
        /// 重建索引
        /// </summary>
        public void RebuildIndex()
        {   //pageSize参数决定了每次批量取多少条数据进行索引。要注意的是,如果是分布式搜索,客户端会将这部分数据通过WCF传递给服务器端,而WCF默认的最大传输数据量是65535B,pageSize较大时这个设置显然是不够用的,WCF会报400错误;系统现在将最大传输量放宽了,但仍要注意一次不要传输过多,如遇异常,可适当调小pageSize的值
            int            pageSize     = 1000;
            int            pageIndex    = 1;
            long           totalRecords = 0;
            bool           isBeginning  = true;
            bool           isEndding    = false;
            MicroblogQuery query        = new MicroblogQuery();

            do
            {
                //分页获取微博列表
                PagingDataSet <MicroblogEntity> microblogs = microBlogService.GetMicroblogs(query, pageSize, pageIndex);
                totalRecords = microblogs.TotalRecords;

                isEndding = (pageSize * pageIndex < totalRecords) ? false : true;

                //重建索引
                List <MicroblogEntity> microblogsList = microblogs.ToList <MicroblogEntity>();

                IEnumerable <Document> docs = MicroblogIndexDocument.Convert(microblogsList);

                searchEngine.RebuildIndex(docs, isBeginning, isEndding);

                isBeginning = false;
                pageIndex++;
            }while (!isEndding);
        }
Esempio n. 2
0
        public ActionResult ListFavorites(string spaceKey, int?pageIndex)
        {
            pageResourceManager.InsertTitlePart("我的收藏");

            long userId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            PagingDataSet <long>            pdsObjectIds = favoriteService.GetPagingObjectIds(userId, pageIndex ?? 1);
            IEnumerable <MicroblogEntity>   microblogs   = microblogService.GetMicroblogs(pdsObjectIds);
            PagingDataSet <MicroblogEntity> pds          = new PagingDataSet <MicroblogEntity>(microblogs)
            {
                TotalRecords  = pdsObjectIds.TotalRecords - (microblogs.Count()),
                PageSize      = pdsObjectIds.PageSize,
                PageIndex     = pdsObjectIds.PageIndex,
                QueryDuration = pdsObjectIds.QueryDuration
            };

            return(View(pds));
        }
        public ActionResult ManageMicroblogs(int pageIndex = 1, string userId = null, string keyword = null, MediaType?mediaType = null, AuditStatus?auditStatus = null, DateTime?startdate = null, DateTime?enddate = null, int pageSize = 20, string tenantTypeId = null, long?ownerId = null)
        {
            pageResourceManager.InsertTitlePart("微博管理");

            #region 组装搜索条件
            MicroblogQuery query = new MicroblogQuery();

            long?id = null;
            if (!string.IsNullOrEmpty(userId))
            {
                userId = userId.TrimStart(',').TrimEnd(',');
                if (!string.IsNullOrEmpty(userId))
                {
                    id = long.Parse(userId);
                }
            }
            query.OwnerId      = ownerId;
            query.Keyword      = keyword;
            query.UserId       = id;
            query.MediaType    = mediaType;
            query.AuditStatus  = auditStatus;
            query.TenantTypeId = tenantTypeId;
            if (startdate != DateTime.MinValue)
            {
                query.StartDate = startdate;
            }

            if (enddate != DateTime.MinValue && enddate.HasValue)
            {
                query.EndDate = enddate.Value.AddDays(1);
            }

            #endregion

            ViewData["userId"] = id;
            PagingDataSet <MicroblogEntity> microblogs = microblogService.GetMicroblogs(query, pageSize, pageIndex);
            if (tenantTypeId == null)
            {
                tenantTypeId = TenantTypeIds.Instance().User();
            }
            ViewData["tenantTypeId"] = tenantTypeId;
            return(View(microblogs));
        }