//验证用户信息
        public bool valideUserInfo(string logionname, string password)
        {
            string path = "~/App_Data/user.json";

            try
            {
                string    filepath = Server.MapPath(path);
                string    json     = TextFileOper.GetFileJson(filepath);
                UserInfos lstUser  = JsonConvert.DeserializeObject <UserInfos>(json);
                if (lstUser == null || lstUser.rows == null)
                {
                    return(false);
                }
                for (int i = 0; i < lstUser.rows.Count; i++)
                {
                    UserInfo user = lstUser.rows[i];
                    if (user.logionname == logionname && user.password == password && user.state == "1")
                    {
                        loginUserInfo        = user;
                        loginUserInfo.userid = i;
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #2
0
        //json文件路径:"~/Content/json/test.json"
        public ActionResult GetJsonFromFile(string name)
        {
            string path = "~/App_Data/";

            if (string.IsNullOrEmpty(name))
            {
                name = "user.json";
            }
            path += name;
            try
            {
                string filepath = Server.MapPath(path);
                string json     = TextFileOper.GetFileJson(filepath);
                return(Content(json));
            }
            catch (Exception ex)
            {
                return(Content("fail:" + ex.Message));
            }
        }