Пример #1
0
        /// <summary>
        /// 获取余额
        /// </summary>
        /// <returns></returns>
        public double GetUserBanlance()
        {
            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL         = "http://" + Domain + "/tools/_ajax//getUserBanlance";
            httpItem.Method      = "POST";
            httpItem.Postdata    = "{\"userName\": \"" + _userName + "\"}";
            httpItem.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host        = Domain;
            httpItem.Referer     = "http://" + Domain + "/home";
            httpItem.ContentType = "application/json";
            httpItem.Cookie      = Cookie;
            HttpResult httpRes = http.GetHtml(httpItem);

            if (httpRes.StatusCode == System.Net.HttpStatusCode.OK)
            {
                requestFailCount = 0;
                string           html     = httpRes.Html;
                JsonUserBanlance jsResult = Util.DeserializeObject <JsonUserBanlance>(html);
                string           code     = jsResult.code;
                if (code == "success")
                {
                    return(jsResult.data.money);
                }
                else
                {
                    if (code == "nologin")
                    {
                        RepeatLogin();
                    }
                    return(GetUserBanlance());
                }
            }
            else
            {
                requestFailCount++;
                LogsRecord.write("接口调用异常", "获取余额,次数=" + requestFailCount + ",异常=" + httpRes.Html);
                if (requestFailCount >= requestMaxFailCount)
                {
                    throw new LogException("请求异常," + httpRes.Html);
                }
                return(GetUserBanlance());
            }
        }
Пример #2
0
        /// <summary>
        /// 获取余额
        /// </summary>
        /// <returns></returns>
        public double GetUserBanlance()
        {
            Ku.Common.HttpHelper http     = new Common.HttpHelper();
            HttpItem             httpItem = new HttpItem();

            httpItem.URL         = "http://" + Domain + "/tools/_ajax//getUserBanlance";
            httpItem.Method      = "POST";
            httpItem.Postdata    = "{\"userName\": \"" + userName + "\"}";
            httpItem.UserAgent   = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36";
            httpItem.Host        = Domain;
            httpItem.Referer     = "http://" + Domain + "/home";
            httpItem.ContentType = "application/json";
            httpItem.Cookie      = Cookie;
            HttpResult       httpRes  = http.GetHtml(httpItem);
            string           html     = httpRes.Html;
            JsonUserBanlance jsResult = Util.DeserializeObject <JsonUserBanlance>(html);

            return(jsResult.data.money);
        }