| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #include "StdAfx.h"
- #include "SLogic.h"
- #include "SItemAgentDetail.h"
- #include "SItemAgentStatus.h"
- SINGLETON_IMPLEMENT(CSLogic)
- CSLogic::CSLogic(void)
- {
- }
- CSLogic::~CSLogic(void)
- {
- }
- /*****************************************************************
- **【函数名称】 __getAgentLoginId
- **【函数功能】 获取座席签入ID
- **【参数】
- **【返回值】
- ****************************************************************/
- ULONG CSLogic::__getAgentLoginId( UINT AgentId )
- {
- CString SQL;
- SQL.Format("SELECT LoginId FROM rep_agent_detail where AgentId = %d ORDER BY LoginId DESC", AgentId);
- ULONG LoginID = IOtlConnection::getInstance()->GetSingleDataInt(SQL);
- return ++LoginID;
- }
- /*****************************************************************
- **【函数名称】 __onAgentLogin
- **【函数功能】 坐席签入处理
- **【参数】 AgentId:签入坐席的工号
- **【返回值】
- ****************************************************************/
- void CSLogic::__onAgentLogin( UINT AgentId )
- {
- // 获取当前坐席的签入ID
- ULONG LoginID = __getAgentLoginId(AgentId);
- CSItem* pItemDetail = new CSItemAgentDetail(AgentId, LoginID);
- m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemDetail));
- CSItem* pItemStatus = new CSItemAgentStatus(AgentId, LoginID);
- m_ItemMap.insert(pair<UINT, CSItem*>(AgentId, pItemStatus));
- }
- /*****************************************************************
- **【函数名称】 __onAgentLogout
- **【函数功能】 坐席签出处理
- **【参数】 AgentId: 签出坐席的工号
- **【返回值】
- ****************************************************************/
- void CSLogic::__onAgentLogout( UINT AgentId )
- {
- SItemMap::iterator itrBegin;
- SItemMap::iterator itrEnd;
- itrBegin = m_ItemMap.find(AgentId);
- if(itrBegin == m_ItemMap.end())
- return;
- itrEnd = m_ItemMap.upper_bound(AgentId);
- CSItem* pItem = NULL;
- for(SItemMap::iterator itr = itrBegin; itr != itrEnd; ++itr)
- {
- pItem = itr->second;
- if(pItem != NULL)
- delete pItem;
- }
- m_ItemMap.erase(itrBegin, itrEnd);
- }
- /*****************************************************************
- **【函数名称】 OnRepEvent
- **【函数功能】 统计事件变化通知
- **【参数】 AgentId: 坐席工号
- EvtType: 事件类型
- Param: 参数
- **【返回值】
- ****************************************************************/
- void CSLogic::onSEvent( UINT AgentId, REP_EVENT EvtType, PARAM Param )
- {
- // 坐席签入处理
- if(EvtType == REP_EVENT_LOGIN)
- __onAgentLogin(AgentId);
- SItemMap::iterator itr;
- SItemMap::iterator itrEnd;
- itr = m_ItemMap.find(AgentId);
- if(itr == m_ItemMap.end())
- return;
- itrEnd = m_ItemMap.upper_bound(AgentId);
- // 事件消息群发
- for(; itr != itrEnd; ++itr)
- {
- itr->second->onSEvent(EvtType, Param);
- }
- // 坐席签出处理
- if(EvtType == REP_EVENT_LOGOUT)
- __onAgentLogout(AgentId);
- }
|