| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #include "DataInterface/DataCondenser.h"
- #include <INIReader.h>
- #include <Logging.h>
- #include <MySQLClient.h>
- #include <iostream>
- #include <sstream>
- #include <string>
- int main(int argc, char** argv)
- {
- try
- {
- Logging::OpenLog();
- Logging::SetLogMask(Logging::Severity::Info);
- INIReader iniReader("DataCondenser.ini");
- if (iniReader.ParseError() != 0)
- throw std::runtime_error("Can't read DataCondenser.ini.");
- MySQL::MySQLClient mySQLClient;
- {
- std::string hostname = iniReader.Get("MySQL", "Hostname", "");
- if (hostname.empty())
- throw std::runtime_error("MySQL Hostname directive missing in ini file.");
- std::string username = iniReader.Get("MySQL", "Username", "");
- if (username.empty())
- throw std::runtime_error("MySQL Username directive missing in ini file.");
- std::string password = iniReader.Get("MySQL", "Password", "");
- if (password.empty())
- throw std::runtime_error("MySQL Password directive missing in ini file.");
- std::string database = iniReader.Get("MySQL", "Database", "");
- if (database.empty())
- throw std::runtime_error("MySQL Database directive missing in ini file.");
- mySQLClient.Connect(hostname, username, password, database);
- }
- DataStorageInterface::DataInterface::DataCondenser condenser(&mySQLClient);
- condenser.CondenseData();
- Logging::CloseLog();
- }
- catch (const std::exception& e)
- {
- std::cerr << "Exception caught" << std::endl;
- std::stringstream ss;
- ss << "Type : " << typeid(e).name() << std::endl;
- ss << "ERROR: " << e.what() << std::endl;
- Logging::Log(Logging::Severity::Error, ss.str());
- Logging::CloseLog();
- return -1;
- }
- return 0;
- }
|