public ActionResult ManageSearchedTerms(int? pageIndex = 1, int pageSize = 20) { CountService countService = new CountService(TenantTypeIds.Instance().Search()); StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Search()); IEnumerable<ISearcher> searchers = SearcherFactory.GetDisplaySearchers(); #region 搜索条件 int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().SearchCount()); string countTypeNday = countService.GetStageCountType(CountTypes.Instance().SearchCount(), stageCountDays); string countTypeAll = CountTypes.Instance().SearchCount(); pageResourceManager.InsertTitlePart("管理搜索热词"); string term = Request.QueryString.GetString("term", string.Empty).Trim(); bool isRealtime = false; DateTime? startDate = null; DateTime? endDate = null; if (Request.QueryString.Get<DateTime>("startdate") != DateTime.MinValue) startDate = Request.QueryString.Get<DateTime>("startDate"); if (Request.QueryString.Get<DateTime>("enddate") != DateTime.MinValue) endDate = Request.QueryString.Get<DateTime>("endDate"); if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value) { DateTime? changDate = startDate; startDate = endDate; endDate = changDate; } if (endDate.HasValue) endDate = endDate.Value; #endregion #region 下拉列表 string searchTypeCode = Request.QueryString.GetString("searchTypeCode", string.Empty); Dictionary<string, string> searchTypeDic = new Dictionary<string, string>(); searchTypeDic[SearcherFactory.GlobalSearchCode] = SearcherFactory.GlobalSearchName; foreach (var searcher in searchers) { searchTypeDic[searcher.Code] = searcher.Name; } SelectList selectList = new SelectList(searchTypeDic.Select(n => new { text = n.Value, value = n.Key }), "value", "text", searchTypeCode); ViewData["searchTypeCode"] = selectList; #endregion if (string.IsNullOrEmpty(searchTypeCode)) { isRealtime = true; } ViewData["searchTypeDic"] = searchTypeDic; #region Count IEnumerable<SearchedTerm> manuals = null; if (pageIndex == 1) manuals = termService.GetManuals(searchTypeCode); Dictionary<long, int> countTypeNdayDic = new Dictionary<long, int>(); Dictionary<long, int> countTypeAllDic = new Dictionary<long, int>(); if (manuals != null) { if (!string.IsNullOrEmpty(term)) manuals = manuals.Where(n => Regex.IsMatch(n.Term, "^" + term.Trim())); if (!string.IsNullOrEmpty(searchTypeCode)) manuals = manuals.Where(n => n.SearchTypeCode == searchTypeCode); if (startDate != null) manuals = manuals.Where(n => n.DateCreated >= startDate); if (endDate != null) manuals = manuals.Where(n => n.DateCreated <= endDate); foreach (var item in manuals) { countTypeNdayDic[item.Id] = countService.Get(countTypeNday, item.Id); countTypeAllDic[item.Id] = countService.Get(countTypeAll, item.Id); } } ViewData["manuals"] = manuals; PagingDataSet<SearchedTerm> searchedTerms = termService.Gets(searchTypeCode, term, startDate, endDate, isRealtime, pageSize, pageIndex ?? 1); foreach (var item in searchedTerms) { countTypeNdayDic[item.Id] = countService.Get(countTypeNday, item.Id); countTypeAllDic[item.Id] = countService.Get(countTypeAll, item.Id); } ViewData["countTypeNdayDic"] = countTypeNdayDic; ViewData["countTypeAllDic"] = countTypeAllDic; #endregion return View(searchedTerms); }
/// <summary> /// 用户状态菜单控件 /// </summary> /// <param name="spaceKey">空间标识</param> public ActionResult _UserStatus(string spaceKey) { User user = userService.GetUser(spaceKey) as User; CountService countService = new CountService(TenantTypeIds.Instance().User()); int countPerDay = countService.GetStageCount(CountTypes.Instance().HitTimes(), 7, user.UserId); int countAll = countService.Get(CountTypes.Instance().HitTimes(), user.UserId); ViewData["accessedCount"] = countPerDay + "/" + countAll; VisitService visitService = new VisitService(TenantTypeIds.Instance().User()); IEnumerable<Visit> visits = visitService.GetTopMyVisits(user.UserId, 1); if (visits != null && visits.FirstOrDefault() != null) { ViewData["lastVisitDate"] = visits.FirstOrDefault().LastVisitTime.ToFriendlyDate(); } return View(user); }
public ActionResult PrivacyHome(string spaceKey) { IUser currentUser = UserContext.CurrentUser; if (UserContext.CurrentUser == null) return Redirect(SiteUrls.Instance().Login(true)); pageResourceManager.InsertTitlePart("无权访问"); long userId = UserIdToUserNameDictionary.GetUserId(spaceKey); ViewData["followedUsers"] = followService.GetTopFollowedUserIds(userId, 30).ToDictionary(n => n, m => userService.GetFullUser(m) == null ? UserIdToUserNameDictionary.GetUserName(m) : userService.GetFullUser(m).DisplayName); ViewData["followerUsers"] = followService.GetFollowerUserIds(userId, Follow_SortBy.LastContent_Desc, 1).ToDictionary(n => n, m => userService.GetFullUser(m) == null ? UserIdToUserNameDictionary.GetUserName(m) : userService.GetFullUser(m).DisplayName); User user = userService.GetFullUser(spaceKey); if (user == null) return HttpNotFound(); CountService countService = new CountService(TenantTypeIds.Instance().User()); int countStageDay = countService.GetStageCount(CountTypes.Instance().HitTimes(), 7, user.UserId); int countAll = countService.Get(CountTypes.Instance().HitTimes(), user.UserId); ViewData["accessedCount"] = countStageDay + "/" + countAll; ViewData["user"] = user; bool seeFollow = false; if (privacyService.Validate(user.UserId, currentUser != null ? currentUser.UserId : 0, PrivacyItemKeys.Instance().InviteFollow())) { seeFollow = true; } ViewData["seeFollow"] = seeFollow; return View(); }