多数据源中间件标准版1.0

SLogic.cpp 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. #include "StdAfx.h"
  2. #include "SLogic.h"
  3. #include "SItemAgentDetail.h"
  4. #include "SItemAgentStatus.h"
  5. #include "SItemAgenStateDuration.h"
  6. #include "SItemAgenStateTimeDetail.h"
  7. SINGLETON_IMPLEMENT(CSLogic)
  8. CSLogic::CSLogic(void)
  9. {
  10. }
  11. CSLogic::~CSLogic(void)
  12. {
  13. }
  14. /*****************************************************************
  15. **【函数名称】 __getAgentLoginId
  16. **【函数功能】 获取座席签入ID
  17. **【参数】
  18. **【返回值】
  19. ****************************************************************/
  20. ULONG CSLogic::__getAgentLoginId( UINT AgentId )
  21. {
  22. //CString SQL;
  23. //SQL.Format("SELECT LoginId FROM rep_agent_detail where AgentId = %d ORDER BY LoginId DESC", AgentId);
  24. //ULONG LoginID = IOtlConnection::getInstance()->GetSingleDataInt(SQL);
  25. //return ++LoginID;
  26. // 20201211 合并12345功能
  27. CString SQL;
  28. ULONG LoginID = 0;
  29. CTime m_time;
  30. m_time = CTime::GetCurrentTime(); //获取当前时间日期
  31. CString str = m_time.Format(_T("%Y%m%d"));
  32. int Timeid = atoi(str.GetBuffer(0));
  33. SQL.Format("SELECT LoginId FROM rep_agentState_Duration where AgentId = %d ORDER BY LoginId DESC", AgentId);
  34. LoginID = IOtlConnection::getInstance()->GetSingleDataInt(SQL);
  35. ULONG LoninIDTime = LoginID / 100;
  36. if (LoginID == 0 || LoginID > 2917092801 || LoninIDTime < Timeid)
  37. {
  38. long lognid = Timeid * 100 + 1;
  39. return lognid;
  40. }
  41. return ++LoginID;
  42. }
  43. /*****************************************************************
  44. **【函数名称】 __onAgentLogin
  45. **【函数功能】 坐席签入处理
  46. **【参数】 AgentId:签入坐席的工号
  47. **【返回值】
  48. ****************************************************************/
  49. void CSLogic::__onAgentLogin( UINT AgentId )
  50. {
  51. // 获取当前坐席的签入ID
  52. ULONG LoginID = __getAgentLoginId(AgentId);
  53. CSItem* pItemDetail = new CSItemAgentDetail(AgentId, LoginID);
  54. m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemDetail));
  55. CSItem* pItemStatus = new CSItemAgentStatus(AgentId, LoginID);
  56. m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemStatus));
  57. }
  58. void CSLogic::__onAgentLogin(UINT AgentId, UINT Exten)
  59. {
  60. // 获取当前坐席的签入ID
  61. ULONG LoginID = __getAgentLoginId(AgentId);
  62. CSItem* pItemDetail = new CSItemAgentDetail(AgentId, LoginID);
  63. m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemDetail));
  64. CSItem* pItemStatus = new CSItemAgentStatus(AgentId, LoginID);
  65. m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemStatus));
  66. CSItem* pItemState = new CSItemAgenState(AgentId, Exten, LoginID);
  67. m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemState));
  68. CSItem* pItemStateTimeDetail = new CSItemAgenStateTimeDetail(AgentId);
  69. m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemStateTimeDetail));
  70. }
  71. /*****************************************************************
  72. **【函数名称】 __onAgentLogout
  73. **【函数功能】 坐席签出处理
  74. **【参数】 AgentId: 签出坐席的工号
  75. **【返回值】
  76. ****************************************************************/
  77. void CSLogic::__onAgentLogout( UINT AgentId )
  78. {
  79. SItemMap::iterator itrBegin;
  80. SItemMap::iterator itrEnd;
  81. itrBegin = m_ItemMap.find(AgentId);
  82. if(itrBegin == m_ItemMap.end())
  83. return;
  84. itrEnd = m_ItemMap.upper_bound(AgentId);
  85. CSItem* pItem = NULL;
  86. for(SItemMap::iterator itr = itrBegin; itr != itrEnd; ++itr)
  87. {
  88. pItem = itr->second;
  89. if(pItem != NULL)
  90. delete pItem;
  91. }
  92. m_ItemMap.erase(itrBegin, itrEnd);
  93. }
  94. /*****************************************************************
  95. **【函数名称】 OnRepEvent
  96. **【函数功能】 统计事件变化通知
  97. **【参数】 AgentId: 坐席工号
  98. EvtType: 事件类型
  99. Param: 参数
  100. **【返回值】
  101. ****************************************************************/
  102. //void CSLogic::onSEvent( UINT AgentId, REP_EVENT EvtType, PARAM Param )
  103. //{
  104. // // 坐席签入处理
  105. // if(EvtType == REP_EVENT_LOGIN)
  106. // __onAgentLogin(AgentId);
  107. //
  108. // SItemMap::iterator itr;
  109. // SItemMap::iterator itrEnd;
  110. //
  111. // itr = m_ItemMap.find(AgentId);
  112. // if(itr == m_ItemMap.end())
  113. // return;
  114. //
  115. // itrEnd = m_ItemMap.upper_bound(AgentId);
  116. // // 事件消息群发
  117. // for(; itr != itrEnd; ++itr)
  118. // {
  119. // itr->second->onSEvent(EvtType, Param);
  120. // }
  121. //
  122. // // 坐席签出处理
  123. // if(EvtType == REP_EVENT_LOGOUT)
  124. // __onAgentLogout(AgentId);
  125. //}
  126. void CSLogic::onSEvent(UINT AgentId, UINT Exten, REP_EVENT EvtType, PARAM Param)
  127. {
  128. // 坐席签入处理
  129. if (EvtType == REP_EVENT_LOGIN)
  130. __onAgentLogin(AgentId, Exten);
  131. SItemMap::iterator itr;
  132. SItemMap::iterator itrEnd;
  133. itr = m_ItemMap.find(AgentId);
  134. if (itr == m_ItemMap.end())
  135. return;
  136. itrEnd = m_ItemMap.upper_bound(AgentId);
  137. // 事件消息群发
  138. for (; itr != itrEnd; ++itr)
  139. {
  140. itr->second->onSEvent(EvtType, Param);
  141. }
  142. // 坐席签出处理
  143. if (EvtType == REP_EVENT_LOGOUT)
  144. __onAgentLogout(AgentId);
  145. }