Add bank profile toggling in DeviceWidget and enhance error handling in EventHandler
- Implemented `sendBankStatus` logic with `NetworkService` and threading for bank profile enable/disable functionality. - Improved error handling in `EventHandler` by logging and updating events when bank profiles are disabled.
This commit is contained in:
parent
e1b977becc
commit
b395ed41a5
@ -450,7 +450,13 @@ void EventHandler::processNextTask(const QString &deviceId) {
|
||||
|
||||
const AccountInfo account = AccountDAO::getAccountById(event.accountId);
|
||||
const ApplicationInfo app = ApplicationDAO::getApplication(deviceId, account.appCode);
|
||||
if (app.status != "active") break;
|
||||
if (app.status != "active") {
|
||||
qWarning() << "[EventHandler] Bank profile disabled for" << account.appCode << "device:" << deviceId;
|
||||
EventDAO::updateEvent(event.id, EventStatus::Error, "Bank profile is disabled");
|
||||
sendTaskError(eventTypeToString(event.type), event.externalId, event.bankName,
|
||||
"Bank profile is disabled: " + account.appCode);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!EventDAO::updateEvent(event.id, EventStatus::InProgress, "")) {
|
||||
qCritical() << "[EventHandler] Failed to set InProgress, event id:" << event.id;
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#include "dao/ApplicationDAO.h"
|
||||
#include "dao/DeviceDAO.h"
|
||||
#include "db/ApplicationInfo.h"
|
||||
#include "net/NetworkService.h"
|
||||
#include <QThread>
|
||||
|
||||
|
||||
QString getColorByStatus(const ApplicationInfo &app) {
|
||||
@ -35,8 +37,23 @@ QString getColorByStatus(const ApplicationInfo &app) {
|
||||
}
|
||||
|
||||
void sendBankStatus(const QString &deviceId, const QString &code, const QString &status) {
|
||||
Q_UNUSED(deviceId) Q_UNUSED(code) Q_UNUSED(status)
|
||||
// TODO: заменить на новый API
|
||||
const ApplicationInfo app = ApplicationDAO::getApplication(deviceId, code);
|
||||
if (app.bankProfileId.isEmpty()) {
|
||||
qWarning() << "[DeviceWidget] sendBankStatus: no bankProfileId for" << code;
|
||||
return;
|
||||
}
|
||||
|
||||
const bool enable = (status == "active");
|
||||
auto *thread = new QThread;
|
||||
auto *net = new NetworkService;
|
||||
net->moveToThread(thread);
|
||||
net->addExtra("bank_profile_id", app.bankProfileId);
|
||||
net->addExtra("enable", enable);
|
||||
QObject::connect(thread, &QThread::started, net, &NetworkService::toggleBankProfile);
|
||||
QObject::connect(net, &NetworkService::finished, thread, &QThread::quit);
|
||||
QObject::connect(net, &NetworkService::finished, net, &QObject::deleteLater);
|
||||
QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||
thread->start();
|
||||
}
|
||||
|
||||
void DeviceWidget::buildBankRow(const ApplicationInfo &app, QWidget *rowWidget, QWidget *parent, bool isOffline) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user