/// <summary> /// 采纳满意回答 /// </summary> /// <remarks> /// 1.如果问题有悬赏则悬赏分值转移到回答者的帐户(如有交易税,需要扣除),通过EventModule实现 /// 2.除了悬赏分的交易,回答被采纳,回答者还会获得新产生的积分,通过EventModule实现 /// 3.注意需要发送通知给问题的关注者,通过EventModule实现 /// 4.需要触发的事件:SetBestAnswer的OnAfter /// </remarks> /// <param name="question">问题实体</param> /// <param name="answer">回答实体</param> public void SetBestAnswer(AskQuestion question, AskAnswer answer) { if (!answer.IsBest) { answer.IsBest = true; //调用Service中的Update方法,以触发相应的事件,但是不更新审核状态 this.UpdateAnswer(answer, false); //todo:jiangshl,改为EventModule处理 //处理威望 OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User()); //用户获得威望值 PointService pointService = new PointService(); //提问者获取威望值 PointItem questionPointItem = pointService.GetPointItem(PointItemKeys.Instance().Ask_AcceptedAnswer()); ownerDataService.Change(question.UserId, OwnerDataKeys.Instance().UserAskReputation(), questionPointItem.ReputationPoints); //回答者获得威望 PointItem AnswerPointItem = pointService.GetPointItem(PointItemKeys.Instance().Ask_AnswerWereAccepted()); ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), AnswerPointItem.ReputationPoints); //用户计数 ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().AnswerAcceptCount(), 1); } }
/// <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> 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="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 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 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 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> /// <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="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="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> private void PhotoPointModule_After(Photo photo, 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().Photo_UploadPhoto(); if (eventArgs.OldAuditStatus == null) { eventOperationType = EventOperationType.Instance().Create(); } else { eventOperationType = EventOperationType.Instance().Approved(); } } else if (auditDirection == false) //减积分 { pointItemKey = PointItemKeys.Instance().Photo_DeletePhoto(); if (eventArgs.NewAuditStatus == null) { eventOperationType = EventOperationType.Instance().Delete(); } else { eventOperationType = EventOperationType.Instance().Disapproved(); } } if (!string.IsNullOrEmpty(pointItemKey)) { string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "照片", HtmlUtility.TrimHtml(photo.Description, 64)); pointService.GenerateByRole(photo.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == photo.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> /// <param name="objectId"></param> /// <param name="eventArgs"></param> private void PhotoSupportEventModule_After(long objectId, SupportOpposeEventArgs eventArgs) { if (eventArgs.TenantTypeId == TenantTypeIds.Instance().Photo()) { //如果不是第一次顶踩,则不处理 if (!eventArgs.FirstTime) { return; } if (eventArgs.EventOperationType == EventOperationType.Instance().Support()) { Photo photo = photoService.GetPhoto(objectId); //处理积分和威望 string pointItemKey = PointItemKeys.Instance().Photo_BeLiked(); //喜欢时产生积分 string eventOperationType = EventOperationType.Instance().Support(); string description = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventOperationType), "照片", HtmlUtility.TrimHtml(photo.Description, 64)); pointService.GenerateByRole(photo.UserId, pointItemKey, description); } } }
/// <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="pointItemKeys"></param> /// <returns></returns> public static string Photo_BeLabelled_Delete(this PointItemKeys pointItemKeys) { return("Photo_BeLabelled_Delete"); }
/// <summary> /// 照片被喜欢 /// </summary> /// <param name="pointItemKeys"></param> /// <returns></returns> public static string Photo_BeLiked(this PointItemKeys pointItemKeys) { return("Photo_BeLiked"); }
/// <summary> /// 删除照片 /// </summary> /// <param name="pointItemKeys"></param> /// <returns></returns> public static string Photo_DeletePhoto(this PointItemKeys pointItemKeys) { return("Photo_DeletePhoto"); }
/// <summary> /// 上传照片 /// </summary> /// <param name="pointItemKeys"></param> /// <returns></returns> public static string Photo_UploadPhoto(this PointItemKeys pointItemKeys) { return("Photo_UploadPhoto"); }
/// <summary> /// 删除群组 /// </summary> public static string Group_DeleteGroup(this PointItemKeys pointItemKeys) { return("Group_DeleteGroup"); }