/// <summary> /// 详细页面地址 /// </summary> /// <param name="itemId">推荐内容Id</param> /// <returns></returns> public string RecommendItemDetail(long itemId) { BarThread barThread = new BarThreadService().Get(itemId); if (barThread == null) return string.Empty; return SiteUrls.Instance().ThreadDetail(itemId); }
/// <summary> /// 删除用户记录(删除用户时使用) /// </summary> /// <param name="userId">被删除用户</param> /// <param name="takeOverUserName">接管用户名</param> /// <param name="takeOverAll">是否接管被删除用户的所有内容</param> public void DeleteUser(long userId, string takeOverUserName, bool takeOverAll) { long takeOverUserId = UserIdToUserNameDictionary.GetUserId(takeOverUserName); IUserService userService = DIContainer.Resolve <IUserService>(); User takeOver = userService.GetFullUser(takeOverUserId); BarSectionService barSectionService = new BarSectionService(); BarThreadService barThreadService = new BarThreadService(); BarPostService barPostService = new BarPostService(); //删除用户时,不删除贴吧,把贴吧转让,如果没有指定转让人,那就转给网站初始管理员 if (takeOver == null) { takeOverUserId = new SystemDataService().GetLong("Founder"); takeOver = userService.GetFullUser(takeOverUserId); } barThreadRepository.DeleteUser(userId, takeOver, takeOverAll); if (takeOver != null) { if (!takeOverAll) { barThreadService.DeletesByUserId(userId); barPostService.DeletesByUserId(userId); } } //else //{ // barSectionService.DeletesByUserId(userId); // barThreadService.DeletesByUserId(userId); // barPostService.DeletesByUserId(userId); //} }
/// <summary> /// body是否有显示的权限(主要是针对于回复可见的情况) /// </summary> /// <param name="authorizer"></param> /// <param name="threadId"></param> /// <returns></returns> public static bool BarThread_BodyShow(this Authorizer authorizer, long threadId) { BarThreadService service = new BarThreadService(); BarPostService barPostService = new Bar.BarPostService(); BarThread thread = service.Get(threadId); if (thread == null) { return(false); } if (!thread.IsHidden) { return(true); } if (barPostService.IsPosted(UserContext.CurrentUser == null ? 0 : UserContext.CurrentUser.UserId, threadId)) { return(true); } return(BarThread_Edit(authorizer, thread)); }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarPostActivityModule_After(BarPost sender, AuditEventArgs eventArgs) { ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //生成动态 { BarThreadService barThreadService = new BarThreadService(); BarThread barThread = barThreadService.Get(sender.ThreadId); if (barThread == null) return; if (sender.UserId == barThread.UserId) return; var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId); if (barUrlGetter == null) return; if (sender.ParentId > 0) { BarPost parentPost = new BarPostService().Get(sender.ParentId); if (parentPost == null) return; if (parentPost.UserId == sender.UserId) return; } Activity actvity = Activity.New(); actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateBarPost(); actvity.ApplicationId = BarConfig.Instance().ApplicationId; //仅一级回复可以上传附件 if (sender.ParentId == 0) { AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().BarPost()); IEnumerable<Attachment> attachments = attachmentService.GetsByAssociateId(sender.PostId); if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image)) actvity.HasImage = true; //actvity.HasMusic = barThread.HasMusic; //actvity.HasVideo = barThread.HasVideo; } actvity.IsOriginalThread = true; actvity.IsPrivate = barUrlGetter.IsPrivate(barThread.SectionId); actvity.OwnerId = barThread.SectionId; actvity.OwnerName = barThread.BarSection.Name; actvity.OwnerType = barUrlGetter.ActivityOwnerType; actvity.ReferenceId = barThread.ThreadId; actvity.ReferenceTenantTypeId = TenantTypeIds.Instance().BarThread(); actvity.SourceId = sender.PostId; actvity.TenantTypeId = TenantTypeIds.Instance().BarPost(); actvity.UserId = sender.UserId; //创建从属内容,不向自己的动态收件箱推送动态 activityService.Generate(actvity, false); } else if (auditDirection == false) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().BarPost(), sender.PostId); } }
public string ThreadDetail(long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1, long? anchorPostId = null, bool isAnchorPostList = false, long? childPostIndex = null) { BarThread thread = new BarThreadService().Get(threadId); if (thread == null) return string.Empty; string spaceKey = TopicIdToTopicKeyDictionary.GetTopicKey(thread.SectionId); if (string.IsNullOrEmpty(spaceKey)) return string.Empty; return SiteUrls.Instance().TopicThreadDetail(spaceKey, threadId, onlyLandlord, sortBy, pageIndex, anchorPostId, isAnchorPostList, childPostIndex); }
/// <summary> /// �༭����ҳ�� /// </summary> /// <param name="threadId">����id</param> /// <param name="postId">����id</param> /// <returns>�༭����ҳ��</returns> public string EditPost(long threadId, long? postId = null) { BarThread thread = new BarThreadService().Get(threadId); if (thread == null) return string.Empty; string spaceKey = GroupIdToGroupKeyDictionary.GetGroupKey(thread.SectionId); if (string.IsNullOrEmpty(spaceKey)) return string.Empty; return SiteUrls.Instance().GroupEditPost(spaceKey, threadId, postId); }
/// <summary> /// 详细页面地址 /// </summary> /// <param name="itemId">推荐内容Id</param> /// <returns></returns> public string RecommendItemDetail(long itemId) { BarThread barThread = new BarThreadService().Get(itemId); if (barThread == null) { return(string.Empty); } return(SiteUrls.Instance().ThreadDetail(itemId)); }
/// <summary> /// 是否具有编辑帖子的权限 /// </summary> /// <param name="authorizer"></param> /// <param name="threadId">帖子的id</param> /// <returns>是否具有对应的权限</returns> public static bool BarThread_Edit(this Authorizer authorizer, long threadId) { BarThreadService service = new BarThreadService(); BarThread thread = service.Get(threadId); if (thread == null) { return(false); } return(BarThread_Edit(authorizer, thread)); }
/// <summary> /// 获取被评论对象名称 /// </summary> /// <param name="commentedObjectId">被评论对象Id</param> /// <param name="tenantTypeId">租户类型Id</param> /// <returns></returns> public string GetCommentedObjectName(long commentedObjectId, string tenantTypeId) { if (tenantTypeId == TenantTypeIds.Instance().BarThread()) { BarThread barThread = new BarThreadService().Get(commentedObjectId); if (barThread != null) { return barThread.Subject; } } return string.Empty; }
/// <summary> /// 获取主题帖的回帖排行分页集合 /// </summary> /// <param name="threadId">主题帖Id</param> /// <param name="onlyStarter">仅看楼主</param> /// <param name="sortBy">回帖排序依据(默认为按创建时间正序排序)</param> /// <param name="pageIndex">页码</param> /// <returns>回复贴列表</returns> public PagingDataSet <BarPost> Gets(long threadId, bool onlyStarter = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1) { BarThread thread = new BarThreadService().Get(threadId); long starterId = 0; if (thread != null) { starterId = thread.UserId; } return(barPostRepository.Gets(threadId, onlyStarter, starterId, sortBy, pageIndex)); }
/// <summary> /// 获取被评论对象名称 /// </summary> /// <param name="commentedObjectId">被评论对象Id</param> /// <param name="tenantTypeId">租户类型Id</param> /// <returns></returns> public string GetCommentedObjectName(long commentedObjectId, string tenantTypeId) { if (tenantTypeId == TenantTypeIds.Instance().BarThread()) { BarThread barThread = new BarThreadService().Get(commentedObjectId); if (barThread != null) { return(barThread.Subject); } } return(string.Empty); }
/// <summary> /// 转换成BarPost类型 /// </summary> /// <returns></returns> public BarPost AsBarPost() { BarThread thread = new BarThreadService().Get(this.ThreadId); BarPostService service = new BarPostService(); BarPost post = null; //编辑的情况 if (this.PostId.HasValue) { post = service.Get(this.PostId ?? 0); if (post == null) { return(null); } } else { //创建的情况 post = BarPost.New(); post.AuditStatus = AuditStatus.Success; post.TenantTypeId = thread.TenantTypeId; post.ThreadId = this.ThreadId; if (UserContext.CurrentUser != null) { post.UserId = UserContext.CurrentUser.UserId; post.Author = UserContext.CurrentUser.DisplayName; } else { post.UserId = 0; post.Author = "匿名用户"; } post.OwnerId = thread == null ? 0 : thread.OwnerId; post.SectionId = thread == null ? 0 : thread.SectionId; post.ParentId = this.ParentId; } if (!string.IsNullOrEmpty(this.Body)) { post.Body = this.Body; } else { this.MultilineBody = WebUtility.HtmlEncode(this.MultilineBody); this.MultilineBody = new EmotionService().EmoticonTransforms(this.MultilineBody); post.Body = this.MultilineBody; } return(post); }
public CommentedObject GetCommentedObject(long commentedObjectId) { BarThread barThread = new BarThreadService().Get(commentedObjectId); if (barThread != null) { CommentedObject commentedObject = new CommentedObject(); commentedObject.DetailUrl = SiteUrls.Instance().ThreadDetail(commentedObjectId); commentedObject.Name = barThread.Subject; commentedObject.Author = barThread.Author; commentedObject.UserId = barThread.UserId; return commentedObject; } return null; }
/// <summary> /// 删除帖吧 /// </summary> /// <param name="sectionId">帖吧Id</param> public void Delete(long sectionId) { BarSection section = barSectionRepository.Get(sectionId); if (section == null) { return; } EventBus <BarSection> .Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Delete())); //帖子 BarThreadService barThreadService = new BarThreadService(); barThreadService.DeletesBySectionId(sectionId); CategoryService categoryService = new CategoryService(); //帖吧分类 categoryService.ClearCategoriesFromItem(sectionId, null, TenantTypeIds.Instance().BarSection()); //帖子分类 var categories = categoryService.GetRootCategories(TenantTypeIds.Instance().BarThread(), sectionId); foreach (var category in categories) { categoryService.Delete(category.CategoryId); } //帖吧标签 TagService tagService = new TagService(TenantTypeIds.Instance().BarThread()); tagService.ClearTagsFromOwner(sectionId); //删除Logo DeleteLogo(sectionId); //删除推荐记录 RecommendService recommendService = new RecommendService(); recommendService.Delete(sectionId, TenantTypeIds.Instance().BarSection()); int affectCount = barSectionRepository.Delete(section); if (affectCount > 0) { EventBus <BarSection> .Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Delete())); EventBus <BarSection, AuditEventArgs> .Instance().OnAfter(section, new AuditEventArgs(null, section.AuditStatus)); } }
/// <summary> /// 数据库中的对象转换为EditModel /// </summary> /// <returns></returns> public static BarPostEditModel AsEditModel(this BarPost post) { BarSettings barSettings = DIContainer.Resolve <ISettingsManager <BarSettings> >().Get(); BarThread thread = new BarThreadService().Get(post.ThreadId); return(new BarPostEditModel { Body = post.GetBody(), ParentId = post.ParentId, PostId = post.PostId, Subject = thread.Subject, ThreadId = post.ThreadId, SectionId = post.SectionId }); }
public CommentedObject GetCommentedObject(long commentedObjectId) { BarThread barThread = new BarThreadService().Get(commentedObjectId); if (barThread != null) { CommentedObject commentedObject = new CommentedObject(); commentedObject.DetailUrl = SiteUrls.Instance().ThreadDetail(commentedObjectId); commentedObject.Name = barThread.Subject; commentedObject.Author = barThread.Author; commentedObject.UserId = barThread.UserId; return(commentedObject); } return(null); }
/// <summary> /// 编辑回帖页面 /// </summary> /// <param name="threadId">帖子id</param> /// <param name="postId">回帖id</param> /// <returns>编辑回帖页面</returns> public string EditPost(long threadId, long?postId = null) { BarThread thread = new BarThreadService().Get(threadId); if (thread == null) { return(string.Empty); } string spaceKey = GroupIdToGroupKeyDictionary.GetGroupKey(thread.SectionId); if (string.IsNullOrEmpty(spaceKey)) { return(string.Empty); } return(SiteUrls.Instance().GroupEditPost(spaceKey, threadId, postId)); }
public string ThreadDetail(long threadId, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, int pageIndex = 1, long?anchorPostId = null, bool isAnchorPostList = false, long?childPostIndex = null) { BarThread thread = new BarThreadService().Get(threadId); if (thread == null) { return(string.Empty); } string spaceKey = GroupIdToGroupKeyDictionary.GetGroupKey(thread.SectionId); if (string.IsNullOrEmpty(spaceKey)) { return(string.Empty); } return(SiteUrls.Instance().GroupThreadDetail(spaceKey, threadId, onlyLandlord, sortBy, pageIndex, anchorPostId, isAnchorPostList, childPostIndex)); }
public AssociatedInfo GetAssociatedInfo(long associateId, string tenantTypeId = "") { BarThreadService barService = new BarThreadService(); BarThread barThread = new BarThreadService().Get(associateId); if (barThread != null) { IBarUrlGetter urlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId); return new AssociatedInfo() { DetailUrl = urlGetter.ThreadDetail(barThread.ThreadId), Subject = barThread.Subject }; } return null; }
public AssociatedInfo GetAssociatedInfo(long associateId, string tenantTypeId = "") { BarThreadService barService = new BarThreadService(); BarThread barThread = new BarThreadService().Get(associateId); if (barThread != null) { IBarUrlGetter urlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId); return(new AssociatedInfo() { DetailUrl = urlGetter.ThreadDetail(barThread.ThreadId), Subject = barThread.Subject }); } return(null); }
/// <summary> /// 将ViewModel转换成数据库存储实体 /// </summary> /// <returns></returns> public BarThread AsBarThread() { BarThreadService barThreadService = new BarThreadService(); BarSectionService barSectionService = new BarSectionService(); BarThread barThread = null; if (this.ThreadId > 0) { barThread = barThreadService.Get(this.ThreadId); } else { barThread = BarThread.New(); barThread.UserId = UserContext.CurrentUser.UserId; barThread.Author = UserContext.CurrentUser.DisplayName; } if (barThread == null) { return(barThread); } barThread.SectionId = this.SectionId; if (this.StickyDate.CompareTo(DateTime.UtcNow) > 0) { barThread.StickyDate = this.StickyDate; } barThread.Subject = this.Subject; barThread.Body = this.Body; barThread.IsHidden = this.IsHidden; barThread.IsEssential = this.IsEssential; barThread.IsSticky = this.IsSticky; barThread.LastModified = DateTime.UtcNow; barThread.TenantTypeId = TenantTypeIds.Instance().Bar(); BarSection barSection = barSectionService.Get(this.SectionId); if (barSection != null) { barThread.OwnerId = barSection.OwnerId; barThread.TenantTypeId = barSection.TenantTypeId; } return(barThread); }
/// <summary> /// 创建评分 /// </summary> /// <param name="rating">评分</param> /// <returns>true-评分成功,false-评分失败(可能今日评分已超过限额)</returns> public bool Create(BarRating rating) { BarThreadService barThreadService = new BarThreadService(); BarThread thread = barThreadService.Get(rating.ThreadId); EventBus<BarRating>.Instance().OnBefore(rating, new CommonEventArgs(EventOperationType.Instance().Create())); bool result = false; bool.TryParse(barRatingRepository.Insert(rating).ToString(), out result); if (result) { //给楼主加威望/交易积分 IUserService userService = DIContainer.Resolve<IUserService>(); userService.ChangePoints(thread.UserId, 0, rating.ReputationPoints, rating.TradePoints); PointService pointService = new PointService(); pointService.CreateRecord(thread.UserId, "帖子评分", "发布的帖子被其他用户评分", 0, rating.ReputationPoints, rating.TradePoints); EventBus<BarRating>.Instance().OnAfter(rating, new CommonEventArgs(EventOperationType.Instance().Create())); } return result; }
void BarRatingEventModule_After(BarRating sender, CommonEventArgs eventArgs) { ActivityService activityService = new ActivityService(); if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { Activity actvity = Activity.New(); actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateBarRating(); actvity.ApplicationId = BarConfig.Instance().ApplicationId; BarThreadService barThreadService = new BarThreadService(); BarThread barThread = barThreadService.Get(sender.ThreadId); if (barThread == null) return; var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId); if (barUrlGetter == null) return; actvity.IsOriginalThread = true; actvity.IsPrivate = barUrlGetter.IsPrivate(barThread.SectionId); actvity.OwnerId = barThread.SectionId; actvity.OwnerName = barThread.BarSection.Name; actvity.OwnerType = barUrlGetter.ActivityOwnerType; actvity.ReferenceId = barThread.ThreadId; actvity.ReferenceTenantTypeId = TenantTypeIds.Instance().BarThread(); actvity.SourceId = sender.RatingId; actvity.TenantTypeId = TenantTypeIds.Instance().BarRating(); actvity.UserId = sender.UserId; //自己回复自己时,不向自己的动态收件箱推送动态 if (actvity.UserId == barThread.UserId) activityService.Generate(actvity, false); else activityService.Generate(actvity, true); } else { activityService.DeleteSource(TenantTypeIds.Instance().BarRating(), sender.RatingId); } }
/// <summary> /// 创建评分 /// </summary> /// <param name="rating">评分</param> /// <returns>true-评分成功,false-评分失败(可能今日评分已超过限额)</returns> public bool Create(BarRating rating) { BarThreadService barThreadService = new BarThreadService(); BarThread thread = barThreadService.Get(rating.ThreadId); EventBus <BarRating> .Instance().OnBefore(rating, new CommonEventArgs(EventOperationType.Instance().Create())); bool result = false; bool.TryParse(barRatingRepository.Insert(rating).ToString(), out result); if (result) { //给楼主加威望/交易积分 IUserService userService = DIContainer.Resolve <IUserService>(); userService.ChangePoints(thread.UserId, 0, rating.ReputationPoints, rating.TradePoints); PointService pointService = new PointService(); pointService.CreateRecord(thread.UserId, "帖子评分", "发布的帖子被其他用户评分", 0, rating.ReputationPoints, rating.TradePoints); EventBus <BarRating> .Instance().OnAfter(rating, new CommonEventArgs(EventOperationType.Instance().Create())); } return(result); }
/// <summary> /// 任务执行的内容 /// </summary> /// <param name="taskDetail">任务配置状态信息</param> public void Execute(TaskDetail taskDetail) { BarThreadService barThreadService = new BarThreadService(); barThreadService.ExpireStickyThreads(); }
/// <summary> /// 将ViewModel转换成数据库存储实体 /// </summary> /// <returns></returns> public BarThread AsBarThread() { BarThreadService barThreadService = new BarThreadService(); BarSectionService barSectionService = new BarSectionService(); BarThread barThread = null; if (this.ThreadId > 0) { barThread = barThreadService.Get(this.ThreadId); } else { barThread = BarThread.New(); barThread.UserId = UserContext.CurrentUser.UserId; barThread.Author = UserContext.CurrentUser.DisplayName; } if (barThread == null) return barThread; barThread.SectionId = this.SectionId; if (this.StickyDate.CompareTo(DateTime.UtcNow) > 0) barThread.StickyDate = this.StickyDate; barThread.Subject = this.Subject; barThread.Body = this.Body; barThread.IsHidden = this.IsHidden; barThread.IsEssential = this.IsEssential; barThread.IsSticky = this.IsSticky; barThread.LastModified = DateTime.UtcNow; barThread.TenantTypeId = TenantTypeIds.Instance().Bar(); BarSection barSection = barSectionService.Get(this.SectionId); if (barSection != null) { barThread.OwnerId = barSection.OwnerId; barThread.TenantTypeId = barSection.TenantTypeId; } return barThread; }
/// <summary> /// 转换成BarPost类型 /// </summary> /// <returns></returns> public BarPost AsBarPost() { BarThread thread = new BarThreadService().Get(this.ThreadId); BarPostService service = new BarPostService(); BarPost post = null; //编辑的情况 if (this.PostId.HasValue) { post = service.Get(this.PostId ?? 0); if (post == null) return null; } else { //创建的情况 post = BarPost.New(); post.AuditStatus = AuditStatus.Success; post.TenantTypeId = thread.TenantTypeId; post.ThreadId = this.ThreadId; if (UserContext.CurrentUser != null) { post.UserId = UserContext.CurrentUser.UserId; post.Author = UserContext.CurrentUser.DisplayName; } else { post.UserId = 0; post.Author = "匿名用户"; } post.OwnerId = thread == null ? 0 : thread.OwnerId; post.SectionId = thread == null ? 0 : thread.SectionId; post.ParentId = this.ParentId; } if (!string.IsNullOrEmpty(this.Body)) { post.Body = this.Body; } else { this.MultilineBody = WebUtility.HtmlEncode(this.MultilineBody); this.MultilineBody = new EmotionService().EmoticonTransforms(this.MultilineBody); post.Body = this.MultilineBody; } return post; }
/// <summary> /// 数据库中的对象转换为EditModel /// </summary> /// <returns></returns> public static BarPostEditModel AsEditModel(this BarPost post) { BarSettings barSettings = DIContainer.Resolve<ISettingsManager<BarSettings>>().Get(); BarThread thread = new BarThreadService().Get(post.ThreadId); return new BarPostEditModel { Body = post.GetBody(), ParentId = post.ParentId, PostId = post.PostId, Subject = thread.Subject, ThreadId = post.ThreadId, SectionId = post.SectionId }; }
/// <summary> /// 删除用户记录(删除用户时使用) /// </summary> /// <param name="userId">被删除用户</param> /// <param name="takeOverUserName">接管用户名</param> /// <param name="takeOverAll">是否接管被删除用户的所有内容</param> public void DeleteUser(long userId, string takeOverUserName, bool takeOverAll) { long takeOverUserId = UserIdToUserNameDictionary.GetUserId(takeOverUserName); IUserService userService = DIContainer.Resolve<IUserService>(); User takeOver = userService.GetFullUser(takeOverUserId); BarSectionService barSectionService = new BarSectionService(); BarThreadService barThreadService = new BarThreadService(); BarPostService barPostService = new BarPostService(); //删除用户时,不删除贴吧,把贴吧转让,如果没有指定转让人,那就转给网站初始管理员 if (takeOver == null) { takeOverUserId = new SystemDataService().GetLong("Founder"); takeOver = userService.GetFullUser(takeOverUserId); } barThreadRepository.DeleteUser(userId, takeOver, takeOverAll); if (takeOver != null) { if (!takeOverAll) { barThreadService.DeletesByUserId(userId); barPostService.DeletesByUserId(userId); } } //else //{ // barSectionService.DeletesByUserId(userId); // barThreadService.DeletesByUserId(userId); // barPostService.DeletesByUserId(userId); //} }
/// <summary> /// 任务执行的内容 /// </summary> /// <param name="taskDetail">任务配置状态信息</param> public void Execute(TaskDetail taskDetail) { BarThreadService barThreadService = new BarThreadService(); barThreadService.ExpireStickyThreads(); }
/// <summary> /// 是否具有删除BarThread的权限 /// </summary> /// <param name="threadId"></param> /// <returns></returns> public static bool BarThread_Delete(this Authorizer authorizer, long threadId) { BarThread thread = new BarThreadService().Get(threadId); return authorizer.BarThread_Delete(thread); }
/// <summary> /// 是否具有编辑帖子的权限 /// </summary> /// <param name="authorizer"></param> /// <param name="threadId">帖子的id</param> /// <returns>是否具有对应的权限</returns> public static bool BarThread_Edit(this Authorizer authorizer, long threadId) { BarThreadService service = new BarThreadService(); BarThread thread = service.Get(threadId); if (thread == null) return false; return BarThread_Edit(authorizer, thread); }
/// <summary> /// 删除用户在应用中的数据 /// </summary> /// <param name="userId">用户Id</param> /// <param name="takeOverUserName">用于接管删除用户时不能删除的内容(例如:用户创建的群组)</param> /// <param name="isTakeOver">是否接管被删除用户可被接管的内容</param> protected override void DeleteUser(long userId, string takeOverUserName, bool isTakeOver) { BarThreadService barThreadService = new BarThreadService(); barThreadService.DeleteUser(userId, takeOverUserName, isTakeOver); }
/// <summary> /// body是否有显示的权限(主要是针对于回复可见的情况) /// </summary> /// <param name="authorizer"></param> /// <param name="threadId"></param> /// <returns></returns> public static bool BarThread_BodyShow(this Authorizer authorizer, long threadId) { BarThreadService service = new BarThreadService(); BarPostService barPostService = new Bar.BarPostService(); BarThread thread = service.Get(threadId); if (thread == null) return false; if (!thread.IsHidden) return true; if (barPostService.IsPosted(UserContext.CurrentUser == null ? 0 : UserContext.CurrentUser.UserId, threadId)) return true; //todo:需要判断是否已经留言过 return BarThread_Edit(authorizer, thread); }
/// <summary> /// 通知处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarPostNoticeModule_After(BarPost sender, AuditEventArgs eventArgs) { AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //创建回帖发通知 { BarThreadService barThreadService = new BarThreadService(); BarThread barThread = barThreadService.Get(sender.ThreadId); if (barThread == null) return; long toUserId = barThread.UserId; //自己给自己的帖子进行回帖,不必通知 if (sender.UserId == barThread.UserId) return; if (sender.ParentId > 0) { BarPostService barPostService = new BarPostService(); BarPost parentPost = barPostService.Get(sender.ParentId); if (parentPost == null || (parentPost.UserId == sender.UserId)) return; toUserId = parentPost.UserId; } NoticeService noticeService = Tunynet.DIContainer.Resolve<NoticeService>(); Notice notice = Notice.New(); notice.UserId = toUserId; notice.ApplicationId = BarConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Reply(); notice.LeadingActorUserId = sender.UserId; notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectId = sender.PostId; notice.RelativeObjectName = HtmlUtility.TrimHtml(barThread.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetailGotoPost(sender.PostId)); notice.TemplateName = NoticeTemplateNames.Instance().NewReply(); noticeService.Create(notice); } }
/// <summary> /// 删除群组是删除贴吧相关的 /// </summary> /// <param name="group"></param> /// <param name="eventArgs"></param> private void DeleteGroup_Before(GroupEntity group, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { BarPostService barPostService = new BarPostService(); BarThreadService barThreadService = new BarThreadService(); PagingDataSet<BarThread> barThreads = barThreadService.Gets(group.GroupId); new BarSectionService().Delete(group.GroupId); barThreadService.DeletesBySectionId(group.GroupId); foreach (var barThread in barThreads) { barPostService.DeletesByThreadId(barThread.ThreadId); } } }
/// <summary> /// 删除帖吧 /// </summary> /// <param name="sectionId">帖吧Id</param> public void Delete(long sectionId) { BarSection section = barSectionRepository.Get(sectionId); if (section == null) return; EventBus<BarSection>.Instance().OnBefore(section, new CommonEventArgs(EventOperationType.Instance().Delete())); //帖子 BarThreadService barThreadService = new BarThreadService(); barThreadService.DeletesBySectionId(sectionId); CategoryService categoryService = new CategoryService(); //帖吧分类 categoryService.ClearCategoriesFromItem(sectionId, null, TenantTypeIds.Instance().BarSection()); //帖子分类 var categories = categoryService.GetRootCategories(TenantTypeIds.Instance().BarThread(), sectionId); foreach (var category in categories) { categoryService.Delete(category.CategoryId); } //帖吧标签 TagService tagService = new TagService(TenantTypeIds.Instance().BarThread()); tagService.ClearTagsFromOwner(sectionId); //删除Logo DeleteLogo(sectionId); //删除推荐记录 RecommendService recommendService = new RecommendService(); recommendService.Delete(sectionId, TenantTypeIds.Instance().BarSection()); int affectCount = barSectionRepository.Delete(section); if (affectCount > 0) { EventBus<BarSection>.Instance().OnAfter(section, new CommonEventArgs(EventOperationType.Instance().Delete())); EventBus<BarSection, AuditEventArgs>.Instance().OnAfter(section, new AuditEventArgs(null, section.AuditStatus)); } }
/// <summary> /// 是否具有删除BarThread的权限 /// </summary> /// <param name="threadId"></param> /// <returns></returns> public static bool BarThread_Delete(this Authorizer authorizer, long threadId) { BarThread thread = new BarThreadService().Get(threadId); return(authorizer.BarThread_Delete(thread)); }
/// <summary> /// 删除用户在应用中的数据 /// </summary> /// <param name="userId">用户Id</param> /// <param name="takeOverUserName">用于接管删除用户时不能删除的内容(例如:用户创建的群组)</param> /// <param name="isTakeOver">是否接管被删除用户可被接管的内容</param> protected override void DeleteUser(long userId, string takeOverUserName, bool isTakeOver) { BarThreadService barThreadService = new BarThreadService(); barThreadService.DeleteUser(userId, takeOverUserName, isTakeOver); }