Ejemplo n.º 1
0
        public ActionResult EditUser(User user)
        {
            try
            {
                UserService service = new UserService();
                var oldUser = service.GetUserById(UserInfo.UserId);
                if (oldUser != null)
                {
                    oldUser.Adress = user.Adress;
                    oldUser.QQ = user.QQ;
                    oldUser.LocationId = Request.Form["LocationId[]"];

                    if (!string.IsNullOrEmpty(Request.Form["Photo"]))
                    {
                        oldUser.Photo = Request.Form["Photo"];
                    }
                    if (service.UserUpdate(oldUser))
                    {
                        Session[USERINFO] = oldUser;
                    }
                }
            }
            catch (Exception ex)
            {
                LogService.Log("会员列表", ex.ToString());
            }
            return RedirectToAction("ViewUser");
        }
Ejemplo n.º 2
0
 public User GetUserById(int id)
 {
     User user = new User();
     try
     {
         user = userRepository.FindOne(u => u.UserId.Equals(id));
     }
     catch (Exception e)
     {
         LogService.Log("查询用户失败", e.ToString());
     }
     return user;
 }
Ejemplo n.º 3
0
 private User ConvertToUserObject(SqlDataReader reader)
 {
     User user = new User();
     user.UserId = reader["UserId"].DBToInt32();
     user.UserName = reader["UserName"].DBToString();
     user.Adress = reader["Adress"].DBToString();
     user.Cellphone = reader["Cellphone"].DBToString();
     user.CreateTime = reader["CreateTime"].DBToDateTime();
     user.Email = reader["Email"].DBToString();
     user.IdentiyImg = reader["IdentiyImg"].DBToString();
     user.LastUpdatedTime = reader["LastUpdatedTime"].DBToDateTime();
     user.EncryptedPassword = reader["EncryptedPassword"].DBToString();
     user.LocationId = reader["LocationId"].DBToString();
     user.LoginIdentiy = reader["LoginIdentiy"].DBToString();
     user.QQ = reader["QQ"].DBToString();
     user.SiteUrl = reader["SiteUrl"].DBToString();
     user.State = reader["State"].DBToInt32();
     user.UCard = reader["UCard"].DBToString();
     user.UserType = reader["UserType"].DBToInt32();
     user.Vip = reader["Vip"].DBToInt32();
     user.Photo = reader["Photo"].DBToString();
     return user;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 注册用户。返回UserId
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool UserRegister(SqlConnection conn, User user, out int userId)
        {
            bool result = false;
            userId = -1;
            SqlParameter[] parameters =
            {
                new SqlParameter(column_UserId, SqlDbType.Int,4),
                new SqlParameter("@UserName", user.UserName),
                new SqlParameter("@EncryptedPassword", user.EncryptedPassword),
                new SqlParameter("@UserType", user.UserType),
                new SqlParameter("@Adress", user.Adress),
                new SqlParameter("@LocationId", user.LocationId),
                new SqlParameter("@Cellphone", user.Cellphone),
                new SqlParameter("@Email", user.Email),
                new SqlParameter("@QQ", user.QQ),
                new SqlParameter("@UCard", user.UCard),
                new SqlParameter("@SiteUrl", user.SiteUrl),
                new SqlParameter("@LoginIdentiy", user.LoginIdentiy),
                new SqlParameter("@IdentiyImg", user.IdentiyImg),
                new SqlParameter("@Vip", user.Vip),
                new SqlParameter("@CreateTime", DateTime.Now),
                new SqlParameter("@LastUpdatedTime", DateTime.Now)
               };
            parameters[0].Direction = ParameterDirection.Output;
            DBHelper.CheckSqlSpParameter(parameters);

            result = DBHelper.RunNonQueryProcedure(conn, SP_UserRegister, parameters) > 0;
            userId = Convert.ToInt32(parameters[0].Value);

            return result;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 更新用户信息。
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool UpdateUser(SqlConnection conn, User user)
 {
     SqlParameter[] parameters =
     {
         new SqlParameter(Constants.column_UserId, user.UserId),
         new SqlParameter("@Adress", user.Adress),
         new SqlParameter(Constants.column_cellphone, user.Cellphone),
         new SqlParameter("@LocationId", user.LocationId),
         new SqlParameter("@Email", user.Email),
         new SqlParameter("@QQ", user.QQ),
         new SqlParameter("@UCard", user.UCard),
         new SqlParameter("@SiteUrl", user.SiteUrl),
         new SqlParameter("@Vip", user.Vip),
         new SqlParameter("@Photo", user.Photo),
         new SqlParameter("@IdentiyImg", user.IdentiyImg)
        };
     DBHelper.CheckSqlSpParameter(parameters);
     return DBHelper.RunNonQueryProcedure(conn, sp_UpdateUser, parameters) > 0;
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 找回密码
 /// </summary>
 /// <param name="conn"></param>
 /// <param name="column"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool ResetUserPasswordById(SqlConnection conn, User user)
 {
     if (user == null)
     {
         throw new ArgumentNullException("密码重置:用户信息不能为空");
     }
     const string sp_GetBackPassword = "******";
     SqlParameter[] sqlParameters = new SqlParameter[]
     {
        new SqlParameter(Constants.column_UserId, user.UserId),
        new SqlParameter("@EncryptedPassword", user.EncryptedPassword)
     };
     return DBHelper.RunNonQueryProcedure(conn,
         sp_GetBackPassword, sqlParameters) > 0;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 找回密码,成功返回True
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool ResetUserPassword(User user)
 {
     bool result = false;
     var conn = DBHelper.GetSqlConnection();
     try
     {
         conn.Open();
         result = userDao.ResetUserPasswordById(conn, user);
     }
     catch (Exception e)
     {
         LogService.Log("用户注册失败--" + e.Message, e.ToString().ToString());
     }
     finally
     {
         conn.Close();
     }
     return result;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 根据UserName查询用户
 /// </summary>
 /// <param name="username">用户名、用户注册邮箱、注册手机号</param>
 /// <returns></returns>
 public User GetUserByUserName(string username)
 {
     User user = new User();
     var conn = DBHelper.GetSqlConnection();
     try
     {
         conn.Open();
         user = userDao.GetUserByUserName(username, conn);
     }
     catch (Exception e)
     {
         LogService.Log("查询用户失败--" + e.Message, e.ToString());
     }
     finally
     {
         conn.Close();
     }
     return user;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 用户注册,成功返回True
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private bool UserRegister(User user, out int userId, out string errorMessage, SqlConnection conn)
        {
            bool result = false;
            errorMessage = "注册用户失败!请再次尝试,如频繁遇到此错误,请联系客户人员!我们会第一时间帮您解决问题!感谢您使用活动在线网!";
            userId = -1;

            try
            {

                if (conn.State != System.Data.ConnectionState.Open)
                {
                    conn.Open();
                }

                if (user == null)
                {
                    errorMessage = "当前网络不稳定,请稍后再试!";
                }
                else if (string.IsNullOrWhiteSpace(user.UserName))
                {
                    errorMessage = "请输入用户名!";
                }
                else if (string.IsNullOrWhiteSpace(user.EncryptedPassword))
                {
                    errorMessage = "请输入账户密码!";
                }
                else if (string.IsNullOrWhiteSpace(user.Email))
                {
                    errorMessage = "请输入注册邮箱!邮箱可用于找回密码!";
                }
                else if (string.IsNullOrWhiteSpace(user.Cellphone))
                {
                    errorMessage = "请输入手机号码!";
                }
                else if (string.IsNullOrWhiteSpace(user.UCard))
                {
                    errorMessage = "请输入认证身份证号码!";
                }
                else if (!userDao.VerifyUserInfo(conn, "UserName", user.UserName))
                {
                    errorMessage = "您当前使用的用户名已被使用,请重新输入!";
                }
                else if (!userDao.VerifyUserInfo(conn, "Email", user.Email))
                {
                    errorMessage = "您当前注册的邮箱号已被使用,请仔细确认!如您的输入无误,建议您使用邮箱找回密码功能进行密码重置!";
                }
                else if (!userDao.VerifyUserInfo(conn, "Cellphone", user.Cellphone))
                {
                    errorMessage = "您当前注册的手机号已被使用,请仔细确认!";
                }
                else if (!userDao.VerifyUserInfo(conn, "UCard", user.UCard))
                {
                    errorMessage = "您当前注册认证的身份证号已被使用,请仔细确认!";
                }
                else
                {
                    user.Vip = (int)VipState.Normal;
                    user.EncryptedPassword = user.EncryptedPassword.ToMD5();

                    result = userDao.UserRegister(conn, user, out userId);
                }
            }
            catch (Exception e)
            {
                result = false;
                errorMessage = "注册用户失败!请再次尝试,如频繁遇到此错误,请联系客户人员!我们会第一时间帮您解决问题!感谢您使用活动在线网!";
                LogService.Log("用户注册失败--" + e.Message, e.ToString().ToString());
            }

            return result;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 微信端用户注册,成功后自动绑定该微信账号
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool WeChatUserRegister(User user, string openId, out string errorMessage)
        {
            bool result = false;
            errorMessage = "";
            var conn = DBHelper.GetSqlConnection();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    conn.Open();
                    int userId;
                    result = UserRegister(user, out userId, out errorMessage, conn);

                    if (result)
                    {
                        WeChatUser wechatUser = userDao.GetWeChatUser(openId, conn);
                        wechatUser.UserId = userId;

                        result = userDao.UpdateWeChatUser(conn, wechatUser);

                    }

                    if (result)
                    {
                        scope.Complete();
                    }
                }
            }
            catch (Exception e)
            {
                errorMessage = "注册用户失败!请再次尝试,如频繁遇到此错误,请联系客户人员!我们会第一时间帮您解决问题!感谢您使用活动在线网!";
                LogService.Log("用户注册失败--" + e.Message, e.ToString().ToString());
            }
            finally
            {
                conn.Close();
            }
            return result;
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 用户修改基础信息,成功返回True
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool UserUpdate(User user)
 {
     bool result = false;
     var conn = DBHelper.GetSqlConnection();
     try
     {
         conn.Open();
         result = userDao.UpdateUser(conn, user);
     }
     catch (Exception e)
     {
         LogService.Log("修改用户失败--" + e.Message, e.ToString().ToString());
     }
     finally
     {
         conn.Close();
     }
     return result;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 用户注册,成功返回True
        /// </summary>
        /// <param name="user"></param>
        /// <param name="errorMessage"></param>
        /// <returns></returns>
        public bool UserRegister(User user, out string errorMessage)
        {
            var conn = DBHelper.GetSqlConnection();
            var result = false;

            try
            {
                int userId = -1;
                result = UserRegister(user, out userId, out errorMessage, conn);
            }
            finally
            {
                conn.Close();
            }

            return result;
        }