From: Maxim Mamontov Date: Sun, 25 Jan 2015 18:03:33 +0000 (+0200) Subject: Added in-to-traff-type conversion. X-Git-Tag: 2.409~208 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/92c80f9accb9816105923994b7091edc9198f9b6 Added in-to-traff-type conversion. --- diff --git a/include/stg/tariff.h b/include/stg/tariff.h index 1b6413b3..5d01cba0 100644 --- a/include/stg/tariff.h +++ b/include/stg/tariff.h @@ -41,6 +41,7 @@ public: static std::string TraffTypeToString(TRAFF_TYPE type); static TRAFF_TYPE StringToTraffType(const std::string& value); + static TRAFF_TYPE IntToTraffType(int value); virtual ~TARIFF() {} virtual double GetPriceWithTraffType(uint64_t up, @@ -117,4 +118,12 @@ std::istream & operator>>(std::istream & stream, TARIFF::TRAFF_TYPE & traffType) return stream; } +inline +TARIFF::TRAFF_TYPE TARIFF::IntToTraffType(int value) +{ + if (value < 0 || value > TRAFF_MAX) + return TRAFF_UP_DOWN; + return static_cast(value); +} + #endif diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp index f757d055..f7aef966 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp @@ -275,13 +275,10 @@ try st->Get(3, td->tariffConf.fee); st->Get(4, td->tariffConf.free); st->Get(5, td->tariffConf.passiveCost); - st->Get(6, td->tariffConf.traffType); + //st->Get(6, td->tariffConf.traffType); + td->tariffConf.traffType = TARIFF::IntToTraffType(Get(st, 6)); if (schemaVersion > 0) - { - std::string period; - st->Get(7, period); - td->tariffConf.period = TARIFF::StringToPeriod(period); - } + td->tariffConf.period = TARIFF::StringToPeriod(Get(st, 7)); st->Close(); st->Prepare("select * from tb_tariffs_params where fk_tariff = ?"); st->Set(1, id);