コード例 #1
0
ファイル: CNetProxy.cs プロジェクト: LegendRiver/FBAW_Project
        public bool loadNetPorxyFromTianLuServer(List <CNetProxy> netProxyList)
        {
            //
            string errorMessage            = string.Empty;
            string httpRequestErrorMessage = string.Empty;
            string netProxyContent         = string.Empty;
            string serverUrl = @"http://office.tianluweiye.com:8008/service/proxies?speed=10000&num=30";

            netProxyContent = CHttpRequest.GetHttpWebRequest(serverUrl, out errorMessage);
            if (netProxyContent == null)
            {
                errorMessage = string.Format("Load from server<{0}>,error message<{1}> faild.", serverUrl, httpRequestErrorMessage);
                return(false);
            }

            string afterConvert = CPublic.unicode_js_GBK(netProxyContent);
            JArray items        = JArray.Parse(afterConvert);

            if ((items == null) || (items.Count == 0))
            {
                errorMessage = string.Format("Convert to JObject faild, content<{0}>.", afterConvert);
                return(false);
            }

            return(parseNetProxyFromTianLu(netProxyList, items));
        }
コード例 #2
0
ファイル: CNetProxy.cs プロジェクト: LegendRiver/FBAW_Project
        public bool loadNetProxyFromServer(List <CNetProxy> netProxyTable, out string errorMessage)
        {
            string       httpRequestErrorMessage = string.Empty;
            string       netProxyContent         = string.Empty;
            string       serverUrl = _SystemConfig.getConfigItem("NetProxyManagementServiceUrl").ToString();
            UTF8Encoding encoder   = new UTF8Encoding();

            if ((serverUrl == null) || (serverUrl == string.Empty))
            {
                errorMessage = string.Format("Not config<{0}>, please check it.", "NetProxyManagementServiceUrl");
                return(false);
            }

            netProxyContent = CHttpRequest.getHttpWebRequest(serverUrl, "func=QUERY_NO_BASE64", encoder, out httpRequestErrorMessage);
            if (netProxyContent == null)
            {
                errorMessage = string.Format("Load from server<{0}>,error message<{1}> faild.", serverUrl, httpRequestErrorMessage);
                return(false);
            }

            string  afterConvert = CPublic.unicode_js_GBK(netProxyContent);
            JObject jobject      = JObject.Parse(afterConvert);

            if (jobject == null)
            {
                errorMessage = string.Format("Convert to JObject faild, content<{0}>.", afterConvert);
                return(false);
            }

            int errorCode = jobject["error_code"].Value <int>();

            if (errorCode != 0)
            {
                errorMessage = string.Format("Load net proxy data from server<{0}> faild, error code<{1}>,error message<{2}>.", serverUrl,
                                             errorCode,
                                             jobject["message"].Value <string>());
                return(false);
            }

            errorMessage = "";

            return(parseNetProxyList(jobject["data"].ToArray <JToken>(), netProxyTable));
        }