예제 #1
0
        public ActionResult _Related(string spaceKey, long threadId)
        {
            BlogThread blogThread = blogService.Get(threadId);

            //获取标题、标签、用户分类组成的关键字集合
            List <string>        keywords        = new List <string>();
            IEnumerable <string> subjectKeywords = blogThread.Keywords.Split(' ', ',', '.', '、', '|', '-', '\\', '/', ':', ':', ';', ';').AsEnumerable();

            if (subjectKeywords.Count() > 0)
            {
                keywords.AddRange(subjectKeywords);
            }
            keywords.AddRange(blogThread.TagNames);
            keywords.AddRange(blogThread.OwnerCategoryNames);

            //调用搜索器进行搜索10条相关日志
            BlogFullTextQuery query = new BlogFullTextQuery();

            query.PageSize        = 10;
            query.IsRelationBlog  = true;
            query.Keywords        = keywords;
            query.CurrentThreadId = threadId;
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet <BlogThread> blogThreads = blogSearcher.Search(query);

            return(View(blogThreads));
        }
예제 #2
0
        /// <summary>
        /// 日志全局搜索
        /// </summary>
        public ActionResult _GlobalSearch(BlogFullTextQuery query, int topNumber)
        {
            query.PageSize  = topNumber;//每页记录数
            query.PageIndex = 1;

            //调用搜索器进行搜索
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet <BlogThread> blogThreads = blogSearcher.Search(query);

            return(PartialView(blogThreads));
        }
예제 #3
0
        /// <summary>
        /// 日志快捷搜索
        /// </summary>
        public ActionResult _QuickSearch(BlogFullTextQuery query, int topNumber)
        {
            query.PageSize  = topNumber;//每页记录数
            query.PageIndex = 1;
            query.Range     = BlogSearchRange.SUBJECT;
            query.Keyword   = Server.UrlDecode(query.Keyword);

            //调用搜索器进行搜索
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet <BlogThread> blogThreads = blogSearcher.Search(query);

            return(PartialView(blogThreads));
        }
예제 #4
0
        /// <summary>
        /// 文章搜索
        /// </summary>
        public ActionResult Search(BlogFullTextQuery query)
        {
            query.Keyword  = WebUtility.UrlDecode(query.Keyword);
            query.PageSize = 20;//每页记录数

            //调用搜索器进行搜索
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet <BlogThread> blogThreads = blogSearcher.Search(query);

            //添加到用户搜索历史
            IUser CurrentUser = UserContext.CurrentUser;

            if (CurrentUser != null)
            {
                if (!string.IsNullOrWhiteSpace(query.Keyword))
                {
                    SearchHistoryService searchHistoryService = new SearchHistoryService();
                    searchHistoryService.SearchTerm(CurrentUser.UserId, BlogSearcher.CODE, query.Keyword);
                }
            }

            //添加到热词
            if (!string.IsNullOrWhiteSpace(query.Keyword))
            {
                SearchedTermService searchedTermService = new SearchedTermService();
                searchedTermService.SearchTerm(BlogSearcher.CODE, query.Keyword);
            }

            //获取站点分类,并设置站点分类的选中项
            IEnumerable <Category> siteCategories   = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread());
            SelectList             siteCategoryList = new SelectList(siteCategories.Select(n => new { text = n.CategoryName, value = n.CategoryId }), "value", "text", query.SiteCategoryId);

            ViewData["siteCategoryList"] = siteCategoryList;

            //设置页面Meta
            if (string.IsNullOrWhiteSpace(query.Keyword))
            {
                pageResourceManager.InsertTitlePart("文章搜索");//设置页面Title
            }
            else
            {
                pageResourceManager.InsertTitlePart(query.Keyword + "的相关文章");//设置页面Title
            }

            return(View(blogThreads));
        }
예제 #5
0
        public ActionResult _Related(string spaceKey, long threadId)
        {
            BlogThread blogThread = blogService.Get(threadId);

            //获取标题、标签、用户分类组成的关键字集合
            List<string> keywords = new List<string>();
            IEnumerable<string> subjectKeywords = blogThread.Keywords.Split(' ', ',', '.', '、', '|', '-', '\\', '/', ':', ':', ';', ';').AsEnumerable();
            if (subjectKeywords.Count() > 0)
            {
                keywords.AddRange(subjectKeywords);
            }
            keywords.AddRange(blogThread.TagNames);
            keywords.AddRange(blogThread.OwnerCategoryNames);

            //调用搜索器进行搜索10条相关文章
            BlogFullTextQuery query = new BlogFullTextQuery();
            query.PageSize = 10;
            query.IsRelationBlog = true;
            query.Keywords = keywords;
            query.CurrentThreadId = threadId;
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet<BlogThread> blogThreads = blogSearcher.Search(query);

            return View(blogThreads);
        }
예제 #6
0
        /// <summary>
        /// 日志快捷搜索
        /// </summary>
        public ActionResult _QuickSearch(BlogFullTextQuery query, int topNumber)
        {
            query.PageSize = topNumber;//每页记录数
            query.PageIndex = 1;
            query.Range = BlogSearchRange.SUBJECT;
            query.Keyword = Server.UrlDecode(query.Keyword);

            //调用搜索器进行搜索
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet<BlogThread> blogThreads = blogSearcher.Search(query);

            return PartialView(blogThreads);
        }
예제 #7
0
        /// <summary>
        /// 日志全局搜索
        /// </summary>
        public ActionResult _GlobalSearch(BlogFullTextQuery query, int topNumber)
        {
            query.PageSize = topNumber;//每页记录数
            query.PageIndex = 1;

            //调用搜索器进行搜索
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet<BlogThread> blogThreads = blogSearcher.Search(query);

            return PartialView(blogThreads);
        }
예제 #8
0
        /// <summary>
        /// 日志搜索
        /// </summary>
        public ActionResult Search(BlogFullTextQuery query)
        {
            query.Keyword = WebUtility.UrlDecode(query.Keyword);
            query.PageSize = 20;//每页记录数

            //调用搜索器进行搜索
            BlogSearcher blogSearcher = (BlogSearcher)SearcherFactory.GetSearcher(BlogSearcher.CODE);
            PagingDataSet<BlogThread> blogThreads = blogSearcher.Search(query);

            //添加到用户搜索历史
            IUser CurrentUser = UserContext.CurrentUser;
            if (CurrentUser != null)
            {
                if (!string.IsNullOrWhiteSpace(query.Keyword))
                {
                    SearchHistoryService searchHistoryService = new SearchHistoryService();
                    searchHistoryService.SearchTerm(CurrentUser.UserId, BlogSearcher.CODE, query.Keyword);
                }
            }

            //添加到热词
            if (!string.IsNullOrWhiteSpace(query.Keyword))
            {
                SearchedTermService searchedTermService = new SearchedTermService();
                searchedTermService.SearchTerm(BlogSearcher.CODE, query.Keyword);
            }

            //获取站点分类,并设置站点分类的选中项
            IEnumerable<Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread());
            SelectList siteCategoryList = new SelectList(siteCategories.Select(n => new { text = n.CategoryName, value = n.CategoryId }), "value", "text", query.SiteCategoryId);
            ViewData["siteCategoryList"] = siteCategoryList;

            //设置页面Meta
            if (string.IsNullOrWhiteSpace(query.Keyword))
            {
                pageResourceManager.InsertTitlePart("日志搜索");//设置页面Title
            }
            else
            {
                pageResourceManager.InsertTitlePart(query.Keyword + "的相关日志");//设置页面Title
            }

            return View(blogThreads);
        }