/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); //注册帖吧计数服务 CountService countService = new CountService(TenantTypeIds.Instance().BarSection()); countService.RegisterCounts(); //注册计数服务 countService.RegisterCountPerDay(); //需要统计阶段计数时,需注册每日计数服务 countService.RegisterStageCount(CountTypes.Instance().ThreadAndPostCount(), 1); //注册帖子计数服务 countService = new CountService(TenantTypeIds.Instance().BarThread()); countService.RegisterCounts(); //注册计数服务 countService.RegisterCountPerDay(); //需要统计阶段计数时,需注册每日计数服务 countService.RegisterStageCount(CountTypes.Instance().HitTimes(), 1, 7); //注册贴吧用户计数服务 List <string> tenantTypeIds = new List <string>() { TenantTypeIds.Instance().User(), TenantTypeIds.Instance().Group() }; OwnerDataSettings.RegisterStatisticsDataKeys(tenantTypeIds , OwnerDataKeys.Instance().ThreadCount() , OwnerDataKeys.Instance().PostCount() , OwnerDataKeys.Instance().FollowSectionCount()); TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().BarThread(), new BarTagUrlGetter()); TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().Group(), new BarTagUrlGetter()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(ApplicationIds.Instance().Bar(), new List <string> { "BarAdministrator" }); }
/// <summary> /// 搜索词记录及计数 /// </summary> /// <param name="searchTypeCode">搜索类型编码</param> /// <param name="term">搜索词</param> public void SearchTerm(string searchTypeCode, string term) { long id = searchedTermRepository.InsertOrUpdate(searchTypeCode, term, false); CountService countService = new CountService(TenantTypeIds.Instance().Search()); countService.ChangeCount(CountTypes.Instance().SearchCount(), id, 0, 1, false); }
/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); OwnerDataSettings.RegisterStatisticsDataKeys(TenantTypeIds.Instance().User(), OwnerDataKeys.Instance().PhotoCount()); //注册相册的计数服务 CountService albumCountService = new CountService(TenantTypeIds.Instance().Album()); albumCountService.RegisterCounts(); //注册照片的计数服务 CountService photoCountService = new CountService(TenantTypeIds.Instance().Photo()); photoCountService.RegisterCounts(); photoCountService.RegisterCountPerDay(); photoCountService.RegisterStageCount(CountTypes.Instance().HitTimes(), 7); //注册标签云标签链接接口实现 TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().Photo(), new PhotoTagUrlGetter()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(applicationId, new List <string> { "PhotoAdministrator" }); }
/// <summary> /// 移动帖子 /// </summary> /// <param name="threadId">要移动帖子的ThreadId</param> /// <param name="moveToSectionId">转移到帖吧的SectionId</param> public void MoveThread(long threadId, long moveToSectionId) { BarThread thread = barThreadRepository.Get(threadId); if (thread.SectionId == moveToSectionId) { return; } long oldSectionId = thread.SectionId; var barSectionService = new BarSectionService(); var oldSection = barSectionService.Get(oldSectionId); if (oldSection == null) { return; } var newSection = barSectionService.Get(moveToSectionId); if (newSection == null) { return; } barThreadRepository.MoveThread(threadId, moveToSectionId); CountService countService = new CountService(TenantTypeIds.Instance().BarSection()); countService.ChangeCount(CountTypes.Instance().ThreadCount(), oldSection.SectionId, oldSection.UserId, -1, true); countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), oldSection.SectionId, oldSection.UserId, -1, true); countService.ChangeCount(CountTypes.Instance().ThreadCount(), newSection.SectionId, newSection.UserId, 1, true); countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), newSection.SectionId, newSection.UserId, 1, true); }
/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); //注册日志Rss浏览计数服务 CountService countService = new CountService(TenantTypeIds.Instance().Microblog()); countService.RegisterCounts(); //注册计数服务 countService.RegisterCountPerDay(); //需要统计阶段计数时,需注册每日计数服务 countService.RegisterStageCount(CountTypes.Instance().CommentCount(), 1); //注册微博用户计数服务 List <string> tenantTypeIds = new List <string>() { TenantTypeIds.Instance().User(), TenantTypeIds.Instance().Group() }; OwnerDataSettings.RegisterStatisticsDataKeys(tenantTypeIds, OwnerDataKeys.Instance().ThreadCount()); TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().Microblog(), new MicroblogTagUrlGetter()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(ApplicationIds.Instance().Microblog(), new List <string> { "MicroblogAdministrator" }); }
/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); //注册日志计数服务 CountService countService = new CountService(TenantTypeIds.Instance().BlogThread()); //注册计数服务 countService.RegisterCounts(); //需要统计阶段计数时,需注册每日计数服务 countService.RegisterCountPerDay(); //注册日志浏览计数服务 countService.RegisterStageCount(CountTypes.Instance().HitTimes(), 7); //注册用户计数服务 OwnerDataSettings.RegisterStatisticsDataKeys(TenantTypeIds.Instance().User(), OwnerDataKeys.Instance().ThreadCount()); //标签云中标签的链接 TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().BlogThread(), new BlogTagUrlGetter()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(ApplicationIds.Instance().Blog(), new List <string> { "BlogAdministrator" }); }
/// <summary> /// 获取匹配的前N条最热的搜索词(仅非人工干预) /// </summary> /// <param name="keyword">要匹配的关键字</param> /// <param name="topNumber">获取的数据条数</param> /// <param name="searchTypeCode">搜索类型编码</param> /// <returns>用户最多搜索的前topNumber的搜索词</returns> public IEnumerable <SearchedTerm> GetTops(string keyword, int topNumber, string searchTypeCode) { CountService countService = new CountService(TenantTypeIds.Instance().Search()); StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Search()); int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().SearchCount()); string countType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().SearchCount(), stageCountDays); string countTableName = countService.GetTableName_Counts(); return(GetTopEntities(topNumber, CachingExpirationType.ObjectCollection, () => { StringBuilder cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.None)); cacheKey.AppendFormat("SearchTypeCode-{0}::CountType-{1}::Keyword-{2}", searchTypeCode, countType, keyword); return cacheKey.ToString(); }, () => { var sql = Sql.Builder; sql.Select("*") .From("tn_SearchedTerms") .InnerJoin(countTableName) .On("tn_SearchedTerms.Id = " + countTableName + ".ObjectId") .Where("tn_SearchedTerms.Term like @0", keyword + "%"); if (!String.IsNullOrEmpty(searchTypeCode)) { sql.Where("SearchTypeCode = @0", searchTypeCode); } sql.Where("IsAddedByAdministrator = @0", 0) .Where("CountType = @0", countType) .Where("OwnerId = @0", 0) .OrderBy("StatisticsCount desc"); return sql; })); }
/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); //注册计数服务 CountService countService = new CountService(TenantTypeIds.Instance().ContentItem()); countService.RegisterCounts(); countService.RegisterCountPerDay(); countService.RegisterStageCount(CountTypes.Instance().HitTimes(), 7); countService.RegisterStageCount(CountTypes.Instance().CommentCount(), 7); countService = new CountService(TenantTypeIds.Instance().ContentAttachment()); countService.RegisterCounts(); //注册用户计数服务(用于内容计数) OwnerDataSettings.RegisterStatisticsDataKeys(TenantTypeIds.Instance().User(), OwnerDataKeys.Instance().ContributeCount()); //注册标签云标签链接接口实现 TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().ContentItem(), new CmsTagUrlGetter()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(applicationId, new List <string> { "CMSAdministrator" }); }
/// <summary> /// 分页获取搜索词(仅非人工干预) /// </summary> /// <param name="searchTypeCode">搜索类型编码</param> /// <param name="term">搜索词</param> /// <param name="startDate">开始日期</param> /// <param name="endDate">结束日期</param> /// <param name="isRealtime">是否实时缓存</param> /// <param name="pageIndex">当前页码</param> /// <param name="pageSize">每页条数</param> /// <returns>按条件检索的热词</returns> public PagingDataSet <SearchedTerm> Gets(string searchTypeCode, string term, DateTime?startDate, DateTime?endDate, bool isRealtime, int pageSize, int pageIndex) { CountService countService = new CountService(TenantTypeIds.Instance().Search()); string countTableName = countService.GetTableName_Counts(); string countType = CountTypes.Instance().SearchCount(); StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Search()); int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().SearchCount()); return(GetPagingEntities(pageSize, pageIndex, CachingExpirationType.ObjectCollection, () => { //done:zhangp,by mazq cacheKey应该与查询条件关联 StringBuilder cacheKey; if (isRealtime) { cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.GlobalVersion)); } else { cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.AreaVersion, "SearchTypeCode", searchTypeCode)); } cacheKey.AppendFormat("SearchTypeCode-{0}::Term-{1}::StartData-{2}::EndData-{3}", searchTypeCode, term, startDate, endDate); return cacheKey.ToString(); }, () => { var sql = Sql.Builder; sql.Select("*") .From("tn_SearchedTerms") .InnerJoin(countTableName) .On("tn_SearchedTerms.Id = " + countTableName + ".ObjectId") .Where("IsAddedByAdministrator = @0", 0) .Where("CountType = @0", countType) .Where("OwnerId = @0", 0); if (!String.IsNullOrEmpty(searchTypeCode)) { sql.Where("SearchTypeCode = @0", searchTypeCode); } if (!String.IsNullOrEmpty(term)) { sql.Where("Term like @0", term + "%"); } if (startDate.HasValue) { sql.Where("DateCreated >= @0", startDate); } if (endDate.HasValue) { sql.Where("DateCreated <= @0", endDate); } sql.OrderBy("StatisticsCount desc"); return sql; } )); }
/// <summary> /// 获取匹配的前N条最热的搜索词(仅非人工干预) /// </summary> /// <param name="keyword">要匹配的关键字</param> /// <param name="topNumber">获取的数据条数</param> /// <param name="searchTypeCode">搜索类型编码</param> /// <returns>用户最多搜索的前topNumber的搜索词</returns> public IEnumerable <SearchedTerm> GetTops(string keyword, int topNumber, string searchTypeCode) { CountService countService = new CountService(TenantTypeIds.Instance().Search()); StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Search()); int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().SearchCount()); string countType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().SearchCount(), stageCountDays); string countTableName = countService.GetTableName_Counts(); var sql = Sql.Builder; var whereSql = Sql.Builder; var orderSql = Sql.Builder; sql.Select("*").From("tn_SearchedTerms"); sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, countType)) .On("Id = c.ObjectId"); orderSql.OrderBy("c.StatisticsCount desc"); whereSql.Where("IsAddedByAdministrator = @0", false); if (!string.IsNullOrEmpty(keyword)) { whereSql.Where("tn_SearchedTerms.Term like @0", StringUtility.StripSQLInjection(keyword) + "%"); } if (!String.IsNullOrEmpty(searchTypeCode)) { whereSql.Where("SearchTypeCode = @0", searchTypeCode); } sql.Append(whereSql).Append(orderSql); var primaryKeys = CreateDAO().FetchTopPrimaryKeys <SearchedTerm>(topNumber, sql); return(PopulateEntitiesByEntityIds(primaryKeys)); }
/// <summary> /// 获取前N条最热的搜索词(仅非人工干预) /// </summary> /// <param name="topNumber">获取的数据条数</param> /// <param name="searchTypeCode">搜索类型编码</param> /// <returns>用户最多搜索的前topNumber的搜索词</returns> public IEnumerable <SearchedTerm> GetTops(int topNumber, string searchTypeCode) { CountService countService = new CountService(TenantTypeIds.Instance().Search()); StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Search()); int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().SearchCount()); string countType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().SearchCount(), stageCountDays); string countTableName = countService.GetTableName_Counts(); return(GetTopEntities(topNumber, CachingExpirationType.ObjectCollection, () => { StringBuilder cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.None)); cacheKey.AppendFormat("SearchTypeCode-{0}::CountType-{1}", searchTypeCode, countType); return cacheKey.ToString(); }, () => { var sql = Sql.Builder; var whereSql = Sql.Builder; var orderSql = Sql.Builder; sql.Select("*").From("tn_SearchedTerms"); sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, countType)) .On("Id = c.ObjectId"); orderSql.OrderBy("c.StatisticsCount desc"); if (!String.IsNullOrEmpty(searchTypeCode)) { whereSql.Where("SearchTypeCode = @0", searchTypeCode); } whereSql.Where("IsAddedByAdministrator = @0", false); sql.Append(whereSql).Append(orderSql); return sql; })); }
/// <summary> /// 分页获取搜索词(仅非人工干预) /// </summary> /// <param name="searchTypeCode">搜索类型编码</param> /// <param name="term">搜索词</param> /// <param name="startDate">开始日期</param> /// <param name="endDate">结束日期</param> /// <param name="isRealtime">是否实时缓存</param> /// <param name="pageIndex">当前页码</param> /// <param name="pageSize">每页条数</param> /// <returns>按条件检索的热词</returns> public PagingDataSet <SearchedTerm> Gets(string searchTypeCode, string term, DateTime?startDate, DateTime?endDate, bool isRealtime, int pageSize, int pageIndex) { CountService countService = new CountService(TenantTypeIds.Instance().Search()); string countTableName = countService.GetTableName_Counts(); string countType = CountTypes.Instance().SearchCount(); StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Search()); int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().SearchCount()); return(GetPagingEntities(pageSize, pageIndex, CachingExpirationType.ObjectCollection, () => { StringBuilder cacheKey; if (isRealtime) { cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.GlobalVersion)); } else { cacheKey = new StringBuilder(RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.AreaVersion, "SearchTypeCode", searchTypeCode)); } cacheKey.AppendFormat("SearchTypeCode-{0}::Term-{1}::StartData-{2}::EndData-{3}", searchTypeCode, term, startDate, endDate); return cacheKey.ToString(); }, () => { var sql = Sql.Builder; var whereSql = Sql.Builder; var orderSql = Sql.Builder; sql.Select("*").From("tn_SearchedTerms"); sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, countType)) .On("Id = c.ObjectId"); orderSql.OrderBy("c.StatisticsCount desc"); whereSql.Where("IsAddedByAdministrator = @0", false); if (!String.IsNullOrEmpty(searchTypeCode)) { whereSql.Where("SearchTypeCode = @0", searchTypeCode); } if (!String.IsNullOrEmpty(term)) { whereSql.Where("Term like @0", "%" + StringUtility.StripSQLInjection(term) + "%"); } if (startDate.HasValue) { whereSql.Where("DateCreated >= @0", startDate); } if (endDate.HasValue) { whereSql.Where("DateCreated <= @0", endDate); } sql.Append(whereSql).Append(orderSql); return sql; } )); }
/// <summary> /// 创建回复贴 /// </summary> /// <param name="post">回复贴</param> public bool Create(BarPost post) { BarSectionService barSectionService = new BarSectionService(); BarSection barSection = barSectionService.Get(post.SectionId); if (barSection == null) { return(false); } EventBus <BarPost> .Instance().OnBefore(post, new CommonEventArgs(EventOperationType.Instance().Create())); //设置审核状态 auditService.ChangeAuditStatusForCreate(post.UserId, post); long id = 0; long.TryParse(barPostRepository.Insert(post).ToString(), out id); if (id > 0) { new AttachmentService(TenantTypeIds.Instance().BarPost()).ToggleTemporaryAttachments(post.UserId, TenantTypeIds.Instance().BarPost(), id); //计数 CountService countService = new CountService(TenantTypeIds.Instance().BarSection()); countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, 1, true); if (post.TenantTypeId == TenantTypeIds.Instance().Group()) { //群组内容计数+1 OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group()); groupOwnerDataService.Change(post.SectionId, OwnerDataKeys.Instance().PostCount(), 1); } else if (post.TenantTypeId == TenantTypeIds.Instance().Bar()) { //用户内容计数+1 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); ownerDataService.Change(post.UserId, OwnerDataKeys.Instance().PostCount(), 1); } //更新帖子主题计数缓存 RealTimeCacheHelper realTimeCacheHelper = EntityData.ForType(typeof(BarThread)).RealTimeCacheHelper; string cacheKey = realTimeCacheHelper.GetCacheKeyOfEntity(post.ThreadId); ICacheService cacheService = DIContainer.Resolve <ICacheService>(); BarThread barThread = cacheService.Get <BarThread>(cacheKey); if (barThread != null && barThread.ThreadId > 0) { barThread.PostCount++; cacheService.Set(cacheKey, barThread, CachingExpirationType.SingleObject); } new AtUserService(TenantTypeIds.Instance().BarPost()).ResolveBodyForEdit(post.GetBody(), post.UserId, post.PostId); EventBus <BarPost> .Instance().OnAfter(post, new CommonEventArgs(EventOperationType.Instance().Create())); EventBus <BarPost, AuditEventArgs> .Instance().OnAfter(post, new AuditEventArgs(null, post.AuditStatus)); } return(id > 0); }
/// <summary> /// 更新帖吧 /// </summary> /// <param name="section">帖吧</param> /// <param name="userId">当前操作人</param> /// <param name="managerIds">管理员用户Id</param> /// <param name="sectionedFile">帖吧标识图</param> public void Update(BarSection section, long userId, IEnumerable <long> managerIds, Stream sectionedFile) { EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Update())); //上传Logo if (sectionedFile != null) { LogoService logoService = new LogoService(TenantTypeIds.Instance().BarSection()); section.LogoImage = logoService.UploadLogo(section.SectionId, sectionedFile); } auditService.ChangeAuditStatusForUpdate(userId, section); barSectionRepository.Update(section); if (managerIds != null && managerIds.Count() > 0) { List <long> mangagerIds_list = managerIds.ToList(); mangagerIds_list.Remove(section.UserId); managerIds = mangagerIds_list; } barSectionRepository.UpdateManagerIds(section.SectionId, managerIds); if (section.TenantTypeId == TenantTypeIds.Instance().Bar()) { SubscribeService subscribeService = new SubscribeService(TenantTypeIds.Instance().BarSection()); //帖吧主、吧管理员自动关注本帖吧 int followedCount = 0; bool result = subscribeService.Subscribe(section.SectionId, section.UserId); if (result) { followedCount++; } if (managerIds != null && managerIds.Count() > 0) { foreach (var managerId in managerIds) { result = subscribeService.Subscribe(section.SectionId, managerId); if (result) { followedCount++; } } } //增加帖吧的被关注数 CountService countService = new CountService(TenantTypeIds.Instance().BarSection()); countService.ChangeCount(CountTypes.Instance().FollowedCount(), section.SectionId, section.UserId, followedCount, true); } EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Update())); }
/// <summary> /// 商品描述 /// </summary> /// <returns></returns> public ActionResult GiftDetail(long giftId) { ViewData["giftId"] = giftId; //获取商品 PointGift gift = pointMallService.GetGift(giftId); //更新计数 CountService countService = new CountService(TenantTypeIds.Instance().PointGift()); countService.ChangeCount(CountTypes.Instance().HitTimes(), giftId, gift.UserId, 1); pageResourceManager.InsertTitlePart(gift.Name); IUser currentUser = UserContext.CurrentUser; if (currentUser != null) { //设置最近浏览 HttpCookie cookie = Request.Cookies["LastViewedGifts" + currentUser.UserId]; if (cookie != null) { string[] cookieGiftIds = cookie.Value.ToString().Split(','); cookie.Value = ""; foreach (string cookieGiftId in cookieGiftIds) { if (!string.IsNullOrWhiteSpace(cookieGiftId)) { if (Convert.ToInt64(cookieGiftId) != giftId) { cookie.Value = cookie.Value + "," + cookieGiftId; } } } cookie.Value = giftId + "," + cookie.Value; Response.Cookies.Set(cookie); } else { cookie = new HttpCookie("LastViewedGifts" + currentUser.UserId); cookie.Value = giftId.ToString(); Response.Cookies.Add(cookie); } } //获取 ViewData["successCommentsCount"] = pointMallService.GetRecordsCount(giftId, ApproveStatus.Approved).TotalRecords; ViewData["pendingCommentsCount"] = pointMallService.GetRecordsCount(giftId, ApproveStatus.Pending).TotalRecords; return(View(gift)); }
/// <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="thread">主题帖</param> public bool Create(BarThread thread) { BarSectionService barSectionService = new BarSectionService(); EventBus <BarThread> .Instance().OnBefore(thread, new CommonEventArgs(EventOperationType.Instance().Create())); //设置审核状态 auditService.ChangeAuditStatusForCreate(thread.UserId, thread); long id = 0; long.TryParse(barThreadRepository.Insert(thread).ToString(), out id); if (id > 0) { new AttachmentService(TenantTypeIds.Instance().BarThread()).ToggleTemporaryAttachments(thread.UserId, TenantTypeIds.Instance().BarThread(), id); BarSection barSection = barSectionService.Get(thread.SectionId); if (barSection != null) { //计数 CountService countService = new CountService(TenantTypeIds.Instance().BarSection()); countService.ChangeCount(CountTypes.Instance().ThreadCount(), barSection.SectionId, barSection.UserId, 1, true); countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, 1, true); if (thread.TenantTypeId == TenantTypeIds.Instance().Group()) { //群组内容计数+1 OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group()); groupOwnerDataService.Change(thread.SectionId, OwnerDataKeys.Instance().ThreadCount(), 1); } } if (thread.TenantTypeId == TenantTypeIds.Instance().Bar()) { //用户内容计数+1 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); ownerDataService.Change(thread.UserId, OwnerDataKeys.Instance().ThreadCount(), 1); } AtUserService atUserService = new AtUserService(TenantTypeIds.Instance().BarThread()); atUserService.ResolveBodyForEdit(thread.GetBody(), thread.UserId, thread.ThreadId); EventBus <BarThread> .Instance().OnAfter(thread, new CommonEventArgs(EventOperationType.Instance().Create())); EventBus <BarThread, AuditEventArgs> .Instance().OnAfter(thread, new AuditEventArgs(null, thread.AuditStatus)); } return(id > 0); }
/// <summary> /// 群组空间主页 /// </summary> /// <param name="spaceKey">群组标识</param> /// <returns></returns> public ActionResult Home(string spaceKey) { GroupEntity group = groupService.Get(spaceKey); //已修改 if (group == null) { return(HttpNotFound()); } IEnumerable <ApplicationBase> applications = applicationService.GetInstalledApplicationsOfOwner(PresentAreaKeysOfBuiltIn.GroupSpace, group.GroupId); //这里先判断group是否为空,再插入了群组名 pageResourceManager.InsertTitlePart(group.GroupName); //浏览计数 new CountService(TenantTypeIds.Instance().Group()).ChangeCount(CountTypes.Instance().HitTimes(), group.GroupId, group.UserId); //1.为什么匿名用户就不让访问? //2.这里有个大问题,私密群组应该不允许非群组成员访问, //可以参考Common\Mvc\Attributes\UserSpaceAuthorizeAttribute.cs,在Group\Extensions\增加一个GroupSpaceAuthorizeAttribute //3.当设置为私密群组并且允许用户申请加入时,应允许用户浏览群组首页,但只能看部分信息,具体需求可找宝声确认; //当前用户 IUser user = UserContext.CurrentUser; if (user != null) { //ok,传递这些结果可以吗? //已修改 //这样做很不好,直接用Authorizer bool isMember = groupService.IsMember(group.GroupId, user.UserId); visitService.CreateVisit(user.UserId, user.DisplayName, group.GroupId, group.GroupName); ViewData["isMember"] = isMember; } ViewData["isPublic"] = group.IsPublic; TempData["GroupMenu"] = GroupMenu.Home; ViewData["applications"] = applications; return(View(group)); }
/// <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)); }
/// <summary> /// 专题空间主页 /// </summary> /// <param name="spaceKey">专题标识</param> /// <returns></returns> public ActionResult Home(string spaceKey) { TopicEntity topic = topicService.Get(spaceKey); //已修改 if (topic == null) { return(HttpNotFound()); } IEnumerable <ApplicationBase> applications = applicationService.GetInstalledApplicationsOfOwner(PresentAreaKeysOfExtension.TopicSpace, topic.TopicId); //这里先判断topic是否为空,再插入了专题名 pageResourceManager.InsertTitlePart(topic.TopicName); //浏览计数 new CountService(TenantTypeIds.Instance().Topic()).ChangeCount(CountTypes.Instance().HitTimes(), topic.TopicId, topic.UserId); //1.为什么匿名用户就不让访问? //2.这里有个大问题,私密专题应该不允许非专题成员访问, //可以参考Common\Mvc\Attributes\UserSpaceAuthorizeAttribute.cs,在topic\Extensions\增加一个topicSpaceAuthorizeAttribute //3.当设置为私密专题并且允许用户申请加入时,应允许用户浏览专题首页,但只能看部分信息,具体需求可找宝声确认; //当前用户 IUser user = UserContext.CurrentUser; if (user != null) { //ok,传递这些结果可以吗? //已修改 //这样做很不好,直接用Authorizer bool isMember = topicService.IsMember(topic.TopicId, user.UserId); visitService.CreateVisit(user.UserId, user.DisplayName, topic.TopicId, topic.TopicName); ViewData["isMember"] = isMember; } ViewData["isPublic"] = topic.IsPublic; TempData["TopicMenu"] = TopicMenu.Home; ViewData["applications"] = applications; return(View(topic)); }
/// <summary> /// 删除回复贴 /// </summary> /// <param name="postId">回复贴Id</param> public void Delete(long postId) { BarPost post = barPostRepository.Get(postId); if (post == null) { return; } BarSectionService barSectionService = new BarSectionService(); BarSection barSection = barSectionService.Get(post.SectionId); if (barSection == null) { return; } EventBus <BarPost> .Instance().OnBefore(post, new CommonEventArgs(EventOperationType.Instance().Delete())); int affectCount = barPostRepository.Delete(post); if (affectCount > 0) { //更新帖吧的计数 CountService countService = new CountService(TenantTypeIds.Instance().BarSection()); countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, -1 - post.ChildPostCount, true); if (post.TenantTypeId == TenantTypeIds.Instance().Group()) { //群组内容计数-1 OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group()); groupOwnerDataService.Change(post.SectionId, OwnerDataKeys.Instance().PostCount(), -1); } else if (post.TenantTypeId == TenantTypeIds.Instance().Bar()) { //用户内容计数-1 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); ownerDataService.Change(post.UserId, OwnerDataKeys.Instance().PostCount(), -1); } EventBus <BarPost> .Instance().OnAfter(post, new CommonEventArgs(EventOperationType.Instance().Delete())); EventBus <BarPost, AuditEventArgs> .Instance().OnAfter(post, new AuditEventArgs(post.AuditStatus, null)); } }
/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().Group(), new GroupTagUrlGetter()); //注册群组计数服务 CountService countService = new CountService(TenantTypeIds.Instance().Group()); countService.RegisterCounts(); //注册计数服务 countService.RegisterCountPerDay(); //需要统计阶段计数时,需注册每日计数服务 countService.RegisterStageCount(CountTypes.Instance().HitTimes(), 7); OwnerDataSettings.RegisterStatisticsDataKeys(TenantTypeIds.Instance().User() , OwnerDataKeys.Instance().CreatedGroupCount() , OwnerDataKeys.Instance().JoinedGroupCount()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(applicationId, new List <string> { "GroupAdministrator" }); }
/// <summary> /// 照片详细显示 /// </summary> /// <returns></returns> public ActionResult Detail(long photoId) { Photo photo = photoService.GetPhoto(photoId); //更新计数 CountService countService = new CountService(TenantTypeIds.Instance().Photo()); countService.ChangeCount(CountTypes.Instance().HitTimes(), photoId, photo.UserId, 1, true); Album album = photo.Album; if (photo == null || !authorizer.Album_View(album)) { if (Request.IsAjaxRequest()) { return(Json(new StatusMessageData(StatusMessageType.Hint, "没有浏览照片的权限"))); } else { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Body = "没有浏览照片的权限", Title = "没有权限", StatusMessageType = StatusMessageType.Hint }))); } } IUser currentUser = UserContext.CurrentUser; PagingDataSet <Photo> photos = photoService.GetPhotosOfAlbum(null, photo.AlbumId, currentUser != null && currentUser.UserId == album.UserId, pageSize: 1000, pageIndex: 1); ViewData["album"] = album; ViewData["photos"] = photos.ToList(); if (Request.IsAjaxRequest()) { return(PartialView("_Details", photo)); } return(View(photo)); }
public override void ProcessRequest(HttpContext context) { long attachmentId = context.Request.QueryString.Get <long>("attachmentId", 0); if (attachmentId <= 0) { WebUtility.Return404(context); return; } ContentAttachmentService contentAttachmentService = new ContentAttachmentService(); ContentAttachment attachment = contentAttachmentService.Get(attachmentId); if (attachment == null) { WebUtility.Return404(context); return; } IUser currentUser = UserContext.CurrentUser; //下载计数 CountService countService = new CountService(TenantTypeIds.Instance().ContentAttachment()); countService.ChangeCount(CountTypes.Instance().DownloadCount(), attachment.AttachmentId, attachment.UserId, 1, false); bool enableCaching = context.Request.QueryString.GetBool("enableCaching", true); context.Response.Status = "302 Object Moved"; context.Response.StatusCode = 302; LinktimelinessSettings linktimelinessSettings = DIContainer.Resolve <ISettingsManager <LinktimelinessSettings> >().Get(); string token = Utility.EncryptTokenForAttachmentDownload(linktimelinessSettings.Highlinktimeliness, attachmentId); context.Response.Redirect(SiteUrls.Instance().ContentAttachmentTempUrl(attachment.AttachmentId, token, enableCaching), true); context.Response.Flush(); context.Response.End(); }
/// <summary> /// 应用加载 /// </summary> public override void Load() { base.Load(); //注册词条计数服务 CountService countService = new CountService(TenantTypeIds.Instance().WikiPage()); //注册计数服务 countService.RegisterCounts(); //需要统计阶段计数时,需注册每日计数服务 countService.RegisterCountPerDay(); //注册词条浏览计数服务 countService.RegisterStageCount(CountTypes.Instance().HitTimes(), 7); //注册标签云标签链接接口实现 TagUrlGetterManager.RegisterGetter(TenantTypeIds.Instance().WikiPage(), new WikiTagUrlGetter()); //添加应用管理员角色 ApplicationAdministratorRoleNames.Add(applicationId, new List <string> { "WikiAdministrator" }); }
public ActionResult _DetailPhotoSide(long photoId) { Photo photo = photoService.GetPhoto(photoId); photo.Description = Formatter.FormatMultiLinePlainTextForEdit(photo.Description, false); //如果没有读到对象则返回空内容 if (photo == null) { return(Content(string.Empty)); } Dictionary <int, string> enabledEXIF = new Dictionary <int, string>(); enabledEXIF.Add(0x010F, "设备制造厂商"); enabledEXIF.Add(0x0110, "相机型号"); enabledEXIF.Add(0x9003, "拍摄日期"); enabledEXIF.Add(0xa002, "宽度"); enabledEXIF.Add(0xa003, "高度"); enabledEXIF.Add(0x9205, "最大光圈"); enabledEXIF.Add(0x920a, "焦距"); enabledEXIF.Add(0x829A, "曝光时间"); enabledEXIF.Add(0x8824, "感光度"); enabledEXIF.Add(0x9209, "闪光灯"); ViewData["EnabledEXIF"] = enabledEXIF; ViewData["EXIFMetaData"] = photoService.GetPhotoEXIFMetaData(photoId); ViewData["PhotoLabels"] = photoService.GetLabelsOfPhoto(TenantTypeIds.Instance().User(), photoId); CountService countService = new CountService(TenantTypeIds.Instance().Photo()); ViewData["CommentCount"] = countService.Get(CountTypes.Instance().CommentCount(), photoId); return(View(photo)); }
public ActionResult Detail(string spaceKey, long threadId, int pageIndex = 1, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, long?postId = null, long?childPostIndex = null) { BarThread barThread = barThreadService.Get(threadId); if (barThread == null) { return(HttpNotFound()); } GroupEntity group = groupService.Get(spaceKey); if (group == null) { return(HttpNotFound()); } BarSection section = barSectionService.Get(barThread.SectionId); if (section == null || section.TenantTypeId != TenantTypeIds.Instance().Group()) { return(HttpNotFound()); } //验证是否通过审核 long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey); if (!authorizer.IsAdministrator(BarConfig.Instance().ApplicationId) && barThread.UserId != currentSpaceUserId && (int)barThread.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(BarConfig.Instance().ApplicationId))) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "尚未通过审核", Body = "由于当前帖子尚未通过审核,您无法浏览当前内容。", StatusMessageType = StatusMessageType.Hint }))); } pageResourceManager.InsertTitlePart(section.Name); pageResourceManager.InsertTitlePart(barThread.Subject); Category category = categoryService.Get(barThread.CategoryId ?? 0); string keyWords = string.Join(",", barThread.TagNames); pageResourceManager.SetMetaOfKeywords(category != null ? category.CategoryName + "," + keyWords : keyWords); //设置Keyords类型的Meta pageResourceManager.SetMetaOfDescription(HtmlUtility.TrimHtml(barThread.GetResolvedBody(), 120)); //设置Description类型的Meta ViewData["EnableRating"] = barSettings.EnableRating; //更新浏览计数 CountService countService = new CountService(TenantTypeIds.Instance().BarThread()); countService.ChangeCount(CountTypes.Instance().HitTimes(), barThread.ThreadId, barThread.UserId, 1, false); PagingDataSet <BarPost> barPosts = barPostService.Gets(threadId, onlyLandlord, sortBy, pageIndex); if (pageIndex > barPosts.PageCount && pageIndex > 1) { return(Detail(spaceKey, threadId, barPosts.PageCount)); } if (Request.IsAjaxRequest()) { return(PartialView("~/Applications/Bar/Views/Bar/_ListPost.cshtml", barPosts)); } ViewData["barThread"] = barThread; ViewData["group"] = group; return(View(barPosts)); }
/// <summary> /// 词条详细页 /// </summary> /// <returns></returns> public ActionResult PageDetail(long pageId, long?versionId = null) { SiteSettings siteSettings = siteSettingsManager.Get(); if (!siteSettings.EnableAnonymousBrowse) { //匿名用户访问 if (UserContext.CurrentUser == null) { string EncryptKey = System.Configuration.ConfigurationManager.AppSettings["EncryptKey"].ToString(); if (EncryptKey != "false") { string anonymous = Request.QueryString.Get("anonymous"); if (string.IsNullOrEmpty(anonymous)) { return(Redirect(SiteUrls.Instance().Login(true))); } } } } WikiPage currentPage = wikiService.Get(pageId); //待审核的词条只有作者和管理员查看 if (currentPage.AuditStatus != AuditStatus.Success) { if (UserContext.CurrentUser == null) { return(Redirect(SiteUrls.Instance().Login(true))); } else if (!DIContainer.Resolve <Authorizer>().Page_Manage(currentPage) && UserContext.CurrentUser.UserId != currentPage.UserId) { return(Redirect(SiteUrls.Instance().Index())); } } //判断输入参数的有效性 if (currentPage == null) { return(HttpNotFound()); } if (versionId.HasValue && versionId.Value > 0) { //设置标题 pageResourceManager.InsertTitlePart("查看词条历史版本"); ViewData["LastestVersion"] = wikiService.GetPageVersion(versionId.Value); } else { //设置标题 pageResourceManager.InsertTitlePart("词条详细页"); //浏览量 CountService countService = new CountService(TenantTypeIds.Instance().WikiPage()); countService.ChangeCount(CountTypes.Instance().HitTimes(), pageId, currentPage.UserId, 1, false); //获取数据在View展示 //A 词条当前版本 ViewData["LastestVersion"] = currentPage.LastestVersion; } //B 分类-最新版本的属性中有 //C 标签-最新版本的属性中有 //D 附件 IEnumerable <Attachment> attachments = attachmentService.GetsByAssociateId(pageId); if (attachments != null && attachments.Count() > 0) { ViewData["attachmentCount"] = attachments.Where(n => n.MediaType == MediaType.Other).Count(); } IEnumerable <WikiPage> hotPages = wikiService.GetTops(TenantTypeIds.Instance().Wiki(), 10, null, null, SortBy_WikiPage.StageHitTimes); ViewData["hotPages"] = hotPages; //增加计数 CountService usercountService = new CountService(TenantTypeIds.Instance().User()); return(View(currentPage)); }
/// <summary> /// Gets和GetTops的sql语句 /// </summary> private Sql Getsqls(string areaCode, long?categoryId, string keyword, SortBy_Group sortBy) { Sql sql = Sql.Builder; var whereSql = Sql.Builder; var orderSql = Sql.Builder; sql.Select("spb_Groups.*").From("spb_Groups"); if (categoryId != null && categoryId.Value > 0) { CategoryService categoryService = new CategoryService(); IEnumerable <Category> categories = categoryService.GetDescendants(categoryId.Value); List <long> categoryIds = new List <long> { categoryId.Value }; if (categories != null && categories.Count() > 0) { categoryIds.AddRange(categories.Select(n => n.CategoryId)); } sql.InnerJoin("tn_ItemsInCategories") .On("spb_Groups.GroupId = tn_ItemsInCategories.ItemId"); whereSql.Where("tn_ItemsInCategories.CategoryId in(@categoryIds)", new { categoryIds = categoryIds }); } if (!string.IsNullOrEmpty(areaCode)) { if (areaCode.Equals("A1560000", StringComparison.CurrentCultureIgnoreCase)) { //已修改 whereSql.Where("AreaCode like '1%' or AreaCode like '2%' or AreaCode like '3%' or AreaCode like '4%' or AreaCode like '5%' or AreaCode like '6%' or AreaCode like '7%' or AreaCode like '8%' or AreaCode like '9%' "); } else { areaCode = areaCode.TrimEnd('0'); if (areaCode.Length % 2 == 1) { areaCode = areaCode + "0"; } whereSql.Where("AreaCode like @0 ", StringUtility.StripSQLInjection(areaCode) + "%"); } } if (!string.IsNullOrEmpty(keyword)) { whereSql.Where("GroupName like @0", StringUtility.StripSQLInjection(keyword) + "%"); } whereSql.Where("spb_Groups.IsPublic = 1"); //已修改 switch (this.PubliclyAuditStatus) { case PubliclyAuditStatus.Again: case PubliclyAuditStatus.Fail: case PubliclyAuditStatus.Pending: case PubliclyAuditStatus.Success: whereSql.Where("AuditStatus=@0", this.PubliclyAuditStatus); break; case PubliclyAuditStatus.Again_GreaterThanOrEqual: case PubliclyAuditStatus.Pending_GreaterThanOrEqual: whereSql.Where("AuditStatus>@0", this.PubliclyAuditStatus); break; default: break; } CountService countService = new CountService(TenantTypeIds.Instance().Group()); string countTableName = countService.GetTableName_Counts(); switch (sortBy) { case SortBy_Group.DateCreated_Desc: orderSql.OrderBy("DateCreated desc"); break; case SortBy_Group.GrowthValue_Desc: orderSql.OrderBy("GrowthValue desc"); break; case SortBy_Group.MemberCount_Desc: orderSql.OrderBy("MemberCount desc"); break; case SortBy_Group.HitTimes: sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, CountTypes.Instance().HitTimes())) .On("GroupId = c.ObjectId"); orderSql.OrderBy("c.StatisticsCount desc"); break; case SortBy_Group.StageHitTimes: StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().Group()); int stageCountDays = stageCountTypeManager.GetMaxDayCount(CountTypes.Instance().HitTimes()); string stageCountType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().HitTimes(), stageCountDays); sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, stageCountType)) .On("GroupId = c.ObjectId"); orderSql.OrderBy("c.StatisticsCount desc"); break; default: orderSql.OrderBy("DateCreated desc"); break; } sql.Append(whereSql).Append(orderSql); return(sql); }
/// <summary> /// 日志详细页 /// </summary> public ActionResult Detail(string spaceKey, long threadId) { BlogThread blogThread = blogService.Get(threadId); if (blogThread == null) { return(HttpNotFound()); } if (!authorizer.BlogThread_View(blogThread)) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "没有权限", Body = "由于空间主人的权限设置,您无法浏览当前内容。", StatusMessageType = StatusMessageType.Hint }))); } long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey); if (!authorizer.IsAdministrator(BlogConfig.Instance().ApplicationId) && blogThread.UserId != currentSpaceUserId && (int)blogThread.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(BlogConfig.Instance().ApplicationId))) { return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel { Title = "尚未通过审核", Body = "由于当前日志尚未通过审核,您无法浏览当前内容。", StatusMessageType = StatusMessageType.Hint }))); } //附件信息 IEnumerable <Attachment> attachments = attachmentService.GetsByAssociateId(threadId); if (attachments != null && attachments.Count() > 0) { ViewData["attachments"] = attachments.Where(n => n.MediaType == MediaType.Other); } //更新浏览计数 CountService countService = new CountService(TenantTypeIds.Instance().BlogThread()); countService.ChangeCount(CountTypes.Instance().HitTimes(), blogThread.ThreadId, blogThread.UserId, 1, false); //设置SEO信息 pageResourceManager.InsertTitlePart(blogThread.Author); pageResourceManager.InsertTitlePart(blogThread.ResolvedSubject); List <string> keywords = new List <string>(); keywords.AddRange(blogThread.TagNames); keywords.AddRange(blogThread.OwnerCategoryNames); string keyword = string.Join(" ", keywords.Distinct()); if (!string.IsNullOrEmpty(blogThread.Keywords)) { keyword += " " + blogThread.Keywords; } pageResourceManager.SetMetaOfKeywords(keyword); if (!string.IsNullOrEmpty(blogThread.Summary)) { pageResourceManager.SetMetaOfDescription(HtmlUtility.StripHtml(blogThread.Summary, true, false)); } return(View(blogThread)); }