123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #ifndef RVC_MOD_CENTERSETTING_H__
- #define RVC_MOD_CENTERSETTING_H__
- #pragma once
- #include "CenterSetting_server_g.h"
- using namespace CenterSetting;
- #include "CenterSettingConn.h"
- #include <regex>
- #include <map>
- #include <string>
- #ifdef RVC_OS_LINUX
- #include <mutex>
- #endif
- using namespace std;
- enum DownloadStat
- {
- SUCC = 1,
- AccessServiceFail = 2,
- EXIST = 3,
- MANUAL = 4,
- AllAddressNull = 5,
- CalcSM3Fail = 6,
- CheckSM3Fail = 7,
- UNknown = 8
- };
- static void HTTPLogCallback(const char* msg){
- }
- class CCenterSettingEntity : public CEntityBase, public ITimerListener
- {
- public:
- CCenterSettingEntity() : m_strFilePath(true){}
- virtual ~CCenterSettingEntity() {}
- virtual const char* GetEntityName() const { return "CenterSetting"; }
- virtual bool IsService()const{ return true; }
- virtual void OnStarted();
- virtual void OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext);
- virtual void OnTimeout(DWORD dwTimerID);
- virtual CServerSessionBase* OnNewSession(const char* /*pszRemoteEntityName*/, const char* /*pszClass*/);
- ErrorCodeEnum DownloadCenterSetting(SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer sp);
- ErrorCodeEnum GetAccessUrl(CSimpleStringA &url);
- ErrorCodeEnum GetCertainAceessUrl(CSimpleStringA &accessName, CSimpleStringA& url);
- private:
- ErrorCodeEnum BeginDownloadCenterSetting(bool bByHand = false, const string& url = "");
- private:
- CenterSettingsMicroServiceHelper* m_pMicroServiceHelper;
- CSimpleStringA m_strFilePath;
- CSmartPointer<IConfigInfo> m_pCenterConfig;
- CSimpleStringA m_strBakPath;
- #ifdef _MSC_VER
- CRITICAL_SECTION m_lock;
- #else
- std::mutex m_lock;
- #endif
- SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer m_spDownloadCall;
- friend class CCenterSettingConn;
- bool m_isUseMemCfg;
- };
- class CCenterSettingService : public CenterSettingService_ServerSessionBase
- {
- public:
- CCenterSettingService(CCenterSettingEntity* pEntity) :m_pEntity(pEntity){}
- virtual ~CCenterSettingService(){}
- virtual void Handle_Downloadv2(SpReqAnsContext<CenterSettingService_Downloadv2_Req, CenterSettingService_Downloadv2_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(CenterSettingService_LogCode_Downloadv2).setAPI(__FUNCTION__)(__FUNCTION__);
- m_pEntity->DownloadCenterSetting(ctx);
- }
- /** 有必要废弃,采用通用化的接口获取即可,特别是要JS化时 [Gifur@2023823]*/
- virtual void Handle_GetAccessUrl(SpReqAnsContext<CenterSettingService_GetAccessUrl_Req, CenterSettingService_GetAccessUrl_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(CenterSettingService_LogCode_GetAccessUrl).setAPI(__FUNCTION__)(__FUNCTION__);
- auto rc = m_pEntity->GetAccessUrl(ctx->Ans.HostUrl); //获取初始化地址,是的,就是初始化地址,不要在意这里的名称问题,之前同事开发接口的时候估计随手一打
- ctx->Answer(rc);
- }
- virtual void Handle_GetCertainAceessUrl(SpReqAnsContext<CenterSettingService_GetCertainAceessUrl_Req, CenterSettingService_GetCertainAceessUrl_Ans>::Pointer ctx)
- {
- DbgToBeidou(ctx->link, __FUNCTION__)();
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode(CenterSettingService_LogCode_GetCertainAceessUrl).setAPI(__FUNCTION__)(__FUNCTION__);
- auto rc = m_pEntity->GetCertainAceessUrl(ctx->Req.reqName, ctx->Ans.CertainAceessUrl); //获取准入地址,这个接口是后面加的
- ctx->Answer(rc);
- }
- private:
- CCenterSettingEntity* m_pEntity;
- };
- #endif /*RVC_MOD_CENTERSETTING_H__*/
|