/// <summary> /// 动态处理程序 /// </summary> /// <param name="group"></param> /// <param name="eventArgs"></param> private void TopicEntityActivityModule_After(TopicEntity group, AuditEventArgs eventArgs) { //生成动态 ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //生成动态 { if (group == null) return; //生成Owner为用户的动态 Activity actvityOfBar = Activity.New(); actvityOfBar.ActivityItemKey = ActivityItemKeys.Instance().CreateTopic(); actvityOfBar.ApplicationId = TopicConfig.Instance().ApplicationId; actvityOfBar.IsOriginalThread = true; actvityOfBar.IsPrivate = !group.IsPublic; actvityOfBar.UserId = group.UserId; actvityOfBar.ReferenceId = 0;//没有涉及到的实体 actvityOfBar.ReferenceTenantTypeId = string.Empty; actvityOfBar.SourceId = group.TopicId; actvityOfBar.TenantTypeId = TenantTypeIds.Instance().Topic(); actvityOfBar.OwnerId = group.UserId; actvityOfBar.OwnerName = group.User.DisplayName; actvityOfBar.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfBar, true); } else if (auditDirection == false) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().Topic(), group.TopicId); } }
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="comment"></param> /// <param name="eventArgs"></param> private void BlogCommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs) { NoticeService noticeService = new NoticeService(); BlogThread blogThread = null; if (comment.TenantTypeId == TenantTypeIds.Instance().BlogThread()) { //生成动态 ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) { //创建评论的动态[关注评论者的粉丝可以看到该评论] Activity activity = Activity.New(); activity.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogComment(); activity.ApplicationId = BlogConfig.Instance().ApplicationId; BlogService blogService = new BlogService(); blogThread = blogService.Get(comment.CommentedObjectId); if (blogThread == null || blogThread.UserId == comment.UserId) { return; } activity.IsOriginalThread = true; activity.IsPrivate = false; activity.OwnerId = comment.UserId; activity.OwnerName = comment.Author; activity.OwnerType = ActivityOwnerTypes.Instance().User(); activity.ReferenceId = blogThread.ThreadId; activity.ReferenceTenantTypeId = TenantTypeIds.Instance().BlogThread(); activity.SourceId = comment.Id; activity.TenantTypeId = TenantTypeIds.Instance().Comment(); activity.UserId = comment.UserId; //是否是公开的(用于是否推送站点动态) bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false; activityService.Generate(activity, false, isPublic); //创建评论的动态[关注该日志的用户可以看到该评论] Activity activityOfBlogComment = Activity.New(); activityOfBlogComment.ActivityItemKey = activity.ActivityItemKey; activityOfBlogComment.ApplicationId = activity.ApplicationId; activityOfBlogComment.IsOriginalThread = activity.IsOriginalThread; activityOfBlogComment.IsPrivate = activity.IsPrivate; activityOfBlogComment.ReferenceId = activity.ReferenceId; activityOfBlogComment.ReferenceTenantTypeId = activity.ReferenceTenantTypeId; activityOfBlogComment.SourceId = activity.SourceId; activityOfBlogComment.TenantTypeId = activity.TenantTypeId; activityOfBlogComment.UserId = activity.UserId; activityOfBlogComment.OwnerId = blogThread.ThreadId; activityOfBlogComment.OwnerName = blogThread.ResolvedSubject; activityOfBlogComment.OwnerType = ActivityOwnerTypes.Instance().Blog(); activityService.Generate(activityOfBlogComment, false, isPublic); } else if (auditDirection == false) { activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id); } } }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="blogThread"></param> /// <param name="eventArgs"></param> private void BlogThreadActivityModule_After(BlogThread blogThread, AuditEventArgs eventArgs) { //生成动态 ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) { //初始化Owner为用户的动态 Activity activityOfUser = Activity.New(); activityOfUser.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogThread(); activityOfUser.ApplicationId = BlogConfig.Instance().ApplicationId; //判断是否有图片、音频、视频 AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().BlogThread()); IEnumerable<Attachment> attachments = attachmentService.GetsByAssociateId(blogThread.ThreadId); if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image)) { activityOfUser.HasImage = true; } activityOfUser.HasMusic = false; activityOfUser.HasVideo = false; activityOfUser.IsOriginalThread = !blogThread.IsReproduced; activityOfUser.IsPrivate = blogThread.PrivacyStatus == PrivacyStatus.Private ? true : false; activityOfUser.UserId = blogThread.UserId; activityOfUser.ReferenceId = 0; activityOfUser.ReferenceTenantTypeId = string.Empty; activityOfUser.SourceId = blogThread.ThreadId; activityOfUser.TenantTypeId = TenantTypeIds.Instance().BlogThread(); activityOfUser.OwnerId = blogThread.UserId; activityOfUser.OwnerName = blogThread.Author; activityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); //是否是公开的(用于是否推送站点动态) bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false; //生成动态 activityService.Generate(activityOfUser, true, isPublic); } //删除动态 else if (auditDirection == false) { activityService.DeleteSource(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId); } }
/// <summary> /// 微博动态 /// </summary> /// <param name="sender">微博实体</param> /// <param name="eventArgs">事件参数</param> private void MicroblogActivityModule_After(MicroblogEntity sender, AuditEventArgs eventArgs) { ActivityService activityService = new ActivityService(); bool? auditDirection = new AuditService().ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) { var microblogUrlGetter = MicroblogUrlGetterFactory.Get(sender.TenantTypeId); if (microblogUrlGetter == null) return; Activity actvity = Activity.New(); actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateMicroblog(); actvity.ApplicationId = MicroblogConfig.Instance().ApplicationId; actvity.HasImage = sender.HasPhoto; actvity.HasMusic = sender.HasMusic; actvity.HasVideo = sender.HasVideo; actvity.IsOriginalThread = !sender.IsForward; actvity.IsPrivate = false; actvity.SourceId = sender.MicroblogId; actvity.TenantTypeId = TenantTypeIds.Instance().Microblog(); actvity.UserId = sender.UserId; //生成Owner为用户的动态 if (microblogUrlGetter.ActivityOwnerType == ActivityOwnerTypes.Instance().User()) { Activity actvityOfUser = Activity.New(); actvityOfUser.ActivityItemKey = actvity.ActivityItemKey; actvityOfUser.ApplicationId = actvity.ApplicationId; actvityOfUser.HasImage = actvity.HasImage; actvityOfUser.HasMusic = actvity.HasMusic; actvityOfUser.HasVideo = actvity.HasVideo; actvityOfUser.IsOriginalThread = actvity.IsOriginalThread; actvityOfUser.IsPrivate = actvity.IsPrivate; actvityOfUser.UserId = actvity.UserId; actvityOfUser.ReferenceId = actvity.ReferenceId; actvityOfUser.SourceId = actvity.SourceId; actvityOfUser.TenantTypeId = actvity.TenantTypeId; actvityOfUser.OwnerId = sender.UserId; actvityOfUser.OwnerName = sender.User.DisplayName; actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfUser, true); } else { actvity.OwnerId = sender.OwnerId; actvity.OwnerType = microblogUrlGetter.ActivityOwnerType; actvity.OwnerName = microblogUrlGetter.GetOwnerName(sender.OwnerId); activityService.Generate(actvity, false); //生成Owner为用户的动态 if (!microblogUrlGetter.IsPrivate(sender.OwnerId)) { Activity actvityOfUser = Activity.New(); actvityOfUser.ActivityItemKey = actvity.ActivityItemKey; actvityOfUser.ApplicationId = actvity.ApplicationId; actvityOfUser.HasImage = actvity.HasImage; actvityOfUser.HasMusic = actvity.HasMusic; actvityOfUser.HasVideo = actvity.HasVideo; actvityOfUser.IsOriginalThread = actvity.IsOriginalThread; actvityOfUser.IsPrivate = actvity.IsPrivate; actvityOfUser.UserId = actvity.UserId; actvityOfUser.ReferenceId = actvity.ReferenceId; actvityOfUser.SourceId = actvity.SourceId; actvityOfUser.TenantTypeId = actvity.TenantTypeId; actvityOfUser.OwnerId = sender.UserId; actvityOfUser.OwnerName = sender.User.DisplayName; actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfUser, false); } } } else if (auditDirection == false) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().Microblog(), sender.MicroblogId); } }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="barThread"></param> /// <param name="eventArgs"></param> private void BarThreadActivityModule_After(BarThread barThread, AuditEventArgs eventArgs) { //1、通过审核的内容才生成动态;(不满足) //2、把通过审核的内容设置为未通过审核或者删除内容,需要移除动态;(不满足) //3、把未通过审核的内容通过审核,需要添加动态; (不满足) //4、详见动态需求说明 //生成动态 ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //生成动态 { if (barThread.BarSection == null) return; var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId); if (barUrlGetter == null) return; //生成Owner为帖吧的动态 Activity actvityOfBar = Activity.New(); actvityOfBar.ActivityItemKey = ActivityItemKeys.Instance().CreateBarThread(); actvityOfBar.ApplicationId = BarConfig.Instance().ApplicationId; AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().BarThread()); IEnumerable<Attachment> attachments = attachmentService.GetsByAssociateId(barThread.ThreadId); if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image)) actvityOfBar.HasImage = true; actvityOfBar.IsOriginalThread = true; actvityOfBar.IsPrivate = false; actvityOfBar.UserId = barThread.UserId; actvityOfBar.ReferenceId = 0;//没有涉及到的实体 actvityOfBar.ReferenceTenantTypeId = string.Empty; actvityOfBar.SourceId = barThread.ThreadId; actvityOfBar.TenantTypeId = TenantTypeIds.Instance().BarThread(); actvityOfBar.OwnerId = barThread.SectionId; actvityOfBar.OwnerName = barThread.BarSection.Name; actvityOfBar.OwnerType = barUrlGetter.ActivityOwnerType; activityService.Generate(actvityOfBar, false); if (!barUrlGetter.IsPrivate(barThread.SectionId)) { //生成Owner为用户的动态 Activity actvityOfUser = Activity.New(); actvityOfUser.ActivityItemKey = actvityOfBar.ActivityItemKey; actvityOfUser.ApplicationId = actvityOfBar.ApplicationId; actvityOfUser.HasImage = actvityOfBar.HasImage; actvityOfUser.HasMusic = actvityOfBar.HasMusic; actvityOfUser.HasVideo = actvityOfBar.HasVideo; actvityOfUser.IsOriginalThread = actvityOfBar.IsOriginalThread; actvityOfUser.IsPrivate = actvityOfBar.IsPrivate; actvityOfUser.UserId = actvityOfBar.UserId; actvityOfUser.ReferenceId = actvityOfBar.ReferenceId; actvityOfUser.SourceId = actvityOfBar.SourceId; actvityOfUser.TenantTypeId = actvityOfBar.TenantTypeId; actvityOfUser.OwnerId = barThread.UserId; actvityOfUser.OwnerName = barThread.User.DisplayName; actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfUser, false); } } else if (auditDirection == false) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().BarThread(), barThread.ThreadId); } }
/// <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); } }
/// <summary> /// 动态处理程序 /// </summary> /// <param name="groupMember"></param> /// <param name="eventArgs"></param> private void GroupMemberActivityModule_After(GroupMember groupMember, CommonEventArgs eventArgs) { ActivityService activityService = new ActivityService(); if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { //生成动态 if (groupMember == null) return; var group = new GroupService().Get(groupMember.GroupId); if (group == null) return; //生成Owner为群组的动态 Activity actvityOfGroup = Activity.New(); actvityOfGroup.ActivityItemKey = ActivityItemKeys.Instance().CreateGroupMember(); actvityOfGroup.ApplicationId = GroupConfig.Instance().ApplicationId; actvityOfGroup.IsOriginalThread = true; actvityOfGroup.IsPrivate = !group.IsPublic; actvityOfGroup.UserId = groupMember.UserId; actvityOfGroup.ReferenceId = 0; actvityOfGroup.ReferenceTenantTypeId = string.Empty; actvityOfGroup.SourceId = groupMember.Id; actvityOfGroup.TenantTypeId = TenantTypeIds.Instance().User(); actvityOfGroup.OwnerId = group.GroupId; actvityOfGroup.OwnerName = group.GroupName; actvityOfGroup.OwnerType = ActivityOwnerTypes.Instance().Group(); activityService.Generate(actvityOfGroup, false); //生成Owner为用户的动态 Activity actvityOfUser = Activity.New(); actvityOfUser.ActivityItemKey = ActivityItemKeys.Instance().JoinGroup(); actvityOfUser.ApplicationId = actvityOfGroup.ApplicationId; actvityOfUser.HasImage = actvityOfGroup.HasImage; actvityOfUser.HasMusic = actvityOfGroup.HasMusic; actvityOfUser.HasVideo = actvityOfGroup.HasVideo; actvityOfUser.IsOriginalThread = actvityOfGroup.IsOriginalThread; actvityOfUser.IsPrivate = actvityOfGroup.IsPrivate; actvityOfUser.UserId = actvityOfGroup.UserId; actvityOfUser.ReferenceId = actvityOfGroup.ReferenceId; actvityOfGroup.ReferenceTenantTypeId = actvityOfGroup.ReferenceTenantTypeId; actvityOfUser.SourceId = actvityOfGroup.SourceId; actvityOfUser.TenantTypeId = actvityOfGroup.TenantTypeId; actvityOfUser.OwnerId = groupMember.UserId; actvityOfUser.OwnerName = groupMember.User.DisplayName; actvityOfUser.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(actvityOfUser, false); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) //删除动态 { activityService.DeleteSource(TenantTypeIds.Instance().User(), groupMember.UserId); } }