123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #ifndef RVC_MOD_COMM_ENTITY_SETTINGS_HPP_
- #define RVC_MOD_COMM_ENTITY_SETTINGS_HPP_
- #include "SpBase.h"
- #include "fileutil.h"
- namespace SP
- {
- namespace Module
- {
- namespace Comm
- {
- namespace Settings
- {
- /*!
- * @brief 判断当前是否处于安装模式,对于某些实体在安装时需要配合执行功能所以会启动,但是又需要屏蔽掉常规模式下的自动执行
- * 就需要通过此接口判断以停止某些功能
- * @param[in]
- * @param[out]
- * @return :
- */
- static inline bool IsInConfigScheduleMode(CEntityBase* pEntity)
- {
- CSimpleStringA strtermState;
- pEntity->GetFunction()->GetSysVar("TerminalStage", strtermState);
- return strtermState.IsStartWith("Z=");
- }
- static inline ErrorCodeEnum StoreHeadBranchServicesMode(CEntityBase* pEntity, BOOL fEnable)
- {
- CSmartPointer<IConfigInfo> pConfig;
- pEntity->GetFunction()->OpenConfig(Config_Cache, pConfig);
- return pConfig->WriteConfigValueInt("MicroServicesConfig", "SourceFrom", fEnable? 2 : 1);
- }
- /*!
- * @brief 提供另外一种保底的方法检测集中配置从哪里下载
- * @param[in] 实体句柄
- * @return : -1:集中配置文件不存在;0:分行服务;1:总行服务
- */
- static int DetectCenterSettingFilesSyncFromWhere(CEntityBase* pEntity)
- {
- CSimpleStringA strFilePath;
- pEntity->GetFunction()->GetPath("CenterSetting", strFilePath);
- if (!ExistsFileA(strFilePath)) {
- return -1;
- }
- CSmartPointer<IConfigInfo> pConfig;
- pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pConfig);
- int fromType(0);
- pConfig->ReadConfigValueInt("CenterSetting", "ProvideByHeadBank", fromType);
- return (fromType == 1) ? 1 : 0;
- }
- static inline bool IsUsingHeadBranchServices(CEntityBase* pEntity)
- {
- CSmartPointer<IConfigInfo> pConfig;
- pEntity->GetFunction()->OpenConfig(Config_Cache, pConfig);
- int enable(0);
- pConfig->ReadConfigValueInt("MicroServicesConfig", "SourceFrom", enable);
- return (enable == 2);
- }
- static inline bool IsUsingSubBranchServerConfig(CEntityBase* pEntity)
- {
- CSmartPointer<IConfigInfo> pConfig;
- pEntity->GetFunction()->OpenConfig(Config_Cache, pConfig);
- int enable(0);
- pConfig->ReadConfigValueInt("MicroServicesConfig", "SourceFrom", enable);
- return (enable == 1);
- }
- /*!
- * @brief 先从集中配置中读取信息,如果没有,再从本地cfg实体配置文件读取信息
- * section 使用实体名称,从 GetFunction()->GetEntityName中获取
- * @param[in] retStrValue 不为空,则说明读的时字符串,retDwValue 不为空说明读取的是数字,不能都为空,也不能都不为空
- * @param[out]
- * @return :
- */
- static inline ErrorCodeEnum ReadConfigFromCenterAfterCfg(
- CEntityBase* pEntity, LPCTSTR lpcszKey, CSimpleStringA* retStrValue, int* retValue)
- {
- ErrorCodeEnum result(Error_Succeed);
- if ((lpcszKey == NULL || strlen(lpcszKey) == 0)
- || (retStrValue == NULL && retValue == NULL)
- || (retStrValue != NULL && retValue != NULL)
- || pEntity == NULL) {
- return Error_Param;
- }
- CSmartPointer<IConfigInfo> pCenConfig;
- result = pEntity->GetFunction()->OpenConfig(Config_CenterSetting, pCenConfig);
- if (retStrValue != NULL) {
- result = pCenConfig->ReadConfigValue(pEntity->GetEntityName(), lpcszKey, *retStrValue);
- if (retStrValue->IsNullOrEmpty()) {
- CSmartPointer<IConfigInfo> pCfgConfig;
- result = pEntity->GetFunction()->OpenConfig(Config_Software, pCfgConfig);
- result = pCfgConfig->ReadConfigValue(pEntity->GetEntityName(), lpcszKey, *retStrValue);
- }
- } else if(retValue != NULL) {
- result = pCenConfig->ReadConfigValueInt(pEntity->GetEntityName(), lpcszKey, *retValue);
- if (*retValue == 0) {
- CSmartPointer<IConfigInfo> pCfgConfig;
- result = pEntity->GetFunction()->OpenConfig(Config_Software, pCfgConfig);
- result = pCfgConfig->ReadConfigValueInt(pEntity->GetEntityName(), lpcszKey, *retValue);
- }
- }
- return result;
- }
- } //namespace Settings
- } //namespace Comm
- } //namespace Module
- } //SP
- #endif //RVC_MOD_COMM_ENTITY_SETTINGS_HPP_
|