Пример #1
0
        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));
        }
        private string getDataStorePath()
        {
            string configItemValue = string.Format("{0}", _Config.getConfigItem(CONFIG_ITEM_USER_DATA_PATH));

            if (configItemValue == null)
            {
                return(string.Format("{0}/{1}", CPublic.getAppStartPath(), "data"));
            }

            return(configItemValue);
        }
Пример #3
0
        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));
        }
Пример #4
0
 private static void initLocalVaribles()
 {
     _LocalMacAddressList = CPublic.getMacByNetworkInterface();
     _LocalIPAddressList  = CPublic.getLocalIpAddress();
 }
Пример #5
0
        static int Main(string[] args)
        {
            E_ERROR_CODE errorCode = E_ERROR_CODE.ERROR;

            _SystemLog    = new CSystemLog(true, LOG_LEVEL.DEBUG, string.Format("{0}/{1}", CPublic.getAppStartPath(), "system_log"));
            _SystemConfig = new CSystemConfig(CPublic.SYSTEM_CONFIG_FILE, _SystemLog);
            errorCode     = _SystemConfig.initConfig();
            if (errorCode != E_ERROR_CODE.OK)
            {
                _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, string.Format("Init system config <{0}> failed, error code <{1}>.", CPublic.SYSTEM_CONFIG_FILE, errorCode));
                return((int)errorCode);
            }

            _SystemConfig.printSystemConfig();

            _AppsflyerConfigFilePath = string.Format("{0}", _SystemConfig.getConfigItem(CONFIG_ITEM_APPSFLYER_CONFIG_FILE)).Trim();
            if (!File.Exists(_AppsflyerConfigFilePath))
            {
                _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, string.Format("Appsflyer config file <{0}> not exits.", _AppsflyerConfigFilePath));
                return((int)E_ERROR_CODE.ERROR_FILE_NOT_EXIST);
            }

            CAdSeeDataSpider appsFlyerDataSpider = new CAdSeeDataSpider(_AppsflyerConfigFilePath, _SystemLog);

            errorCode = appsFlyerDataSpider.initAppsFlyerSpiderConfig();
            if (errorCode != E_ERROR_CODE.OK)
            {
                appsFlyerDataSpider.cleanUp();
                _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, string.Format("Init appsflyer spider config failed, error code <{0}>.", errorCode));
                return((int)errorCode);
            }

            errorCode = appsFlyerDataSpider.initWebDriver();
            if (errorCode != E_ERROR_CODE.OK)
            {
                appsFlyerDataSpider.cleanUp();
                _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, string.Format("Init webdriver failed, error code <{0}>.", errorCode));
                return((int)errorCode);
            }
            errorCode = appsFlyerDataSpider.openHomePage();
            if ((errorCode != E_ERROR_CODE.OK) || (!appsFlyerDataSpider.IsLoginSuccessed))
            {
                _SystemLog.writeLog2Console(LOG_LEVEL.ERR, string.Format("Login appsflyer system failed, after <{0}> login again.", 60));
                return((int)errorCode);
            }

            errorCode = appsFlyerDataSpider.downloadAndroidAppAdData();
            return((int)errorCode);
        }