mirror of
https://gitlab.com/spaceti-app/integrations/acs/colnod-connector.git
synced 2026-07-12 11:50:37 +02:00
60 lines
1.8 KiB
C++
60 lines
1.8 KiB
C++
#include <QCoreApplication>
|
|
|
|
#include "syncmanager.h"
|
|
#include <QCommandLineParser>
|
|
#include "serversdk/requestmanager.h"
|
|
#include "serversdk/request.h"
|
|
|
|
#include "serversdk/logger.h"
|
|
#include "serversdk/core.h"
|
|
|
|
#include "colnodapi.h"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
// App setup
|
|
QCoreApplication app(argc, argv);
|
|
QCoreApplication::setApplicationName("colnod-connector");
|
|
QCoreApplication::setApplicationVersion("1.0");
|
|
|
|
// Command line parsing
|
|
QCommandLineParser parser;
|
|
parser.setApplicationDescription("Colnod sync");
|
|
QCommandLineOption dryModeOption("dryMode", "ColnodAPI", "Read-only mode, prints changes which would normally be made");
|
|
QCommandLineOption dropTablesOption("dropTables", "ColnodAPI", "Delete tables with datas from Colnod");
|
|
QCommandLineOption createTablesOption("createTables", "ColnodAPI", "Create tables to saving data from Colnod");
|
|
parser.addOption(dryModeOption);
|
|
parser.addOption(dropTablesOption);
|
|
parser.addOption(createTablesOption);
|
|
parser.process(app);
|
|
|
|
|
|
// Logger initializiaton
|
|
serversdk::initAppLogger(); // <-- then Logger::outputMessage will handle all messages
|
|
|
|
// Log messge Filtering
|
|
QStringList filters;
|
|
filters << "qt.*=false";
|
|
filters << "sdk*=false";
|
|
//filters << "*=false";
|
|
QLoggingCategory::setFilterRules(filters.join(QStringLiteral("\n")));
|
|
|
|
|
|
|
|
SyncManager syncManager(parser.isSet(dryModeOption));
|
|
|
|
// Initialize database and colnod API
|
|
if (!syncManager.databaseInitialization()) {
|
|
qCritical() << "Not possible to initialize sync application";
|
|
return -1;
|
|
}
|
|
|
|
// Synchronizaiton
|
|
if (!syncManager.startSynchronization()) {
|
|
qCritical() << "Not possible to start synchronization";
|
|
return -1;
|
|
}
|
|
|
|
return QCoreApplication::exec();
|
|
}
|