Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
+2
-3
@@ -127,9 +127,8 @@ ClientMessage::ClientMessage(DataManager *dataManager, LtsWebSocket::ReplyHandle
|
||||
// ####### ClientMessage end #######
|
||||
|
||||
// ####### ServicesInformation begin #######
|
||||
ErrorMessage::ErrorMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data)
|
||||
: ClientMessage(dataManager, client, type, typeId, uuid, data)
|
||||
{}
|
||||
ErrorMessage::ErrorMessage(DataManager *dataManager, LtsWebSocket::ReplyHandler *client, const QString &type, const int typeId, const QString &uuid, const QJsonValue &data) : ClientMessage(dataManager, client, type, typeId, uuid, data),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
void ErrorMessage::process()
|
||||
{
|
||||
|
||||
+7
-7
@@ -27,13 +27,13 @@ DataManager::DataManager(MainHandler *mainHandler)
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
void DataManager::handleErrorMessage(const OcBaseDownload::WebSocketInterface::Messages::ErrorMessage::ErrorData &errData)
|
||||
{
|
||||
ERROR_LOG() << "uuid: " << errData.uuid << " error class: " << errData.errorClass << " text: " << errData.errorMessage;
|
||||
ERROR_LOG(m_logger) << "uuid: " << errData.uuid << " error class: " << errData.errorClass << " text: " << errData.errorMessage;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
void DataManager::servicePortsInformation(const QVector<Messages::ServicePortsInformation::ExerciseInformation> &exerciseInformation)
|
||||
{
|
||||
DEBUG_LOG() << "Got ServicePortsInformation from websocket";
|
||||
DEBUG_LOG(m_logger) << "Got ServicePortsInformation from websocket";
|
||||
switch (m_currentDownload)
|
||||
{
|
||||
case CurrentDownload::PDF:
|
||||
@@ -44,7 +44,7 @@ void DataManager::servicePortsInformation(const QVector<Messages::ServicePortsIn
|
||||
break;
|
||||
case CurrentDownload::NOTHING:
|
||||
default:
|
||||
WARNING_LOG() << "Got Ports Information in neither BASE nor PDF download mode";
|
||||
WARNING_LOG(m_logger) << "Got Ports Information in neither BASE nor PDF download mode";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ void DataManager::servicePortsInformation(const QVector<Messages::ServicePortsIn
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
void DataManager::handlePdfListMessage(const Messages::PdfListMessage::PdfListData &pdfListData)
|
||||
{
|
||||
DEBUG_LOG() << "Got PDF list from websocket";
|
||||
DEBUG_LOG(m_logger) << "Got PDF list from websocket";
|
||||
m_mainHandler->handlerPdfDownload()->handlePdfListData(pdfListData);
|
||||
}
|
||||
|
||||
@@ -64,19 +64,19 @@ void DataManager::setCurrentDownload(CurrentDownload currentDownload)
|
||||
switch (m_currentDownload)
|
||||
{
|
||||
case CurrentDownload::PDF:
|
||||
DEBUG_LOG() << "Setting current download mode to PDF";
|
||||
DEBUG_LOG(m_logger) << "Setting current download mode to PDF";
|
||||
m_mainHandler->dds()->fts()->enableStartBaseDownload(false);
|
||||
m_mainHandler->dds()->fts()->enableGetPdfList();
|
||||
m_mainHandler->dds()->fts()->enableStartPdfDownload();
|
||||
break;
|
||||
case CurrentDownload::BASE:
|
||||
DEBUG_LOG() << "Setting current download mode to BASE";
|
||||
DEBUG_LOG(m_logger) << "Setting current download mode to BASE";
|
||||
m_mainHandler->dds()->fts()->enableStartBaseDownload();
|
||||
m_mainHandler->dds()->fts()->enableGetPdfList(false);
|
||||
m_mainHandler->dds()->fts()->enableStartPdfDownload(false);
|
||||
break;
|
||||
case CurrentDownload::NOTHING:
|
||||
DEBUG_LOG() << "Setting current download mode to NOTHING";
|
||||
DEBUG_LOG(m_logger) << "Setting current download mode to NOTHING";
|
||||
m_mainHandler->dds()->fts()->enableAll();
|
||||
break;
|
||||
default:
|
||||
|
||||
+5
-5
@@ -43,9 +43,9 @@ bool WebSocketInterfaceHandler::init()
|
||||
{
|
||||
cleanup();
|
||||
|
||||
DEBUG_LOG() << "WebSocketInterfaceHandler::init";
|
||||
DEBUG_LOG(m_logger) << "WebSocketInterfaceHandler::init";
|
||||
m_dataManager = new DataManager(m_mainHandler);
|
||||
DEBUG_LOG() << "... ok";
|
||||
DEBUG_LOG(m_logger) << "... ok";
|
||||
|
||||
m_messageFactory = new Messages::ClientMessageFactory(m_dataManager);
|
||||
|
||||
@@ -55,7 +55,7 @@ bool WebSocketInterfaceHandler::init()
|
||||
void WebSocketInterfaceHandler::open(const QString &hostname, int port)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "Opening " << hostname << ":" << port;
|
||||
DEBUG_LOG(m_logger) << "Opening " << hostname << ":" << port;
|
||||
|
||||
recreateWebSocket();
|
||||
|
||||
@@ -79,7 +79,7 @@ void WebSocketInterfaceHandler::close()
|
||||
bool WebSocketInterfaceHandler::send(LtsWebSocket::ReplyMessage *message)
|
||||
{
|
||||
|
||||
DEBUG_LOG() << "Sending: " << message->toJsonString();
|
||||
DEBUG_LOG(m_logger) << "Sending: " << message->toJsonString();
|
||||
|
||||
if (!m_webSocketClient)
|
||||
return false;
|
||||
@@ -112,7 +112,7 @@ void WebSocketInterfaceHandler::recreateWebSocket()
|
||||
connect(m_webSocketClient, &LtsWebSocket::LtsWebSocketClient::dataReceived,
|
||||
this, [this]()
|
||||
{
|
||||
DEBUG_LOG() << "data received restart timer";
|
||||
DEBUG_LOG(m_logger) << "data received restart timer";
|
||||
m_webSocketActivityTimer->start();
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ bool CopyDatabase::doCopy()
|
||||
{
|
||||
if (!runPgDump())
|
||||
{
|
||||
ERROR_LOG() << "Error running pg_dump";
|
||||
ERROR_LOG(m_logger) << "Error running pg_dump";
|
||||
emit copyDbFailed();
|
||||
return false;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ void CopyDatabase::onDropDbFinished(int exitCode, QProcess::ExitStatus exitStatu
|
||||
|
||||
if (exitCode > 0)
|
||||
{
|
||||
ERROR_LOG() << "DropDb failed";
|
||||
ERROR_LOG(m_logger) << "DropDb failed";
|
||||
emit dropDatabaseFailed();
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ void CopyDatabase::onCreateDbFinished(int exitCode, QProcess::ExitStatus exitSta
|
||||
|
||||
if (exitCode > 0)
|
||||
{
|
||||
ERROR_LOG() << "CreateDB failed";
|
||||
ERROR_LOG(m_logger) << "CreateDB failed";
|
||||
emit copyDbFailed();
|
||||
return;
|
||||
}
|
||||
@@ -179,7 +179,7 @@ void CopyDatabase::onPgLoadFinished(int exitCode, QProcess::ExitStatus exitStatu
|
||||
|
||||
if (exitCode > 0)
|
||||
{
|
||||
ERROR_LOG() << "Loading db failed";
|
||||
ERROR_LOG(m_logger) << "Loading db failed";
|
||||
emit copyDbFailed();
|
||||
return;
|
||||
}
|
||||
@@ -207,7 +207,7 @@ void CopyDatabase::onPgSetGrantFinished(int exitCode, QProcess::ExitStatus exitS
|
||||
|
||||
if (exitCode > 0)
|
||||
{
|
||||
ERROR_LOG() << "Set grants to ets_admin failed";
|
||||
ERROR_LOG(m_logger) << "Set grants to ets_admin failed";
|
||||
emit copyDbFailed();
|
||||
return;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ void CopyDatabase::handleProcFinished(int exitCode, QProcess::ExitStatus exitSta
|
||||
if (!out.isEmpty())
|
||||
out += '\n';
|
||||
out += m_proc->readAllStandardOutput();
|
||||
ERROR_LOG() << "Process finished - exitCode: " << exitCode << ", exitStatus = " << exitStatus << ", " << out;
|
||||
ERROR_LOG(m_logger) << "Process finished - exitCode: " << exitCode << ", exitStatus = " << exitStatus << ", " << out;
|
||||
}
|
||||
m_proc->disconnect(this);
|
||||
m_proc->deleteLater();
|
||||
@@ -250,7 +250,7 @@ void CopyDatabase::handleProcFinished(int exitCode, QProcess::ExitStatus exitSta
|
||||
|
||||
void CopyDatabase::onErrorOccured(QProcess::ProcessError error)
|
||||
{
|
||||
ERROR_LOG() << "error: " << error << ", " << m_proc->readAllStandardOutput() << ", " << m_proc->readAllStandardError();
|
||||
ERROR_LOG(m_logger) << "error: " << error << ", " << m_proc->readAllStandardOutput() << ", " << m_proc->readAllStandardError();
|
||||
}
|
||||
|
||||
QString CopyDatabase::getDumpFile() const
|
||||
@@ -263,7 +263,7 @@ QString CopyDatabase::executablePath(const QString &program)
|
||||
QString errStr;
|
||||
const QString ret = NGL::postgresExecutablePath(program, errStr);
|
||||
if (!errStr.isEmpty())
|
||||
WARNING_LOG() << errStr;
|
||||
WARNING_LOG(m_logger) << errStr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ Q_SIGNALS:
|
||||
void dropDatabaseFailed();
|
||||
void dropDatabaseFinished();
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool runDropDb(const QString &dbName);
|
||||
void onDropDbFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void runGrant();
|
||||
@@ -52,6 +53,7 @@ private:
|
||||
|
||||
QString executablePath(const QString &program);
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QString m_dbHost;
|
||||
QString m_srcDbName;
|
||||
QString m_dstDbName;
|
||||
|
||||
@@ -17,14 +17,14 @@ namespace OcBaseDownload
|
||||
DdsHandler::DdsHandler(int domainId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Global, 0))
|
||||
{
|
||||
DEBUG_LOG() << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
if(!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG() << "Error initializing dds connections - aborting";
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ bool DdsHandler::init(const QStringList &qosFileList)
|
||||
m_ddsFts = OcBaseDownload::Interface::Fts::create(m_ddsConnector);
|
||||
|
||||
bool bRet = m_ddsFts->enableAll();
|
||||
INFO_LOG() << "Fts initialised";
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
std::shared_ptr<OcBaseDownload::Interface::Fts> fts() const { return m_ddsFts; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<DTS::CurrentRunningState> m_dtsCurrentRunningState;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
|
||||
+50
-50
@@ -84,7 +84,7 @@ bool HandlerBaseDownload::init()
|
||||
if (!m_scmDtc->enableServiceInformation() ||
|
||||
!m_scmDtc->enableGroupInformation())
|
||||
{
|
||||
ERROR_LOG() << "Enabling SCM Data-Topics failed.";
|
||||
ERROR_LOG(m_logger) << "Enabling SCM Data-Topics failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,11 +92,11 @@ bool HandlerBaseDownload::init()
|
||||
if (!m_scmFtc->enableRestartGroup() ||
|
||||
!m_scmFtc->enableStopGroup())
|
||||
{
|
||||
ERROR_LOG() << "Enabling SCM Function-Topics failed.";
|
||||
ERROR_LOG(m_logger) << "Enabling SCM Function-Topics failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG() << "HandlerBaseDownload initialised!";
|
||||
INFO_LOG(m_logger) << "HandlerBaseDownload initialised!";
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -559,7 +559,7 @@ void HandlerBaseDownload::receiveFlmData()
|
||||
" FROM ") + tableName + where + where2);
|
||||
|
||||
|
||||
ERROR_LOG() << "FUCK FUCK WE ARE HERE!" << " snapshid id is= " << snapshotFolderId << " also my statement: " << stmt;
|
||||
ERROR_LOG(m_logger) << "FUCK FUCK WE ARE HERE!" << " snapshid id is= " << snapshotFolderId << " also my statement: " << stmt;
|
||||
std::unique_ptr<NSqlQuery> query = std::unique_ptr<NSqlQuery>(new NSqlQuery(remoteDbIfc->database(), m_logger));
|
||||
query->prepare(stmt);
|
||||
QVector<Database::FlmFileContent> dataVec;
|
||||
@@ -591,10 +591,10 @@ void HandlerBaseDownload::receiveFlmData()
|
||||
data.fileTypeId == FileManagement::FileType::Png)
|
||||
&& data.folderId != snapshotFolderId)
|
||||
{
|
||||
DEBUG_LOG() << "skip";
|
||||
DEBUG_LOG(m_logger) << "skip";
|
||||
continue;
|
||||
}
|
||||
// ERROR_LOG() << "ADD " << data.name;
|
||||
// ERROR_LOG(m_logger) << "ADD " << data.name;
|
||||
|
||||
dataVec.append(data);
|
||||
}
|
||||
@@ -602,7 +602,7 @@ void HandlerBaseDownload::receiveFlmData()
|
||||
|
||||
if (!dataVec.isEmpty())
|
||||
{
|
||||
ERROR_LOG() << "Data vec has sisze: " << dataVec.size();
|
||||
ERROR_LOG(m_logger) << "Data vec has sisze: " << dataVec.size();
|
||||
storeToDataVecMap(DbDataType::FlmFileContent, std::vector<Database::FlmFileContent>(dataVec.begin(), dataVec.end()));
|
||||
m_remoteDbRetryCounter = 0;
|
||||
}
|
||||
@@ -682,10 +682,10 @@ QSqlDatabase HandlerBaseDownload::openDb(const QString &databaseName, bool remot
|
||||
s->databaseDriver(),
|
||||
remote ? m_hostname : s->databaseHostname(),
|
||||
remote ? Settings::remoteDbName() : databaseName);
|
||||
DEBUG_LOG() << "Trying to open database " << s->databaseHostname() << ":" << databaseName;
|
||||
DEBUG_LOG(m_logger) << "Trying to open database " << s->databaseHostname() << ":" << databaseName;
|
||||
if (!dbConnection.isOpen())
|
||||
{
|
||||
ERROR_LOG() << "Error opening database " << s->databaseHostname() << ":" << databaseName;
|
||||
ERROR_LOG(m_logger) << "Error opening database " << s->databaseHostname() << ":" << databaseName;
|
||||
if (bOk)
|
||||
*bOk = false;
|
||||
}
|
||||
@@ -725,11 +725,11 @@ void HandlerBaseDownload::updateBaseDownloadReply()
|
||||
|
||||
void HandlerBaseDownload::onStartBaseDownloadRequest(const rti::core::SampleIdentity &cookie, const StartBaseDownloadRequest &request)
|
||||
{
|
||||
DEBUG_LOG() << "Got Request, check for old one : " << request.hostname();
|
||||
DEBUG_LOG(m_logger) << "Got Request, check for old one : " << request.hostname();
|
||||
|
||||
if (request.timeStamp() < (QDateTime::currentMSecsSinceEpoch() - 10 * 1000)) //(5Sekunden)
|
||||
{
|
||||
DEBUG_LOG() << "old call? ignore! ";
|
||||
DEBUG_LOG(m_logger) << "old call? ignore! ";
|
||||
m_reply.progress(0);
|
||||
m_reply.errorString(std::string());
|
||||
m_reply.currentStep(std::string());
|
||||
@@ -937,7 +937,7 @@ void HandlerBaseDownload::switchState()
|
||||
break;
|
||||
default:
|
||||
{
|
||||
ERROR_LOG() << "State " << m_currentState << " is not handled properly.";
|
||||
ERROR_LOG(m_logger) << "State " << m_currentState << " is not handled properly.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -970,7 +970,7 @@ void HandlerBaseDownload::dropOldDatabase()
|
||||
const int revId = val.midRef(idx + 1).toInt(&bOk);
|
||||
if (!bOk)
|
||||
continue;
|
||||
DEBUG_LOG() << val << ", " << revId << ", " << curId;
|
||||
DEBUG_LOG(m_logger) << val << ", " << revId << ", " << curId;
|
||||
if (revId < curId - 1 || revId >= curId)
|
||||
m_databasesToDrop += val;
|
||||
}
|
||||
@@ -1017,14 +1017,14 @@ void HandlerBaseDownload::onCopyDbFinished()
|
||||
|
||||
void HandlerBaseDownload::checkForAsmFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all ASM base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all ASM base data arrived.";
|
||||
|
||||
if (m_dataVecMap.contains(AsmTrainingArea) &&
|
||||
m_dataVecMap.contains(AsmLocation) &&
|
||||
m_dataVecMap.contains(AsmAsset) &&
|
||||
m_dataVecMap.contains(AsmTechnicalArea))
|
||||
{
|
||||
INFO_LOG() << "All ASM base data arrived.";
|
||||
INFO_LOG(m_logger) << "All ASM base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
checkAliveTimer();
|
||||
@@ -1032,12 +1032,12 @@ void HandlerBaseDownload::checkForAsmFinished()
|
||||
|
||||
void HandlerBaseDownload::checkForExmFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all EXM base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all EXM base data arrived.";
|
||||
if (m_dataVecMap.contains(ExmExercise) &&
|
||||
m_dataVecMap.contains(ExmExercisePhase) &&
|
||||
m_dataVecMap.contains(ExmExerciseStateChange))
|
||||
{
|
||||
INFO_LOG() << "All EXM base data arrived.";
|
||||
INFO_LOG(m_logger) << "All EXM base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
checkAliveTimer();
|
||||
@@ -1045,7 +1045,7 @@ void HandlerBaseDownload::checkForExmFinished()
|
||||
|
||||
void HandlerBaseDownload::checkForIsmFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all ISM base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all ISM base data arrived.";
|
||||
if (m_dataVecMap.contains(IsmAsset) &&
|
||||
m_dataVecMap.contains(IsmMainStructureElement) &&
|
||||
m_dataVecMap.contains(IsmStructureElement) &&
|
||||
@@ -1054,7 +1054,7 @@ void HandlerBaseDownload::checkForIsmFinished()
|
||||
m_dataVecMap.contains(IsmMountingPointSchedule) &&
|
||||
m_dataVecMap.contains(IsmMountingPointPlan))
|
||||
{
|
||||
INFO_LOG() << "All ISM base data arrived.";
|
||||
INFO_LOG(m_logger) << "All ISM base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
checkAliveTimer();
|
||||
@@ -1062,22 +1062,22 @@ void HandlerBaseDownload::checkForIsmFinished()
|
||||
|
||||
void HandlerBaseDownload::checkForPpmEx0Finished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all PPM Ex0 base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all PPM Ex0 base data arrived.";
|
||||
if (m_dataVecMap.contains(PpmEquipmentType) &&
|
||||
m_dataVecMap.contains(PpmType))
|
||||
{
|
||||
INFO_LOG() << "All PPM Ex0 base data arrived.";
|
||||
INFO_LOG(m_logger) << "All PPM Ex0 base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerBaseDownload::checkForPpmExNFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all PPM ExN base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all PPM ExN base data arrived.";
|
||||
if (m_dataVecMap.contains(PpmParty) &&
|
||||
m_dataVecMap.contains(PpmParticipant))
|
||||
{
|
||||
INFO_LOG() << "All PPM ExN base data arrived.";
|
||||
INFO_LOG(m_logger) << "All PPM ExN base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
checkAliveTimer();
|
||||
@@ -1085,7 +1085,7 @@ void HandlerBaseDownload::checkForPpmExNFinished()
|
||||
|
||||
void HandlerBaseDownload::checkForOpmFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all OPM base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all OPM base data arrived.";
|
||||
if (m_dataVecMap.contains(OpmGroup) &&
|
||||
m_dataVecMap.contains(OpmGroupGroup) &&
|
||||
m_dataVecMap.contains(OpmOperator) &&
|
||||
@@ -1095,7 +1095,7 @@ void HandlerBaseDownload::checkForOpmFinished()
|
||||
m_dataVecMap.contains(OpmAclAllow) &&
|
||||
m_dataVecMap.contains(OpmAclDeny))
|
||||
{
|
||||
INFO_LOG() << "All OPM base data arrived.";
|
||||
INFO_LOG(m_logger) << "All OPM base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
checkAliveTimer();
|
||||
@@ -1103,11 +1103,11 @@ void HandlerBaseDownload::checkForOpmFinished()
|
||||
|
||||
void HandlerBaseDownload::checkForFlmFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Checking if all FLM base data arrived.";
|
||||
DEBUG_LOG(m_logger) << "Checking if all FLM base data arrived.";
|
||||
if (m_dataVecMap.contains(FlmFolder) &&
|
||||
m_dataVecMap.contains(FlmFileContent))
|
||||
{
|
||||
INFO_LOG() << "All FLM base data arrived.";
|
||||
INFO_LOG(m_logger) << "All FLM base data arrived.";
|
||||
stateFinished();
|
||||
}
|
||||
checkAliveTimer();
|
||||
@@ -1442,13 +1442,13 @@ void HandlerBaseDownload::insertPpmExNDbData(bool live)
|
||||
participantData.push_back(newEntry);
|
||||
partyToUnit.insert(party.id, newEntry.id);
|
||||
|
||||
TRACE_LOG() << "Adding: " << newEntry.name << " to participantData.";
|
||||
TRACE_LOG(m_logger) << "Adding: " << newEntry.name << " to participantData.";
|
||||
}
|
||||
// insert pseudo-units
|
||||
ppmDbHandler->db()->upsert(participantData);
|
||||
#endif
|
||||
}
|
||||
DEBUG_LOG() << "Now add participants: " << getDbDataVec<ParticipantManagement::Database::PpmParticipant>(PpmParticipant).size();
|
||||
DEBUG_LOG(m_logger) << "Now add participants: " << getDbDataVec<ParticipantManagement::Database::PpmParticipant>(PpmParticipant).size();
|
||||
for (const auto &participant : getDbDataVec<ParticipantManagement::Database::PpmParticipant>(PpmParticipant))
|
||||
{
|
||||
if (participant.partyId == 0)
|
||||
@@ -1464,7 +1464,7 @@ void HandlerBaseDownload::insertPpmExNDbData(bool live)
|
||||
newParticipant.superiorId = partyToUnit.value(participant.partyId);
|
||||
newParticipant.hierarchyNumber = participant.id;
|
||||
#endif
|
||||
DEBUG_LOG() << "XXXXXXXX Adding Participant: " << newParticipant.id << " typeId: " << newParticipant.typeId << " typeClass: " << typeClass << " supperioer " << newParticipant.superiorId;
|
||||
DEBUG_LOG(m_logger) << "XXXXXXXX Adding Participant: " << newParticipant.id << " typeId: " << newParticipant.typeId << " typeClass: " << typeClass << " supperioer " << newParticipant.superiorId;
|
||||
|
||||
newParticipants.push_back(std::move(newParticipant));
|
||||
}
|
||||
@@ -1587,7 +1587,7 @@ inline void resetVector(QPair<bool, QVector<T>> &dbVector)
|
||||
void HandlerBaseDownload::cleanup(const Core::FtReplyState &replyState, const std::string &errStr)
|
||||
{
|
||||
if (errStr.size() > 0)
|
||||
ERROR_LOG() << "Base Download ended with error: " << errStr;
|
||||
ERROR_LOG(m_logger) << "Base Download ended with error: " << errStr;
|
||||
|
||||
// cleanup db data
|
||||
qDeleteAll(m_dataVecMap);
|
||||
@@ -1649,7 +1649,7 @@ void HandlerBaseDownload::copyFromOldDatabase()
|
||||
const QString schemaName = QLatin1String("ex_") + QString::number(m_exerciseId);
|
||||
if (m_exTblGen->existsSchema(schemaName, dbIn))
|
||||
{
|
||||
DEBUG_LOG() << "### Copying old files from schema " << schemaName;
|
||||
DEBUG_LOG(m_logger) << "### Copying old files from schema " << schemaName;
|
||||
{
|
||||
// own transaction when old ex_N schema does not exist.
|
||||
DBTransaction trans(m_dbConnection);
|
||||
@@ -1721,7 +1721,7 @@ void HandlerBaseDownload::copyFromOldDatabase()
|
||||
for (const QString &table : std::as_const(tableList))
|
||||
{
|
||||
if (!copyTable(dbIn, m_dbConnection, table))
|
||||
ERROR_LOG() << "Failed to copy table " << table;
|
||||
ERROR_LOG(m_logger) << "Failed to copy table " << table;
|
||||
checkAliveTimer();
|
||||
}
|
||||
trans.commit();
|
||||
@@ -2187,7 +2187,7 @@ void HandlerBaseDownload::onStopGroupReply(const Core::FunctionReplyObject &repl
|
||||
return;
|
||||
}
|
||||
if (!m_stopGroupIds.remove(reply.id()))
|
||||
WARNING_LOG() << "Got unknown reply id for stop group request: " << reply.id();
|
||||
WARNING_LOG(m_logger) << "Got unknown reply id for stop group request: " << reply.id();
|
||||
|
||||
if (!m_stopGroupIds.isEmpty())
|
||||
return;
|
||||
@@ -2214,7 +2214,7 @@ void HandlerBaseDownload::restartCoreGroup()
|
||||
// we are also restarted... so answer here directly with 'finished'
|
||||
stateFinished();
|
||||
if (request.type() != Core::ServiceGroupType::Core)
|
||||
WARNING_LOG() << "Could not find core group to restart...";
|
||||
WARNING_LOG(m_logger) << "Could not find core group to restart...";
|
||||
|
||||
const auto restartCb = [this, request]()
|
||||
{
|
||||
@@ -2231,7 +2231,7 @@ void HandlerBaseDownload::onRestartGroupReply(const Core::FunctionReplyObject &r
|
||||
return;
|
||||
}
|
||||
// we won't get here since we're restarted too
|
||||
ERROR_LOG() << "onRestartGroupReply?";
|
||||
ERROR_LOG(m_logger) << "onRestartGroupReply?";
|
||||
stateFinished();
|
||||
}
|
||||
|
||||
@@ -2266,11 +2266,11 @@ bool HandlerBaseDownload::copyTable(const QSqlDatabase &dbIn, const QSqlDatabase
|
||||
NSqlQuery qIn(dbIn);
|
||||
NSqlQuery qOut(dbOut);
|
||||
|
||||
DEBUG_LOG() << "Copying " << tableName << " started";
|
||||
DEBUG_LOG(m_logger) << "Copying " << tableName << " started";
|
||||
const QSqlRecord record = dbIn.record(tableName);
|
||||
if (record.isEmpty())
|
||||
{
|
||||
ERROR_LOG() << "Empty record for " << tableName;
|
||||
ERROR_LOG(m_logger) << "Empty record for " << tableName;
|
||||
return false;
|
||||
}
|
||||
QStringList selectTableColumns;
|
||||
@@ -2291,18 +2291,18 @@ bool HandlerBaseDownload::copyTable(const QSqlDatabase &dbIn, const QSqlDatabase
|
||||
selectTableColumns.join(QStringLiteral(", ")),
|
||||
insertTablePlaceholder.join(QStringLiteral(", "))));
|
||||
|
||||
DEBUG_LOG() << selectTableCommand;
|
||||
DEBUG_LOG() << insertTableCommand;
|
||||
DEBUG_LOG(m_logger) << selectTableCommand;
|
||||
DEBUG_LOG(m_logger) << insertTableCommand;
|
||||
|
||||
if (!qOut.prepare(insertTableCommand))
|
||||
{
|
||||
ERROR_LOG() << "qOut prepare failed... " << qOut.lastError().text();
|
||||
ERROR_LOG(m_logger) << "qOut prepare failed... " << qOut.lastError().text();
|
||||
return false;
|
||||
}
|
||||
if (!qIn.exec(selectTableCommand))
|
||||
{
|
||||
ERROR_LOG() << "qIn select failed... " << qIn.lastError().text();
|
||||
DEBUG_LOG() << "FAILED statement: " << selectTableCommand;
|
||||
ERROR_LOG(m_logger) << "qIn select failed... " << qIn.lastError().text();
|
||||
DEBUG_LOG(m_logger) << "FAILED statement: " << selectTableCommand;
|
||||
qIn.finish();
|
||||
return false;
|
||||
}
|
||||
@@ -2312,17 +2312,17 @@ bool HandlerBaseDownload::copyTable(const QSqlDatabase &dbIn, const QSqlDatabase
|
||||
qOut.bindValue(insertTablePlaceholder.at(i), qIn.value(i));
|
||||
if (!qOut.exec())
|
||||
{
|
||||
ERROR_LOG() << "qOut insert failed.. " << qOut.lastError().text();
|
||||
DEBUG_LOG() << "FAILED statement: " << insertTableCommand;
|
||||
ERROR_LOG(m_logger) << "qOut insert failed.. " << qOut.lastError().text();
|
||||
DEBUG_LOG(m_logger) << "FAILED statement: " << insertTableCommand;
|
||||
qOut.finish();
|
||||
return false;
|
||||
}
|
||||
checkAliveTimer();
|
||||
}
|
||||
DEBUG_LOG() << "Copying " << tableName << " finished";
|
||||
DEBUG_LOG(m_logger) << "Copying " << tableName << " finished";
|
||||
|
||||
if (!fixUpSequence(dbOut, tableName))
|
||||
WARNING_LOG() << "Failed to update sequence for table " << tableName;
|
||||
WARNING_LOG(m_logger) << "Failed to update sequence for table " << tableName;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2344,14 +2344,14 @@ bool HandlerBaseDownload::fixUpSequence(const QSqlDatabase &dbOut, const QString
|
||||
keyField = QStringLiteral("id");
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Updating sequence " << seqName << " for table " << tableName;
|
||||
DEBUG_LOG(m_logger) << "Updating sequence " << seqName << " for table " << tableName;
|
||||
|
||||
const QString stmt(QStringLiteral("SELECT setval('%1', COALESCE((SELECT MAX(%2)+1 FROM %3), 1), false)").arg(seqName, keyField, tableName));
|
||||
|
||||
if (!qOut.exec(stmt))
|
||||
{
|
||||
ERROR_LOG() << "FAILED to update sequence for table " << tableName << " : " << qOut.lastError().text();
|
||||
DEBUG_LOG() << "FAILED statement: " << stmt;
|
||||
ERROR_LOG(m_logger) << "FAILED to update sequence for table " << tableName << " : " << qOut.lastError().text();
|
||||
DEBUG_LOG(m_logger) << "FAILED statement: " << stmt;
|
||||
qOut.finish();
|
||||
return false;
|
||||
}
|
||||
|
||||
+25
-25
@@ -52,7 +52,7 @@ HandlerPdfDownload::~HandlerPdfDownload()
|
||||
|
||||
bool HandlerPdfDownload::init()
|
||||
{
|
||||
INFO_LOG() << "HandlerPdfDownload initialised!";
|
||||
INFO_LOG(m_logger) << "HandlerPdfDownload initialised!";
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ void HandlerPdfDownload::handleServicePortsInformation(const QVector<WebSocketIn
|
||||
m_webSocket->open(m_hostname, flmPort);
|
||||
else
|
||||
{
|
||||
ERROR_LOG() << "Could not connect to FileManagement WebSocket server.";
|
||||
ERROR_LOG(m_logger) << "Could not connect to FileManagement WebSocket server.";
|
||||
m_currentMode = Mode::PORT_REQUEST;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +139,7 @@ void HandlerPdfDownload::onGetPdfListRequest(const rti::core::SampleIdentity &co
|
||||
void HandlerPdfDownload::onStartPdfDownloadRequest(const rti::core::SampleIdentity &cookie, const StartPdfDownloadRequest &request)
|
||||
{
|
||||
|
||||
ERROR_LOG() <<" onOcPdfDownloadRequest START" ;
|
||||
ERROR_LOG(m_logger) <<" onOcPdfDownloadRequest START" ;
|
||||
m_downloadReply = PdfDownloadReply();
|
||||
m_downloadCookie = cookie;
|
||||
|
||||
@@ -150,13 +150,13 @@ void HandlerPdfDownload::onStartPdfDownloadRequest(const rti::core::SampleIdenti
|
||||
for (int32_t id : request.documentIds())
|
||||
str.append(QString::number(id) + QStringLiteral(" "));
|
||||
|
||||
DEBUG_LOG() << str;
|
||||
DEBUG_LOG(m_logger) << str;
|
||||
}
|
||||
|
||||
if (m_hostname.isEmpty())
|
||||
{
|
||||
QString errorStr = QStringLiteral("Not able to start PDF download. Hostname not set.");
|
||||
ERROR_LOG() << errorStr;
|
||||
ERROR_LOG(m_logger) << errorStr;
|
||||
m_downloadReply.errorString(errorStr.toStdString());
|
||||
m_fts->startPdfDownloadReply(m_downloadCookie, m_downloadReply);
|
||||
return;
|
||||
@@ -200,26 +200,26 @@ void HandlerPdfDownload::onStartPdfDownloadRequest(const rti::core::SampleIdenti
|
||||
|
||||
void HandlerPdfDownload::onOcPdfDownloadRequest(const rti::core::SampleIdentity &cookie, const OcPdfDownloadRequest &request)
|
||||
{
|
||||
DEBUG_LOG() <<Q_FUNC_INFO<<" START OcPdfDownloadRequest" ;
|
||||
DEBUG_LOG(m_logger) <<Q_FUNC_INFO<<" START OcPdfDownloadRequest" ;
|
||||
m_ocPdfDownloadCookie = cookie;
|
||||
m_ocPdfDownloadReply = Core::FunctionReply();
|
||||
|
||||
if(openRemoteDbConnection(QStringLiteral("lts_ets_pro")) == false)
|
||||
{
|
||||
QString errorStr = QStringLiteral("Not able to open remote connection to DB");
|
||||
ERROR_LOG() << errorStr;
|
||||
ERROR_LOG(m_logger) << errorStr;
|
||||
m_ocPdfDownloadReply.errorString(errorStr.toStdString());
|
||||
m_fts->ocPdfDownloadReply(m_ocPdfDownloadCookie, m_ocPdfDownloadReply);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG() << "Got PDF download request for ids: "<< request.folderId();
|
||||
DEBUG_LOG(m_logger) << "Got PDF download request for ids: "<< request.folderId();
|
||||
|
||||
m_folderId = request.folderId();
|
||||
if(m_folderId == -1)
|
||||
{
|
||||
QString errorStr = QStringLiteral("Not able to start PDF download. Folder id not valid.");
|
||||
ERROR_LOG() << errorStr;
|
||||
ERROR_LOG(m_logger) << errorStr;
|
||||
m_ocPdfDownloadReply.errorString(errorStr.toStdString());
|
||||
m_fts->ocPdfDownloadReply(m_ocPdfDownloadCookie, m_ocPdfDownloadReply);
|
||||
return;
|
||||
@@ -228,7 +228,7 @@ void HandlerPdfDownload::onOcPdfDownloadRequest(const rti::core::SampleIdentity
|
||||
if (m_hostname.isEmpty())
|
||||
{
|
||||
QString errorStr = QStringLiteral("Not able to start PDF download. Hostname not set.");
|
||||
ERROR_LOG() << errorStr;
|
||||
ERROR_LOG(m_logger) << errorStr;
|
||||
m_ocPdfDownloadReply.errorString(errorStr.toStdString());
|
||||
m_fts->ocPdfDownloadReply(m_ocPdfDownloadCookie, m_ocPdfDownloadReply);
|
||||
return;
|
||||
@@ -255,7 +255,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
|
||||
auto remoteDbIfc = remoteDb->db();
|
||||
const QString dir = QStringLiteral("%1/OcPdf/%2/").arg(QDir::tempPath()).arg(m_operatorName);
|
||||
DEBUG_LOG()<<" export path: "<<dir;
|
||||
DEBUG_LOG(m_logger)<<" export path: "<<dir;
|
||||
QDir directory(dir);
|
||||
if(!directory.exists())
|
||||
directory.mkpath(dir);
|
||||
@@ -266,7 +266,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
QString strm = QStringLiteral("Select id from flm.flm_folder WHERE name = '" ) + m_operatorName + QStringLiteral("' and '") +
|
||||
QString::number(m_folderId) + QStringLiteral("' = ANY(path) LIMIT 1;");
|
||||
|
||||
DEBUG_LOG() << "folder content ID querry" << strm;
|
||||
DEBUG_LOG(m_logger) << "folder content ID querry" << strm;
|
||||
|
||||
std::unique_ptr<NSqlQuery> query = std::unique_ptr<NSqlQuery>(new NSqlQuery(remoteDbIfc->database(), m_logger));
|
||||
query->prepare(strm);
|
||||
@@ -321,7 +321,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
|
||||
if(idsList.isEmpty())
|
||||
{
|
||||
WARNING_LOG()<< " pdf files outdated! ";
|
||||
WARNING_LOG(m_logger)<< " pdf files outdated! ";
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
tableName = (QStringLiteral("flm.flm_file_content"));
|
||||
stmt = (QStringLiteral("SELECT id, name, file_status_id, content, last_modified FROM ") + tableName + where);
|
||||
|
||||
DEBUG_LOG() << "### statement: " << stmt;
|
||||
DEBUG_LOG(m_logger) << "### statement: " << stmt;
|
||||
|
||||
query->prepare(stmt);
|
||||
|
||||
@@ -353,7 +353,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
|
||||
if(data.fileStatusId == FileManagement::FileStatus::Deleted)
|
||||
{
|
||||
DEBUG_LOG()<< " skip ";
|
||||
DEBUG_LOG(m_logger)<< " skip ";
|
||||
continue;
|
||||
}
|
||||
dataVec.append(data);
|
||||
@@ -362,7 +362,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
else
|
||||
{
|
||||
const QString errorStr = tr("Not able to export PDF.");
|
||||
ERROR_LOG() << errorStr;
|
||||
ERROR_LOG(m_logger) << errorStr;
|
||||
m_ocPdfDownloadReply.errorString(errorStr.toStdString());
|
||||
return;
|
||||
}
|
||||
@@ -377,7 +377,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
if(fileInfo.exists() && file.remove() == false)
|
||||
{
|
||||
QString err = QStringLiteral("Couldn't replace existing file: ") + data.name;
|
||||
WARNING_LOG()<< err;
|
||||
WARNING_LOG(m_logger)<< err;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -395,7 +395,7 @@ void HandlerPdfDownload::exportOcPdfFileContent()
|
||||
|
||||
bool HandlerPdfDownload::openRemoteDbConnection(const QString &remoteDatabaseName)
|
||||
{
|
||||
DEBUG_LOG() <<" Open RemoteDb Connection..." ;
|
||||
DEBUG_LOG(m_logger) <<" Open RemoteDb Connection..." ;
|
||||
if (m_remoteDbConnection.isValid())
|
||||
closeDb(m_remoteDbConnection);
|
||||
|
||||
@@ -420,10 +420,10 @@ QSqlDatabase HandlerPdfDownload::openDb(const QString &databaseName, bool remote
|
||||
s->databaseDriver(),
|
||||
remote ? m_remoteHostName : s->databaseHostname(),
|
||||
remote ? Settings::remoteDbName() : databaseName);
|
||||
DEBUG_LOG() << "Trying to open database " << s->databaseHostname() << ":" << databaseName;
|
||||
DEBUG_LOG(m_logger) << "Trying to open database " << s->databaseHostname() << ":" << databaseName;
|
||||
if (!dbConnection.isOpen())
|
||||
{
|
||||
ERROR_LOG() << "Error opening database " << s->databaseHostname() << ":" << databaseName;
|
||||
ERROR_LOG(m_logger) << "Error opening database " << s->databaseHostname() << ":" << databaseName;
|
||||
if (bOk)
|
||||
*bOk = false;
|
||||
}
|
||||
@@ -443,7 +443,7 @@ void HandlerPdfDownload::closeDb(QSqlDatabase &dbConn)
|
||||
|
||||
void HandlerPdfDownload::onConnected()
|
||||
{
|
||||
INFO_LOG() << "Connected to WebSocket server";
|
||||
INFO_LOG(m_logger) << "Connected to WebSocket server";
|
||||
|
||||
switch (m_currentMode)
|
||||
{
|
||||
@@ -458,12 +458,12 @@ void HandlerPdfDownload::onConnected()
|
||||
|
||||
void HandlerPdfDownload::onDisconnected()
|
||||
{
|
||||
INFO_LOG() << "Disconnected from server.";
|
||||
INFO_LOG(m_logger) << "Disconnected from server.";
|
||||
}
|
||||
|
||||
void HandlerPdfDownload::onNewDownloadState(int progress, const QString &msg)
|
||||
{
|
||||
DEBUG_LOG() << msg;
|
||||
DEBUG_LOG(m_logger) << msg;
|
||||
m_downloadReply.replyState(Core::FtReplyState::InProgress);
|
||||
m_downloadReply.progress(progress);
|
||||
m_downloadReply.currentStep(msg.toStdString());
|
||||
@@ -472,7 +472,7 @@ void HandlerPdfDownload::onNewDownloadState(int progress, const QString &msg)
|
||||
|
||||
void HandlerPdfDownload::onAllDownloadsFinished()
|
||||
{
|
||||
DEBUG_LOG() << "Downloads finished";
|
||||
DEBUG_LOG(m_logger) << "Downloads finished";
|
||||
m_downloadReply.replyState(Core::FtReplyState::Completed);
|
||||
m_downloadReply.currentStep(tr("Downloads finished").toStdString());
|
||||
m_downloadReply.progress(100);
|
||||
@@ -481,7 +481,7 @@ void HandlerPdfDownload::onAllDownloadsFinished()
|
||||
|
||||
void HandlerPdfDownload::openWebSocket()
|
||||
{
|
||||
DEBUG_LOG() << "Opening websocket to: " << m_hostname << ":" << m_currentPort;
|
||||
DEBUG_LOG(m_logger) << "Opening websocket to: " << m_hostname << ":" << m_currentPort;
|
||||
m_webSocket->open(m_hostname, m_currentPort);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,15 +13,14 @@
|
||||
namespace OcBaseDownload
|
||||
{
|
||||
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
MainHandler::MainHandler(QObject *parent) : QObject(parent)
|
||||
, m_ddsHandler(nullptr)
|
||||
, m_handlerBaseDownload(nullptr)
|
||||
, m_handlerPdfDownload(nullptr)
|
||||
, m_handlerWebSocket(nullptr)
|
||||
, m_scmDtc(nullptr)
|
||||
, m_scmFtc(nullptr)
|
||||
{}
|
||||
, m_scmFtc(nullptr),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
@@ -39,24 +38,24 @@ bool MainHandler::init(int domainId)
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation ddsHandler failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG() << "Initialisation ddsHandler succesful.";
|
||||
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
|
||||
|
||||
// create SCM Dtc
|
||||
m_scmDtc = ServiceManagement::Interface::Dtc::create(m_ddsHandler->dds());
|
||||
DEBUG_LOG() << "Created SCM Dtc";
|
||||
DEBUG_LOG(m_logger) << "Created SCM Dtc";
|
||||
|
||||
// create SCM Ftc
|
||||
m_scmFtc = ServiceManagement::Interface::Ftc::create(m_ddsHandler->dds());
|
||||
DEBUG_LOG() << "Created SCM Ftc";
|
||||
DEBUG_LOG(m_logger) << "Created SCM Ftc";
|
||||
|
||||
// create handler base download
|
||||
m_handlerWebSocket = std::make_shared<WebSocketInterface::WebSocketInterfaceHandler>(this);
|
||||
if (!m_handlerWebSocket->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerWebSocket failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerWebSocket failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -64,7 +63,7 @@ bool MainHandler::init(int domainId)
|
||||
m_handlerBaseDownload = std::make_shared<HandlerBaseDownload>(this, this);
|
||||
if (!m_handlerBaseDownload->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerBaseDownload failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerBaseDownload failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -72,7 +71,7 @@ bool MainHandler::init(int domainId)
|
||||
m_handlerPdfDownload = std::make_shared<HandlerPdfDownload>(this, this);
|
||||
if (!m_handlerBaseDownload->init())
|
||||
{
|
||||
ERROR_LOG() << "Initialisation HandlerPdfDownload failed.";
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerPdfDownload failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
std::shared_ptr<ServiceManagement::Interface::Ftc> scmFtc() const { return m_scmFtc; }
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<HandlerBaseDownload> m_handlerBaseDownload;
|
||||
std::shared_ptr<HandlerPdfDownload> m_handlerPdfDownload;
|
||||
|
||||
+13
-14
@@ -15,20 +15,19 @@
|
||||
|
||||
namespace OcBaseDownload
|
||||
{
|
||||
PdfDownloadSocket::PdfDownloadSocket(const QString &hostName, QObject *parent)
|
||||
: QObject(parent)
|
||||
PdfDownloadSocket::PdfDownloadSocket(const QString &hostName, QObject *parent) : QObject(parent)
|
||||
, m_socket(new QTcpSocket(this))
|
||||
, m_readTimeout(new QTimer(this))
|
||||
, m_sizeToDownload(0)
|
||||
{
|
||||
DEBUG_LOG() << "PdfDownloadSocket::PdfDownloadSocket";
|
||||
, m_sizeToDownload(0),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
DEBUG_LOG(m_logger) << "PdfDownloadSocket::PdfDownloadSocket";
|
||||
connect(m_socket, &QTcpSocket::connected, this, &PdfDownloadSocket::connected);
|
||||
connect(m_socket, &QTcpSocket::readyRead, this, &PdfDownloadSocket::readyRead);
|
||||
unsigned short port = NGL::Connections::port(NGL::Connections::eConnection::FLM_PDF_SERVER);
|
||||
m_socket->connectToHost(hostName, port);
|
||||
m_socket->waitForConnected();
|
||||
|
||||
DEBUG_LOG() << "hostname " << hostName << " port " << port;
|
||||
DEBUG_LOG(m_logger) << "hostname " << hostName << " port " << port;
|
||||
|
||||
m_readTimeout->setInterval(10000);
|
||||
m_readTimeout->setSingleShot(false);
|
||||
@@ -37,23 +36,23 @@ PdfDownloadSocket::PdfDownloadSocket(const QString &hostName, QObject *parent)
|
||||
|
||||
PdfDownloadSocket::~PdfDownloadSocket()
|
||||
{
|
||||
DEBUG_LOG() << "~PdfDownloadSocket";
|
||||
DEBUG_LOG(m_logger) << "~PdfDownloadSocket";
|
||||
m_socket->close();
|
||||
}
|
||||
|
||||
void PdfDownloadSocket::readyRead()
|
||||
{
|
||||
DEBUG_LOG() << "reading...";
|
||||
DEBUG_LOG(m_logger) << "reading...";
|
||||
m_readTimeout->stop();
|
||||
|
||||
m_downloadedData.append(m_socket->readAll());
|
||||
|
||||
DEBUG_LOG() << m_downloadedData.size() << " of " << m_sizeToDownload << " bytes downloaded";
|
||||
DEBUG_LOG(m_logger) << m_downloadedData.size() << " of " << m_sizeToDownload << " bytes downloaded";
|
||||
|
||||
if (m_downloadedData.size() >= m_sizeToDownload)
|
||||
{
|
||||
m_sizeToDownload = 0;
|
||||
DEBUG_LOG() << "Download finished";
|
||||
DEBUG_LOG(m_logger) << "Download finished";
|
||||
emit downloadFinished(m_downloadedData);
|
||||
}
|
||||
else
|
||||
@@ -62,17 +61,17 @@ void PdfDownloadSocket::readyRead()
|
||||
|
||||
void PdfDownloadSocket::connected()
|
||||
{
|
||||
DEBUG_LOG() << "connected...";
|
||||
DEBUG_LOG(m_logger) << "connected...";
|
||||
}
|
||||
|
||||
void PdfDownloadSocket::onReadTimeout()
|
||||
{
|
||||
//check for filesize
|
||||
m_readTimeout->stop();
|
||||
DEBUG_LOG() << "TimerEnd" << m_downloadedData.size() << " expected " << m_sizeToDownload;
|
||||
DEBUG_LOG(m_logger) << "TimerEnd" << m_downloadedData.size() << " expected " << m_sizeToDownload;
|
||||
|
||||
if (m_downloadedData.size() < m_sizeToDownload)
|
||||
WARNING_LOG() << "not enough data: got " << m_downloadedData.size() << " expected " << m_sizeToDownload;
|
||||
WARNING_LOG(m_logger) << "not enough data: got " << m_downloadedData.size() << " expected " << m_sizeToDownload;
|
||||
|
||||
emit downloadFinished(m_downloadedData);
|
||||
}
|
||||
@@ -89,7 +88,7 @@ void PdfDownloadSocket::downloadFromHost(const int fileId, const qint64 fileSize
|
||||
m_socket->readAll();
|
||||
|
||||
int writeHeaderSize = m_socket->write(cmd);
|
||||
DEBUG_LOG() << "writeHeaderSize = " << writeHeaderSize;
|
||||
DEBUG_LOG(m_logger) << "writeHeaderSize = " << writeHeaderSize;
|
||||
m_readTimeout->start();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ private slots:
|
||||
void onReadTimeout();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
QTcpSocket *m_socket;
|
||||
QTimer *m_readTimeout;
|
||||
int m_sizeToDownload;
|
||||
|
||||
@@ -21,16 +21,15 @@
|
||||
|
||||
namespace OcBaseDownload
|
||||
{
|
||||
PdfDownloader::PdfDownloader(const QVector<WebSocketInterface::Messages::PdfListMessage::PdfInformation> &pdfInfoVec, MainHandler *mainHandler, const QString &hostName, int exerciseId, QObject *parent)
|
||||
: QObject(parent)
|
||||
PdfDownloader::PdfDownloader(const QVector<WebSocketInterface::Messages::PdfListMessage::PdfInformation> &pdfInfoVec, MainHandler *mainHandler, const QString &hostName, int exerciseId, QObject *parent) : QObject(parent)
|
||||
, m_pdfInfoVec(pdfInfoVec)
|
||||
, m_socket(new PdfDownloadSocket(hostName, this))
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_exTblGen(new DBAdministration::ExerciseTableGenerator(getLogger("ExerciseTableGenerator"), NGL::directory(NGL::FileType::ConfigFile, QLatin1String("xml")), this))
|
||||
, m_downloadCount(0)
|
||||
, m_totalDownloads(pdfInfoVec.size())
|
||||
{
|
||||
, m_totalDownloads(pdfInfoVec.size()),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
connect(m_socket, &PdfDownloadSocket::downloadFinished,
|
||||
this, &PdfDownloader::onSingleDownloadFinished);
|
||||
}
|
||||
@@ -42,17 +41,17 @@ PdfDownloader::~PdfDownloader()
|
||||
|
||||
bool PdfDownloader::startDownload()
|
||||
{
|
||||
DEBUG_LOG() << "Downloading startet";
|
||||
DEBUG_LOG(m_logger) << "Downloading startet";
|
||||
|
||||
if (!m_socket->isConnected())
|
||||
{
|
||||
ERROR_LOG() << "Download could not be startet. Socket not connected.";
|
||||
ERROR_LOG(m_logger) << "Download could not be startet. Socket not connected.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!openDbConnection())
|
||||
{
|
||||
ERROR_LOG() << "Could not open database connection";
|
||||
ERROR_LOG(m_logger) << "Could not open database connection";
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,24 +60,24 @@ bool PdfDownloader::startDownload()
|
||||
|
||||
void PdfDownloader::onSingleDownloadFinished(const QByteArray &data)
|
||||
{
|
||||
DEBUG_LOG() << "Downloading file " << m_currentDownload.name << " finished.";
|
||||
DEBUG_LOG(m_logger) << "Downloading file " << m_currentDownload.name << " finished.";
|
||||
|
||||
++m_downloadCount;
|
||||
|
||||
if (!data.size())
|
||||
WARNING_LOG() << "Got finished download without data";
|
||||
WARNING_LOG(m_logger) << "Got finished download without data";
|
||||
|
||||
QString msg = QString::fromUtf8(data);
|
||||
if (msg.startsWith(QStringLiteral("ERROR")))
|
||||
{
|
||||
ERROR_LOG() << msg;
|
||||
ERROR_LOG(m_logger) << msg;
|
||||
startNextDownload();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_dbConnection.isValid())
|
||||
{
|
||||
ERROR_LOG() << "Database not open";
|
||||
ERROR_LOG(m_logger) << "Database not open";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ void PdfDownloader::onSingleDownloadFinished(const QByteArray &data)
|
||||
|
||||
if (!flmDbHandler->init(0, m_dbConnection))
|
||||
{
|
||||
ERROR_LOG() << "Couldn't initialise flmDbHandler";
|
||||
ERROR_LOG(m_logger) << "Couldn't initialise flmDbHandler";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,7 +109,7 @@ void PdfDownloader::onSingleDownloadFinished(const QByteArray &data)
|
||||
flmDbHandler->db()->insert(dbData);
|
||||
|
||||
if (!trans.commit())
|
||||
ERROR_LOG() << "Error while inserting FLM data into database.";
|
||||
ERROR_LOG(m_logger) << "Error while inserting FLM data into database.";
|
||||
|
||||
startNextDownload();
|
||||
}
|
||||
@@ -119,7 +118,7 @@ bool PdfDownloader::startNextDownload()
|
||||
{
|
||||
if (m_pdfInfoVec.isEmpty())
|
||||
{
|
||||
DEBUG_LOG() << "No more pending downloads.";
|
||||
DEBUG_LOG(m_logger) << "No more pending downloads.";
|
||||
|
||||
closeDb(m_dbConnection);
|
||||
emit allDownloadsFinished();
|
||||
@@ -131,7 +130,7 @@ bool PdfDownloader::startNextDownload()
|
||||
|
||||
emit newState(100 / m_totalDownloads * m_downloadCount, tr("Downloading file \"%1\"").arg(m_currentDownload.name));
|
||||
|
||||
DEBUG_LOG() << "Downloading file " << m_currentDownload.name;
|
||||
DEBUG_LOG(m_logger) << "Downloading file " << m_currentDownload.name;
|
||||
|
||||
m_socket->downloadFromHost(m_currentDownload.id, m_currentDownload.fileSize);
|
||||
|
||||
@@ -168,10 +167,10 @@ QSqlDatabase PdfDownloader::openDb(bool *bOk)
|
||||
s->databaseDriver(),
|
||||
s->databaseHostname(),
|
||||
s->databaseName());
|
||||
DEBUG_LOG() << "Trying to open database " << s->databaseHostname() << ":" << s->databaseName();
|
||||
DEBUG_LOG(m_logger) << "Trying to open database " << s->databaseHostname() << ":" << s->databaseName();
|
||||
if (!dbConnection.isOpen())
|
||||
{
|
||||
ERROR_LOG() << "Error opening database " << s->databaseHostname() << ":" << s->databaseName();
|
||||
ERROR_LOG(m_logger) << "Error opening database " << s->databaseHostname() << ":" << s->databaseName();
|
||||
if (bOk)
|
||||
*bOk = false;
|
||||
}
|
||||
@@ -182,7 +181,7 @@ void PdfDownloader::closeDb(QSqlDatabase &dbConn)
|
||||
{
|
||||
const QString connName = dbConn.connectionName();
|
||||
|
||||
DEBUG_LOG() << "Closing database: " << connName;
|
||||
DEBUG_LOG(m_logger) << "Closing database: " << connName;
|
||||
|
||||
dbConn.close();
|
||||
dbConn = QSqlDatabase();
|
||||
|
||||
@@ -47,6 +47,8 @@ private Q_SLOTS:
|
||||
void onSingleDownloadFinished(const QByteArray &data);
|
||||
|
||||
private: // other
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
typedef WebSocketInterface::Messages::PdfListMessage::PdfInformation PdfInfo;
|
||||
|
||||
private: // methods
|
||||
|
||||
Reference in new issue
Block a user