/// <summary> /// 资讯详情页 /// </summary> public ActionResult ContentItemDetail(long contentItemId) { ContentItem contentItem = contentItemService.Get(contentItemId); if (contentItem == null || contentItem.User == null) { return HttpNotFound(); } //验证是否通过审核 long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(contentItem.User.UserName); if (!authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId) && contentItem.UserId != currentSpaceUserId && (int)contentItem.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId))) return Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "尚未通过审核", Body = "由于当前资讯尚未通过审核,您无法浏览当前内容。", StatusMessageType = StatusMessageType.Hint })); AttachmentService<Attachment> attachmentService = new AttachmentService<Attachment>(TenantTypeIds.Instance().ContentItem()); //更新浏览计数 CountService countService = new CountService(TenantTypeIds.Instance().ContentItem()); countService.ChangeCount(CountTypes.Instance().HitTimes(), contentItem.ContentItemId, contentItem.UserId, 1, true); if (UserContext.CurrentUser != null) { //创建访客记录 VisitService visitService = new VisitService(TenantTypeIds.Instance().ContentItem()); visitService.CreateVisit(UserContext.CurrentUser.UserId, UserContext.CurrentUser.DisplayName, contentItem.ContentItemId, contentItem.Title); } //设置SEO信息 pageResourceManager.InsertTitlePart(contentItem.Title); List<string> keywords = new List<string>(); keywords.AddRange(contentItem.TagNames); string keyword = string.Join(" ", keywords.Distinct()); keyword += " " + string.Join(" ", ClauseScrubber.TitleToKeywords(contentItem.Title)); pageResourceManager.SetMetaOfKeywords(keyword); pageResourceManager.SetMetaOfDescription(contentItem.Summary); return View(contentItem); }
/// <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); }
private void DeleteUserEventMoudle_After(IUser sender, DeleteUserEventArgs eventArgs) { IUserService userService = DIContainer.Resolve<IUserService>(); #region 数据 //清除应用数据 applicationService.DeleteUser(sender.UserId, eventArgs.TakeOverUserName, eventArgs.TakeOverAll); //删除用户信息 new UserProfileService().Delete(sender.UserId); //清除用户内容计数数据 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); ownerDataService.ClearOwnerData(sender.UserId); //清除用户关于分类的数据 CategoryService categoryService = new CategoryService(); categoryService.CleanByUser(sender.UserId); //清除用户动态 ActivityService activityService = new ActivityService(); activityService.CleanByUser(sender.UserId); //清除用户评论 new CommentService().DeleteUserComments(sender.UserId, false); #endregion #region 消息 //清除用户关于私信的数据 MessageService messageService = new MessageService(); messageService.ClearSessionsFromUser(sender.UserId); //清除请求的用户数据 InvitationService invitationService = new InvitationService(); invitationService.CleanByUser(sender.UserId); //清除通知的用户数据 NoticeService noticeService = new NoticeService(); noticeService.CleanByUser(sender.UserId); InviteFriendService inviteFriendService = new InviteFriendService(); inviteFriendService.CleanByUser(sender.UserId); //清除站外提醒的用户数据 ReminderService reminderService = new ReminderService(); reminderService.CleanByUser(sender.UserId); #endregion #region 关注/访客 //清除用户关于关注用户的数据 FollowService followService = new FollowService(); followService.CleanByUser(sender.UserId); //清除访客记录的用户数据 VisitService visitService = new VisitService(string.Empty); visitService.CleanByUser(sender.UserId); #endregion #region 帐号 //清除帐号绑定数据 var accountBindingService = new AccountBindingService(); var accountBindings = new AccountBindingService().GetAccountBindings(sender.UserId); foreach (var accountBinding in accountBindings) { accountBindingService.DeleteAccountBinding(accountBinding.UserId, accountBinding.AccountTypeKey); } #endregion #region 装扮 //调整皮肤文件使用次数 var user = userService.GetFullUser(sender.UserId); if (user == null) return; var presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.UserSpace); string defaultThemeAppearance = string.Join(",", presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey); if (!user.IsUseCustomStyle) new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.UserSpace, null, !string.IsNullOrEmpty(user.ThemeAppearance) ? user.ThemeAppearance : defaultThemeAppearance); #endregion }