예제 #1
0
        /// <summary>
        /// 获取用户的token
        /// </summary>
        /// <param name="loginName"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public static string GetToken(string loginName, string pwd)
        {
            LoginModel rm = new LoginModel();

            try
            {
                APILoginModel model = new APILoginModel();
                model.Name      = loginName;
                model.Pass      = pwd;
                model.LoginType = 0;
                rm = HttpApi.GetApiResult <LoginModel>("User/Login", model);
                //   Tokens.Add(rm.Item.UserId, rm.AccessToken);
                return(rm.AccessToken);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(ex);
                return("");
            }
        }
예제 #2
0
        /// <summary>
        /// 登陆,成功返回用户信息
        ///  state 0. 表示请求正常,正确返回
        /// 1000. 表示账户不存在
        /// </summary>
        /// <param name="loginName">登录名</param>
        /// <param name="pwd">密码</param>
        /// <returns></returns>
        public static LoginModel UserLogin(string loginName, string pwd)
        {
            LoginModel rm = new LoginModel();

            try
            {
                APILoginModel model = new APILoginModel();
                model.Name      = loginName;
                model.Pass      = pwd;
                model.LoginType = 0;
                rm = HttpApi.GetApiResult <LoginModel>("User/Login", model);
                ReadResource.ExecBack(rm, "Login");
            }
            catch (Exception ex)
            {
                LogHelper.ErrorLog(ex);
                return(new LoginModel {
                    State = -1,
                    Message = ex.Message
                });
            }
            return(rm);
        }