Exemplo n.º 1
0
        /// <summary>
        /// 更新用户个人信息
        /// </summary>
        /// <param name="userInfo">用户个人信息</param>
        public static void UpdateUserInfo(UserInfo userInfo)
        {
            //更新个人信息
            UserData.UpdateUserInfo(userInfo);

            //第一次更新个人信息
            UserInfoUpdateLog log = new UserInfoUpdateLog {
                UserId = userInfo.UserId, InfoType = 2
            };
            bool isFirst = LogsBiz.IsFirstUpdateSelfInfoByUser(log);

            if (isFirst)
            {
                UserConfig userConfig = UserConfigs.GetUserConfigCache();
                if (userConfig.SetPersonalExpChanged != 0)
                {
                    UpdateUserExp(userInfo.UserId, userConfig.SetPersonalExpChanged, "设置个人信息");
                }

                if (userConfig.SetPersonalCoinChanged != 0)
                {
                    UpdateUserCoin(userInfo.UserId, userConfig.SetPersonalCoinChanged, "设置个人信息");
                }
            }

            //记录个人信息更新日志
            log.Comment    = "更新个人信息";
            log.CreateDate = DateTime.Now;
            LogsBiz.CreateLogs <UserInfoUpdateLog>(log);

            //重置用户缓存
            SetUserCacheInfo(userInfo.UserId);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 用户更改密码
        /// </summary>
        /// <param name="uAccount"></param>
        public static void UserChangedPassword(UserAccount uAccount)
        {
            UserData.ChangeUserPassword(uAccount);

            UserPasswordChanagedLog log = new UserPasswordChanagedLog
            {
                UserId     = uAccount.UserId,
                MethodType = 0,
                Comment    = "用户自行修改密码",
                CreateDate = DateTime.Now
            };

            LogsBiz.CreateLogs <UserPasswordChanagedLog>(log);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 用户虚拟币账户余额变更及日志记录(异步)
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="coinChanged">虚拟币账户余额变更值</param>
        /// <param name="actionName">引起变更的操作名称</param>
        public static async void UpdateUserCoin(int userId, int coinChanged, string actionName)
        {
            await Task.Run(() =>
            {
                UserData.UserCoinChanged(userId, coinChanged);

                UserVirtualCoinChangedLog log = new UserVirtualCoinChangedLog
                {
                    UserId             = userId,
                    VirtualCoinChanged = coinChanged,
                    Comment            = string.Format("用户 {0} 操作,虚拟币变化:{1}", actionName, coinChanged),
                    CreateDate         = DateTime.Now
                };
                LogsBiz.CreateLogs <UserVirtualCoinChangedLog>(log);
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// 用户经验值变更及日志记录(异步)
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="expChanged">经验值变更值</param>
        /// <param name="actionName">引起变更的操作名称</param>
        public static async void UpdateUserExp(int userId, int expChanged, string actionName)
        {
            await Task.Run(() =>
            {
                UserData.UserExpChanged(userId, expChanged);

                UserExpChangedLog log = new UserExpChangedLog
                {
                    UserId     = userId,
                    ExpChanged = expChanged,
                    Comment    = string.Format("用户 {0} 操作,经验值变化:{1}", actionName, expChanged),
                    CreateDate = DateTime.Now
                };
                LogsBiz.CreateLogs <UserExpChangedLog>(log);
            });
        }
Exemplo n.º 5
0
        /// <summary>
        /// 设置用户个人信息背景图片
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="iconData">背景图片文件数据</param>
        /// <param name="fileExtName">图片扩展名</param>
        /// <returns>头像图片文件访问的HTTP路径</returns>
        public static string SetUserBackIcon(int userId, byte[] iconData, string fileExtName)
        {
            string iconUrl = iconData.SaveMediaFile(FileTarget.User, userId, MediaType.Image, fileExtName);

            if (!string.IsNullOrEmpty(iconUrl))
            {
                //更新用户背景图片
                UserData.UpdateUserIcon(userId, iconUrl, 1);

                //第一次更新背景图片
                UserInfoUpdateLog log = new UserInfoUpdateLog {
                    UserId = userId, InfoType = 0
                };
                bool isFirst = LogsBiz.IsFirstUpdateSelfInfoByUser(log);
                if (isFirst)
                {
                    UserConfig userConfig = UserConfigs.GetUserConfigCache();
                    if (userConfig.SetBackIconExpChanged != 0)
                    {
                        UpdateUserExp(userId, userConfig.SetBackIconExpChanged, "设置背景图片");
                    }

                    if (userConfig.SetBackIconCoinChanged != 0)
                    {
                        UpdateUserCoin(userId, userConfig.SetBackIconCoinChanged, "设置背景图片");
                    }
                }

                //记录背景图片更新日志
                log.Comment    = "更新背景图片";
                log.CreateDate = DateTime.Now;
                LogsBiz.CreateLogs <UserInfoUpdateLog>(log);

                //重置用户缓存
                SetUserCacheInfo(userId);

                //返回补全的背景图片HTTP路径
                return(iconUrl.ImageUrlFixed(480, 240));
            }
            return(iconUrl);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获取用户验证信息
        /// </summary>
        /// <param name="uAccount">用户账户信息(用户名和密码)</param>
        /// <param name="userAccess">用户对应的登录权限</param>
        /// <returns>用户验证信息</returns>
        public static UserVaildInfo GetUserVaildInfo(UserAccount uAccount, UserAccess userAccess = UserAccess.App)
        {
            UserVaildInfo uVaildInfo = UserData.GetUserVaildInfo(uAccount.UserName, userAccess);

            #region 密码

            uAccount.Password = string.Format("MIAP_{0}_{1}_GW", uAccount.Password, uVaildInfo.PasswordSalt).CreateMD5Encrypt();
            if (!uAccount.Password.Equals(uVaildInfo.Password))
            {
                uVaildInfo.UserId = 0;
                return(uVaildInfo);
            }

            #endregion

            #region 账户是否通过验证

            if (!uVaildInfo.IsApproved)
            {
                uVaildInfo.UserId = -1;
                return(uVaildInfo);
            }

            #endregion

            #region 是否被锁定

            if (uVaildInfo.IsLocked)
            {
                if (DateTime.Now < uVaildInfo.LastLockedoutDate)
                {
                    uVaildInfo.UserId = -2;
                    return(uVaildInfo);
                }

                //锁定时间到期,解锁
                UserData.SetUsesUnLocked(uVaildInfo.UserId);
                //记录状态变更日志
                UserStatusChangedLog log = new UserStatusChangedLog
                {
                    UserId     = uVaildInfo.UserId,
                    Action     = 1,
                    Comment    = "锁定时间到期,自动解锁!",
                    CreateDate = DateTime.Now
                };
                LogsBiz.CreateLogs <UserStatusChangedLog>(log);
            }

            #endregion

            #region 是否为试用账号,如果是,试用账号状态

            if (uVaildInfo.UserSite > 0)
            {
                UserWithSchool uWithSchool = UserData.GetUserWithSchool(uVaildInfo.UserId);
                UserWithSchool tempUserWithSchoolInfo;
                //试用账号
                if (uWithSchool.IsTrial)
                {
                    if (!uWithSchool.IsActivated)
                    {
                        //激活试用账号
                        UserConfig userConfig = UserConfigs.GetUserConfigCache();
                        tempUserWithSchoolInfo = new UserWithSchool
                        {
                            UserId        = uWithSchool.UserId,
                            IsActivated   = true,
                            ActivatedDate = DateTime.Now,
                            IsExpired     = false,
                            ExpiredDate   = userConfig.TrialAccountExpiredDay > 0 ? DateTime.Now.AddDays(userConfig.TrialAccountExpiredDay) : DateTime.MaxValue
                        };
                        UserData.SchoolTrialUserStatusChanged(tempUserWithSchoolInfo);
                    }
                    else
                    {
                        //超时时间已过,将试用账号设为过期
                        if (!uWithSchool.IsExpired && DateTime.Now >= uWithSchool.ExpiredDate)
                        {
                            tempUserWithSchoolInfo = new UserWithSchool
                            {
                                UserId        = uWithSchool.UserId,
                                IsActivated   = uWithSchool.IsActivated,
                                ActivatedDate = uWithSchool.ActivatedDate,
                                IsExpired     = true,
                                ExpiredDate   = uWithSchool.ExpiredDate
                            };
                            UserData.SchoolTrialUserStatusChanged(tempUserWithSchoolInfo, 1);

                            uWithSchool.IsExpired = true;
                        }

                        //试用账号已过期
                        if (uWithSchool.IsExpired)
                        {
                            uVaildInfo.UserId = -3;
                            return(uVaildInfo);
                        }
                    }
                }
            }

            #endregion

            return(uVaildInfo);
        }