|
|
@@ -1,7 +1,7 @@
|
|
|
#include "mod_GuiConsole.h"
|
|
|
#include "publicFunExport.h"
|
|
|
#include <EventCode.h>
|
|
|
-#include <mod_guiconsole/GUIConsole_msg_g.h>
|
|
|
+#include "GUIConsole_msg_g.h"
|
|
|
|
|
|
|
|
|
bool isPad = false;
|
|
|
@@ -137,15 +137,47 @@ std::pair<DWORD, std::string> CGUIConsoleEntity::closePerformanceSender()
|
|
|
return std::pair<DWORD, std::string>(Error_Succeed, "");
|
|
|
}
|
|
|
|
|
|
-std::pair<DWORD, std::string> CGUIConsoleEntity::VTMSystemControl()
|
|
|
+std::pair<DWORD, std::string> CGUIConsoleEntity::VTMSystemControl(SpReqAnsContext<GUIConsoleService_VTMSystemControl_Req, GUIConsoleService_VTMSystemControl_Ans>::Pointer ctx)
|
|
|
{
|
|
|
+ CSmartPointer<IEntityFunction> pFunc = GetFunction();
|
|
|
+ CSmartPointer<IEntityFunctionPrivilege> pFuncPrivilege = pFunc.ConvertCase<IEntityFunctionPrivilege>();
|
|
|
+ if(pFuncPrivilege == NULL)
|
|
|
+ LogWarn(ErrorCodeEnum::)
|
|
|
+
|
|
|
+
|
|
|
+ if(!ctx->Req.rebootFunction.Compare("RestartApp", true))
|
|
|
+
|
|
|
return std::pair<DWORD, std::string>(Error_Succeed, "");
|
|
|
}
|
|
|
|
|
|
-std::pair<DWORD, std::string> CGUIConsoleEntity::VTM_controlEntity()
|
|
|
+std::pair<DWORD, std::string> CGUIConsoleEntity::VTM_controlEntity(SpReqAnsContext<GUIConsoleService_VTM_controlEntity_Req, GUIConsoleService_VTM_controlEntity_Ans>::Pointer ctx)
|
|
|
{
|
|
|
-
|
|
|
- return std::pair<DWORD, std::string>(Error_Succeed, "");
|
|
|
+ ErrorCodeEnum ret = ErrorCodeEnum::Error_Succeed;
|
|
|
+ if (!ctx->Req.operation.Compare("Start", true))
|
|
|
+ ret = AsyncStartEntity(ctx->Req.entityName, NULL, NULL);
|
|
|
+ else if (!ctx->Req.operation.Compare("Stop", true))
|
|
|
+ ret = AsyncStopEntity(ctx->Req.entityName, NULL);
|
|
|
+ else if (!ctx->Req.operation.Compare("Pause", true))
|
|
|
+ ret = AsyncPauseEntity(ctx->Req.entityName, NULL);
|
|
|
+ else if (!ctx->Req.operation.Compare("Continue", true))
|
|
|
+ ret = AsyncContinueEntity(ctx->Req.entityName, NULL);
|
|
|
+ else if (!ctx->Req.operation.Compare("Terminate", true))
|
|
|
+ ret = AsyncTerminateEntity(ctx->Req.entityName, NULL);
|
|
|
+
|
|
|
+
|
|
|
+ LogInfo msg;
|
|
|
+ msg.sysError = ret;
|
|
|
+ msg.userCode = ret;
|
|
|
+ msg.timeStr = GenerateTimeStr().c_str();
|
|
|
+ msg.entityName = ctx->Req.entityName;
|
|
|
+ msg.message = CSimpleString::Format("%s %s %s, ret:%d", ctx->Req.entityName, ctx->Req.operation
|
|
|
+ , (ret == ErrorCodeEnum::Error_Succeed ? "Success" : "Failed"), ret);
|
|
|
+ SpSendBroadcast(GetFunction(), eMsg_LogInfo, eMsgSig_LogInfo, msg);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return std::pair<DWORD, std::string>(ret, "");
|
|
|
}
|
|
|
|
|
|
CGUIConsoleEntity::CGUIConsoleEntity()
|
|
|
@@ -201,10 +233,39 @@ void CGUIConsoleSession::Handle_VTMSystemControl(SpReqAnsContext<GUIConsoleServi
|
|
|
|
|
|
void CGUIConsoleSession::Handle_VTM_controlEntity(SpReqAnsContext<GUIConsoleService_VTM_controlEntity_Req, GUIConsoleService_VTM_controlEntity_Ans>::Pointer ctx)
|
|
|
{
|
|
|
- auto ret = m_pEntity->VTM_controlEntity();
|
|
|
+ auto ret = m_pEntity->VTM_controlEntity(ctx);
|
|
|
ctx->Answer((ErrorCodeEnum)ret.first, (ErrorCodeEnum)ret.first);
|
|
|
}
|
|
|
|
|
|
+void CGUIConsoleSession::Handle_GetAllEntityList(SpReqAnsContext<GUIConsoleService_GetAllEntityList_Req, GUIConsoleService_GetAllEntityList_Ans>::Pointer ctx)
|
|
|
+{
|
|
|
+ CAutoArray<EntityEntry> Entities;
|
|
|
+ auto ret = m_pEntity->GetAllEntity(Entities);
|
|
|
+ if (ret.first != ErrorCodeEnum::Error_Succeed)
|
|
|
+ {
|
|
|
+ ctx->Answer((ErrorCodeEnum)ret.first, (ErrorCodeEnum)ret.first);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ctx->Ans.entityName.Init(Entities.GetCount());
|
|
|
+ ctx->Ans.status.Init(Entities.GetCount());
|
|
|
+ ctx->Ans.processId.Init(Entities.GetCount());
|
|
|
+ ctx->Ans.versionNo.Init(Entities.GetCount());
|
|
|
+ ctx->Ans.lastStartTime.Init(Entities.GetCount());
|
|
|
+
|
|
|
+ CSimpleStringA activeVer;
|
|
|
+ m_pEntity->GetFunction()->GetRunningVersion(activeVer);
|
|
|
+ for (int i = 0; i < Entities.GetCount(); ++i) {
|
|
|
+ ctx->Ans.entityName[i] = Entities[i].Name;
|
|
|
+ ctx->Ans.status[i] = Entities[i].GetStateName(Entities[i].State);
|
|
|
+ ctx->Ans.processId[i] = Entities[i].Pid;
|
|
|
+ ctx->Ans.versionNo[i] = activeVer;
|
|
|
+ ctx->Ans.lastStartTime[i] = Entities[i].lastStartTime.ToTimeString();
|
|
|
+ }
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
ErrorCodeEnum CGUIConsoleEntity::AsyncStartEntity(const char* entity_name, const char* cmdline, void* pData)
|
|
|
{
|
|
|
CSmartPointer<IEntityFunction> pFunc = GetFunction();
|
|
|
@@ -330,25 +391,38 @@ ErrorCodeEnum CGUIConsoleEntity::GetEntity(const char* entity_name, EntityEntry&
|
|
|
e.Pid = (int)RunInfo.dwProcessID;
|
|
|
e.DevelopID = (int)StaticInfo.wEntityDevelopID;
|
|
|
e.DebugLevel = RunInfo.eDebugLevel;
|
|
|
+ e.lastStartTime = RunInfo.tmLastStart;
|
|
|
}
|
|
|
}
|
|
|
return Error;
|
|
|
}
|
|
|
|
|
|
|
|
|
-ErrorCodeEnum CGUIConsoleEntity::GetAllEntity(CAutoArray<EntityEntry>& Entities)
|
|
|
+std::pair<DWORD, std::string> CGUIConsoleEntity::GetAllEntity(CAutoArray<EntityEntry>& Entities)
|
|
|
{
|
|
|
CSmartPointer<IEntityFunction> spFunc = GetFunction();
|
|
|
CAutoArray<CSimpleStringA> strEntityNames;
|
|
|
CAutoArray<WORD> wDevelopIDs;
|
|
|
ErrorCodeEnum Error = spFunc->GetAllRegistedEntity(strEntityNames, wDevelopIDs);
|
|
|
- if (Error == Error_Succeed) {
|
|
|
- Entities.Init(strEntityNames.GetCount());
|
|
|
- for (int i = 0; i < strEntityNames.GetCount(); ++i) {
|
|
|
- Error = GetEntity(strEntityNames[i], Entities[i]);
|
|
|
- }
|
|
|
+ if (Error_Succeed != Error)
|
|
|
+ {
|
|
|
+ LogWarn(SeverityLevelEnum::Severity_Middle, Error, WARN_GUICONSOLE_GETALLENTITY_REGISTERED, "GetAllEntity-GetAllRegistedEntity failed");
|
|
|
+ return std::make_pair(WARN_GUICONSOLE_GETALLENTITY_REGISTERED, "");
|
|
|
}
|
|
|
- return Error;
|
|
|
+
|
|
|
+ CSimpleString ErrInfo;
|
|
|
+ Entities.Init(strEntityNames.GetCount());
|
|
|
+ for (int i = 0; i < strEntityNames.GetCount(); ++i) {
|
|
|
+ Error = GetEntity(strEntityNames[i], Entities[i]);
|
|
|
+ if (Error != Error_Succeed)
|
|
|
+ ErrInfo += CSimpleString::Format("|%s %d|", strEntityNames[i].GetData(), Error);
|
|
|
+ }
|
|
|
+ if (ErrInfo.GetLength() > 0)
|
|
|
+ {
|
|
|
+ LogWarn(SeverityLevelEnum::Severity_Middle, Error, WARN_GUICONSOLE_GETALLENTITY_GETENTITY, ErrInfo.GetData());
|
|
|
+ return std::make_pair(WARN_GUICONSOLE_GETALLENTITY_GETENTITY, "");
|
|
|
+ }
|
|
|
+ return std::make_pair(ErrorCodeEnum::Error_Succeed, "");
|
|
|
}
|
|
|
|
|
|
void CGUIConsoleEntity::OnAnswer(CSmartPointer<IAsynWaitSp> pAsynWaitSp)
|