Commit 565b27de by 李定达

1.mcdmanager.exe使用守护版本

parent 2701981e
#include "fmcontrol.h"
#include "fmcontrol.h"
#include "fmtools.h"
#include "QsLog.h"
#include "fmdefine.h"
......@@ -19,6 +19,8 @@
FmControl::FmControl()
{
bool m_init_flag = true;
int m_keepsleeptime = 0;
m_keepTimer.setInterval(KEEP_INTERVAL);
connect(&m_keepTimer, &QTimer::timeout, this, &FmControl::onKeepProcess);
}
......@@ -41,6 +43,35 @@ void FmControl::onKeepProcess()
{
QString error;
QStringList diedProcList;
QLOG_INFO() << qApp->applicationDirPath() + "/update.flag";
if(m_init_flag == false)
{
QFile file(qApp->applicationDirPath() + "/update.flag");
if(file.exists())
{
++ m_keepsleeptime;
m_keepsleeptime %= 121;
if(m_keepsleeptime < 120)
{
QLOG_WARN() << "update.flag file exit wait times : " << m_keepsleeptime;
return ;
}
else
{
file.remove();
m_keepsleeptime = 0;
}
}
}
m_init_flag = false;
if(!_GetDiedProcess(FmTools::GetInstance().GetKeepExes(), diedProcList, error))
{
QLOG_ERROR() << QString("get died process failed [%1]").arg(error);
......@@ -52,6 +83,7 @@ void FmControl::onKeepProcess()
{
QString exePath = QString("%1/%2").arg(m_appDir, path);
QLOG_INFO() << QString("launch [%1]").arg(exePath);
if(!_LaunchProcess(exePath, error))
{
QLOG_ERROR() << QString("launch process failed [%1]").arg(error);
......
......@@ -18,6 +18,10 @@ public:
void Start();
private:
// 初始化标志位
bool m_init_flag;
// 停止启动程序计数器
int m_keepsleeptime;
// 程序守护定时器
QTimer m_keepTimer;
// 记录程序所在的目录
......
......@@ -11,7 +11,7 @@
#define INIPATH_TIMEOUT1 "SoftInfo/timeout1"
#define SERVICE_NAME "Fmupdate"
#define SERVICE_DESC "用于非码程序的升级服务"
#define SERVICE_DESC "using freemud mcdmanager.exe guard"
#define KEEP_INTERVAL 5*1000
#define CHECK_INTERVAL 10*60*1000
......
......@@ -2,7 +2,7 @@ include("QsLog/QsLog.pri")
include("QtService/src/qtservice.pri")
include("Quazip/quazip.pri")
QT += core network sql xml
QT += core network
QT -= gui
CONFIG += c++11
......
......@@ -2,10 +2,10 @@
#include "fmdefine.h"
#include <QJsonObject>
#include <QJsonDocument>
#include <QSqlDatabase>
#include <QDomComment>
#include <QDomElement>
#include <QSqlQuery>
//#include <QSqlDatabase>
//#include <QDomComment>
//#include <QDomElement>
//#include <QSqlQuery>
#include <QFile>
#include <QDir>
......@@ -22,82 +22,82 @@ FmTools::FmTools()
#ifdef BALIBEITIAN
#define MY_CFG "FMPOS.ini"
QFile file("C:/SPCINT/DATA/DBPOS/SHOPINFO.INI");
if(file.exists())
m_siIniPath = "C:/SPCINT/DATA/DBPOS/SHOPINFO.INI";
else
{
m_siIniPath = qApp->applicationDirPath() + "/" + MY_CFG;
m_partnerId = "1321";
m_keyStoreId = "SHOPINFO/STORECD";
m_keyPosId = "SHOPINFO/POSNO";;
QString tmppath = "C:/SPC/POS/INI/PosConfig.ini";
QDomDocument doc;
QFile file(tmppath);
if(!file.open(QFile::ReadOnly | QFile::Text))
{
return ;
}
QString strs;
int line, row;
if(!doc.setContent(&file, &strs, &line, &row))
{
file.close();
return ;
}
file.close();
QDomElement root = doc.documentElement();
if(root.tagName().compare("MESSAGE", Qt::CaseInsensitive) != 0)
{
return ;
}
QDomNode n = root.firstChild();
QString tmpposno, tmpstoreid;
while(!n.isNull())
{
QDomElement e = n.toElement();
if(e.nodeName().compare("pos", Qt::CaseInsensitive) == 0)
{
QDomNode ser = e.firstChild();
while(!ser.isNull())
{
QDomElement na = ser.toElement();
if(na.nodeName().compare("StoreNo", Qt::CaseInsensitive) == 0)
{
tmpstoreid = na.firstChild().nodeValue();
}
if(na.nodeName().compare("PosNo", Qt::CaseInsensitive) == 0)
{
tmpposno = na.firstChild().nodeValue();
}
ser = ser.nextSibling();
}
}
n = n.nextSibling();
}
QSettings set(m_siIniPath, QSettings::IniFormat);
set.setValue(m_keyStoreId, tmpstoreid);
set.setValue(m_keyPosId, tmpposno);
}
m_partnerId = "1321";
m_keyStoreId = "SHOPINFO/STORECD";
m_keyPosId = "SHOPINFO/POSNO";
// #define MY_CFG "FMPOS.ini"
// QFile file("C:/SPCINT/DATA/DBPOS/SHOPINFO.INI");
// if(file.exists())
// m_siIniPath = "C:/SPCINT/DATA/DBPOS/SHOPINFO.INI";
// else
// {
// m_siIniPath = qApp->applicationDirPath() + "/" + MY_CFG;
// m_partnerId = "1321";
// m_keyStoreId = "SHOPINFO/STORECD";
// m_keyPosId = "SHOPINFO/POSNO";;
// QString tmppath = "C:/SPC/POS/INI/PosConfig.ini";
// QDomDocument doc;
// QFile file(tmppath);
// if(!file.open(QFile::ReadOnly | QFile::Text))
// {
// return ;
// }
// QString strs;
// int line, row;
// if(!doc.setContent(&file, &strs, &line, &row))
// {
// file.close();
// return ;
// }
// file.close();
// QDomElement root = doc.documentElement();
// if(root.tagName().compare("MESSAGE", Qt::CaseInsensitive) != 0)
// {
// return ;
// }
// QDomNode n = root.firstChild();
// QString tmpposno, tmpstoreid;
// while(!n.isNull())
// {
// QDomElement e = n.toElement();
// if(e.nodeName().compare("pos", Qt::CaseInsensitive) == 0)
// {
// QDomNode ser = e.firstChild();
// while(!ser.isNull())
// {
// QDomElement na = ser.toElement();
// if(na.nodeName().compare("StoreNo", Qt::CaseInsensitive) == 0)
// {
// tmpstoreid = na.firstChild().nodeValue();
// }
// if(na.nodeName().compare("PosNo", Qt::CaseInsensitive) == 0)
// {
// tmpposno = na.firstChild().nodeValue();
// }
// ser = ser.nextSibling();
// }
// }
// n = n.nextSibling();
// }
// QSettings set(m_siIniPath, QSettings::IniFormat);
// set.setValue(m_keyStoreId, tmpstoreid);
// set.setValue(m_keyPosId, tmpposno);
// }
// m_partnerId = "1321";
// m_keyStoreId = "SHOPINFO/STORECD";
// m_keyPosId = "SHOPINFO/POSNO";
#endif
#ifdef SHIQIJIA
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment