Exemplo n.º 1
0
        /// <summary>
        /// 登录请求
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult UserLogin(SND_LoginUserInfo model)
        {
            bool   result = false;
            string msg    = string.Empty;

            //数据验证
            if (string.IsNullOrEmpty(model.UserName))
            {
                msg = "用户名不能为空";
                return(Json(new { result = result, Msg = msg }));
            }
            if (string.IsNullOrEmpty(model.Pwd))
            {
                msg = "密码不能为空";
                return(Json(new { result = result, Msg = msg }));
            }


            UserInfo userInfo = userBll.AdminLogin(model.UserName, model.Pwd, out msg);

            if (userInfo != null)//登录成功 将登录信息存入cookie
            {
                string userStr = JsonConvertTool.SerializeObject(userInfo);

                CookieHelper.SetCookie(PubConstant.COOKIE_NAME, userStr, DateTime.Now.AddMinutes(ConvertHelper.ToInt32(Auxiliary.ConfigKey("UserLogTimeout"))));

                result = true;
            }


            return(Json(new { result = result, Msg = msg }));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 登录请求
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult LoginSumbit(SND_LoginUserInfo model)
        {
            bool   result = false;
            string msg    = string.Empty;

            bool resultTemp = false;

            //数据验证
            if (string.IsNullOrEmpty(model.UserName))
            {
                msg = "用户名不能为空";
                return(Json(new { result = result, Msg = msg }));
            }
            if (string.IsNullOrEmpty(model.Pwd))
            {
                msg = "密码不能为空";
                return(Json(new { result = result, Msg = msg }));
            }


            UserInfo userInfo = userBll.UserLogin(model.UserName, model.Pwd, out msg);



            if (userInfo != null)//登录成功 将登录信息存入cookie
            {
                string userStr = JsonConvertTool.SerializeObject(userInfo);

                CookieHelper.SetCookie(PubConstant.COOKIE_NAME, userStr, DateTime.Now.AddMinutes(ConvertHelper.ToInt32(Auxiliary.ConfigKey("UserLogTimeout"))));

                result = true;

                ////是否今日第一次登陆
                //if (userInfo.TodayIsLogin == 0)
                //{

                //    //静态分配并生成记录

                //    resultTemp = accountBll.StaticDistribution(userInfo.UserId);
                //    //动态分配并生成记录

                //    resultTemp = accountBll.DynamicDistribution(userInfo.UserId);

                //    //修改今日登录状态
                //    userInfo.TodayIsLogin = 1;

                //    resultTemp = userBll.UpdateUserInfo(userInfo);

                //}
            }


            return(Json(new { result = result, Msg = msg }));
        }