Scan Json create and save.

This commit is contained in:
Krad
2022-05-11 15:44:43 +08:00
parent 1abd387617
commit f7540385a4
5 changed files with 89 additions and 8 deletions

View File

@@ -10,6 +10,7 @@
#include <QDateTime>
#include <qdebug.h>
#include "appvals/AppGlobalValues.h"
#include "json/ScanJson.h"
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
#define THROW_ERROR(errormsg)\
@@ -31,7 +32,6 @@ const char* getStatusString(int status)
return "";
}
std::string getJsonFromPatInf(QObject* obj)
{
return ((QString*)obj)->toStdString();
@@ -229,6 +229,22 @@ void DeviceManager::timerEvent(QTimerEvent* event) {
QString s("%1 %2");
s = s.arg(QDateTime::currentDateTime().toString("yyyy/MM/dd HH:mm:ss")).arg("Scan finished");
TRIGGER_EVENT(GUIEvents::GlobalBannerMessage, nullptr, (QObject*)&s);
QString outputPath = GetDeviceInfo(DeviceInfo::DEV_OUTPATH);
outputPath = outputPath.replace("\\","/");
if (outputPath.endsWith('/')) outputPath = outputPath.remove(outputPath.length()-1,1);
QStringList list = outputPath.split('/');
if (list.length()){
if (AppGlobalValues::EmptyScanFlag().toBool()){
ScanJson::Current()->setEmptyScanID(list.last().toStdString().c_str());
}else{
ScanJson::Current()->setScanID(list.last().toStdString().c_str());
}
ScanJson::Current()->save();
}
else{
QString msg("Scan Output Path error!");
THROW_ERROR(msg);
}
}
//一般不会出现其他情况
else {
@@ -267,6 +283,7 @@ void DeviceManager::processScan(const char* json, bool empty) {
AppGlobalValues::setInProcessing(true);
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
qDebug() << "SetScanInfo>>>>>>>>>>>>>>>>>>>>";
AppGlobalValues::setEmptyScanFlag(empty);
int ret = SetScanInfo(json, empty ? 1 : 0);
if (ret) {
qDebug() << ">>>>>>>>>>>>>>>>>>>>SetScanInfo failed";
@@ -293,6 +310,9 @@ void DeviceManager::processScan(const char* json, bool empty) {
}
void DeviceManager::close() {
#ifdef _WIN32
StopDevice();
#endif
previewDataCaller->terminate();
delete previewDataCaller;
}