From fef1d43d5febebd00a86c2c2711f188a5d04aa00 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 28 Sep 2023 11:56:20 +0200 Subject: [PATCH] Adapated information of update-progress-status. --- worker.cpp | 86 +++++++++++++++++++++--------------------------------- 1 file changed, 33 insertions(+), 53 deletions(-) diff --git a/worker.cpp b/worker.cpp index 98ffd78..d4f0c07 100644 --- a/worker.cpp +++ b/worker.cpp @@ -171,8 +171,7 @@ void Worker::privateUpdate() { stopProgressLoop(); emit replaceLast("Initializing customer environment", UPDATE_STEP_DONE); - int progress = (m_mainWindow->progressValue()/10) + 10; - setProgress(progress); + setProgress(5); m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CLONE_AND_CHECKOUT_SUCCESS, QString("CLONED AND CHECKED OUT: ") + m_customerRepository); @@ -182,7 +181,7 @@ void Worker::privateUpdate() { m_ismasClient.cloneAndCheckoutCustomerRepository( m_updateStatus.m_statusDescription)); - setProgress(progress + 10); + setProgress(10); IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + @@ -196,9 +195,7 @@ void Worker::privateUpdate() { m_returnCode = 0; } else { stopProgressLoop(); - - int progress = (m_mainWindow->progressValue()/10) + 10; - setProgress(progress); + setProgress(0); emit replaceLast("Initializing customer environment", UPDATE_STEP_FAIL); @@ -211,11 +208,9 @@ void Worker::privateUpdate() { m_returnCode = -3; } } else { - m_ismasClient.setProgressInPercent(10); - if (updateTriggerSet()) { - m_ismasClient.setProgressInPercent(20); - if (customerEnvironment()) { - m_ismasClient.setProgressInPercent(30); + if (updateTriggerSet(5)) { + if (customerEnvironment(30)) { + m_ismasClient.setProgressInPercent(50); if (filesToUpdate()) { // send message to ISMAS about files which have been // checked in into git repository @@ -225,23 +220,19 @@ void Worker::privateUpdate() { QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAContinues("CHECK-FILES-TO-UPDATE", m_updateStatus.m_statusDescription)); - m_ismasClient.setProgressInPercent(40); - if (updateFiles(50)) { - m_ismasClient.setProgressInPercent(50); + if (updateFiles(60)) { + m_ismasClient.setProgressInPercent(70); if (syncCustomerRepositoryAndFS()) { - m_ismasClient.setProgressInPercent(60); + m_ismasClient.setProgressInPercent(80); if (sendIsmasLastVersionNotification()) { - m_ismasClient.setProgressInPercent(70); + m_ismasClient.setProgressInPercent(90); sentIsmasLastVersionNotification = true; if (saveLogFile()) { - m_ismasClient.setProgressInPercent(80); - IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSASucceeded("")); // mark update as activated -> this resets the WAIT button - m_ismasClient.setProgressInPercent(95); IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAActivated()); @@ -416,7 +407,7 @@ std::optional Worker::getApismVersion() { #define CHECK_UPDATE_TRIGGER_SET "Check update trigger ..." -bool Worker::updateTriggerSet() { +bool Worker::updateTriggerSet(int progress) { if (m_withoutIsmasDirectPort) { // useful for testing return true; } @@ -452,8 +443,7 @@ bool Worker::updateTriggerSet() { = IsmasClient::sendRequestReceiveResponse( IsmasClient::APISM::DIRECT_PORT, "#M=APISM#C=REQ_ISMASPARAMETER#J={}")) { stopProgressLoop(); - int progress = (m_mainWindow->progressValue()/10) + 10; - setProgress(progress); + setProgress(m_mainWindow->progressValue()/10 + 11); QString msg = result.value(); @@ -492,15 +482,13 @@ bool Worker::updateTriggerSet() { emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL); return false; } - progress += 1; - setProgress(progress); + setProgress(m_mainWindow->progressValue()/10 + 11); QJsonObject obj = document.object(); // always look for an 'error' first if (obj.contains("error")) { - progress += 1; - setProgress(progress); + setProgress(m_mainWindow->progressValue()/10 + 11); QString value = obj.value("error").toString(); emit showErrorMessage("check update trigger", QString("REPEAT %1 error=<").arg(repeat) + value + ">"); qInfo() << "REPEAT" << repeat << "In updateTriggerSet() error=<" @@ -585,8 +573,7 @@ bool Worker::updateTriggerSet() { emit replaceLast(CHECK_UPDATE_TRIGGER_SET, UPDATE_STEP_FAIL); return false; } - progress += 1; - setProgress(progress); + setProgress(m_mainWindow->progressValue()/10 + 11); if (obj.contains("Fileupload")) { QJsonValue v = obj.value("Fileupload"); @@ -604,11 +591,17 @@ bool Worker::updateTriggerSet() { m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_SANITY_CHECK_OK, QString("MACHINE-NR (%1) AND CUST-NR (%2) OK") .arg(m_machineNr).arg(m_customerNr)); + + m_ismasClient.setProgressInPercent(progress); + IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, QString("#M=APISM#C=CMD_EVENT#J=") + m_ismasClient.updateOfPSAContinues("MACHINE-AND-CUSTOMER-CHECK", m_updateStatus.m_statusDescription)); + progress += 5; + m_ismasClient.setProgressInPercent(progress); + m_updateStatus = UpdateStatus(UPDATE_STATUS::ISMAS_UPDATE_TRIGGER_SET, QString("UPDATE TRIGGER SET. CONTINUE. ")); IsmasClient::sendRequestReceiveResponse(IsmasClient::APISM::DB_PORT, @@ -620,9 +613,7 @@ bool Worker::updateTriggerSet() { } else if (QRegExp("\\s*").exactMatch(triggerValue)) { // check for whitespace stopProgressLoop(); - int progress = (m_mainWindow->progressValue()/10) + 10; - progress += 1; - setProgress(progress); + setProgress(m_mainWindow->progressValue()/10 + 11); emit showErrorMessage("check update trigger", "empty update-trigger"); QThread::sleep(6); continue; @@ -677,9 +668,7 @@ bool Worker::updateTriggerSet() { } } else { stopProgressLoop(); - int progress = (m_mainWindow->progressValue()/10) + 10; - progress += 1; - setProgress(progress); + setProgress(m_mainWindow->progressValue()/10 + 11); emit showErrorMessage("check update trigger", "no ISMAS response"); QThread::sleep(6); } @@ -697,14 +686,14 @@ bool Worker::updateTriggerSet() { return false; } -bool Worker::customerEnvironment() { +bool Worker::customerEnvironment(int progress) { emit appendText("\nPrepare customer environment ..."); if (QDir(m_customerRepository).exists()) { startProgressLoop(); + setProgress(m_mainWindow->progressValue()/10 + 11); if (m_gc.gitCheckoutBranch()) { stopProgressLoop(); - int progress = (m_mainWindow->progressValue()/10) + 10; - setProgress(progress); + m_ismasClient.setProgressInPercent(progress); m_updateStatus = UpdateStatus(UPDATE_STATUS::GIT_CHECKOUT_BRANCH, QString("CHECKED-OUT BRANCH ") + m_gc.branchName()); @@ -719,8 +708,8 @@ bool Worker::customerEnvironment() { return true; } else { stopProgressLoop(); - int progress = (m_mainWindow->progressValue()/10) + 10; - setProgress(progress); + m_ismasClient.setProgressInPercent(0); + emit showErrorMessage("cust-env", QString("Checkout ") + m_customerRepository + " failed"); Utils::printCriticalErrorMsg(QString("CHECKOUT OF " + m_customerRepository + "FAILED")); @@ -756,17 +745,10 @@ bool Worker::filesToUpdate() { Utils::printInfoMsg("FILES-TO-UPDATE " + m_filesToUpdate.join(',')); - int const size = m_filesToUpdate.size(); - if (size > 1) { - emit appendText(QString("Found %1 files to update :").arg(size), UPDATE_STEP_DONE); - for (int i = 0; i < size; ++i) { - emit appendText(QString("\n ") + m_filesToUpdate.at(i)); - } - } else { - emit appendText("Found 1 file to update :", UPDATE_STEP_DONE); - emit appendText(QString("\n ") + m_filesToUpdate.at(0)); - } - return true; + stopProgressLoop(); + setProgress(100); + + return false; } emit showErrorMessage("files to update", "pulling files failed"); Utils::printCriticalErrorMsg("PULLING FILES FAILED"); @@ -785,9 +767,7 @@ bool Worker::filesToUpdate() { QString("no changes in ") + m_customerRepository + " (checked-in any files?)"); - Utils::printCriticalErrorMsg("NO CHANGES IN " - + m_customerRepository - + " (CHECKED IN ANY FILES?)"); + setProgress(progress + 30); } emit replaceLast(QString("Fetch changes files ..."), UPDATE_STEP_FAIL);