Configuration file readout

specification of the format in the spec
This commit is contained in:
Tina_Azure
2023-04-12 00:26:47 +02:00
parent bfa49c2281
commit 1965b06868
5 changed files with 186 additions and 29 deletions

View File

@ -8,9 +8,16 @@
using namespace std;
int main() {
int main(int argc, char *argv[]) {
Utilities::config configuration;
configuration.readConfigFile();
if (argc > 0)
configuration.configPath = argv[1];
if (configuration.readConfigFile()) {
std::cout << "ERROR: Unable to read configuration file: " << configuration.configPath << endl;
std::cout << "Aborting Startup!" << endl;
return 1;
}
crow::SimpleApp app;
@ -126,6 +133,17 @@ int main() {
auto page = crow::mustache::load(templateHTML);
crow::mustache::context ctx(resultJsonTemplate);
bool commissionState = false;
if (resultTemplate.size() > 0) {
//use freelancerID based on SQL_STATEMENT_SELECT_TEMPLATE
pqxx::result resultCommissionState = Database::executePreparedStatement_SELECT_FREELANCER_COMMISSION_STATE(databaseConnection, stoi(resultTemplate.at(0).at(2).c_str()));
//the commissionstate
if (resultCommissionState.size() == 0 || stoi(resultCommissionState.at(0).at(0).c_str()) == 1)
commissionState = true;
}
ctx["ERROR_COMMISSIONS_CLOSED"] = commissionState;
return page.render(ctx);
});
@ -202,7 +220,7 @@ int main() {
pqxx::result resultCommissionState = Database::executePreparedStatement_SELECT_FREELANCER_COMMISSION_STATE(databaseConnection, newRequest.freelancerID);
//the commissionstate
if (resultCommissionState.size() == 0 || stoi(resultTemplate.at(0).at(0).c_str()) == 1) {
if (resultCommissionState.size() == 0 || stoi(resultCommissionState.at(0).at(0).c_str()) == 1) {
ctx["ERROR_COMMISSIONS_CLOSED"] = true;
}
else {