华辉中间件项目(代码服务器上没有,用杨成电脑的源代码上传的)

Config.cpp 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "StdAfx.h"
  2. #include "Config.h"
  3. #include "DBCtrl.h"
  4. #include "Logger.h"
  5. #include "CtiDataDef.h"
  6. SINGLETON_IMPLEMENT(CConfig)
  7. CConfig::CConfig(void) : m_RecFilePath(_T("")), m_RecType(RECORD_TYPE_TRUNK), m_ListenPort(CTI_LISTEN_PORT), m_DevType(DEV_TYPE_IPO), m_IvrFlowNum(0), m_RecFormat(RECORD_FORMAT_MP3)
  8. {
  9. }
  10. CConfig::~CConfig(void)
  11. {
  12. }
  13. /*****************************************************************
  14. **【函数名称】 loadConfig
  15. **【函数功能】 加载配置
  16. **【参数】
  17. **【返回值】 成功TRUE,失败FALSE
  18. ****************************************************************/
  19. bool CConfig::loadConfig()
  20. {
  21. char buff[MAX_BUFF_SIZE] = { 0 };
  22. IOtlConnection* pDbConn = IOtlConnection::getInstance();
  23. // 读取是否使用TTS
  24. //CString strTts = pDbConn->GetSingleDataStr(_T("SELECT value FROM conf_system WHERE name = 'UseTts'"));
  25. //m_IsUseTts = atoi(strTts.GetBuffer(0));
  26. // 读取录音类型
  27. m_RecType = (RECORD_TYPE)pDbConn->GetSingleDataStr2Int(_T("SELECT value FROM conf_system WHERE name = 'RecType'"));
  28. // 读取录音格式
  29. m_RecFormat = (RECORD_FORMAT)pDbConn->GetSingleDataStr2Int(_T("SELECT value FROM conf_system WHERE name = 'RecFormat'"));
  30. // 读取录音文件路径
  31. m_RecFilePath = pDbConn->GetSingleDataStr(_T("SELECT value FROM conf_system WHERE name = 'RecPath'"));
  32. if(m_RecFilePath == "") m_RecFilePath = DEFAULT_RECORD_PATH;
  33. // 读取日志文件路径
  34. m_LogFilePath = pDbConn->GetSingleDataStr(_T("SELECT value FROM conf_system WHERE name = 'LogPath'"));
  35. // 读取Cti监听端口
  36. m_ListenPort = pDbConn->GetSingleDataStr2Int(_T("SELECT value FROM conf_system WHERE name = 'CtiPort'"));
  37. // 读取底层设备类型
  38. m_DevType = (DEV_TYPE)pDbConn->GetSingleDataStr2Int(_T("SELECT value FROM conf_system WHERE name = 'DevType'"));
  39. // 读取IVR流程个数
  40. m_IvrFlowNum = pDbConn->GetSingleDataStr2Int(_T("SELECT value FROM conf_system WHERE name = 'IvrFlowCount'"));
  41. if (m_IvrFlowNum <= 0)
  42. {
  43. ILogger::getInstance().log(LOG_CLASS_GENERAL, LOG_LEVEL_ERROR, _T("{Config}: 获取流程数量错误"));
  44. }
  45. return true;
  46. }
  47. /*****************************************************************
  48. **【函数名称】 queryLastCallId
  49. **【函数功能】 从数据库查询CALLID
  50. **【参数】
  51. **【返回值】 CallId
  52. ****************************************************************/
  53. ULONG CConfig::queryLastCallId()
  54. {
  55. CString strQuery = "select value from stat_callid where name = 'callid'";
  56. return IOtlConnection::getInstance()->GetSingleDataInt(strQuery);
  57. }
  58. /*****************************************************************
  59. **【函数名称】 updateCallId
  60. **【函数功能】 更新数据库中的CALLID
  61. **【参数】 CallId:新的CallID
  62. **【返回值】
  63. ****************************************************************/
  64. void CConfig::updateCallId( ULONG CallId )
  65. {
  66. CString strQuery;
  67. strQuery.Format("update stat_callid set value = %ld where name = 'callid'", CallId);
  68. IOtlConnection::getInstance()->ExecCommand(strQuery);
  69. }