Beispiel #1
0
        public JsonResult LoginSys(string LoginId, string LoginPwd, string ValidationCode)
        {
            try
            {
                if (!ValidateCode(ValidationCode))
                {
                    return(Json("驗證碼錯誤"));
                }

                UserModel LoginUserInfo = ModelFactory.Login(LoginId, LoginPwd);

                if (LoginUserInfo == null)
                {
                    return(Json("系統發生錯誤"));
                }

                Session["LoginUserInfo"] = JsonConvert.SerializeObject(LoginUserInfo);

                return(Json("1"));//代表已經處裡完
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
            catch
            {
                return(Json("系統發生錯誤"));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="LoginId"></param>
        /// <param name="LoginPwd"></param>
        /// <returns></returns>
        public JsonResult Login(string LoginId, string LoginPwd)
        {
            try
            {
                LoginModelFactory ModelFactory  = new LoginModelFactory();
                UserModel         LoginUserInfo = ModelFactory.Login(LoginId, LoginPwd);

                AppLoginModel Login = new AppLoginModel();
                if (LoginUserInfo == null)
                {
                    Login.Result      = "0";
                    Login.UserId      = "";
                    Login.UserName    = "";
                    Login.UserEName   = "";
                    Login.Company     = "";
                    Login.CompanyName = "";
                }
                else
                {
                    Login.Result      = "1";
                    Login.UserId      = LoginUserInfo.UserId;
                    Login.UserName    = LoginUserInfo.UserName;
                    Login.UserEName   = LoginUserInfo.UserEName;
                    Login.Company     = LoginUserInfo.Company;
                    Login.CompanyName = LoginUserInfo.CompanyName;
                }


                return(Json(Login, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                AppLoginModel Login = new AppLoginModel();

                Login.Result      = "0";
                Login.UserId      = "";
                Login.UserName    = "";
                Login.UserEName   = "";
                Login.Company     = "";
                Login.CompanyName = "";
                return(Json(Login, JsonRequestBehavior.AllowGet));
            }
        }