Exemplo n.º 1
0
 /// <summary>
 /// 任务执行的内容
 /// </summary>
 /// <param name="taskDetail">任务配置状态信息</param>
 public void Execute(TaskDetail taskDetail)
 {
     InviteFriendService inviteFriendService = new InviteFriendService();
     inviteFriendService.DeleteTrashInvitationCodes();
 }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 任务执行的内容
        /// </summary>
        /// <param name="taskDetail">任务配置状态信息</param>
        public void Execute(TaskDetail taskDetail)
        {
            InviteFriendService inviteFriendService = new InviteFriendService();

            inviteFriendService.DeleteTrashInvitationCodes();
        }
Exemplo n.º 4
0
        private void DeleteUserEventMoudle_After(IUser sender, DeleteUserEventArgs eventArgs)
        {
            IUserService userService = DIContainer.Resolve<IUserService>();

            #region 数据
            //清除应用数据
            applicationService.DeleteUser(sender.UserId, eventArgs.TakeOverUserName, eventArgs.TakeOverAll);

            //删除用户信息
            new UserProfileService().Delete(sender.UserId);

            //清除用户内容计数数据
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.ClearOwnerData(sender.UserId);

            //清除用户关于分类的数据
            CategoryService categoryService = new CategoryService();
            categoryService.CleanByUser(sender.UserId);

            //清除用户动态
            ActivityService activityService = new ActivityService();
            activityService.CleanByUser(sender.UserId);

            //清除用户评论
            new CommentService().DeleteUserComments(sender.UserId, false);

            #endregion

            #region 消息

            //清除用户关于私信的数据
            MessageService messageService = new MessageService();
            messageService.ClearSessionsFromUser(sender.UserId);

            //清除请求的用户数据
            InvitationService invitationService = new InvitationService();
            invitationService.CleanByUser(sender.UserId);

            //清除通知的用户数据
            NoticeService noticeService = new NoticeService();
            noticeService.CleanByUser(sender.UserId);

            InviteFriendService inviteFriendService = new InviteFriendService();
            inviteFriendService.CleanByUser(sender.UserId);

            //清除站外提醒的用户数据
            ReminderService reminderService = new ReminderService();
            reminderService.CleanByUser(sender.UserId);

            #endregion

            #region 关注/访客

            //清除用户关于关注用户的数据
            FollowService followService = new FollowService();
            followService.CleanByUser(sender.UserId);

            //清除访客记录的用户数据
            VisitService visitService = new VisitService(string.Empty);
            visitService.CleanByUser(sender.UserId);

            #endregion

            #region 帐号

            //清除帐号绑定数据
            var accountBindingService = new AccountBindingService();
            var accountBindings = new AccountBindingService().GetAccountBindings(sender.UserId);
            foreach (var accountBinding in accountBindings)
            {
                accountBindingService.DeleteAccountBinding(accountBinding.UserId, accountBinding.AccountTypeKey);
            }

            #endregion

            #region 装扮

            //调整皮肤文件使用次数
            var user = userService.GetFullUser(sender.UserId);
            if (user == null)
                return;
            var presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.UserSpace);
            string defaultThemeAppearance = string.Join(",", presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey);
            if (!user.IsUseCustomStyle)
                new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.UserSpace, null, !string.IsNullOrEmpty(user.ThemeAppearance) ? user.ThemeAppearance : defaultThemeAppearance);

            #endregion
        }