/// <summary> /// 顶踩的积分处理 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void SupportEventModule_After(long objectId, SupportOpposeEventArgs eventArgs) { //如果不是第一次顶踩,则不处理 if (!eventArgs.FirstTime) { return; } //处理积分和威望 string pointItemKey = PointItemKeys.Instance().CreateEvaluation(); if (eventArgs.EventOperationType == EventOperationType.Instance().Support()) { //顶时产生积分 string eventOperationType = EventOperationType.Instance().Support(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "内容"); pointService.GenerateByRole(eventArgs.UserId, pointItemKey, description); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Oppose()) { //踩时产生积分 string eventOperationType = EventOperationType.Instance().Oppose(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "内容"); pointService.GenerateByRole(eventArgs.UserId, pointItemKey, description); } }
/// <summary> /// 处理加精操作加积分 /// </summary> /// <param name="blogThread">日志</param> /// <param name="eventArgs">事件</param> private void BlogThreadPointModuleForManagerOperation_After(BlogThread blogThread, CommonEventArgs eventArgs) { NoticeService noticeService = new NoticeService(); string pointItemKey = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()) { pointItemKey = PointItemKeys.Instance().EssentialContent(); PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "日志", blogThread.ResolvedSubject); pointService.GenerateByRole(blogThread.UserId, pointItemKey, description); if (blogThread.UserId > 0) { Notice notice = Notice.New(); notice.UserId = blogThread.UserId; notice.ApplicationId = BlogConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = blogThread.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(blogThread.UserId))); notice.RelativeObjectName = HtmlUtility.TrimHtml(blogThread.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().BlogDetail(blogThread.User.UserName, blogThread.ThreadId)); notice.TemplateName = NoticeTemplateNames.Instance().ManagerSetEssential(); noticeService.Create(notice); } } }
/// <summary> /// 评论的积分处理 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void CommentCreatAndDeleteEventModel_After(Comment sender, CommonEventArgs eventArgs) { PointService pointService = new PointService(); if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_CreateComment"), sender.Author, sender.Subject); pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().CreateComment(), description, true); } if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_DeleteComment"), sender.Author, sender.Subject); pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().DeleteComment(), description, true); } }
/// <summary> /// 用户积分处理 /// </summary> /// <param name="sender">关注实体</param> /// <param name="eventArgs">事件参数</param> void FollowPointModule_After(FollowEntity sender, CommonEventArgs eventArgs) { IUserService userservice = DIContainer.Resolve <IUserService>(); IUser followedUser = userservice.GetUser(sender.FollowedUserId); if (followedUser == null) { return; } string pointItemKey = string.Empty; PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_FollowUser"), followedUser.DisplayName); #region 设置积分项Key if (EventOperationType.Instance().Create() == eventArgs.EventOperationType) { pointItemKey = PointItemKeys.Instance().FollowUser(); } else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType) { pointItemKey = PointItemKeys.Instance().CancelFollowUser(); } #endregion pointService.GenerateByRole(sender.UserId, pointItemKey, description); }
/// <summary> /// 批量关注积分处理 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void BatchFollowPointModule_After(int sender, BatchFollowEventArgs eventArgs) { if (EventOperationType.Instance().Create() == eventArgs.EventOperationType && sender > 0) { string pointItemKey = string.Empty; pointItemKey = PointItemKeys.Instance().FollowUser(); PointService pointService = new PointService(); for (int i = 0; i < sender; i++) { pointService.GenerateByRole(eventArgs.UserId, pointItemKey, "批量添加关注"); } //更新用户缓存 ICacheService cacheService = DIContainer.Resolve <ICacheService>(); RealTimeCacheHelper realTimeCacheHelper = EntityData.ForType(typeof(User)).RealTimeCacheHelper; if (cacheService.EnableDistributedCache) { realTimeCacheHelper.IncreaseEntityCacheVersion(eventArgs.UserId); } else { string cacheKey = realTimeCacheHelper.GetCacheKeyOfEntity(eventArgs.UserId); User user = cacheService.Get <User>(cacheKey); if (user != null) { user.FollowedCount = user.FollowedCount + sender; } } } }
/// <summary> /// 用户解除管制后增加邀请人积分 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void FreeModeratedUser_After(User sender, CommonEventArgs eventArgs) { if (sender == null || string.IsNullOrEmpty(eventArgs.EventOperationType)) { return; } if (eventArgs.EventOperationType == EventOperationType.Instance().CancelModerateUser() || eventArgs.EventOperationType == EventOperationType.Instance().AutoNoModeratedUser()) { PointService pointService = new PointService(); string pointItemKey = string.Empty; pointItemKey = PointItemKeys.Instance().FreeModeratedUser(); if (sender != null) { InviteFriendRecord invitingUser = inviteFriendService.GetInvitingUserId(sender.UserId); if (invitingUser != null) { if (!invitingUser.InvitingUserHasBeingRewarded) { string userName = UserIdToUserNameDictionary.GetUserName(invitingUser.UserId); string invitedName = UserIdToUserNameDictionary.GetUserName(sender.UserId); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_FreeModeratedUser"), userName, invitedName); pointService.GenerateByRole(invitingUser.UserId, pointItemKey, description); inviteFriendService.RewardingUser(invitingUser.UserId); } } } } }
/// <summary> /// 创建用户的时候修改积分 /// </summary> /// <param name="sender">创建用户角色</param> /// <param name="eventArgs">参数</param> void RegisterEventModule_After(User sender, CreateUserEventArgs eventArgs) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_Register"), sender.UserName); pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().Register(), description); }
/// <summary> /// 创建邀请记录之后的方法 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void CreateInviteFriendRecordEventModule_After(InviteFriendRecord sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { PointService pointService = new PointService(); string userName = UserIdToUserNameDictionary.GetUserName(sender.UserId); string invitedName = UserIdToUserNameDictionary.GetUserName(sender.InvitedUserId); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_CreateInviteFriendRecord"), userName, invitedName); pointService.GenerateByRole(sender.UserId, PointItemKeys.Instance().InviteUserRegister(), description, true); } }
/// <summary> /// 删除被评论对象时评论的积分处理 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void CommentsDeleteEventModel_After(IEnumerable <Comment> sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() && sender != null) { PointService pointService = new PointService(); foreach (var item in sender) { string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_DeleteComment"), item.Author, item.Subject); pointService.GenerateByRole(item.UserId, PointItemKeys.Instance().DeleteComment(), description); } } }
/// <summary> /// 处理加精、置顶等操作 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarThreadPointModuleForManagerOperation_After(BarThread sender, CommonEventArgs eventArgs) { NoticeService noticeService = new NoticeService(); if (eventArgs.OperatorInfo == null) { return; } string pointItemKey = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()) { pointItemKey = PointItemKeys.Instance().EssentialContent(); if (sender.UserId > 0 && sender.UserId != eventArgs.OperatorInfo.OperatorUserId) { Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = BarConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId))); notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetail(sender.ThreadId)); notice.TemplateName = NoticeTemplateNames.Instance().ManagerSetEssential(); noticeService.Create(notice); } } else if (eventArgs.EventOperationType == EventOperationType.Instance().SetSticky()) { pointItemKey = PointItemKeys.Instance().StickyContent(); if (sender.UserId > 0 && sender.UserId != eventArgs.OperatorInfo.OperatorUserId) { Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = BarConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId))); notice.RelativeObjectName = HtmlUtility.TrimHtml(sender.Subject, 64); notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ThreadDetail(sender.ThreadId)); notice.TemplateName = NoticeTemplateNames.Instance().ManagerSetSticky(); noticeService.Create(notice); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "帖子", sender.Subject); pointService.GenerateByRole(sender.UserId, pointItemKey, description); } }
/// <summary> /// 首次上传头像加分 /// </summary> /// <param name="sender">用户实体</param> /// <param name="eventArgs">事件参数</param> public void UserPointEventModule_After(User sender, CropAvatarEventArgs eventArgs) { string pointItemKey = string.Empty; string eventOperationType = string.Empty; if (eventArgs.IsFirst) { PointService pointService = new PointService(); pointItemKey = PointItemKeys.Instance().FirstUploadAvatar(); string description = ResourceAccessor.GetString("PointRecord_Pattern_FirstUploadAvatar"); pointService.GenerateByRole(sender.UserId, pointItemKey, description, true); } }
/// <summary> /// 处理加精操作加积分 /// </summary> private void PhotoPointModuleForManagerOperation_After(Photo photo, CommonEventArgs eventArgs) { string pointItemKey = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential()) { pointItemKey = PointItemKeys.Instance().EssentialContent(); PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "照片", HtmlUtility.TrimHtml(photo.Description, 64)); pointService.GenerateByRole(photo.UserId, pointItemKey, description); } }
/// <summary> /// 批量关注积分处理 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> void BatchFollowPointModule_After(int sender, BatchFollowEventArgs eventArgs) { if (EventOperationType.Instance().Create() == eventArgs.EventOperationType && sender > 0) { string pointItemKey = string.Empty; pointItemKey = PointItemKeys.Instance().FollowUser(); PointService pointService = new PointService(); for (int i = 0; i < sender; i++) { pointService.GenerateByRole(eventArgs.UserId, pointItemKey, "批量添加关注"); } } }
/// <summary> /// 删除用户 /// </summary> /// <param name="userId">用户Id</param> /// <param name="takeOverUserName">用于接管删除用户的内容(例如:用户创建的群组)</param> /// <param name="takeOverAll">是否接管被删除用户的所有内容</param> /// <remarks>接管被删除用户的所有内容</remarks> /// <returns></returns> public UserDeleteStatus DeleteUser(long userId, string takeOverUserName, bool takeOverAll) { User user = userRepository.Get(userId); if (user == null) { return(UserDeleteStatus.DeletingUserNotFound); } if (takeOverAll) { long takeOverUserId = userRepository.GetUserIdByUserName(takeOverUserName); User takeOverUser = userRepository.Get(takeOverUserId); if (takeOverUser == null) { return(UserDeleteStatus.InvalidTakeOverUsername); } } if (!user.IsModerated && !user.IsForceModerated) { // 邀请用户被删除时扣除邀请人积分 PointService pointService = new PointService(); string pointItemKey = string.Empty; pointItemKey = PointItemKeys.Instance().DeleteInvitedUser(); InviteFriendRecord invitingUser = new InviteFriendService().GetInvitingUserId(user.UserId); if (invitingUser != null) { string userName = UserIdToUserNameDictionary.GetUserName(invitingUser.UserId); string invitedName = UserIdToUserNameDictionary.GetUserName(user.UserId); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_DeleteInvitedUser"), userName, invitedName); pointService.GenerateByRole(invitingUser.UserId, pointItemKey, description); } } EventBus <User, DeleteUserEventArgs> .Instance().OnBefore(user, new DeleteUserEventArgs(takeOverUserName, takeOverAll)); int affectCount = userRepository.Delete(user); if (affectCount > 0) { UserIdToUserNameDictionary.RemoveUserId(userId); UserIdToUserNameDictionary.RemoveUserName(user.UserName); EventBus <User, DeleteUserEventArgs> .Instance().OnAfter(user, new DeleteUserEventArgs(takeOverUserName, takeOverAll)); return(UserDeleteStatus.Deleted); } return(UserDeleteStatus.UnknownFailure); }
/// <summary> /// 照片圈人积分 /// </summary> public void PhotoLabelEventModule_After(PhotoLabel photoLabel, CommonEventArgs eventArgs) { string pointItemKey = string.Empty; string eventOperationType = string.Empty; //加积分 if (eventArgs.EventOperationType == EventOperationType.Instance().Create()) { pointItemKey = PointItemKeys.Instance().Photo_BeLabelled(); eventOperationType = EventOperationType.Instance().Create(); } //减积分 if (eventArgs.EventOperationType == EventOperationType.Instance().Delete()) { pointItemKey = PointItemKeys.Instance().Photo_BeLabelled_Delete(); eventOperationType = EventOperationType.Instance().Delete(); } if (!string.IsNullOrEmpty(pointItemKey)) { string description = string.Format("照片圈人", "", HtmlUtility.TrimHtml(photoLabel.Description, 64)); pointService.GenerateByRole(photoLabel.ObjetId, pointItemKey, description); } }
/// <summary> /// 推荐积分处理 /// </summary> /// <param name="sender">推荐实体</param> /// <param name="eventArgs">事件参数</param> void RecommendPointModule_After(RecommendItem sender, CommonEventArgs eventArgs) { if (eventArgs.EventOperationType != EventOperationType.Instance().Create()) { return; } string pointItemKey = string.Empty; PointService pointService = new PointService(); string description = string.Empty; TenantTypeService tenantTypeService = new TenantTypeService(); var urlGetter = RecommendUrlGetterFactory.Get(sender.TenantTypeId); NoticeService noticeService = new NoticeService(); Notice notice = Notice.New(); notice.TypeId = NoticeTypeIds.Instance().Hint(); //notice.TemplateName = "FollowUser"; notice.UserId = sender.UserId; notice.LeadingActorUserId = sender.ReferrerId; notice.LeadingActor = sender.ReferrerName; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.ReferrerId)); notice.RelativeObjectId = sender.UserId; notice.RelativeObjectName = sender.ItemName; notice.RelativeObjectUrl = sender.DetailUrl; if (sender.TenantTypeId == TenantTypeIds.Instance().User()) { pointItemKey = PointItemKeys.Instance().RecommendUser(); description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendUser")); notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommendedUser(); } else { pointItemKey = PointItemKeys.Instance().RecommendContent(); TenantType tenantType = tenantTypeService.Get(sender.TenantTypeId); if (tenantType == null) { return; } description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_RecommendContent"), tenantType.Name, sender.ItemName); notice.TemplateName = NoticeTemplateNames.Instance().ManagerRecommended(); } noticeService.Create(notice); pointService.GenerateByRole(sender.UserId, pointItemKey, description); }
/// <summary> /// 审核状态发生变化时处理积分 /// </summary> /// <param name="blogThread">日志</param> /// <param name="eventArgs">事件</param> private void BlogThreadPointModule_After(BlogThread blogThread, AuditEventArgs eventArgs) { AuditService auditService = new AuditService(); string pointItemKey = string.Empty; string eventOperationType = string.Empty; bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().Blog_CreateThread(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().Blog_DeleteThread(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "日志", blogThread.Subject); pointService.GenerateByRole(blogThread.UserId, pointItemKey, description); } }
/// <summary> /// 审核状态发生变化时处理积分 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarThreadPointModule_After(BarThread sender, AuditEventArgs eventArgs) { string pointItemKey = string.Empty; string eventOperationType = string.Empty; ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().Bar_CreateThread(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().Bar_DeleteThread(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "帖子", sender.Subject); pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId); } }
/// <summary> /// 积分处理程序 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void BarPostPointModule_After(BarPost sender, AuditEventArgs eventArgs) { AuditService auditService = new AuditService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); string pointItemKey = string.Empty; string eventOperationType = string.Empty; if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().CreateComment(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().DeleteComment(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回帖", HtmlUtility.TrimHtml(sender.GetBody(), 32)); pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId); } }
/// <summary> /// 审核状态发生变化时处理积分 /// </summary> /// <param name="sender">微博实体</param> /// <param name="eventArgs">时间参数</param> private void MicroblogPointModule_After(MicroblogEntity sender, AuditEventArgs eventArgs) { string pointItemKey = string.Empty, eventOperationType = string.Empty; ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().Microblog_CreateMicroblog(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().Microblog_DeleteMicroblog(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "微博", Tunynet.Utilities.HtmlUtility.TrimHtml(sender.Body, 15)); pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId); } }
/// <summary> /// 审核状态发生变化时处理积分 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void GroupEntityPointModule_After(GroupEntity sender, AuditEventArgs eventArgs) { string pointItemKey = string.Empty; string eventOperationType = string.Empty; string description = string.Empty; ActivityService activityService = new ActivityService(); AuditService auditService = new AuditService(); PointService pointService = new PointService(); bool? auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus); if (auditDirection == true) //加积分 { pointItemKey = PointItemKeys.Instance().Group_CreateGroup(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().Group_DeleteGroup(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "群组", sender.GroupName); } pointService.GenerateByRole(sender.UserId, pointItemKey, description); }
/// <summary> /// 处理置顶操作 /// </summary> /// <param name="sender"></param> /// <param name="eventArgs"></param> private void ContentItemPointModuleForManagerOperation_After(ContentItem sender, CommonEventArgs eventArgs) { NoticeService noticeService = new NoticeService(); string pointItemKey = string.Empty; if (eventArgs.EventOperationType == EventOperationType.Instance().SetGlobalSticky() || eventArgs.EventOperationType == EventOperationType.Instance().SetFolderSticky()) { pointItemKey = PointItemKeys.Instance().CMS_StickyNews(); if (sender.UserId > 0) { Notice notice = Notice.New(); notice.UserId = sender.UserId; notice.ApplicationId = CmsConfig.Instance().ApplicationId; notice.TypeId = NoticeTypeIds.Instance().Hint(); notice.LeadingActor = sender.Author; notice.LeadingActorUrl = SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(sender.UserId)); notice.RelativeObjectName = sender.Title; notice.RelativeObjectUrl = SiteUrls.FullUrl(SiteUrls.Instance().ContentItemDetail(sender.ContentItemId)); if (eventArgs.EventOperationType == EventOperationType.Instance().SetGlobalSticky()) { notice.TemplateName = NoticeTemplateNames.Instance().ContributeGlobalStickied(); } else { notice.TemplateName = NoticeTemplateNames.Instance().ContributeFolderStickied(); } noticeService.Create(notice); } } if (!string.IsNullOrEmpty(pointItemKey)) { PointService pointService = new PointService(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "资讯", sender.Title); pointService.GenerateByRole(sender.UserId, pointItemKey, description); } }
/// <summary> /// 回答被赞同的相关事件处理 /// </summary> private void AskAnswerSupportEventModule_After(long objectId, SupportOpposeEventArgs eventArgs) { if (eventArgs.TenantTypeId == TenantTypeIds.Instance().AskAnswer()) { //如果不是第一次顶踩,则不处理 if (!eventArgs.FirstTime) { return; } if (eventArgs.EventOperationType == EventOperationType.Instance().Support()) { AskAnswer answer = askService.GetAnswer(objectId); AskQuestion question = answer.Question; //创建顶回答的动态[关注回答者的粉丝可以看到该顶信息] Activity activityOfFollower = Activity.New(); activityOfFollower.ActivityItemKey = ActivityItemKeys.Instance().SupportAskAnswer(); activityOfFollower.ApplicationId = AskConfig.Instance().ApplicationId; activityOfFollower.IsOriginalThread = true; activityOfFollower.IsPrivate = false; activityOfFollower.TenantTypeId = TenantTypeIds.Instance().AskAnswer(); activityOfFollower.SourceId = answer.AnswerId; activityOfFollower.UserId = eventArgs.UserId; activityOfFollower.ReferenceId = answer.AnswerId; activityOfFollower.ReferenceTenantTypeId = TenantTypeIds.Instance().AskAnswer(); activityOfFollower.OwnerId = eventArgs.UserId; activityOfFollower.OwnerName = userService.GetFullUser(eventArgs.UserId).DisplayName; activityOfFollower.OwnerType = ActivityOwnerTypes.Instance().User(); activityService.Generate(activityOfFollower, true); //创建顶回答的动态[关注该问题的用户可以看到该顶信息] Activity activityOfQuestionSubscriber = Activity.New(); activityOfQuestionSubscriber.ActivityItemKey = ActivityItemKeys.Instance().SupportAskAnswer(); activityOfQuestionSubscriber.ApplicationId = AskConfig.Instance().ApplicationId; activityOfQuestionSubscriber.IsOriginalThread = true; activityOfQuestionSubscriber.IsPrivate = false; activityOfQuestionSubscriber.TenantTypeId = TenantTypeIds.Instance().AskAnswer(); activityOfQuestionSubscriber.SourceId = answer.AnswerId; activityOfQuestionSubscriber.UserId = eventArgs.UserId; activityOfQuestionSubscriber.ReferenceId = answer.AnswerId; activityOfQuestionSubscriber.ReferenceTenantTypeId = TenantTypeIds.Instance().AskAnswer(); activityOfQuestionSubscriber.OwnerId = question.QuestionId; activityOfQuestionSubscriber.OwnerName = question.Subject; activityOfQuestionSubscriber.OwnerType = ActivityOwnerTypes.Instance().AskQuestion(); activityService.Generate(activityOfQuestionSubscriber, false); //处理积分和威望 string pointItemKey = PointItemKeys.Instance().Ask_BeSupported(); //回答收到赞同时产生积分 string eventOperationType = EventOperationType.Instance().Support(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回答", question.Subject); pointService.GenerateByRole(answer.UserId, pointItemKey, description); //记录用户的威望 PointItem pointItem = pointService.GetPointItem(pointItemKey); ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem.ReputationPoints); //赞同者自动关注问题 if (!subscribeService.IsSubscribed(question.QuestionId, eventArgs.UserId)) { subscribeService.Subscribe(question.QuestionId, eventArgs.UserId); //问题关注数计数,用于“可能感兴趣的问题”关联表查询 countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false); } //增加赞同的用户计数 ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().AnswerSupportCount(), 1); } else if (eventArgs.EventOperationType == EventOperationType.Instance().Oppose()) { AskAnswer answer = askService.GetAnswer(objectId); AskQuestion question = answer.Question; //处理积分和威望 string pointItemKey = PointItemKeys.Instance().Ask_BeOpposed(); //回答收到反对时产生积分 string eventOperationType = EventOperationType.Instance().Oppose(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "回答", question.Subject); pointService.GenerateByRole(answer.UserId, pointItemKey, description); //记录用户的威望 PointItem pointItem = pointService.GetPointItem(pointItemKey); ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem.ReputationPoints); //反对者自动关注问题 if (!subscribeService.IsSubscribed(question.QuestionId, eventArgs.UserId)) { subscribeService.Subscribe(answer.QuestionId, eventArgs.UserId); //问题关注数计数,用于“可能感兴趣的问题”关联表查询 countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false); } //增加反对的用户计数 ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().AnswerOpposeCount(), 1); } } }