多数据源中间件标准版1.0

StrategySpecifiedAgent.cpp 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "StdAfx.h"
  2. #include "StrategySpecifiedAgent.h"
  3. #include "Agent.h"
  4. #include "AgentGroup.h"
  5. CStrategySpecifiedAgent::CStrategySpecifiedAgent(void)
  6. {
  7. }
  8. CStrategySpecifiedAgent::~CStrategySpecifiedAgent(void)
  9. {
  10. }
  11. /*****************************************************************
  12. **【函数名称】 _setStrategyInfo
  13. **【函数功能】 设定策略的参照信息
  14. **【参数】
  15. **【返回值】
  16. ****************************************************************/
  17. void CStrategySpecifiedAgent::_setStrategyInfo( const CString& Info )
  18. {
  19. m_AgentIdList.RemoveAll();
  20. CHAR szInfo[AGENT_ID_BUF_LEN];
  21. lstrcpy(szInfo, Info);
  22. // 解析指定的座席工号
  23. char* lpNextToken = NULL;
  24. char* lpToken = strtok_s(szInfo, AGENT_GROUP_SPLIT_FLAG, &lpNextToken);
  25. while(lpToken != NULL)
  26. {
  27. UINT AgentId = 0;
  28. sscanf_s(lpToken, "%d", &AgentId);
  29. m_AgentIdList.Add(AgentId);
  30. lpToken = strtok_s(NULL, AGENT_GROUP_SPLIT_FLAG, &lpNextToken);
  31. } // end while
  32. }
  33. /*****************************************************************
  34. **【函数名称】 _locateAgent
  35. **【函数功能】 得到当前排队策略下可用座席
  36. **【参数】
  37. **【返回值】
  38. ****************************************************************/
  39. CAgent* CStrategySpecifiedAgent::_locateAgent( CAgentGroup& AgentGroup )
  40. {
  41. for(int i=0; i<m_AgentIdList.GetCount(); i++)
  42. {
  43. for(int j = 0; j < AgentGroup.GetCount(); ++j)
  44. {
  45. CAgent* pAgent = AgentGroup[j];
  46. if(pAgent->id() == m_AgentIdList[i] && pAgent->isFree())
  47. {
  48. return pAgent;
  49. }
  50. }
  51. } // end for
  52. return NULL;
  53. }