GrpcPrint/PrintS/main.cpp

98 lines
1.9 KiB
C++
Raw Normal View History

2024-03-15 12:31:34 +08:00
#include "DataManage/DataHandle.h"
2024-03-19 17:45:12 +08:00
#include "global.h"
#include "SystemInfo.h"
#include "Logger.h"
#include "Toast.h"
2024-03-22 11:28:06 +08:00
#include <iostream>
2024-03-27 16:09:22 +08:00
#include <map>
2024-03-15 12:31:34 +08:00
2024-03-19 17:45:12 +08:00
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;
2024-03-27 16:09:22 +08:00
class HBDSystem {
public:
HBDSystem() {}
~HBDSystem() {
DELP(g_log);
DELP(g_SystemInfo);
DELP(g_Toast);
DELP(g_LngManager);
}
2024-03-22 11:28:06 +08:00
2024-03-27 16:09:22 +08:00
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);
2024-03-22 11:28:06 +08:00
2024-03-27 16:09:22 +08:00
g_Admin = ADMIN;
2024-03-15 12:31:34 +08:00
2024-03-27 16:09:22 +08:00
g_isDebug = false;
g_log = new Logger();
g_log->m_LogDao->Init();
g_SystemInfo = new SystemInfo();
g_Toast = new Toast();
}
};
2024-03-26 10:33:00 +08:00
2024-03-19 17:45:12 +08:00
2024-04-07 17:09:01 +08:00
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");
}
2024-03-27 16:09:22 +08:00
int main(int argc, char** argv) {
HBDSystem* hbd = new HBDSystem();
hbd->Init();
2024-03-19 17:45:12 +08:00
2024-03-15 12:31:34 +08:00
DataHandle* dataHandle = new DataHandle();
2024-04-07 17:09:01 +08:00
dataHandle->Init();
Usage();
2024-03-19 17:45:12 +08:00
2024-03-22 11:28:06 +08:00
std::string userInput;
2024-04-07 17:09:01 +08:00
bool unknowCmd = false;
2024-03-22 11:28:06 +08:00
while (true) {
2024-04-07 17:09:01 +08:00
if (!unknowCmd)printf("*请输入命令:");
2024-03-22 11:28:06 +08:00
std::getline(std::cin, userInput); // 读取用户输入
2024-04-07 17:09:01 +08:00
unknowCmd = false;
2024-03-22 11:28:06 +08:00
if (userInput == "r" || userInput == "run") {
printf("service is running...\n");
dataHandle->Run();
}
2024-04-07 17:09:01 +08:00
else if (userInput == "s" || userInput == "stop") {
if (dataHandle) dataHandle->Stop();
printf("service is stoped...\n");
}
else if (userInput == "e" || userInput == "exit") {
2024-04-08 13:43:56 +08:00
printf("service is exiting...\n");
2024-03-22 11:28:06 +08:00
break;
}
2024-04-07 17:09:01 +08:00
else if (userInput == "h" || userInput == "help") {
Usage();
}
2024-03-22 11:28:06 +08:00
else {
2024-04-07 17:09:01 +08:00
printf("未识别的命令,请重新输入命令:");
unknowCmd = true;
2024-03-22 11:28:06 +08:00
}
2024-04-07 17:09:01 +08:00
2024-03-22 11:28:06 +08:00
}
2024-03-27 16:09:22 +08:00
DELP(dataHandle);
DELP(hbd);
2024-03-15 12:31:34 +08:00
return 0;
}