|
@@ -59,6 +59,24 @@ QString convertSecondsToMinutesTimeFormat(int totalSeconds)
|
|
|
}
|
|
}
|
|
|
void ProcessThread::sendExitTime(qint64 updataTime)
|
|
void ProcessThread::sendExitTime(qint64 updataTime)
|
|
|
{
|
|
{
|
|
|
|
|
+ TC::ProcessNameApi processNameApi;
|
|
|
|
|
+ QJsonArray serverArray = processNameApi.get();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取过滤名单
|
|
|
|
|
+ QSet<QString> filter;
|
|
|
|
|
+ for (const QJsonValue &item : serverArray) {
|
|
|
|
|
+ if (!item.isObject()) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const QJsonObject object = item.toObject();
|
|
|
|
|
+ const QString name = object["name"].toString();
|
|
|
|
|
+ if (object.contains("is_confirmed")) {
|
|
|
|
|
+ if (object["is_confirmed"].toInt() == 2) {
|
|
|
|
|
+ filter.insert(name);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ProcessModel processModel{storage};
|
|
ProcessModel processModel{storage};
|
|
|
// 在数据库 获取 不是这个更新日期的数据
|
|
// 在数据库 获取 不是这个更新日期的数据
|
|
|
|
|
|
|
@@ -74,6 +92,8 @@ void ProcessThread::sendExitTime(qint64 updataTime)
|
|
|
if (jsonArray.size() > 0) {
|
|
if (jsonArray.size() > 0) {
|
|
|
for (const auto &json : jsonArray) {
|
|
for (const auto &json : jsonArray) {
|
|
|
const QJsonObject object = json.toObject();
|
|
const QJsonObject object = json.toObject();
|
|
|
|
|
+
|
|
|
|
|
+ const QString name = object["processName"].toString();
|
|
|
QJsonObject sendObject;
|
|
QJsonObject sendObject;
|
|
|
sendObject.insert("pid", object["pid"]);
|
|
sendObject.insert("pid", object["pid"]);
|
|
|
sendObject.insert("pid_name", object["processName"]);
|
|
sendObject.insert("pid_name", object["processName"]);
|
|
@@ -82,7 +102,11 @@ void ProcessThread::sendExitTime(qint64 updataTime)
|
|
|
sendObject.insert("last_check_time", object["updataTime"]);
|
|
sendObject.insert("last_check_time", object["updataTime"]);
|
|
|
sendObject.insert("status", 1);
|
|
sendObject.insert("status", 1);
|
|
|
sendObject.insert("notes", "");
|
|
sendObject.insert("notes", "");
|
|
|
- sendJsonArray.append(sendObject);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 存在过滤里面的 不发送数据
|
|
|
|
|
+ if (!filter.contains(name)) {
|
|
|
|
|
+ sendJsonArray.append(sendObject);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 上传 后 删除
|
|
// 上传 后 删除
|
|
@@ -100,21 +124,6 @@ void ProcessThread::sendExitTime(qint64 updataTime)
|
|
|
QJsonArray jsonArray = qry.toJson();
|
|
QJsonArray jsonArray = qry.toJson();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- bool isok = false;
|
|
|
|
|
- QVariant timeVariant = AppEvent::instance()->configReadValue("ProcessOutTime", &isok);
|
|
|
|
|
-
|
|
|
|
|
- int time = 0;
|
|
|
|
|
- if (isok) {
|
|
|
|
|
- time = timeVariant.toLongLong();
|
|
|
|
|
- } else {
|
|
|
|
|
- // 服务器时间
|
|
|
|
|
- TC::ConfigApi configApi("swrunTime");
|
|
|
|
|
- std::optional<QVariant> value = configApi.get();
|
|
|
|
|
- if (value.has_value()) {
|
|
|
|
|
- time = value.value().toInt();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
QVariant messageBoxPointX = QVariant();
|
|
QVariant messageBoxPointX = QVariant();
|
|
|
QVariant messageBoxPointY = QVariant();
|
|
QVariant messageBoxPointY = QVariant();
|
|
|
QVariant messageText = QVariant("");
|
|
QVariant messageText = QVariant("");
|
|
@@ -123,99 +132,135 @@ void ProcessThread::sendExitTime(qint64 updataTime)
|
|
|
TC::ConfigApi configApi("messageBoxPointX");
|
|
TC::ConfigApi configApi("messageBoxPointX");
|
|
|
std::optional<QVariant> value = configApi.get();
|
|
std::optional<QVariant> value = configApi.get();
|
|
|
if (value.has_value()) {
|
|
if (value.has_value()) {
|
|
|
- messageBoxPointX = value.value().toInt();
|
|
|
|
|
|
|
+ messageBoxPointX = value.value();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
TC::ConfigApi configApi("messageBoxPointY");
|
|
TC::ConfigApi configApi("messageBoxPointY");
|
|
|
std::optional<QVariant> value = configApi.get();
|
|
std::optional<QVariant> value = configApi.get();
|
|
|
if (value.has_value()) {
|
|
if (value.has_value()) {
|
|
|
- messageBoxPointY = value.value().toInt();
|
|
|
|
|
|
|
+ messageBoxPointY = value.value();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
TC::ConfigApi configApi("messageText");
|
|
TC::ConfigApi configApi("messageText");
|
|
|
std::optional<QVariant> value = configApi.get();
|
|
std::optional<QVariant> value = configApi.get();
|
|
|
if (value.has_value()) {
|
|
if (value.has_value()) {
|
|
|
- messageText = value.value().toString();
|
|
|
|
|
|
|
+ messageText = value.value();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
TC::ConfigApi configApi("messageTitle");
|
|
TC::ConfigApi configApi("messageTitle");
|
|
|
std::optional<QVariant> value = configApi.get();
|
|
std::optional<QVariant> value = configApi.get();
|
|
|
if (value.has_value()) {
|
|
if (value.has_value()) {
|
|
|
- messageTitle = value.value().toString();
|
|
|
|
|
|
|
+ messageTitle = value.value();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- QMap<QString, QString> messageProcessName;
|
|
|
|
|
-
|
|
|
|
|
- TC::ProcessNameApi processNameApi;
|
|
|
|
|
- QJsonArray array = processNameApi.get();
|
|
|
|
|
- for (const auto item : array) {
|
|
|
|
|
- if (item.isObject()) {
|
|
|
|
|
- const auto object = item.toObject();
|
|
|
|
|
-
|
|
|
|
|
- const QString name = object["name"].toString();
|
|
|
|
|
- const QString zhName = object["chinese_name"].toString();
|
|
|
|
|
- if (object.contains("is_prompt")) {
|
|
|
|
|
- if (object["is_prompt"].toInt() == 2) {
|
|
|
|
|
- messageProcessName[name] = zhName;
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ for (const QJsonValue &item : serverArray) {
|
|
|
|
|
+ if (!item.isObject()) {
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- // messageProcessName["WeChat.exe"] = "WeChat.exe";
|
|
|
|
|
-
|
|
|
|
|
- // 提示
|
|
|
|
|
- // SELECT * FROM ProcessTime WHERE (updataTime - lastAlertTime) > 1565;
|
|
|
|
|
- if (time > 0) {
|
|
|
|
|
- CWF::SqlQueryManager qry(storage);
|
|
|
|
|
- qry.select("*", processModel.getTableName())
|
|
|
|
|
- .where(QString("(updataTime - lastAlertTime) > %1").arg(time));
|
|
|
|
|
- qry.prepare();
|
|
|
|
|
- QJsonObject jsonObject = qry.exec();
|
|
|
|
|
- QJsonArray jsonArray = qry.toJson();
|
|
|
|
|
-
|
|
|
|
|
- const QStringList keys = messageProcessName.keys();
|
|
|
|
|
-
|
|
|
|
|
- for (const auto &value : jsonArray) {
|
|
|
|
|
- // SLDWORKS.exe
|
|
|
|
|
-
|
|
|
|
|
- const QJsonObject object = value.toObject();
|
|
|
|
|
- const QString processName = object["processName"].toString();
|
|
|
|
|
- const qint64 runTime = object["exitTime"].toVariant().toLongLong()
|
|
|
|
|
- - object["creationTime"].toVariant().toLongLong();
|
|
|
|
|
-
|
|
|
|
|
- for (const QString &key : keys) {
|
|
|
|
|
- if (processName.compare(key, Qt::CaseSensitivity::CaseInsensitive) == 0) {
|
|
|
|
|
- // QVariant messageBoxPointX = QVariant();
|
|
|
|
|
- // QVariant messageBoxPointY = QVariant();
|
|
|
|
|
- // QVariant messageText = QVariant("");
|
|
|
|
|
- // QVariant messageTitle = QVariant(Tr::tr("Tips"));
|
|
|
|
|
- // Program A has been used for 20 minutes, please exercise
|
|
|
|
|
-
|
|
|
|
|
- // const QString text = QString(tr("program %1 %3 run time :%2")
|
|
|
|
|
- // .arg(messageProcessName[key])
|
|
|
|
|
- // .arg(convertSecondsToTimeFormat(runTime))
|
|
|
|
|
- // .arg(messageText.toString()));
|
|
|
|
|
-
|
|
|
|
|
- const QString text = QString(tr("Program %1 has been used for %2 minutes%3")
|
|
|
|
|
- .arg(messageProcessName[key])
|
|
|
|
|
- .arg(convertSecondsToMinutesTimeFormat(runTime))
|
|
|
|
|
- .arg(messageText.toString()));
|
|
|
|
|
- emit messageBox(text, messageBoxPointX, messageBoxPointY, messageTitle);
|
|
|
|
|
|
|
+ const QJsonObject object = item.toObject();
|
|
|
|
|
+
|
|
|
|
|
+ const QString name = object["name"].toString();
|
|
|
|
|
+ const QString zhName = object["chinese_name"].toString();
|
|
|
|
|
+ if (object.contains("is_prompt")) {
|
|
|
|
|
+ if (object["is_prompt"].toInt() == 2) {
|
|
|
|
|
+ const QString name = object["name"].toString();
|
|
|
|
|
+ const QString zhName = object["chinese_name"].toString();
|
|
|
|
|
+ const int time = object["prompt_time"].toInt();
|
|
|
|
|
+ if (time > 0) {
|
|
|
|
|
+ const QString whereTime = QString("(updataTime - lastAlertTime) > %1").arg(time);
|
|
|
|
|
+ const QString whereProcessName = QString("processName = '%1'").arg(name);
|
|
|
|
|
+ const QString whereUpdataTime = QString("updataTime = '%1'").arg(updataTime);
|
|
|
|
|
+ CWF::SqlQueryManager qry(storage);
|
|
|
|
|
+ qry.select("*", processModel.getTableName())
|
|
|
|
|
+ .where(QString("%1 AND %2 AND %3")
|
|
|
|
|
+ .arg(whereTime)
|
|
|
|
|
+ .arg(whereProcessName)
|
|
|
|
|
+ .arg(whereUpdataTime));
|
|
|
|
|
+ qry.prepare();
|
|
|
|
|
+ QJsonObject jsonObject = qry.exec();
|
|
|
|
|
+ QJsonArray jsonArray = qry.toJson();
|
|
|
|
|
+ qDebug() << jsonArray;
|
|
|
|
|
+ for (const auto &value : jsonArray) {
|
|
|
|
|
+ const QJsonObject object = value.toObject();
|
|
|
|
|
+ const QString processName = object["processName"].toString();
|
|
|
|
|
+ const qint64 runTime = object["exitTime"].toVariant().toLongLong()
|
|
|
|
|
+ - object["creationTime"].toVariant().toLongLong();
|
|
|
|
|
+
|
|
|
|
|
+ const QString text = QString(
|
|
|
|
|
+ tr("Program %1 has been used for %2 minutes%3")
|
|
|
|
|
+ .arg(zhName)
|
|
|
|
|
+ .arg(convertSecondsToMinutesTimeFormat(runTime))
|
|
|
|
|
+ .arg(messageText.toString()));
|
|
|
|
|
+ emit messageBox(text, messageBoxPointX, messageBoxPointY, messageTitle);
|
|
|
|
|
+
|
|
|
|
|
+ // 更新 lastAlertTime
|
|
|
|
|
+ ProcessModel processModel{storage};
|
|
|
|
|
+ processModel.buildFromJson(object);
|
|
|
|
|
+ // 更新 消息时间
|
|
|
|
|
+ processModel.setLastAlertTime(updataTime);
|
|
|
|
|
+ processModel.save();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 更新 lastAlertTime
|
|
|
|
|
- ProcessModel processModel{storage};
|
|
|
|
|
- processModel.buildFromJson(object);
|
|
|
|
|
- // 更新 消息时间
|
|
|
|
|
- processModel.setLastAlertTime(updataTime);
|
|
|
|
|
- processModel.save();
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // for (const QJsonValue &item : array) {
|
|
|
|
|
+ // if (item.isObject()) {
|
|
|
|
|
+ // const QJsonObject object = item.toObject();
|
|
|
|
|
+
|
|
|
|
|
+ // const QString name = object["name"].toString();
|
|
|
|
|
+ // const QString zhName = object["chinese_name"].toString();
|
|
|
|
|
+ // if (object.contains("is_prompt")) {
|
|
|
|
|
+ // if (object["is_prompt"].toInt() == 2) {
|
|
|
|
|
+ // messageProcessName[name] = zhName;
|
|
|
|
|
+ // };
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // qDebug() << messageProcessName;
|
|
|
|
|
+ // // SELECT * FROM ProcessTime WHERE (updataTime - lastAlertTime) > 1565;
|
|
|
|
|
+ // if (time > 0) {
|
|
|
|
|
+ // const QString whereTime = QString("(updataTime - lastAlertTime) > %1").arg(time);
|
|
|
|
|
+ // const QString whereProcessName = QString("processName = '%1'").arg("WeChat.exe");
|
|
|
|
|
+ // CWF::SqlQueryManager qry(storage);
|
|
|
|
|
+ // qry.select("*", processModel.getTableName()).where(whereTime);
|
|
|
|
|
+ // qry.prepare();
|
|
|
|
|
+ // QJsonObject jsonObject = qry.exec();
|
|
|
|
|
+ // QJsonArray jsonArray = qry.toJson();
|
|
|
|
|
+
|
|
|
|
|
+ // const QStringList keys = messageProcessName.keys();
|
|
|
|
|
+
|
|
|
|
|
+ // for (const auto &value : jsonArray) {
|
|
|
|
|
+ // // SLDWORKS.exe
|
|
|
|
|
+
|
|
|
|
|
+ // const QJsonObject object = value.toObject();
|
|
|
|
|
+ // const QString processName = object["processName"].toString();
|
|
|
|
|
+ // const qint64 runTime = object["exitTime"].toVariant().toLongLong()
|
|
|
|
|
+ // - object["creationTime"].toVariant().toLongLong();
|
|
|
|
|
+
|
|
|
|
|
+ // for (const QString &key : keys) {
|
|
|
|
|
+ // if (processName.compare(key, Qt::CaseSensitivity::CaseInsensitive) == 0) {
|
|
|
|
|
+ // const QString text = QString(tr("Program %1 has been used for %2 minutes%3")
|
|
|
|
|
+ // .arg(messageProcessName[key])
|
|
|
|
|
+ // .arg(convertSecondsToMinutesTimeFormat(runTime))
|
|
|
|
|
+ // .arg(messageText.toString()));
|
|
|
|
|
+ // emit messageBox(text, messageBoxPointX, messageBoxPointY, messageTitle);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // // 更新 lastAlertTime
|
|
|
|
|
+ // ProcessModel processModel{storage};
|
|
|
|
|
+ // processModel.buildFromJson(object);
|
|
|
|
|
+ // // 更新 消息时间
|
|
|
|
|
+ // processModel.setLastAlertTime(updataTime);
|
|
|
|
|
+ // processModel.save();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool ProcessThread::upDataProcessSql()
|
|
bool ProcessThread::upDataProcessSql()
|