| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #include <iostream>
- #include "Log.h"
- #include "FsProxy.h"
- #include "Config.h"
- #include "TimeScheduler.h"
- #include "TtsBaidu.h"
- #include "SqlWrite.h"
- #include "SoftAuth.h"
- #include <string>
- void AuthFun()
- {
- bool isStop = false;
- while (!isStop)
- {
- std::this_thread::sleep_for(std::chrono::hours(1));
- if (!SoftAuth::GetInstance()->isExpire()) // 授权到期,关闭程序
- {
- LOG_WARN("授权到期,自动关闭程序!");
- isStop = true;
- CFsProxy::GetInstance().release();
- exit(EXIT_SUCCESS);
- }
- }
- }
- int main()
- {
- MYLog::instance()->Init("log4cpp.conf");
- LOG_INFO_S("程序开始启动...");
- //if (!SoftAuth::GetInstance()->Auth())
- //{
- // std::cout << "该机器未授权,请授权后使用" << std::endl;
- // std::string hardc;
- // SoftAuth::GetInstance()->getMachineCode(hardc);
- // //std::cout << SoftAuth::GetInstance()->getMachineCode(hardc) << std::endl;
- // std::cout << "机器码:" << hardc << std::endl;
- // //SoftAuth::GetInstance()->MakeAuth(hardc);
- //
- // std::string code;// = "MWEyZGZmYzctYTVjNC00OWEwLTgxNTgtMTQ3YjNmYTA3Zjc4CjIwMjAwNzE2";
- // std::cout << "请输入授权码:" << std::endl;
- // std::cin >> code;
- // if (!SoftAuth::GetInstance()->Auth(code))
- // {
- // LOG_WARN("授权验证失败,自动关闭程序!");
- // CFsProxy::GetInstance().release();
- // //exit(EXIT_SUCCESS);
- // return 0;
- // }
- //}
- if (!SoftAuth::GetInstance()->AuthV2())
- {
- std::cout << "该机器未授权,请授权后使用" << std::endl;
- std::string hardc;
- SoftAuth::GetInstance()->getMachineCode(hardc);
- std::cout << "机器码:" << hardc << std::endl;
- std::string code;// = "MWEyZGZmYzctYTVjNC00OWEwLTgxNTgtMTQ3YjNmYTA3Zjc4CjIwMjAwNzE2";
- std::cout << "请输入授权码:" << std::endl;
- std::cin >> code;
- if (!SoftAuth::GetInstance()->AuthV2(code))
- {
- LOG_WARN("授权验证失败,自动关闭程序!");
- CFsProxy::GetInstance().release();
- //exit(EXIT_SUCCESS);
- return 0;
- }
- }
- AuthInfo aInfo;
- SoftAuth::GetInstance()->getAuthInfo(aInfo);
- LOG_INFO_S("授权到期时间:" + aInfo.data);
- LOG_INFO_S("授权中继数量:" + std::to_string(aInfo.trunkNum));
- LOG_INFO_S("授权坐席数量:" + std::to_string(aInfo.agentNum));
- if (!SoftAuth::GetInstance()->isExpire()) // 授权到期,关闭程序
- {
- LOG_WARN("授权到期,自动关闭程序!");
- return 0;
- }
- std::thread(std::bind(AuthFun)).detach();
-
-
- CConfig *cfg = CConfig::GetInstance();
- if (!cfg->load())
- {
- LOG_WARN_S("配置文件加载失败!");
- cfg->write();
- return 0;
- }
- if (CFsProxy::GetInstance().init())
- {
- LOG_INFO_S("程序初始化完成,开始运行...");
- CFsProxy::GetInstance().run();
- }
- else
- LOG_ERROR_S("程序初始化失败,程序即将关闭");
- CFsProxy::GetInstance().release();
- return 0;
- }
|