コード例 #1
0
ファイル: UserInfoClass.cs プロジェクト: samuelyi/PK10Tracer
        public static UserInfoClass GetUserInfo(string json)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            UserBaseInfo         bi         = null;

            try
            {
                bi = serializer.Deserialize <UserBaseInfo>(json);  //序列化:对象=>JSON字符串
            }
            catch (Exception ce)
            {
                return(null);
            }
            ////Response.Write(jsonStr);
            ////if (bi == null)
            ////{
            ////    return null;
            ////}

            UserInfoClass ret = new UserInfoClass();

            ret.BaseInfo = bi;
            ////ret.BaseInfo = new UserBaseInfo();
            ////ret.BaseInfo.UserCode = bi["UserCode"].ToString();
            ////ret.BaseInfo.Password = bi["Password"].ToString();
            ////DateTime.TryParse(bi["ExpireDate"].ToString(), out ret.BaseInfo.ExpireDate);
            ////ret.BaseInfo.Odds = double.Parse(bi["Odds"].ToString());
            return(ret);
        }
コード例 #2
0
        public CommResult Login(string loginUrl, string username, string pwd)
        {
            CommResult    ret  = new CommResult();
            string        url  = string.Format(loginUrl, username, pwd);
            string        json = AccessWebServerClass.GetData(url, Encoding.Default);
            UserInfoClass user = UserInfoClass.GetUserInfo(json);

            if (user == null)
            {
                ret.Message = json;
                return(ret);
            }
            ret.Succ    = true;
            ret.Message = null;
            ret.Json    = "";
            ret.Result  = new List <RecordObject>();
            ret.Result.Add(user);
            return(ret);
        }