Exemple #1
0
char* CPublicManage::GetServiceID(int nPublicID, char* szUserID, int tpid /* = 0 */)
{
	CLock m_csLock;
	CAutoLock autolock(&m_csLock);
	m_iCurPublic = nPublicID;
	COPYSTRARRAY(m_szCurUser,szUserID);
	m_iCurTp = tpid > 0?tpid:-1;

	BOOL bRet = FALSE;
	TpRelation tprelation;
	COPYSTRARRAY(m_pstrActiveID,"");
	for (int i = 0;i<m_vTpRelation.size();i++){//遍历公众号对应路由关系表{
		tprelation = m_vTpRelation[i];
		if (nPublicID == tprelation.publicid){
			if (tpid == -1) m_iCurTp = tprelation.tpid;
			std::vector<TpRule>::iterator it_tprule =
				find_if(m_vTpRule.begin(),m_vTpRule.end(),find_id<TpRule>(m_iCurTp));
			if (it_tprule != m_vTpRule.end()){
				switch(it_tprule->typtype){
				case TP_TIME:
					bRet = TimeTP(&(*it_tprule));
					break;
				case TP_PROBLEM:
					bRet = ProblemTP(m_iCurTp);
					break;
				case TP_INTERFACE:
					bRet = InterfaceTP(&(*it_tprule));
					break;
				case TP_CUSTOMERSERVICE:
					bRet = DirectCustomerService(&(*it_tprule));
					break;
				case TP_OTHER:
				default:
					bRet = FALSE;
					break;
				}
			}
		}
		if(bRet) break;
	}

	if (bRet)
	{
		if(m_listUser.size()){
			CUser *pCurUser = m_listUser.back();
			if(!strcmp(pCurUser->GetName(),szUserID)) 
				return pCurUser->GetCurCustomer()->GetName();
		}
		
		CUser *pUser = new CUser(szUserID);
		pUser->Attach(m_pCurCustomer);
		pUser->SetCurPublic(nPublicID);
		pUser->SetCurTp(m_iCurTp);
		m_listUser.push_back(pUser);	

		COPYSTRARRAY(m_pstrActiveID,m_pCurCustomer->GetName());
		
	}
	return m_pstrActiveID;
}
Exemple #2
0
CCustomer* CPublicManage::GetCurMaxDispatchCustomer(int id,int disPatchType)
{
	if (m_listUser.size())
	{
		CUser* pCurUser = m_listUser.back();
		CCustomer* pCurCustomer = pCurUser->GetCurCustomer();
		if (pCurUser && pCurUser->GetState() && 
			m_iCurPublic == pCurUser->GetCurPublic() &&
			!strcmp(m_szCurUser,pCurUser->GetName()) &&
			m_iCurTp     == pCurUser->GetCurTp() &&
			pCurCustomer->GetCurIncode() == id &&
			pCurCustomer->GetDisType() == disPatchType
			){
			pCurCustomer->SetSessionState(FALSE);
			pCurCustomer->SetClientNum(pCurCustomer->GetClientNum()-1);
			return pCurCustomer;
		}
	}

	std::vector<char*> vCustName;
	for (int i = 0;i<m_vDispatchRelation.size();i++){
		if (m_vDispatchRelation[i].incodeid == id){
			vCustName.push_back(m_vDispatchRelation[i].customerservice);
		}
	}
	std::list<CCustomer*> list_tempCust; 
	std::vector<char*>::iterator itCustName = vCustName.begin();
	while (itCustName!=vCustName.end()){
		MYSTATE myState = (MYSTATE)0;
		std::list<CCustomer*>::iterator it_CustObj = m_listCustomer.begin();
		for (;it_CustObj!=m_listCustomer.end();it_CustObj++)
		{
			if(!strcmp((*it_CustObj)->GetName(),*itCustName))
				break;
		}
		GetCustomerState((*it_CustObj)->GetName(),myState);
		if (MYSTATE_NORMAL == myState &&
			(*it_CustObj)->GetDisType() == disPatchType && 
			(*it_CustObj)->GetClientNum() < MAX_CLIENTNUM){
				list_tempCust.push_back(*it_CustObj);
		}
		itCustName++;
	}
	
	std::list<CCustomer*>::iterator itmax_index = list_tempCust.begin();
	if (itmax_index== list_tempCust.end()) return NULL;
	std::list<CCustomer*>::iterator itmax_temp = list_tempCust.begin();
	if (list_tempCust.size() > 1) ++itmax_temp;
	for (;itmax_index != list_tempCust.end();itmax_index++){
		if((*itmax_index)->CmpByDisType(*itmax_temp,disPatchType) > 0 ){
			itmax_temp = itmax_index;
		}
	}
	return *itmax_temp;
}