public CNetProxy(CSystemLog systemLog, CSystemConfig systemConfig) { _SystemLog = systemLog; _SystemConfig = systemConfig; _DbConnection = new CDbConnection(_SystemConfig.getConfigItem("DB_MYSQL_CONNECT_STR").ToString(), _SystemLog); Id = Guid.NewGuid().ToString().ToUpper(); }
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)); }
private static E_ERROR_CODE loadConfigData() { object configItem = null; configItem = _SystemConfig.getConfigItem(CONFIG_ITEM_USER_LOG_PATH); if (configItem == null) { Console.Write(string.Format("Not config<{0}>, plase config it.", CONFIG_ITEM_USER_LOG_PATH)); return(E_ERROR_CODE.ERROR_CONFIG_ITEM_USER_LOG_PATH_NOT_EXIST); } _LogStorePath = configItem.ToString(); configItem = _SystemConfig.getConfigItem(CONFIG_ITEM_IS_WRITE_LOG_TO_SCREEN); if (configItem == null) { Console.Write(string.Format("Not config<{0}>, plase config it.", CONFIG_ITEM_IS_WRITE_LOG_TO_SCREEN)); return(E_ERROR_CODE.CONFIG_ITEM_IS_WRITE_LOG_TO_SCREEN_NOT_EXIST); } try { _IsWriteLog2Screen = Boolean.Parse(configItem.ToString()); } catch { _IsWriteLog2Screen = false; } configItem = _SystemConfig.getConfigItem(CONFIG_ITEM_WRITR_LOG_LEVEL); if (configItem == null) { Console.Write(string.Format("Not config<{0}>, plase config it.", CONFIG_ITEM_WRITR_LOG_LEVEL)); return(E_ERROR_CODE.CONFIG_ITEM_WRITR_LOG_LEVEL_NOT_EXIST); } if (!Enum.TryParse(configItem.ToString(), out _FilterLogLevel)) { _FilterLogLevel = LOG_LEVEL.WARNING; } _SystemLog = new CSystemLog(_LogStorePath, _FilterLogLevel, _IsWriteLog2Screen); configItem = _SystemConfig.getConfigItem(CONFIG_ITEM_DB_MYSQL_CONNECT_STR); if (configItem == null) { Console.Write(string.Format("Not config<{0}>, plase config it.", CONFIG_ITEM_DB_MYSQL_CONNECT_STR)); return(E_ERROR_CODE.CONFIG_ITEM_DB_MYSQL_CONNECT_STR_NOT_EXIST); } _DbConnectStr = configItem.ToString(); configItem = _SystemConfig.getConfigItem(CONFIG_ITEM_UPDATE_BEIDOU_SERVICE_URL); if (configItem == null) { Console.Write(string.Format("Not config<{0}>, plase config it.", CONFIG_ITEM_UPDATE_BEIDOU_SERVICE_URL)); return(E_ERROR_CODE.CONFIG_ITEM_PINEN_BEIDOU_SERVICE_URL_NOT_EXIST); } _PinenBeiDouServiceUrl = configItem.ToString(); configItem = _SystemConfig.getConfigItem(CONFIG_ITEM_REQUEST_CYCLE); if (configItem == null) { Console.Write(string.Format("Not config<{0}>, plase config it.", CONFIG_ITEM_REQUEST_CYCLE)); return(E_ERROR_CODE.CONFIG_ITEM_REQUEST_CYCLE_NOT_EXIST); } try { _RequestCycle = int.Parse(configItem.ToString()); } catch { _RequestCycle = 30; } return(E_ERROR_CODE.OK); }