98 lines
1.9 KiB
C++
98 lines
1.9 KiB
C++
#include "DataManage/DataHandle.h"
|
|
#include "global.h"
|
|
#include "SystemInfo.h"
|
|
#include "Logger.h"
|
|
#include "Toast.h"
|
|
#include <iostream>
|
|
#include <map>
|
|
|
|
UserType g_Admin;
|
|
string g_AppPath;
|
|
string g_AppDisk;
|
|
Logger* g_log;
|
|
LanguageManager* g_LngManager;
|
|
Toast* g_Toast;
|
|
bool g_isDebug;
|
|
uint32_t g_ScanSerial;
|
|
string g_gno;
|
|
SystemInfo* g_SystemInfo;
|
|
|
|
class HBDSystem {
|
|
public:
|
|
HBDSystem() {}
|
|
~HBDSystem() {
|
|
DELP(g_log);
|
|
DELP(g_SystemInfo);
|
|
DELP(g_Toast);
|
|
DELP(g_LngManager);
|
|
}
|
|
|
|
void Init(){
|
|
char szFilePath[MAX_PATH + 1] = { 0 };
|
|
GetModuleFileName(NULL, szFilePath, MAX_PATH);
|
|
(strrchr(szFilePath, '\\'))[1] = 0;
|
|
g_AppPath = szFilePath;
|
|
g_AppDisk = g_AppPath.substr(0, 2);
|
|
|
|
g_Admin = ADMIN;
|
|
|
|
g_isDebug = false;
|
|
g_log = new Logger();
|
|
g_log->m_LogDao->Init();
|
|
g_SystemInfo = new SystemInfo();
|
|
g_Toast = new Toast();
|
|
}
|
|
};
|
|
|
|
|
|
void Usage() {
|
|
printf("print service usage:\n");
|
|
printf(" r(run):start run...\n");
|
|
printf(" s(stop):stop run...\n");
|
|
printf(" e(exit):exit program...\n");
|
|
printf(" h(help):print this information...\n");
|
|
|
|
}
|
|
|
|
|
|
int main(int argc, char** argv) {
|
|
HBDSystem* hbd = new HBDSystem();
|
|
hbd->Init();
|
|
|
|
DataHandle* dataHandle = new DataHandle();
|
|
dataHandle->Init();
|
|
|
|
Usage();
|
|
|
|
std::string userInput;
|
|
bool unknowCmd = false;
|
|
while (true) {
|
|
if (!unknowCmd)printf("*请输入命令:");
|
|
std::getline(std::cin, userInput); // 读取用户输入
|
|
unknowCmd = false;
|
|
if (userInput == "r" || userInput == "run") {
|
|
printf("service is running...\n");
|
|
dataHandle->Run();
|
|
}
|
|
else if (userInput == "s" || userInput == "stop") {
|
|
if (dataHandle) dataHandle->Stop();
|
|
printf("service is stoped...\n");
|
|
}
|
|
else if (userInput == "e" || userInput == "exit") {
|
|
printf("service is exiting...\n");
|
|
break;
|
|
}
|
|
else if (userInput == "h" || userInput == "help") {
|
|
Usage();
|
|
}
|
|
else {
|
|
printf("未识别的命令,请重新输入命令:");
|
|
unknowCmd = true;
|
|
}
|
|
|
|
}
|
|
|
|
DELP(dataHandle);
|
|
DELP(hbd);
|
|
return 0;
|
|
} |