private void ChangeMobile() { if (this.gridView1.RowCount < 1 || this.gridView1.FocusedRowHandle < 0) { XtraMessageBox.Show("请选择需要修改信息的用户!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { UserExtInfo _info = this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as UserExtInfo; Dialog_ChangeUserExtInfo _f = new Dialog_ChangeUserExtInfo(_info); if (_f.ShowDialog() == DialogResult.OK) { using (SinoSZClientBase.UserManagerService.UserManagerServiceClient _umsc = new SinoSZClientBase.UserManagerService.UserManagerServiceClient()) { if (_umsc.SaveUserExtInfo(_info.LogonName, _f.Mobile, _f.Email)) { this.gridView1.BeginUpdate(); _info.EMAIL = _f.Email; _info.Mobile = _f.Mobile; this.gridView1.EndUpdate(); } else { XtraMessageBox.Show("修改用户的手机号码及电子邮件信息失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }
/// <summary> /// 用户登录 /// </summary> /// <param name="context">当前请求上下文应答实例</param> /// <param name="acount">账号信息</param> /// <param name="uAccount">用户账户信息</param> private static void UserSignIn(DataContext context, Account acount, UserAccount uAccount) { UserVaildInfo vaildInfo = UserBiz.GetUserVaildInfo(uAccount); string[] errMessages = new string[] { "密码错误!", "您的账号尚未通过验证!", "您的账号已被锁定,暂时无法登录!", "试用账号已过期!请更换其它账号登录!" }; if (vaildInfo.UserId <= 0) { context.Flush(RespondCode.ShowError, errMessages[Math.Abs(vaildInfo.UserId)]); return; } //更新登录信息 UserExtInfo extInfo = new UserExtInfo { UserId = vaildInfo.UserId, LastLoginDeviceId = context.DeviceId, LastLoginAPPChannel = context.ReqChannel, LastLoginAccountChannel = (int)acount.AccountChannel }; UserBiz.UserSignIn(extInfo); //创建登录日志 CreateSignInLog(context, acount, vaildInfo); //返回登录结果 FlushResult(context, vaildInfo); }
/// <summary> /// 更新用户登录成功相关信息 /// </summary> /// <param name="uExtInfo"></param> public static void UpdateUserWhenSignIn(UserExtInfo uExtInfo) { using (DbCommander cmd = new DbCommander(DbConn.WriteDb, "SP_Users_UpdateUserWhenSignIn", CommandType.StoredProcedure)) { cmd.AddInputParameters("UserId, LastLoginDeviceId, LastLoginAPPChannel, LastLoginAccountChannel, LastLoginDate", uExtInfo.UserId, uExtInfo.LastLoginDeviceId, uExtInfo.LastLoginAPPChannel, uExtInfo.LastLoginAccountChannel, DateTime.Now); cmd.ExecuteNonQuery(); } }
public User(UserExtInfo info) { Name = info.Name; NickName = info.NickName; Gender = info.Gender; Avatar = info.Avatar; Phone = info.Phone; Email = string.Empty; Enabled = 1; }
/// <summary> /// 用户登录 /// </summary> /// <param name="extInfo">用户扩展信息</param> public static void UserSignIn(UserExtInfo extInfo) { UserData.UpdateUserWhenSignIn(extInfo); UserConfig userConfig = UserConfigs.GetUserConfigCache(); //登录增加经验值 if (userConfig.LoginExpChanged != 0) { UpdateUserExp(extInfo.UserId, userConfig.LoginExpChanged, "登录"); } //登录增加虚拟币 if (userConfig.LoginCoinChanged != 0) { UpdateUserCoin(extInfo.UserId, userConfig.LoginCoinChanged, "登录"); } }
/// <summary> /// 用户注册 /// </summary> /// <param name="context">当前请求上下文应答实例</param> /// <param name="acount">账号信息</param> /// <param name="uAccount">用户账户信息</param> /// <param name="uInfo">用户个人信息</param> private static void UserSignUp(DataContext context, Account acount, UserAccount uAccount, UserInfo uInfo) { UserExtInfo extInfo = new UserExtInfo { CreateDeviceId = context.DeviceId, CreateAPPChannel = context.ReqChannel, CreateAccountChannel = (int)acount.AccountChannel }; UserBiz.CreateUser(uAccount, uInfo, extInfo); //注册结果:uAccount.UserId > 0 为成功,反之为失败! if (uAccount.UserId > 0) { //注册成功后,更新游客账户用户名、昵称信息 if (acount.AccountChannel == AccountChannel.Guest) { uAccount.UserName = string.Format("{0}{1}", GuestUserNamePreFix, uAccount.UserId); uInfo.NickName = string.Format("游客{0}", Convert.ToBase64String(uAccount.UserId.GetIntOffsetBytes(), Base64FormattingOptions.None).TrimEnd('=')); UserBiz.UpdateGuestUserInfo(uAccount, uInfo); } //写注册日志 CreateSignUpLog(context, acount, uAccount); //输出登录结果 UserVaildInfo vaildInfo = new UserVaildInfo { UserId = uAccount.UserId, LastLoginDeviceId = context.DeviceId, LastLoginDate = uAccount.CreateDate, LoginCount = uAccount.LoginCount }; SignIn.FlushResult(context, vaildInfo); } else { context.Flush(RespondCode.ExecError); } }
private void AddUser(ISession session, CmdInfo info) { UserExtInfo userExt = info.As <UserExtInfo>(); if (userExt == null) { SendError(session, "参数错误-UserExtInfo"); } try { User user = new User(userExt) { Password = StringUtil.GetMd5String(User.PASSWORD) }; userRepository.InsertOrUpdate(user); SendInfo(session, info.Clone("添加成功")); } catch (Exception e) { SendError(session, e.Message); } }
/// <summary> /// 注册用户账号 /// </summary> /// <param name="uAccount">用户账户信息</param> /// <param name="uInfo">用户个人信息</param> /// <param name="extInfo">用户扩展信息</param> public static void CreateUser(UserAccount uAccount, UserInfo uInfo, UserExtInfo extInfo) { UserConfig userConfig = UserConfigs.GetUserConfigCache(); DateTime dtNow = DateTime.Now; #region UserAccount uAccount.UserId = 0; uAccount.PasswordSalt = EncryptHelper.CreateSalt(16); uAccount.Password = CreatePassword(uAccount.Password, uAccount.PasswordSalt); uAccount.LastPasswordChangedDate = dtNow; uAccount.IsApproved = true; uAccount.ApprovedDate = dtNow; uAccount.IsLocked = false; uAccount.LastLockedoutDate = dtNow; uAccount.CreateDate = dtNow; uAccount.LoginCount = 0; uAccount.LastLoginDate = dtNow; #endregion #region UserInfo uInfo.RealName = string.Empty; uInfo.BackIcon = userConfig == null ? string.Empty : (userConfig.DefaultBackIcon ?? string.Empty); uInfo.HeadIcon = userConfig == null ? string.Empty : (userConfig.DefaultHeadIcon ?? string.Empty); uInfo.Signature = string.Empty; uInfo.Comment = string.Empty; uInfo.Gender = 0; uInfo.Birthday = dtNow.AddYears(-18); //uInfo.UserAge = 0; uInfo.IDCardNo = string.Empty; uInfo.Area = string.Empty; uInfo.Address = string.Empty; uInfo.PostCode = string.Empty; uInfo.Industry = string.Empty; uInfo.Company = string.Empty; uInfo.JobPosition = string.Empty; uInfo.Interests = string.Empty; uInfo.WebSite = string.Empty; uInfo.Email = string.Empty; uInfo.Mobile = string.Empty; uInfo.Telphone = string.Empty; uInfo.QQ = string.Empty; uInfo.MSN = string.Empty; uInfo.OtherInfo = string.Empty; uInfo.LastChangeDate = dtNow; #endregion #region UserExtInfo extInfo.UserSite = 0; extInfo.UserRole = 0; extInfo.UserAccess = UserAccess.App | UserAccess.Web; extInfo.CreateDeviceId = extInfo.CreateDeviceId; extInfo.CreateAPPChannel = extInfo.CreateAPPChannel; extInfo.CreateAccountChannel = extInfo.CreateAccountChannel; extInfo.LastLoginDeviceId = extInfo.CreateDeviceId; extInfo.LastLoginAPPChannel = extInfo.CreateAPPChannel; extInfo.LastLoginAccountChannel = extInfo.CreateAccountChannel; extInfo.ExpScore = 0; extInfo.ExpLevel = 0; extInfo.GradeName = string.Empty; extInfo.GradeIcon = string.Empty; extInfo.VirtualCoinCount = 0; extInfo.FansCount = 0; extInfo.FollowedCount = 0; extInfo.TopicCount = 0; extInfo.ReplyCount = 0; #endregion #region UserCoords UserCoords userCoords = new UserCoords { Longitude = 0, Latitudes = 0, LastChangeTime = dtNow }; #endregion #region UserOptions UserOptions userOptions = new UserOptions { RemindPrivateMessage = true, RemindGroupMessage = true, RemindBeFollowed = false, RemindTopicBeReply = false, LastChangeDate = dtNow }; #endregion #region UserWithSchool UserWithSchool userInSchool = new UserWithSchool { SchoolId = 0, IsTrial = false, TrialedSource = string.Empty, IsActivated = false, ActivatedDate = dtNow, IsExpired = false, ExpiredDate = dtNow, StudNo = string.Empty, ClassInfo = string.Empty, Status = 0, Comment = string.Empty, SyncForBbs = false }; #endregion UserData.CreateUser(uAccount, uInfo, extInfo, userCoords, userOptions, userInSchool); if (uAccount.UserId > 0) { //初始经验值 if (userConfig.InitExp != 0) { UpdateUserExp(uAccount.UserId, userConfig.InitExp, "注册"); } //初始虚拟币 if (userConfig.InitCoin != 0) { UpdateUserCoin(uAccount.UserId, userConfig.InitCoin, "注册"); } } }
public Dialog_ChangeUserExtInfo(UserExtInfo info) { InitializeComponent(); UserInfo = info; InitData(); }
/// <summary> /// 创建用户记录 /// </summary> /// <param name="uAccount">用户账号信息</param> /// <param name="uInfo">用户个人信息</param> /// <param name="extInfo">用户扩展信息</param> /// <param name="userCoords">用户当前位置坐标信息</param> /// <param name="userOptions">用户个人应用设置信息</param> /// <param name="userInSchool">学校用户信息</param> public static void CreateUser(UserAccount uAccount, UserInfo uInfo, UserExtInfo extInfo, UserCoords userCoords, UserOptions userOptions, UserWithSchool userInSchool) { using (DbCommander cmd = new DbCommander(DbConn.WriteDb, "SP_Users_UserAccountCreate", CommandType.StoredProcedure)) { cmd.AddInputParameters( @"UserId, UserName, Password, PasswordFormat, PasswordSalt, LoginCount, CreateDate, NickName, RealName, BackIcon, HeadIcon, Signature, Comment, Gender, Birthday, IDCardNo, Area, Address, PostCode, Industry, Company, JobPosition, Interests, WebSite, Email, Mobile, Telphone, QQ, MSN, OtherInfo, UserSite, UserRole, UserAccess, CreateDeviceId, CreateAPPChannel, CreateAccountChannel, Longitude, Latitudes, RemindPrivateMessage, RemindGroupMessage, RemindBeFollowed, RemindTopicBeReply, SchoolId, IsTrial, TrialedSource, IsActivated, IsExpired, StudNo, ClassInfo, SchoolComment, SyncForBbs, Status", uAccount.UserId, uAccount.UserName, uAccount.Password, uAccount.PasswordFormat, uAccount.PasswordSalt, uAccount.LoginCount, uAccount.CreateDate, uInfo.NickName, uInfo.RealName, uInfo.BackIcon, uInfo.HeadIcon, uInfo.Signature, uInfo.Comment, uInfo.Gender, uInfo.Birthday, uInfo.IDCardNo, uInfo.Area, uInfo.Address, uInfo.PostCode, uInfo.Industry, uInfo.Company, uInfo.JobPosition, uInfo.Interests, uInfo.WebSite, uInfo.Email, uInfo.Mobile, uInfo.Telphone, uInfo.QQ, uInfo.MSN, uInfo.OtherInfo, extInfo.UserSite, extInfo.UserRole, extInfo.UserAccess, extInfo.CreateDeviceId, extInfo.CreateAPPChannel, extInfo.CreateAccountChannel, userCoords.Longitude, userCoords.Latitudes, userOptions.RemindPrivateMessage, userOptions.RemindGroupMessage, userOptions.RemindBeFollowed, userOptions.RemindTopicBeReply, userInSchool.SchoolId, userInSchool.IsTrial, userInSchool.TrialedSource, userInSchool.IsActivated, userInSchool.IsExpired, userInSchool.StudNo, userInSchool.ClassInfo, userInSchool.Comment, userInSchool.SyncForBbs, userInSchool.Status ); uAccount.UserId = Convert.ToInt32(cmd.ExecuteScalar()); } }