예제 #1
0
        /// <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);
            }
        }
예제 #2
0
        /// <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 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);
     }
 }
예제 #4
0
        /// <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);
        }
예제 #5
0
 /// <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, true);
 }
예제 #6
0
        /// <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, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == blogThread.UserId);
            }
        }
예제 #7
0
        /// <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);
                }
            }
        }
예제 #8
0
        /// <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);
            }
        }
예제 #9
0
        /// <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);

            }
        }
예제 #10
0
 /// <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);
     }
 }
예제 #11
0
        /// <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);
                        }
                    }
                }
            }
        }
예제 #12
0
        /// <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);
            }
        }
예제 #13
0
        /// <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>
 private void TopicEntityPointModule_After(TopicEntity 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().Topic_CreateTopic();
         if (eventArgs.OldAuditStatus == null)
             eventOperationType = EventOperationType.Instance().Create();
         else
             eventOperationType = EventOperationType.Instance().Approved();
     }
     else if (auditDirection == false) //减积分
     {
         pointItemKey = PointItemKeys.Instance().Topic_DeleteTopic();
         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.TopicName);
     }
     pointService.GenerateByRole(sender.UserId, pointItemKey, description, eventOperationType == EventOperationType.Instance().Create() || eventOperationType == EventOperationType.Instance().Delete() && eventArgs.OperatorInfo.OperatorUserId == sender.UserId);
 }
예제 #15
0
        /// <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);
        }
예제 #16
0
        /// <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);
                }
            }
        }