public E_ERROR_CODE initConfig() { StreamReader configReader = null; if (!File.Exists(_ConfigFile)) { _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, string.Format("Config file <{0}> not exist.", _ConfigFile)); return(E_ERROR_CODE.ERROR_FILE_NOT_EXIST); } try { configReader = new StreamReader(_ConfigFile, Encoding.UTF8); parseConfigFile(configReader); return(E_ERROR_CODE.OK); } catch (Exception ex) { _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, string.Format("Open config file <{0}> failed, error message <{1}>.", _ConfigFile, ex.Message)); return(E_ERROR_CODE.ERROR_OPEN_FILE_FAILED); } finally { configReader.Close(); configReader.Dispose(); configReader = null; } }
public bool testConnect() { string message = string.Empty; MySqlConnection dbConnection = null; try { dbConnection = getDbConnection(); return(dbConnection.State == System.Data.ConnectionState.Open); } catch (Exception ex) { message = string.Format("Open db faild, error message<{0}>.", ex.Message); _SystemLog.writeLog2Console(LOG_LEVEL.CRIT, message); return(false); } finally { if (dbConnection != null) { dbConnection.Close(); dbConnection.Dispose(); dbConnection = null; } } }
internal E_ERROR_CODE parse(JObject adItem) { string message = string.Empty; if (adItem == null) { message = "Aditem is null"; _SystemLog.writeLog2Console(LOG_LEVEL.ERR, message); return(E_ERROR_CODE.ERROR_APP_AD_IMAGE_ITEM_IS_NULL); } try { pageid = adItem.GetValue("pageid").Value <string>(); } catch (Exception ex) { message = string.Format("Not foun pageid <{0}>, error message <{1}>.", adItem.ToString(), ex.Message); _SystemLog.writeLog2Console(LOG_LEVEL.ERR, message); return(E_ERROR_CODE.ERROR_NOT_FOUND_FIELD_PAGEID); } try { ImageList.Add(adItem.GetValue("actorImg").Value <string>()); } catch (Exception ex) { message = string.Format("Not foun actorImg <{0}>, error message <{1}>.", adItem.ToString(), ex.Message); _SystemLog.writeLog2Console(LOG_LEVEL.ERR, message); return(E_ERROR_CODE.ERROR_NOT_FOUND_FIELD_ACTOR_IMG); } try { ImageList.Add(adItem.GetValue("cdnMarkImg").Value <string>()); } catch (Exception ex) { message = string.Format("Not foun cdnMarkImg <{0}>, error message <{1}>.", adItem.ToString(), ex.Message); _SystemLog.writeLog2Console(LOG_LEVEL.ERR, message); return(E_ERROR_CODE.ERROR_NOT_FOUND_FIELD_ACTOR_CDN_MARK_IMG); } try { ImageList.Add(adItem.GetValue("cdnOriginImg").Value <string>()); } catch (Exception ex) { message = string.Format("Not foun cdnOriginImg <{0}>, error message <{1}>.", adItem.ToString(), ex.Message); _SystemLog.writeLog2Console(LOG_LEVEL.ERR, message); return(E_ERROR_CODE.ERROR_NOT_FOUND_FIELD_ACTOR_CDN_ORIGIN_IMG); } return(E_ERROR_CODE.OK); }
internal LOG_LEVEL getLogLevel() { string configItemValue = string.Format("{0}", _Config.getConfigItem(CONFIG_ITEM_WRITR_LOG_LEVEL)); try { return((LOG_LEVEL)Enum.Parse(typeof(LOG_LEVEL), configItemValue)); } catch (Exception ex) { _SystemLog.writeLog2Console(LOG_LEVEL.ERR, string.Format("Parse log level failed, config <{0}>, error message <{1}>.", configItemValue, ex.Message)); return(LOG_LEVEL.ERR); } }
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); }
public int getIpAddress() { try { IPAddress ipAddress = IPAddress.Parse(IpAddress); Byte[] bytes = ipAddress.GetAddressBytes(); return(Math.Abs(BitConverter.ToInt32(bytes, 0))); } catch (Exception ex) { _SystemLog.writeLog2Console(LOG_LEVEL.ERR, string.Format("Address is not valid ip address<{0}>, error message<{1}>.", IpAddress, ex.Message)); return(-1); } }