X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/cf3954a35eaddf462fbe1247f54c0b4b9f9eac80..2955055088741da83fc54d501e3f49a67b0c6181:/projects/stargazer/plugins/store/mysql/mysql_store.cpp diff --git a/projects/stargazer/plugins/store/mysql/mysql_store.cpp b/projects/stargazer/plugins/store/mysql/mysql_store.cpp index 3e61498f..c84df744 100644 --- a/projects/stargazer/plugins/store/mysql/mysql_store.cpp +++ b/projects/stargazer/plugins/store/mysql/mysql_store.cpp @@ -111,28 +111,23 @@ return msc.GetPlugin(); } //----------------------------------------------------------------------------- MYSQL_STORE_SETTINGS::MYSQL_STORE_SETTINGS() - : settings(NULL), - errorStr(), - dbUser(), - dbPass(), - dbName(), - dbHost() + : settings(NULL) { } //----------------------------------------------------------------------------- -int MYSQL_STORE_SETTINGS::ParseParam(const std::vector & moduleParams, - const std::string & name, std::string & result) +int MYSQL_STORE_SETTINGS::ParseParam(const std::vector & moduleParams, + const std::string & name, std::string & result) { PARAM_VALUE pv; pv.param = name; std::vector::const_iterator pvi; pvi = find(moduleParams.begin(), moduleParams.end(), pv); -if (pvi == moduleParams.end()) +if (pvi == moduleParams.end() || pvi->value.empty()) { errorStr = "Parameter \'" + name + "\' not found."; return -1; } - + result = pvi->value[0]; return 0; @@ -159,10 +154,7 @@ return 0; //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- MYSQL_STORE::MYSQL_STORE() - : errorStr(), - version("mysql_store v.0.67"), - storeSettings(), - settings(), + : version("mysql_store v.0.67"), schemaVersion(0), logger(GetPluginLogger(GetStgLogger(), "store_mysql")) { @@ -376,7 +368,8 @@ if(!IsTablePresent("tariffs",sock)) res += "PassiveCost DOUBLE DEFAULT 0.0, Fee DOUBLE DEFAULT 0.0," "Free DOUBLE DEFAULT 0.0, TraffType VARCHAR(10) DEFAULT ''," - "period VARCHAR(32) NOT NULL DEFAULT 'month')"; + "period VARCHAR(32) NOT NULL DEFAULT 'month'," + "change_policy VARCHAR(32) NOT NULL DEFAULT 'allow')"; if(MysqlQuery(res.c_str(),sock)) { @@ -1625,24 +1618,7 @@ if (GetDouble(row[1+8*DIR_NUM], &td->tariffConf.passiveCost, 0.0) < 0) return -1; } -if (!strcasecmp(str.c_str(), "up")) - td->tariffConf.traffType = TRAFF_UP; -else - if (!strcasecmp(str.c_str(), "down")) - td->tariffConf.traffType = TRAFF_DOWN; - else - if (!strcasecmp(str.c_str(), "up+down")) - td->tariffConf.traffType = TRAFF_UP_DOWN; - else - if (!strcasecmp(str.c_str(), "max")) - td->tariffConf.traffType = TRAFF_MAX; - else - { - mysql_free_result(res); - errorStr = "Cannot read tariff " + tariffName + ". Parameter TraffType incorrect"; - mysql_close(sock); - return -1; - } +td->tariffConf.traffType = TARIFF::StringToTraffType(str); if (schemaVersion > 0) { @@ -1726,21 +1702,7 @@ res += param; strprintf(¶m, " Free=%f,", td.tariffConf.free); res += param; -switch (td.tariffConf.traffType) - { - case TRAFF_UP: - res += " TraffType='up'"; - break; - case TRAFF_DOWN: - res += " TraffType='down'"; - break; - case TRAFF_UP_DOWN: - res += " TraffType='up+down'"; - break; - case TRAFF_MAX: - res += " TraffType='max'"; - break; - } +res += " TraffType='" + TARIFF::TraffTypeToString(td.tariffConf.traffType) + "'"; if (schemaVersion > 0) res += ", Period='" + TARIFF::PeriodToString(td.tariffConf.period) + "'";