升龙物业 老版本 ocx IPO, 加密狗 转值班电话

AgentGroup.cpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #include "StdAfx.h"
  2. #include "AgentGroup.h"
  3. #include "Agent.h"
  4. #include "NetworkAcd.h"
  5. #include "StrategyAD.h"
  6. CAgentGroup::CAgentGroup( void )
  7. {
  8. }
  9. CAgentGroup::~CAgentGroup( void )
  10. {
  11. }
  12. /*****************************************************************
  13. **【函数名称】 add
  14. **【函数功能】 添加座席
  15. **【参数】
  16. **【返回值】
  17. ****************************************************************/
  18. void CAgentGroup::add( CAgent* a_pAgent )
  19. {
  20. ASSERT(a_pAgent != NULL);
  21. m_CsLock4Distribute.Lock();
  22. Add(a_pAgent);
  23. m_CsLock4Distribute.Unlock();
  24. }
  25. /*****************************************************************
  26. **【函数名称】 remove
  27. **【函数功能】 删除座席
  28. **【参数】
  29. **【返回值】
  30. ****************************************************************/
  31. bool CAgentGroup::remove( CAgent* a_pAgent )
  32. {
  33. ASSERT(a_pAgent != NULL);
  34. CSingleLock Lock(&m_CsLock4Distribute, TRUE);
  35. for(int i = 0; i < m_nSize; ++i)
  36. {
  37. if(m_pData[i] == a_pAgent)
  38. {
  39. RemoveAt(i, 1);
  40. TRACE(_T("Succeed @CAgentGroup::remove\r\n"));
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. /*****************************************************************
  47. **【函数名称】 clear
  48. **【函数功能】 释放所有座席
  49. **【参数】
  50. **【返回值】
  51. ****************************************************************/
  52. void CAgentGroup::clear( void )
  53. {
  54. RemoveAll();
  55. }
  56. /*****************************************************************
  57. **【函数名称】 isNoFreeAgent
  58. **【函数功能】 是否座席全忙
  59. **【参数】
  60. **【返回值】
  61. ****************************************************************/
  62. bool CAgentGroup::isNoFreeAgent( void )
  63. {
  64. CSingleLock Lock(&m_CsLock4Distribute, TRUE);
  65. for(int i = 0; i < m_nSize; ++i) // 保证遍历一轮
  66. {
  67. if(m_pData[i]->isFree())
  68. return false;
  69. }
  70. return true;
  71. }
  72. /*****************************************************************
  73. **【函数名称】 distributeAgent
  74. **【函数功能】 分派座席
  75. **【参数】
  76. **【返回值】
  77. ****************************************************************/
  78. QUEUE_AGENT_RESULT CAgentGroup::distributeAgent( CStrategyAD* pStrategy, const CString& InfoEx, UINT& Agent, UINT& Exten )
  79. {
  80. if(m_nSize == 0)
  81. return QUEUE_AGENT_FAILED_NO_AGENT;
  82. // 如果座席全忙
  83. if(isNoFreeAgent())
  84. return QUEUE_AGENT_FAILED_NO_FREE;
  85. CAgent* pAgent = NULL;
  86. CSingleLock Lock(&m_CsLock4Distribute, TRUE);
  87. QUEUE_AGENT_RESULT Result = pStrategy->distributeAgent(*this, InfoEx, pAgent);
  88. if(pAgent != NULL && pAgent->lock()) // 对于无法锁定的座席,默认分配失败
  89. {
  90. Agent = pAgent->id();
  91. Exten = pAgent->assoExten();
  92. return Result;
  93. }
  94. else
  95. {
  96. return QUEUE_AGETN_FAILED_NO_SPEC;
  97. }
  98. }