|
@@ -2,6 +2,7 @@
|
|
#include "SATExecutor.h"
|
|
#include "SATExecutor.h"
|
|
#include "PythonExecutor.h"
|
|
#include "PythonExecutor.h"
|
|
#include "CharEncoding.h"
|
|
#include "CharEncoding.h"
|
|
|
|
+#include "SynSerial.h"
|
|
|
|
|
|
CSATExecutor::CSATExecutor(void)
|
|
CSATExecutor::CSATExecutor(void)
|
|
{
|
|
{
|
|
@@ -35,7 +36,8 @@ SATHTTP::STTask* CSATExecutor::IsThereATaskInProcess()
|
|
{
|
|
{
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
|
|
for ( ; it != m_vtTask.end(); it++ ) {
|
|
for ( ; it != m_vtTask.end(); it++ ) {
|
|
- if ( it->_nExecutionState == 1 ) {
|
|
|
|
|
|
+ // 执行中的任务;
|
|
|
|
+ if ( it->_nExecutionState == SATHTTP::INEXECUTED ) {
|
|
return &(*it);
|
|
return &(*it);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -47,7 +49,8 @@ SATHTTP::STTask* CSATExecutor::GetFreeTask()
|
|
{
|
|
{
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
|
|
for ( ; it != m_vtTask.end(); it++ ) {
|
|
for ( ; it != m_vtTask.end(); it++ ) {
|
|
- if ( it->_nExecutionState == 0 ) {
|
|
|
|
|
|
+ // 未执行的任务;
|
|
|
|
+ if ( it->_nExecutionState == SATHTTP::UNEXECUTED ) {
|
|
return &(*it);
|
|
return &(*it);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -61,8 +64,8 @@ void CSATExecutor::DelFinishedTask()
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
|
|
std::list<SATHTTP::STTask>::iterator it = m_vtTask.begin();
|
|
for ( ; it != m_vtTask.end(); it++ ) {
|
|
for ( ; it != m_vtTask.end(); it++ ) {
|
|
// 状态为2的完成任务;
|
|
// 状态为2的完成任务;
|
|
- if ( it->_nExecutionState == 2 ) {
|
|
|
|
- GLOBAL::WriteTextLog("删除已完成任务:%s", it->Job.strUniqueId.c_str());
|
|
|
|
|
|
+ if ( it->_nExecutionState == SATHTTP::EXECUTED ) {
|
|
|
|
+ GLOBAL::WriteTextLog("==>删除已完成任务:%s", it->Job.strUniqueId.c_str());
|
|
// 删除所有执行器对象;
|
|
// 删除所有执行器对象;
|
|
for (std::vector<SATHTTP::STCase>::iterator _case = it->Job.vtCases.begin(); _case != it->Job.vtCases.end(); _case++ ) {
|
|
for (std::vector<SATHTTP::STCase>::iterator _case = it->Job.vtCases.begin(); _case != it->Job.vtCases.end(); _case++ ) {
|
|
if ( _case->_pExcutor )
|
|
if ( _case->_pExcutor )
|
|
@@ -79,7 +82,8 @@ SATHTTP::STCase* CSATExecutor::IsCaseScriptProcess(std::vector<SATHTTP::STCase>
|
|
{
|
|
{
|
|
std::vector<SATHTTP::STCase>::iterator it = vtCases.begin();
|
|
std::vector<SATHTTP::STCase>::iterator it = vtCases.begin();
|
|
for ( ; it != vtCases.end(); it++) {
|
|
for ( ; it != vtCases.end(); it++) {
|
|
- if ( it->_nExecutionState == 1 ) {
|
|
|
|
|
|
+ // 执行中的脚本;
|
|
|
|
+ if ( it->_nExecutionState == SATHTTP::INEXECUTED ) {
|
|
return &(*it);
|
|
return &(*it);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -91,7 +95,8 @@ SATHTTP::STCase* CSATExecutor::GetFreeCaseScript(std::vector<SATHTTP::STCase> &v
|
|
{
|
|
{
|
|
std::vector<SATHTTP::STCase>::iterator it = vtCases.begin();
|
|
std::vector<SATHTTP::STCase>::iterator it = vtCases.begin();
|
|
for ( ; it != vtCases.end(); it++) {
|
|
for ( ; it != vtCases.end(); it++) {
|
|
- if ( it->_nExecutionState == 0 ) {
|
|
|
|
|
|
+ // 未执行的脚本;
|
|
|
|
+ if ( it->_nExecutionState == SATHTTP::UNEXECUTED ) {
|
|
return &(*it);
|
|
return &(*it);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -101,6 +106,7 @@ SATHTTP::STCase* CSATExecutor::GetFreeCaseScript(std::vector<SATHTTP::STCase> &v
|
|
|
|
|
|
SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
|
|
SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
|
|
{
|
|
{
|
|
|
|
+ // 多取未执行的脚本;
|
|
SATHTTP::STCase* pCase = GetFreeCaseScript(pTask->Job.vtCases);
|
|
SATHTTP::STCase* pCase = GetFreeCaseScript(pTask->Job.vtCases);
|
|
if (pCase) {
|
|
if (pCase) {
|
|
if ( !pCase->_pExcutor ) {
|
|
if ( !pCase->_pExcutor ) {
|
|
@@ -114,14 +120,14 @@ SATHTTP::STCase* CSATExecutor::ExecuteFreeCaseScript(SATHTTP::STTask* pTask)
|
|
pExcutor->SetCaseObje(pCase);
|
|
pExcutor->SetCaseObje(pCase);
|
|
pExcutor->StartScript();
|
|
pExcutor->StartScript();
|
|
// 标记用例执行中;
|
|
// 标记用例执行中;
|
|
- pCase->_nExecutionState = 1;
|
|
|
|
|
|
+ pCase->_nExecutionState = SATHTTP::INEXECUTED;
|
|
}
|
|
}
|
|
- else { // 初始化失败;
|
|
|
|
- pCase->_nExecutionState = 4;
|
|
|
|
|
|
+ else { // 标记脚本失败;
|
|
|
|
+ pCase->_nExecutionResult = SATHTTP::FAIL;
|
|
}
|
|
}
|
|
|
|
|
|
// 标记任务为执行中;
|
|
// 标记任务为执行中;
|
|
- pTask->_nExecutionState = 1;
|
|
|
|
|
|
+ pTask->_nExecutionState = SATHTTP::INEXECUTED;
|
|
// 记录开始时间;
|
|
// 记录开始时间;
|
|
pCase->_ulStartTickCount = GetTickCount64();
|
|
pCase->_ulStartTickCount = GetTickCount64();
|
|
pCase->_strStartTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
|
|
pCase->_strStartTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
|
|
@@ -272,10 +278,9 @@ bool CSATExecutor::UpdateDevice()
|
|
stUpdateDeviceReq.devicelist.assign(m_vtDevice.begin(), m_vtDevice.end());
|
|
stUpdateDeviceReq.devicelist.assign(m_vtDevice.begin(), m_vtDevice.end());
|
|
if ( !::UpdateDeviceMessage(url, stUpdateDeviceReq, stUpdateDeviceResp) )
|
|
if ( !::UpdateDeviceMessage(url, stUpdateDeviceReq, stUpdateDeviceResp) )
|
|
{
|
|
{
|
|
|
|
+ GLOBAL::WriteTextLog("更新设备信息失败");
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
- GLOBAL::WriteTextLog("更新设备信息成功");
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -385,11 +390,11 @@ bool CSATExecutor::UploadCaseLog(SATHTTP::STTask* pTask, SATHTTP::STCase *pCase)
|
|
stSaveLogReq.strUploads = pCase->_strCaseLog;
|
|
stSaveLogReq.strUploads = pCase->_strCaseLog;
|
|
if ( SaveCaseOrTaskLog(url, stSaveLogReq, stSaveLogResp) )
|
|
if ( SaveCaseOrTaskLog(url, stSaveLogReq, stSaveLogResp) )
|
|
{
|
|
{
|
|
- GLOBAL::WriteTextLog("上传日志成功:任务=%s, 用例=%s, 图片=%s", pTask->Job.strUniqueId.c_str(), pCase->strCaseName.c_str(), pCase->_strCaseLog.c_str());
|
|
|
|
|
|
+ GLOBAL::WriteTextLog("上传日志成功:任务=%s, 用例=%s, 日志=%s", pTask->Job.strUniqueId.c_str(), pCase->strCaseName.c_str(), pCase->_strCaseLog.c_str());
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
- GLOBAL::WriteTextLog("上传日志失败:任务=%s, 用例=%s, 图片=%s", pTask->Job.strUniqueId.c_str(), pCase->strCaseName.c_str(), pCase->_strCaseLog.c_str());
|
|
|
|
|
|
+ GLOBAL::WriteTextLog("上传日志失败:任务=%s, 用例=%s, 日志=%s", pTask->Job.strUniqueId.c_str(), pCase->strCaseName.c_str(), pCase->_strCaseLog.c_str());
|
|
|
|
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -403,7 +408,13 @@ bool CSATExecutor::ReportCaseItemFinish(SATHTTP::STTask* pTask, SATHTTP::STCase
|
|
SATHTTP::STJobProcessReq stJobProcessReq;
|
|
SATHTTP::STJobProcessReq stJobProcessReq;
|
|
SATHTTP::STJobProcessResp stJobProcessResp;
|
|
SATHTTP::STJobProcessResp stJobProcessResp;
|
|
|
|
|
|
|
|
+ // 根据测试项结果决定测试项成功与否;
|
|
stJobProcessReq.strResultState = caseItem.result ? "1" : "0";
|
|
stJobProcessReq.strResultState = caseItem.result ? "1" : "0";
|
|
|
|
+ // 如果测试项失败,标记用例和任务失败;
|
|
|
|
+ if ( !caseItem.result ) {
|
|
|
|
+ pCase->_nExecutionResult = SATHTTP::FAIL;
|
|
|
|
+ pTask->_nExecutionResult = SATHTTP::FAIL;
|
|
|
|
+ }
|
|
stJobProcessReq.strCaseScene = "";
|
|
stJobProcessReq.strCaseScene = "";
|
|
// 索引;
|
|
// 索引;
|
|
_itoa_s(pCase->_nCaseStep, szValue, 10);
|
|
_itoa_s(pCase->_nCaseStep, szValue, 10);
|
|
@@ -501,10 +512,23 @@ bool CSATExecutor::ReportCaseFinish(SATHTTP::STTask* pTask, SATHTTP::STCase *pCa
|
|
SATHTTP::STJobProcessResp stJobProcessResp;
|
|
SATHTTP::STJobProcessResp stJobProcessResp;
|
|
|
|
|
|
// 上报用例结果:0表示脚本成功执行, 1表示脚本出错或超时;
|
|
// 上报用例结果:0表示脚本成功执行, 1表示脚本出错或超时;
|
|
- if ( pCase->_nExecutionState == 2 )
|
|
|
|
- stJobProcessReq.strResultState = "0"; // 脚本未执行完成;
|
|
|
|
- else //if ( pCase->_nExecutionState == 1 )
|
|
|
|
- stJobProcessReq.strResultState = "1"; // 脚本执行中,认为fail;
|
|
|
|
|
|
+ if ( pCase->_nExecutionState == SATHTTP::EXECUTED )
|
|
|
|
+ {
|
|
|
|
+ if ( pCase->_nExecutionResult == SATHTTP::SUCCESS )
|
|
|
|
+ stJobProcessReq.strResultState = "0"; // 脚本未执行完成;
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ stJobProcessReq.strResultState = "1";
|
|
|
|
+ // 同时标记任务失败;
|
|
|
|
+ pTask->_nExecutionResult = SATHTTP::FAIL;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ stJobProcessReq.strResultState = "1"; // 脚本执行未完成,认为fail;
|
|
|
|
+ // 同时标记任务失败;
|
|
|
|
+ pTask->_nExecutionResult = SATHTTP::FAIL;
|
|
|
|
+ }
|
|
|
|
|
|
stJobProcessReq.strCaseScene = "";
|
|
stJobProcessReq.strCaseScene = "";
|
|
// 索引;
|
|
// 索引;
|
|
@@ -562,7 +586,7 @@ bool CSATExecutor::ReportCaseFinish(SATHTTP::STTask* pTask, SATHTTP::STCase *pCa
|
|
|
|
|
|
if ( SetResultList(url, stJobProcessReq, stJobProcessResp) )
|
|
if ( SetResultList(url, stJobProcessReq, stJobProcessResp) )
|
|
{
|
|
{
|
|
- GLOBAL::WriteTextLog("上传用例结果完成【失败】:任务=%s, 用例=%s", pTask->Job.strUniqueId.c_str(), pCase->strCaseName.c_str());
|
|
|
|
|
|
+ GLOBAL::WriteTextLog("上传用例结果完成【成功】:任务=%s, 用例=%s", pTask->Job.strUniqueId.c_str(), pCase->strCaseName.c_str());
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -581,8 +605,11 @@ bool CSATExecutor::ReportCaseResult(SATHTTP::STTask* pTask, SATHTTP::STCase *pCa
|
|
std::vector<STCaseItem> vtCaseItem;
|
|
std::vector<STCaseItem> vtCaseItem;
|
|
GetCaseXMLResult(xmlpath, vtCaseItem);
|
|
GetCaseXMLResult(xmlpath, vtCaseItem);
|
|
// 如果测试项空,任务失败;
|
|
// 如果测试项空,任务失败;
|
|
- if ( vtCaseItem.size() == 0 )
|
|
|
|
- pCase->_nExecutionState = 4;
|
|
|
|
|
|
+ if ( vtCaseItem.size() == 0 ) {
|
|
|
|
+ pCase->_nExecutionResult = SATHTTP::ABNORMAL;
|
|
|
|
+ // 同时标记任务失败;
|
|
|
|
+ pTask->_nExecutionResult = SATHTTP::FAIL;
|
|
|
|
+ }
|
|
|
|
|
|
int nIndex = 1;
|
|
int nIndex = 1;
|
|
TCHAR szValue[MAX_PATH] = {0};
|
|
TCHAR szValue[MAX_PATH] = {0};
|
|
@@ -730,8 +757,15 @@ bool CSATExecutor::ReportTaskFinish(SATHTTP::STTask* pTask)
|
|
SATHTTP::STJobProcessResp stJobProcessResp;
|
|
SATHTTP::STJobProcessResp stJobProcessResp;
|
|
|
|
|
|
// 需要处理(只要有用例失败,任务就失败)
|
|
// 需要处理(只要有用例失败,任务就失败)
|
|
- stJobProcessReq.strResultState = "0"; // 脚本执行中,认为fail;
|
|
|
|
-
|
|
|
|
|
|
+ if ( pTask->_nExecutionState == SATHTTP::EXECUTED )
|
|
|
|
+ {
|
|
|
|
+ if ( pTask->_nExecutionResult == SATHTTP::SUCCESS )
|
|
|
|
+ stJobProcessReq.strResultState = "0"; // 脚本执行中,认为fail;
|
|
|
|
+ else
|
|
|
|
+ stJobProcessReq.strResultState = "1"; // 脚本执行中,认为fail;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ stJobProcessReq.strResultState = "1"; // 脚本执行中,认为fail;
|
|
stJobProcessReq.strCaseScene = "";
|
|
stJobProcessReq.strCaseScene = "";
|
|
// 索引;
|
|
// 索引;
|
|
stJobProcessReq.strCaseStep = "0";
|
|
stJobProcessReq.strCaseStep = "0";
|
|
@@ -1051,7 +1085,14 @@ DWORD CSATExecutor::ExecuteScriptThread(LPVOID lpVoid)
|
|
CPythonExecutor *pExcutor = (CPythonExecutor*)pCase->_pExcutor;
|
|
CPythonExecutor *pExcutor = (CPythonExecutor*)pCase->_pExcutor;
|
|
if ( pExcutor ) {
|
|
if ( pExcutor ) {
|
|
if ( pExcutor->IsScriptOver() ) {
|
|
if ( pExcutor->IsScriptOver() ) {
|
|
- pCase->_nExecutionState = 2;
|
|
|
|
|
|
+ // 标记脚本已执行;
|
|
|
|
+ pCase->_nExecutionState = SATHTTP::EXECUTED;
|
|
|
|
+ // 如果脚本异常,标记任务失败;
|
|
|
|
+ if ( pCase->_nExecutionResult == SATHTTP::ABNORMAL ) {
|
|
|
|
+ // 设置任务执行结果失败;
|
|
|
|
+ pTask->_nExecutionResult = SATHTTP::FAIL;
|
|
|
|
+ GLOBAL::WriteTextLog("用例脚本异常退出(%s)", pCase->strCaseName.c_str());
|
|
|
|
+ }
|
|
// 上报服务器,完成脚本用例,并上传用例结果;
|
|
// 上报服务器,完成脚本用例,并上传用例结果;
|
|
that->ReportCaseResult(pTask, pCase);
|
|
that->ReportCaseResult(pTask, pCase);
|
|
}
|
|
}
|
|
@@ -1127,3 +1168,139 @@ DWORD CSATExecutor::ExecuteScriptThread(LPVOID lpVoid)
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+DWORD CSATExecutor::WathTVPortThread(PVOID lpVoid)
|
|
|
|
+{
|
|
|
|
+ CSynSerial tv;
|
|
|
|
+ std::string buffer;
|
|
|
|
+ TCHAR szLastPort[10] = {0};
|
|
|
|
+ _tcscpy_s(szLastPort, GLOBAL::g_stSATConfig.szTVPort);
|
|
|
|
+ std::vector<std::string> vtNotifyReboot;
|
|
|
|
+ std::vector<std::string> vtNotifyShutdown;
|
|
|
|
+ DWORD dwTickCount = GetTickCount();
|
|
|
|
+/*
|
|
|
|
+ while(!g_bStopThread)
|
|
|
|
+ {
|
|
|
|
+ // 读取配置文件;
|
|
|
|
+ GLOBAL::GetIniInfo();
|
|
|
|
+ if ( !GLOBAL::g_stSATConfig.bWatchTVPort )
|
|
|
|
+ {
|
|
|
|
+ Sleep(5000);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( GetTickCount() - dwTickCount > 5000 )
|
|
|
|
+ {// 5秒更新一次;
|
|
|
|
+ dwTickCount = GetTickCount();
|
|
|
|
+ vtNotifyReboot.clear();
|
|
|
|
+ vtNotifyShutdown.clear();
|
|
|
|
+ GLOBAL::Split(GLOBAL::g_stSATConfig.szTVReboot, _T(";"), vtNotifyReboot);
|
|
|
|
+ GLOBAL::Split(GLOBAL::g_stSATConfig.szTVShutdown, _T(";"), vtNotifyShutdown);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 串口是否变更;
|
|
|
|
+ if ( _tcsicmp(szLastPort, GLOBAL::g_stSATConfig.szTVPort) )
|
|
|
|
+ {
|
|
|
|
+ _tcscpy_s(szLastPort, GLOBAL::g_stSATConfig.szTVPort);
|
|
|
|
+ // 重启打开串口;
|
|
|
|
+ tv.CloseSerialPort();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( !tv.IsOpen() )
|
|
|
|
+ {
|
|
|
|
+ tv.OpenSerialPort(szLastPort, 115200, 8, 0, 1, 0, 1000);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( tv.IsOpen() )
|
|
|
|
+ {
|
|
|
|
+ BYTE szBuffer[1024] = {0};
|
|
|
|
+ DWORD dwBuffer = tv.ReadComm(szBuffer, 1024, 1000);
|
|
|
|
+ if ( dwBuffer != 0 )
|
|
|
|
+ {
|
|
|
|
+ int nType = 0; // 0表示无异常类型,-1表示关机异常,1表示重启异常;
|
|
|
|
+ bool bAbnormal = false;
|
|
|
|
+ buffer = (char*)szBuffer;
|
|
|
|
+ __time64_t gmt = time(NULL);// 获取当前日历时间(1900-01-01开始的Unix时间戳);
|
|
|
|
+ // 遍历是否有符合的子串;
|
|
|
|
+ for ( std::vector<std::string>::iterator it = vtNotifyReboot.begin(); it != vtNotifyReboot.end(); it++ )
|
|
|
|
+ {
|
|
|
|
+ if ( _tcsstr(buffer.c_str(), it->c_str()) )
|
|
|
|
+ {
|
|
|
|
+ nType = 1;
|
|
|
|
+ bAbnormal = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( !bAbnormal )
|
|
|
|
+ {
|
|
|
|
+ for ( std::vector<std::string>::iterator it = vtNotifyShutdown.begin(); it != vtNotifyShutdown.end(); it++ )
|
|
|
|
+ {
|
|
|
|
+ if ( _tcsstr(buffer.c_str(), it->c_str()) )
|
|
|
|
+ {
|
|
|
|
+ nType = -1;
|
|
|
|
+ bAbnormal = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 1分钟前,是否有收到脚本通知;
|
|
|
|
+ if ( Global::g_notify.notify )
|
|
|
|
+ {
|
|
|
|
+ __int64 nd = gmt - Global::g_notify.datetime;
|
|
|
|
+#ifdef _DEBUG
|
|
|
|
+ TRACE3("判断时间%ld-通知时间%ld=相差时间%ld\n\n", gmt, Global::g_notify.datetime, nd);
|
|
|
|
+#endif
|
|
|
|
+ if ( nd < 60)
|
|
|
|
+ {
|
|
|
|
+ // 监测的类型与通知类型是否一致;
|
|
|
|
+ if ( (nType == 1 && Global::g_notify.report_type == _T("reboot")) ||
|
|
|
|
+ (nType == -1 && Global::g_notify.report_type == _T("shutdown")) )
|
|
|
|
+ {
|
|
|
|
+ bAbnormal = false;
|
|
|
|
+ // 重置;
|
|
|
|
+ Global::g_notify.notify = false;
|
|
|
|
+ Global::g_notify.datetime = 0;
|
|
|
|
+ Global::g_notify.report_type.clear();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bAbnormal)
|
|
|
|
+ {
|
|
|
|
+ if ( nType == -1 )
|
|
|
|
+ {
|
|
|
|
+ // 遥控:重启电视机;
|
|
|
|
+ if ( Global::g_SendPowerKey )
|
|
|
|
+ Global::g_SendPowerKey();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 压入容器中;
|
|
|
|
+ Global::TLog tlog;
|
|
|
|
+ if ( nType == -1 )
|
|
|
|
+ tlog.report_type = "Abnormal shutdown";
|
|
|
|
+ else if ( nType == 1 )
|
|
|
|
+ tlog.report_type = "Abnormal restart";
|
|
|
|
+ tlog.datetime = gmt; // 发生时间;
|
|
|
|
+
|
|
|
|
+ struct tm gmtm = {0};
|
|
|
|
+ localtime_s(&gmtm, &gmt); // 时间戳转成本地时间;
|
|
|
|
+ TCHAR szDataTime[64] = {0};
|
|
|
|
+ _stprintf_s(szDataTime,_T("Time of exception:%04d-%02d-%02d %02d:%02d:%02d"), gmtm.tm_year + 1900, gmtm.tm_mon+1, gmtm.tm_mday, gmtm.tm_hour, gmtm.tm_min, gmtm.tm_sec);
|
|
|
|
+ tlog.report_data = szDataTime;
|
|
|
|
+ Global::g_vtAbnormal.push_back(tlog);
|
|
|
|
+
|
|
|
|
+ // 最后,重置;
|
|
|
|
+ Global::g_notify.notify = false;
|
|
|
|
+ Global::g_notify.datetime = 0;
|
|
|
|
+ Global::g_notify.report_type.clear();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Sleep(200);
|
|
|
|
+ }
|
|
|
|
+*/
|
|
|
|
+ return 0;
|
|
|
|
+}
|