Add UserOperationLog.
This commit is contained in:
@@ -34,12 +34,25 @@ UserOperationLogForm::UserOperationLogForm(QWidget* parent) {
|
|||||||
btn = new QPushButton(header);
|
btn = new QPushButton(header);
|
||||||
headerLayout->addWidget(btn, 0, Qt::AlignLeft);
|
headerLayout->addWidget(btn, 0, Qt::AlignLeft);
|
||||||
headerLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
|
headerLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
|
||||||
table = new SlideTableView(this);
|
|
||||||
layout->addWidget(header);
|
|
||||||
layout->addWidget(table);
|
|
||||||
model = new LogFileTableModel(this);
|
model = new LogFileTableModel(this);
|
||||||
|
model->setHeader(QStringList()<< "Operation Date" << "Operation Time" << "User" << "Operation");
|
||||||
|
loadUserOperationLog();
|
||||||
|
table = new SlideTableView(this);
|
||||||
|
layout->addWidget(header);
|
||||||
|
layout->addWidget(table);
|
||||||
|
table->setModel(model);
|
||||||
|
table->setAlternatingRowColors(true);
|
||||||
|
table->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
table->verticalHeader()->setDefaultSectionSize(38);
|
||||||
|
table->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
|
||||||
|
table->setColumnWidth(0, 250);
|
||||||
|
table->setColumnWidth(1, 250);
|
||||||
|
table->setColumnWidth(2, 200);
|
||||||
//暂时先放构造函数,之后需要移除,等需要时再调用
|
//暂时先放构造函数,之后需要移除,等需要时再调用
|
||||||
loadUserOperationLog();
|
|
||||||
connect(btn, &QPushButton::clicked, [=]() {
|
connect(btn, &QPushButton::clicked, [=]() {
|
||||||
auto files = UserOperationLog::getHistoryLogFiles();
|
auto files = UserOperationLog::getHistoryLogFiles();
|
||||||
QStringList dates;
|
QStringList dates;
|
||||||
@@ -75,7 +88,6 @@ UserOperationLogForm::~UserOperationLogForm() {
|
|||||||
void UserOperationLogForm::loadUserOperationLog() {
|
void UserOperationLogForm::loadUserOperationLog() {
|
||||||
|
|
||||||
QString filePath = UserOperationLog::Default()->currentLogFile();
|
QString filePath = UserOperationLog::Default()->currentLogFile();
|
||||||
model->setFileName(filePath);
|
|
||||||
btn->setText(fileNameToDate(filePath));
|
btn->setText(fileNameToDate(filePath));
|
||||||
loadUserOperationLog(filePath, fileNameToDate(filePath));
|
loadUserOperationLog(filePath, fileNameToDate(filePath));
|
||||||
selectedDateStr = fileNameToDate(filePath);
|
selectedDateStr = fileNameToDate(filePath);
|
||||||
@@ -83,22 +95,12 @@ void UserOperationLogForm::loadUserOperationLog() {
|
|||||||
|
|
||||||
void UserOperationLogForm::loadUserOperationLog(const QString& fileName, const QString& date) {
|
void UserOperationLogForm::loadUserOperationLog(const QString& fileName, const QString& date) {
|
||||||
selectedDateStr = date;
|
selectedDateStr = date;
|
||||||
model->setFileName(dateToFileName(date));
|
model->setFileName(dateToFileName(date));
|
||||||
btn->setText(date);
|
btn->setText(date);
|
||||||
QStringList header;
|
}
|
||||||
header << "Operation Date" << "Operation Time" << "User" << "Operation";
|
|
||||||
model->setHeader(header);
|
void UserOperationLogForm::showEvent(QShowEvent *aEvent)
|
||||||
// UserOperationLog::getHistoryLogFiles();
|
{
|
||||||
delete table;
|
loadUserOperationLog("", selectedDateStr);
|
||||||
table = new SlideTableView(this);
|
QWidget::showEvent(aEvent);
|
||||||
layout->addWidget(table);
|
|
||||||
table->setModel(model);
|
|
||||||
|
|
||||||
table->setAlternatingRowColors(true);
|
|
||||||
table->setSelectionMode(QAbstractItemView::NoSelection);
|
|
||||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
||||||
table->verticalHeader()->setDefaultSectionSize(38);
|
|
||||||
table->horizontalHeader()->setStretchLastSection(true);
|
|
||||||
table->setColumnWidth(0, 250);
|
|
||||||
table->setColumnWidth(1, 250);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
//
|
|
||||||
// Created by Krad on 2021/11/23.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef GUI_USEROPERATIONLOGFORM_H
|
#ifndef GUI_USEROPERATIONLOGFORM_H
|
||||||
#define GUI_USEROPERATIONLOGFORM_H
|
#define GUI_USEROPERATIONLOGFORM_H
|
||||||
|
|
||||||
@@ -19,6 +15,9 @@ public:
|
|||||||
void loadUserOperationLog();
|
void loadUserOperationLog();
|
||||||
void loadUserOperationLog(const QString& fileName, const QString& date);
|
void loadUserOperationLog(const QString& fileName, const QString& date);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent *aEvent) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTableView* table = nullptr;
|
QTableView* table = nullptr;
|
||||||
QPushButton* btn = nullptr;
|
QPushButton* btn = nullptr;
|
||||||
|
|||||||
@@ -100,6 +100,6 @@ bool ChangePasswordFormDialog::updateReferenceData()
|
|||||||
User::Current()->restorePassword(encryptPwd);
|
User::Current()->restorePassword(encryptPwd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOG_USER_OPERATION(ChangePassword);
|
LOG_USER_OPERATION("Change Password");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ void GUIMessageDialog::startLoading() {
|
|||||||
}
|
}
|
||||||
accept();
|
accept();
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestFullScanStop, nullptr, nullptr);
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestFullScanStop, nullptr, nullptr);
|
||||||
LOG_USER_OPERATION(Stop);
|
LOG_USER_OPERATION("Stop Scan");
|
||||||
});
|
});
|
||||||
mTimerID = startTimer(100);
|
mTimerID = startTimer(100);
|
||||||
mBtnMain->setVisible(true);
|
mBtnMain->setVisible(true);
|
||||||
@@ -117,7 +117,7 @@ void GUIMessageDialog::showExitButton() {
|
|||||||
mTimerID = -1;
|
mTimerID = -1;
|
||||||
}
|
}
|
||||||
accept();
|
accept();
|
||||||
LOG_USER_OPERATION(ConfirmError);
|
LOG_USER_OPERATION("Confirm Error");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "components/ULineEdit.h"
|
#include "components/ULineEdit.h"
|
||||||
#include "action/GetWorkListAction.h"
|
#include "action/GetWorkListAction.h"
|
||||||
#include "action/ActionCreator.h"
|
#include "action/ActionCreator.h"
|
||||||
|
#include "log/UserOperationLog.h"
|
||||||
|
|
||||||
GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent, Qt::WindowFlags aFlags)
|
GetWorkListDialog::GetWorkListDialog(QSqlTableModel* aSqlModel, QTableView* aTableView, QWidget* aParent, Qt::WindowFlags aFlags)
|
||||||
: AsyncActionDialog(ActionCreator::getAsyncAction<GetWorkListAction>("GetWorkListAction"),"Work List", aParent, aFlags)
|
: AsyncActionDialog(ActionCreator::getAsyncAction<GetWorkListAction>("GetWorkListAction"),"Work List", aParent, aFlags)
|
||||||
@@ -254,4 +255,5 @@ void GetWorkListDialog::insertPatient(PatientInformationPointer aPatient)
|
|||||||
mErrorLabel->show();
|
mErrorLabel->show();
|
||||||
}
|
}
|
||||||
mTableView->selectRow(0);
|
mTableView->selectRow(0);
|
||||||
|
LOG_USER_OPERATION(QString("Add Patient, ID:%1").arg(aPatient->ID));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,11 @@ ReconFormWidget::ReconFormWidget(QWidget *parent)
|
|||||||
contentLayout->setContentsMargins(0, 0, 0, 0);
|
contentLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
initTableView(contentLayout);
|
initTableView(contentLayout);
|
||||||
|
|
||||||
connect(mBtnRefresh, &QToolButton::clicked, DeviceManager::Default(), &DeviceManager::updateReconState);
|
connect(mBtnRefresh, &QToolButton::clicked, []()
|
||||||
|
{
|
||||||
|
LOG_USER_OPERATION("Update Recon State")
|
||||||
|
DeviceManager::Default()->updateReconState();
|
||||||
|
});
|
||||||
connect(DeviceManager::Default(), &DeviceManager::updateReconStateFinished, mModel, &QSqlTableModel::select);
|
connect(DeviceManager::Default(), &DeviceManager::updateReconStateFinished, mModel, &QSqlTableModel::select);
|
||||||
connect(DeviceManager::Default(), &DeviceManager::transferStatusUpdated, mModel, &QSqlTableModel::select);
|
connect(DeviceManager::Default(), &DeviceManager::transferStatusUpdated, mModel, &QSqlTableModel::select);
|
||||||
connect(mSearchWidget, &ScanSearchCriteriaForm::searchFilterUpdated, this, &ReconFormWidget::updateSearchFilter);
|
connect(mSearchWidget, &ScanSearchCriteriaForm::searchFilterUpdated, this, &ReconFormWidget::updateSearchFilter);
|
||||||
@@ -157,7 +161,7 @@ void ReconFormWidget::deleteReconRecord()
|
|||||||
{
|
{
|
||||||
mScanTable->selectRow(0);
|
mScanTable->selectRow(0);
|
||||||
mModel->selectRow(0);
|
mModel->selectRow(0);
|
||||||
LOG_USER_OPERATION(DeletePatient)
|
LOG_USER_OPERATION(QString("Delete Recon, ID: %1").arg(mModel->index(currentRowIndex, getTableColumnIndex("PatientID")).data().toString()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -47,6 +47,11 @@ void PatientInformationForm::setProtocol(int type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PatientInformationForm::getPatientID()
|
||||||
|
{
|
||||||
|
return mUI->lbl_ID->text();
|
||||||
|
}
|
||||||
|
|
||||||
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
|
const char* PatientInformationForm::getCurrentPatientJsonString(bool empty)
|
||||||
{
|
{
|
||||||
cJSON* patientInfoObject = cJSON_CreateObject();
|
cJSON* patientInfoObject = cJSON_CreateObject();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
void setPatientInformation(PatientInformation* information);
|
void setPatientInformation(PatientInformation* information);
|
||||||
void setProtocol(int type);
|
void setProtocol(int type);
|
||||||
const char * getCurrentPatientJsonString(bool emptyScan);
|
const char * getCurrentPatientJsonString(bool emptyScan);
|
||||||
|
QString getPatientID();
|
||||||
private:
|
private:
|
||||||
Ui::PatientInformationForm *mUI;
|
Ui::PatientInformationForm *mUI;
|
||||||
PatientInformation* mInfo = nullptr;
|
PatientInformation* mInfo = nullptr;
|
||||||
|
|||||||
@@ -122,12 +122,13 @@ void SelectFormWidget::editPatient() {
|
|||||||
if (addFlag){
|
if (addFlag){
|
||||||
mPatTable->selectRow(0);
|
mPatTable->selectRow(0);
|
||||||
mModel->selectRow(0);
|
mModel->selectRow(0);
|
||||||
|
LOG_USER_OPERATION(QString("Add Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
mPatTable->clicked(mPatTable->currentIndex());
|
mPatTable->clicked(mPatTable->currentIndex());
|
||||||
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
||||||
|
LOG_USER_OPERATION(QString("Edit Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
|
||||||
}
|
}
|
||||||
LOG_USER_OPERATION(AddPatient)
|
|
||||||
mBtnSelect->setEnabled(true);
|
mBtnSelect->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,7 +155,7 @@ void SelectFormWidget::delPatient() {
|
|||||||
mPatTable->selectRow(0);
|
mPatTable->selectRow(0);
|
||||||
mModel->selectRow(0);
|
mModel->selectRow(0);
|
||||||
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
setPatientDetail(mPatTable, mModel, patientDetailForm);
|
||||||
LOG_USER_OPERATION(DeletePatient)
|
LOG_USER_OPERATION(QString("Delete Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//TODO:error handle
|
//TODO:error handle
|
||||||
@@ -166,7 +167,7 @@ void SelectFormWidget::delPatient() {
|
|||||||
void SelectFormWidget::selectPatient() {
|
void SelectFormWidget::selectPatient() {
|
||||||
EventCenter::Default()->triggerEvent(PatientSelected, nullptr, patientDetailForm->getPatientInformation()->Copy());
|
EventCenter::Default()->triggerEvent(PatientSelected, nullptr, patientDetailForm->getPatientInformation()->Copy());
|
||||||
selectedPatientUID = patientDetailForm->getPatientInformation()->PatientUID;
|
selectedPatientUID = patientDetailForm->getPatientInformation()->PatientUID;
|
||||||
LOG_USER_OPERATION(SelectPatient)
|
LOG_USER_OPERATION(QString("Select Patient, ID: %1").arg(patientDetailForm->getPatientInformation()->ID))
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel
|
void SelectFormWidget::initDetailPanel(QHBoxLayout *contentLayout) {// prepare edit panel
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "utilities/LanguageSwitcher.h"
|
#include "utilities/LanguageSwitcher.h"
|
||||||
#include "components/ULineEdit.h"
|
#include "components/ULineEdit.h"
|
||||||
#include "components/ListBox.h"
|
#include "components/ListBox.h"
|
||||||
|
#include "log/UserOperationLog.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -101,6 +102,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
|
|||||||
{
|
{
|
||||||
if(DialogManager::Default()->requestAlertMessage(QString(tr("Shut down now ?")), DialogButtonMode::OkAndCancel,tr("Shut Down")) == QDialog::Accepted)
|
if(DialogManager::Default()->requestAlertMessage(QString(tr("Shut down now ?")), DialogButtonMode::OkAndCancel,tr("Shut Down")) == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
|
LOG_USER_OPERATION("Shut Down")
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestShutdown, nullptr, nullptr);
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestShutdown, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -134,6 +136,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
second = result.ResultData.toInt();
|
second = result.ResultData.toInt();
|
||||||
|
LOG_USER_OPERATION(QString("Set Screen Lock Time to %1 seconds").arg(second))
|
||||||
if(second == 0)
|
if(second == 0)
|
||||||
{
|
{
|
||||||
JsonObject::Instance()->setLockScreenTimeout(QString::number(second));
|
JsonObject::Instance()->setLockScreenTimeout(QString::number(second));
|
||||||
@@ -163,6 +166,7 @@ GeneralForm::GeneralForm(QWidget* aParent)
|
|||||||
JsonObject::Instance()->setDefaultLanguage(language);
|
JsonObject::Instance()->setDefaultLanguage(language);
|
||||||
LanguageSwitcher::getInstance()->setDefaultLanguage(language);
|
LanguageSwitcher::getInstance()->setDefaultLanguage(language);
|
||||||
btnLan->setText(JsonObject::Instance()->defaultLanguage());
|
btnLan->setText(JsonObject::Instance()->defaultLanguage());
|
||||||
|
LOG_USER_OPERATION(QString("Change Language to %1").arg(language))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "AccountTableForm.h"
|
#include "AccountTableForm.h"
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
#include "AboutForm.h"
|
#include "AboutForm.h"
|
||||||
|
#include "UserOperationLogForm.h"
|
||||||
|
|
||||||
SettingFormWidget::SettingFormWidget(QWidget* aParent, Qt::WindowFlags f)
|
SettingFormWidget::SettingFormWidget(QWidget* aParent, Qt::WindowFlags f)
|
||||||
: TabFormWidget(aParent)
|
: TabFormWidget(aParent)
|
||||||
@@ -27,7 +28,7 @@ SettingFormWidget::SettingFormWidget(QWidget* aParent, Qt::WindowFlags f)
|
|||||||
QListWidget* widget = new QListWidget(ui->contentWidget);
|
QListWidget* widget = new QListWidget(ui->contentWidget);
|
||||||
widget->setFixedWidth(250);
|
widget->setFixedWidth(250);
|
||||||
QStringList menus;
|
QStringList menus;
|
||||||
menus << tr("General") << tr("Account") << tr("System") << tr("About");
|
menus << tr("General") << tr("Account") << tr("System") << tr("About") << tr("Operation Log");
|
||||||
widget->addItems(menus);
|
widget->addItems(menus);
|
||||||
widget->setSpacing(3);
|
widget->setSpacing(3);
|
||||||
for (int i = 0; i < menus.count(); ++i)
|
for (int i = 0; i < menus.count(); ++i)
|
||||||
@@ -55,13 +56,16 @@ SettingFormWidget::SettingFormWidget(QWidget* aParent, Qt::WindowFlags f)
|
|||||||
AboutForm* about = new AboutForm(ui->commandWidget);
|
AboutForm* about = new AboutForm(ui->commandWidget);
|
||||||
stackedWidget->addWidget(about);
|
stackedWidget->addWidget(about);
|
||||||
|
|
||||||
|
UserOperationLogForm* operationLog = new UserOperationLogForm(ui->commandWidget);
|
||||||
|
stackedWidget->addWidget(operationLog);
|
||||||
|
|
||||||
widget->setCurrentRow(0);
|
widget->setCurrentRow(0);
|
||||||
connect(widget, &QListWidget::currentRowChanged, [=](int rowindex) {
|
connect(widget, &QListWidget::currentRowChanged, [=](int rowindex) {
|
||||||
stackedWidget->setCurrentIndex(rowindex);
|
stackedWidget->setCurrentIndex(rowindex);
|
||||||
});
|
});
|
||||||
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
|
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
|
||||||
QStringList menus;
|
QStringList menus;
|
||||||
menus << tr("General") << tr("Account") << tr("System") << tr("About");
|
menus << tr("General") << tr("Account") << tr("System") << tr("About") << tr("Operation Log");
|
||||||
widget->clear();
|
widget->clear();
|
||||||
widget->addItems(menus);
|
widget->addItems(menus);
|
||||||
for (int i = 0; i < menus.count(); ++i)
|
for (int i = 0; i < menus.count(); ++i)
|
||||||
|
|||||||
@@ -549,3 +549,8 @@ bool JsonObject::isDmsSimulator()
|
|||||||
{
|
{
|
||||||
return getBool("dms","simulator");
|
return getBool("dms","simulator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int JsonObject::getOperationLogExpireDays()
|
||||||
|
{
|
||||||
|
return QString(getJsonString("operatorlog", "expire")).toInt();
|
||||||
|
}
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ public:
|
|||||||
void setIpRouteList(const QList<QStringList>& list);
|
void setIpRouteList(const QList<QStringList>& list);
|
||||||
|
|
||||||
QStringList getScreenSaverInfomation();
|
QStringList getScreenSaverInfomation();
|
||||||
|
int getOperationLogExpireDays();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ LogFileTableModel::LogFileTableModel(QObject *parent) : QAbstractTableModel(pare
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LogFileTableModel::setFileName(QString fileName) {
|
void LogFileTableModel::setFileName(QString fileName) {
|
||||||
|
beginResetModel();
|
||||||
if (!logdata.isEmpty())logdata.clear();
|
if (!logdata.isEmpty())logdata.clear();
|
||||||
qDebug()<<fileName;
|
qDebug()<<fileName;
|
||||||
QFile f;
|
QFile f;
|
||||||
@@ -25,6 +26,7 @@ void LogFileTableModel::setFileName(QString fileName) {
|
|||||||
logdata.push_back(in.readLine().split("\t"));
|
logdata.push_back(in.readLine().split("\t"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant LogFileTableModel::data(const QModelIndex &index, int role) const {
|
QVariant LogFileTableModel::data(const QModelIndex &index, int role) const {
|
||||||
|
|||||||
@@ -3,15 +3,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "UserOperationLog.h"
|
#include "UserOperationLog.h"
|
||||||
#include <QDate>
|
|
||||||
#include <QDir>
|
|
||||||
#include "appvals/AppGlobalValues.h"
|
#include "appvals/AppGlobalValues.h"
|
||||||
#include "models/User.h"
|
#include "models/User.h"
|
||||||
|
#include <json/jsonobject.h>
|
||||||
|
|
||||||
#include <QDirIterator>
|
#include <QDirIterator>
|
||||||
#include <qdebug.h>
|
#include <QDate>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
namespace
|
||||||
const char * logDir = "./log";
|
{
|
||||||
|
const QString logDir = "./log";
|
||||||
|
}
|
||||||
|
|
||||||
void UserOperationLog::init() {
|
void UserOperationLog::init() {
|
||||||
QDir log_dir("./");
|
QDir log_dir("./");
|
||||||
@@ -58,15 +61,13 @@ QString getOperationName(UserOperation operation)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserOperationLog::log(UserOperation operation, bool processing) {
|
void UserOperationLog::log(const QString& aOperationText)
|
||||||
|
{
|
||||||
reloadFile();
|
reloadFile();
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
AppGlobalValues::setLastOperationTime(now);
|
AppGlobalValues::setLastOperationTime(now);
|
||||||
AppGlobalValues::setLastOperation(operation);
|
|
||||||
QString operationName = getOperationName(operation);
|
|
||||||
AppGlobalValues::setInProcessing(processing);
|
|
||||||
QString UserName = (!User::Current() || User::Current()->getUserCode().isEmpty())?"anonymous":User::Current()->getUserCode();
|
QString UserName = (!User::Current() || User::Current()->getUserCode().isEmpty())?"anonymous":User::Current()->getUserCode();
|
||||||
out << now.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<UserName<<"\t"<<operationName<<endl;
|
out << now.toString(Qt::DateFormat::ISODateWithMs).replace("T","\t")<<"\t"<<UserName<<"\t"<<aOperationText<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserOperationLog::reloadFile() {
|
void UserOperationLog::reloadFile() {
|
||||||
@@ -91,7 +92,6 @@ QStringList UserOperationLog::getHistoryLogFiles() {
|
|||||||
{
|
{
|
||||||
iter.next();
|
iter.next();
|
||||||
list << iter.fileInfo().absoluteFilePath();
|
list << iter.fileInfo().absoluteFilePath();
|
||||||
qDebug()<<iter.fileInfo().absoluteFilePath();
|
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -109,3 +109,23 @@ void UserOperationLog::loadLogFromFile(QString path, QStringList& result) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserOperationLog::cleanHistoryLog()
|
||||||
|
{
|
||||||
|
int expireDays = JsonObject::Instance()->getOperationLogExpireDays();
|
||||||
|
QDateTime currentDate = QDateTime::currentDateTime();
|
||||||
|
QDateTime deleteDate = currentDate.addDays(-expireDays);
|
||||||
|
|
||||||
|
QDir dir(logDir);
|
||||||
|
QStringList logFiles = dir.entryList(QStringList() << "*.log", QDir::Files);
|
||||||
|
for(const QString &logFile : logFiles)
|
||||||
|
{
|
||||||
|
QString filePath = logDir + "/" + logFile;
|
||||||
|
QFileInfo fileInfo(filePath);
|
||||||
|
QDateTime fileDate = fileInfo.created();
|
||||||
|
if (fileDate <= deleteDate)
|
||||||
|
{
|
||||||
|
QFile::remove(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ ADD_OPERATION(ChangePatientInfo)\
|
|||||||
ADD_OPERATION(DeletePatient)\
|
ADD_OPERATION(DeletePatient)\
|
||||||
ADD_OPERATION(SelectPatient)\
|
ADD_OPERATION(SelectPatient)\
|
||||||
ADD_OPERATION(StartRefresh)\
|
ADD_OPERATION(StartRefresh)\
|
||||||
ADD_OPERATION(Stop)\
|
ADD_OPERATION(StopScan)\
|
||||||
|
ADD_OPERATION(StopPreview)\
|
||||||
ADD_OPERATION(StartPreview)\
|
ADD_OPERATION(StartPreview)\
|
||||||
ADD_OPERATION(StartScan)\
|
ADD_OPERATION(StartScan)\
|
||||||
ADD_OPERATION(ConfirmError)\
|
ADD_OPERATION(ConfirmError)\
|
||||||
@@ -55,7 +56,7 @@ public:
|
|||||||
|
|
||||||
static QStringList getHistoryLogFiles();
|
static QStringList getHistoryLogFiles();
|
||||||
|
|
||||||
void log(UserOperation operation, bool processing = false);
|
void log(const QString& aOperationText);
|
||||||
void reloadFile();
|
void reloadFile();
|
||||||
QString currentLogFile(){
|
QString currentLogFile(){
|
||||||
return currentFileName;
|
return currentFileName;
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ int main(int argc, char* argv[])
|
|||||||
QStringList app_args = a.arguments();
|
QStringList app_args = a.arguments();
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
KeyboardManager::getInstance();
|
KeyboardManager::getInstance();
|
||||||
|
UserOperationLog::cleanHistoryLog();
|
||||||
|
|
||||||
if (app_args.contains("-d"))
|
if (app_args.contains("-d"))
|
||||||
//if (true)
|
//if (true)
|
||||||
|
|||||||
@@ -124,12 +124,13 @@ void LoginDialog::doLogin()
|
|||||||
{
|
{
|
||||||
mErrorMessage->setVisible(false);
|
mErrorMessage->setVisible(false);
|
||||||
accept();
|
accept();
|
||||||
LOG_USER_OPERATION(Login);
|
LOG_USER_OPERATION("Login Sucessful");
|
||||||
JsonObject::Instance()->setDefaultUser(strUserCode);
|
JsonObject::Instance()->setDefaultUser(strUserCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
LOG_USER_OPERATION(QString("Login Failed, User Name: %1").arg(strUserCode));
|
||||||
mErrorMessage->setVisible(true);
|
mErrorMessage->setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user