Persing of DailyTicket entry in tariff-file
This commit is contained in:
parent
4c1cd45866
commit
8aa9aa497a
@ -214,53 +214,55 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
DailyTicket.daily_ticket_payment_option_id = k->value.GetInt();
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_unit_id")) {
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
DailyTicket.daily_ticket_unit_id = k->value.GetInt();
|
||||
DailyTicket.daily_ticket_id = k->value.GetInt();
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_price")) {
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_price_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
DailyTicket.daily_ticket_price = k->value.GetInt();
|
||||
DailyTicket.daily_ticket_price_id = k->value.GetInt();
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_tbase_type")) {
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_tb_id")) {
|
||||
if (k->value.IsInt()) {
|
||||
int baseType = k->value.GetInt();
|
||||
switch(baseType) {
|
||||
case (int)ATBTimeBase::TimeBaseType::ABSOLUTE:
|
||||
DailyTicket.daily_ticket_tbase_type = ATBTimeBase::TimeBaseType::ABSOLUTE;
|
||||
break;
|
||||
case (int)ATBTimeBase::TimeBaseType::RELATIVE:
|
||||
DailyTicket.daily_ticket_tbase_type = ATBTimeBase::TimeBaseType::RELATIVE;
|
||||
break;
|
||||
DailyTicket.daily_ticket_tb_id = k->value.GetInt();
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_clearance_customer_ids")) {
|
||||
if (k->value.IsArray()) {
|
||||
auto customerIds = k->value.GetArray();
|
||||
for (rapidjson::SizeType i=0; i < customerIds.Size(); ++i) {
|
||||
if (customerIds[i].IsInt()) {
|
||||
DailyTicket.daily_ticket_clearance_customer_ids.append(customerIds[i].GetInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_clearance_customer_type")) {
|
||||
if (k->value.IsInt()) {
|
||||
int CustomerType = k->value.GetInt();
|
||||
switch (CustomerType) {
|
||||
case (int)ATBCustomer::CustomerType::ADULT:
|
||||
DailyTicket.daily_ticket_clearance_customer_type = ATBCustomer::CustomerType::ADULT;
|
||||
break;
|
||||
case (int)ATBCustomer::CustomerType::CHILD:
|
||||
DailyTicket.daily_ticket_clearance_customer_type = ATBCustomer::CustomerType::CHILD;
|
||||
break;
|
||||
case (int)ATBCustomer::CustomerType::TEEN:
|
||||
DailyTicket.daily_ticket_clearance_customer_type = ATBCustomer::CustomerType::TEEN;
|
||||
break;
|
||||
}
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_from_min")) {
|
||||
if (k->value.IsString()) {
|
||||
std::string const from_min = k->value.GetString();
|
||||
char const *from_min_c_str = from_min.c_str(); // for debugging
|
||||
DailyTicket.daily_ticket_from_min = QTime::fromString(from_min_c_str, Qt::ISODate);
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_weekday_range")) {
|
||||
if (k->value.IsInt()) {
|
||||
DailyTicket.daily_ticket_weekday_range = k->value.GetInt();
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_to_max")) {
|
||||
if (k->value.IsString()) {
|
||||
std::string const to_max = k->value.GetString();
|
||||
char const *to_max_c_str = to_max.c_str();
|
||||
DailyTicket.daily_ticket_to_max = QTime::fromString(to_max_c_str, Qt::ISODate);
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_special_day_range")) {
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_from_offset_min")) {
|
||||
if (k->value.IsInt()) {
|
||||
DailyTicket.daily_ticket_special_day_range = k->value.GetInt();
|
||||
int const from_offset_min = k->value.GetInt();
|
||||
DailyTicket.daily_ticket_from_offset_min = from_offset_min;
|
||||
}
|
||||
} else
|
||||
if (QString(inner_obj_name) == QString("daily_ticket_to_offset_max")) {
|
||||
if (k->value.IsInt()) {
|
||||
int to_offset_max = k->value.GetInt();
|
||||
DailyTicket.daily_ticket_to_offset_max = to_offset_max;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -410,7 +412,9 @@ bool Configuration::ParseJson(Configuration* cfg, const char* json)
|
||||
cfg->YearPeriod.insert(pair<int, ATBPeriodYear>(YearPeriod.pye_id, YearPeriod));
|
||||
break;
|
||||
case MemberType::DailyTicketType:
|
||||
// qCritical() << DailyTicket;
|
||||
cfg->DailyTicket.insert(pair<int, ATBDailyTicket>(DailyTicket.daily_ticket_id, DailyTicket));
|
||||
qCritical() << DailyTicket;
|
||||
DailyTicket.reset();
|
||||
break;
|
||||
case MemberType::CustomerType:
|
||||
// qCritical() << Customer;
|
||||
|
Loading…
Reference in New Issue
Block a user