/// <summary> /// 日志搜索 /// </summary> public ActionResult Search(JournalFullTextQuery query) { query.Keyword = WebUtility.UrlDecode(query.Keyword); query.PageSize = 10;//每页记录数 //调用搜索器进行搜索 JournalSearcher journalSearcher = (JournalSearcher)SearcherFactory.GetSearcher(JournalSearcher.CODE); PagingDataSet<Journal> journals = journalSearcher.Search(query); //添加到用户搜索历史 IUser CurrentUser = UserContext.CurrentUser; if (CurrentUser != null) { if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchHistoryService searchHistoryService = new SearchHistoryService(); searchHistoryService.SearchTerm(CurrentUser.UserId, JournalSearcher.CODE, query.Keyword); } } //添加到热词 if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchedTermService searchedTermService = new SearchedTermService(); searchedTermService.SearchTerm(JournalSearcher.CODE, query.Keyword); } //获取站点分类,并设置站点分类的选中项 IEnumerable<Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().Journals()); 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(journals); }
/// <summary> /// 群组搜索 /// </summary> public ActionResult Search(GroupFullTextQuery query) { query.Keyword = WebUtility.UrlDecode(query.Keyword); query.PageSize = 20;//每页记录数 //调用搜索器进行搜索 GroupSearcher groupSearcher = (GroupSearcher)SearcherFactory.GetSearcher(GroupSearcher.CODE); PagingDataSet<GroupEntity> groups = groupSearcher.Search(query); //添加到用户搜索历史 IUser CurrentUser = UserContext.CurrentUser; if (CurrentUser != null) { if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchHistoryService searchHistoryService = new SearchHistoryService(); searchHistoryService.SearchTerm(CurrentUser.UserId, GroupSearcher.CODE, query.Keyword); } } //添加到热词 if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchedTermService searchedTermService = new SearchedTermService(); searchedTermService.SearchTerm(GroupSearcher.CODE, query.Keyword); } //设置页面Meta if (string.IsNullOrWhiteSpace(query.Keyword)) { pageResourceManager.InsertTitlePart("群组搜索");//设置页面Title } else { pageResourceManager.InsertTitlePart('“' + query.Keyword + '”' + "的相关群组");//设置页面Title } return View(groups); }
/// <summary> /// 帖吧搜索 /// </summary> /// <param name="query"></param> /// <returns></returns> public ActionResult Search(BarFullTextQuery query) { query.Keyword = WebUtility.UrlDecode(query.Keyword); query.PageSize = 20;//每页记录数 //默认搜公共贴吧(非群组)的帖子 query.TenantTypeId = TenantTypeIds.Instance().Bar(); //根据帖吧id查询帖吧名字 string barId = Request.QueryString["barId"]; if (barId != "" && barId != null) { long id = 0; if (long.TryParse(barId, out id)) { BarSection section = barSectionService.Get(id); if (section != null) { query.TenantTypeId = section.TenantTypeId; ViewData["barname"] = section.Name; ViewData["TenantTypeId"] = section.TenantTypeId; } } } //调用搜索器进行搜索 BarSearcher BarSearcher = (BarSearcher)SearcherFactory.GetSearcher(BarSearcher.CODE); PagingDataSet<BarEntity> BarEntities = BarSearcher.Search(query); //添加到用户搜索历史 IUser CurrentUser = UserContext.CurrentUser; if (CurrentUser != null) { SearchHistoryService searchHistoryService = new SearchHistoryService(); searchHistoryService.SearchTerm(CurrentUser.UserId, BarSearcher.CODE, query.Keyword); } //添加到热词 if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchedTermService searchedTermService = new SearchedTermService(); searchedTermService.SearchTerm(BarSearcher.CODE, query.Keyword); } //设置页面Meta if (string.IsNullOrWhiteSpace(query.Keyword)) { pageResourceManager.InsertTitlePart("帖吧搜索");//设置页面Title } else { pageResourceManager.InsertTitlePart('“' + query.Keyword + '”' + "的相关帖吧");//设置页面Title } pageResourceManager.SetMetaOfKeywords("帖吧搜索");//设置Keyords类型的Meta pageResourceManager.SetMetaOfDescription("帖吧搜索");//设置Description类型的Meta if (Request.IsAjaxRequest()) return View("_ListSearchThread", BarEntities); return View(BarEntities); }
public ActionResult UserSearch(UserFullTextQuery query) { query.PageSize = 20;//每页记录数 //调用搜索器进行搜索 UserSearcher userSearcher = (UserSearcher)SearcherFactory.GetSearcher(UserSearcher.CODE); PagingDataSet<User> users = userSearcher.Search(query); IUser CurrentUser = UserContext.CurrentUser; //添加到用户搜索历史 if (CurrentUser != null) { SearchHistoryService searchHistoryService = new SearchHistoryService(); searchHistoryService.SearchTerm(CurrentUser.UserId, UserSearcher.CODE, query.Keyword); } //添加到热词 if (!string.IsNullOrEmpty(query.Keyword)) { SearchedTermService searchedTermService = new SearchedTermService(); searchedTermService.SearchTerm(UserSearcher.CODE, query.Keyword); } //设置页面Meta if (string.IsNullOrWhiteSpace(query.Keyword)) { pageResourceManager.InsertTitlePart("用户搜索");//设置页面Title } else { pageResourceManager.InsertTitlePart('“' + query.Keyword + '”' + "的相关用户");//设置页面Title } pageResourceManager.SetMetaOfKeywords("用户搜索");//设置Keyords类型的Meta pageResourceManager.SetMetaOfDescription("用户搜索");//设置Description类型的Meta return View(users); }
/// <summary> /// 全局搜索页面 /// </summary> /// <returns></returns> public ActionResult GlobalSearch(string keyword) { keyword = WebUtility.UrlDecode(keyword); //查询用于自动完成·的搜索器 IEnumerable<ISearcher> searchersAutoComplete = SearcherFactory.GetQuickSearchers(4); ViewData["searchersAutoComplete"] = searchersAutoComplete; ViewData["keyword"] = keyword; //添加到用户搜索历史 IUser CurrentUser = UserContext.CurrentUser; if (CurrentUser != null) { SearchHistoryService searchHistoryService = new SearchHistoryService(); searchHistoryService.SearchTerm(CurrentUser.UserId, SearcherFactory.GlobalSearchCode, keyword); } //添加到热词 if (!string.IsNullOrEmpty(keyword)) { SearchedTermService searchedTermService = new SearchedTermService(); searchedTermService.SearchTerm(SearcherFactory.GlobalSearchCode, keyword); } //设置页面Meta if (string.IsNullOrWhiteSpace(keyword)) { pageResourceManager.InsertTitlePart("全局搜索");//设置页面Title } else { pageResourceManager.InsertTitlePart('“' + keyword + '”' + "的相关搜索");//设置页面Title } //查询所有搜索器 IEnumerable<ISearcher> searchers = SearcherFactory.GetDisplaySearchers(); pageResourceManager.SetMetaOfKeywords("全局搜索");//设置Keyords类型的Meta pageResourceManager.SetMetaOfDescription("全局搜索");//设置Description类型的Meta return View(searchers); }
/// <summary> /// 资讯搜索 /// </summary> public ActionResult Search(CmsFullTextQuery query) { query.Keyword = WebUtility.UrlDecode(query.Keyword); query.PageSize = 20;//每页记录数 //调用搜索器进行搜索 CmsSearcher cmsSearcher = (CmsSearcher)SearcherFactory.GetSearcher(CmsSearcher.CODE); PagingDataSet<ContentItem> contentItems = cmsSearcher.Search(query); //添加到用户搜索历史 IUser CurrentUser = UserContext.CurrentUser; if (CurrentUser != null) { if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchHistoryService searchHistoryService = new SearchHistoryService(); searchHistoryService.SearchTerm(CurrentUser.UserId, CmsSearcher.CODE, query.Keyword); } } //添加到热词 if (!string.IsNullOrWhiteSpace(query.Keyword)) { SearchedTermService searchedTermService = new SearchedTermService(); searchedTermService.SearchTerm(CmsSearcher.CODE, query.Keyword); } //设置页面Meta if (string.IsNullOrWhiteSpace(query.Keyword)) { pageResourceManager.InsertTitlePart("资讯搜索");//设置页面Title } else { pageResourceManager.InsertTitlePart(query.Keyword + "的相关资讯");//设置页面Title } return View(contentItems); }