Exemplo n.º 1
0
        /// <summary>
        /// 更新数据源中有关用户的信息。
        /// </summary>
        /// <param name="user">一个 MembershipUser 对象,表示要更新的用户及其更新信息。</param>
        public override void UpdateUser(MembershipUser user)
        {
            Contract.Requires(user != null);

            EFUser efUser = user as EFUser;

            Contract.Requires(efUser.UserId > 0);

            IDataParameter[] parameters = new IDataParameter[9];

            parameters[0] = this.db.NewDataParameter("@UserId", efUser.UserId);
            parameters[1] = this.db.NewDataParameter("@UserName", efUser.UserName);
            parameters[2] = this.db.NewDataParameter("@Password", string.IsNullOrWhiteSpace(efUser.Password) ? string.Empty : this.EncodePassword(efUser.Password));
            parameters[3] = this.db.NewDataParameter("@RealName", efUser.RealName);
            parameters[4] = this.db.NewDataParameter("@Email", efUser.Email);
            parameters[5] = this.db.NewDataParameter("@TelNumber", efUser.TelNumber);
            parameters[6] = this.db.NewDataParameter("@Comment", efUser.Comment);
            parameters[7] = this.db.NewDataParameter("@IsApproved", efUser.IsApproved);
            parameters[8] = this.db.NewDataParameter("@ApplicationName", this.ApplicationName);

            int result = this.db.ExecuteNonQuery(CommandType.StoredProcedure, "EF_Membership_Update", parameters);

            if (result == 0)
            {
                throw new Exception("更新应用失败!");
            }
        }
Exemplo n.º 2
0
        EFUser PopulateUser(IDataReader reader)
        {
            EFUser user = new EFUser(this.Name, reader["UserName"].ToString(), null, reader["Email"].ToString(), string.Empty, reader["Comment"].ToString(), (bool)reader["IsApproved"], false, (DateTime)reader["CreationDate"], (DateTime)reader["LastLoginDate"], DateTime.Now, (DateTime)reader["LastPasswordChangedDate"], DateTime.Now)
            {
                UserId    = (int)reader["UserId"],
                RealName  = reader["RealName"].ToString(),
                TelNumber = reader["TelNumber"].ToString()
            };

            return(user);
        }
Exemplo n.º 3
0
        EFUser PopulateUser(IDataReader reader)
        {
            EFUser user = new EFUser(this.Name, reader["UserName"].ToString(), null, reader["Email"].ToString(), string.Empty, reader["Comment"].ToString(), (bool)reader["IsApproved"], false, (DateTime)reader["CreationDate"], (DateTime)reader["LastLoginDate"], DateTime.Now, (DateTime)reader["LastPasswordChangedDate"], DateTime.Now)
            {
                UserId = (int)reader["UserId"],
                RealName = reader["RealName"].ToString(),
                TelNumber = reader["TelNumber"].ToString()
            };

            return user;
        }