Exemplo n.º 1
0
        private long QueryPrimaryID()
        {
            long         id          = -1;
            TUserManager userManager = new TUserManager();
            var          dt          = userManager.GetDataSetByWhere("order by UserID DESC limit 1").Tables[0];

            if (dt.Rows.Count < 1)
            {
                return(id);
            }
            if (long.TryParse(dt.Rows[0]["UserID"].ToString(), out id))
            {
                return(id + 1);
            }
            return(id);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 登录
 /// </summary>
 /// <param name="username">用户名/手机号/邮箱</param>
 /// <param name="password">密码</param>
 /// <returns></returns>
 public LoginResult Login(string username, string password)
 {
     try
     {
         DataTable dt = GetUserInfo(username).Tables[0];
         if (dt.Rows.Count < 1)
         {
             //用户不存在
             LogHelper.Log.Info($"用户名{username}不存在,验证失败!");
             return(LoginResult.Err_Username);
         }
         else
         {
             //用户存在
             //验证登录密码
             TUserManager userManager = new TUserManager();
             var          dtRes       = userManager.GetDataSetByWhere($"where UserName='******' and UserPassword='******'").Tables[0];
             if (dtRes.Rows.Count < 1)
             {
                 //密码验证失败
                 LogHelper.Log.Info($"用户{username}密码验证失败!");
                 return(LoginResult.Err_Password);
             }
             else
             {
                 //通过验证
                 LogHelper.Log.Info(username + " 登录进入 " + DateTime.Now);
                 return(LoginResult.Successful);
             }
         }
     }
     catch (Exception ex)
     {
         LogHelper.Log.Error("用户登录异常..." + ex.Message);
         return(LoginResult.Fail);
     }
 }