//##ModelId=424BB64700A6 void ACDX::setAliasAvailable(CString _epid, CString _callid) { std::list<Agent>::iterator agentElment; Agent _agent; Agent agent = agentByCallId(_epid, _callid); // find first alias while ((agent.isOK) && (_callid.GetLength() > 0)) { // in alias list update element for(agentElment = aliasList.begin(); agentElment != aliasList.end();agentElment++) { _agent = *agentElment; if (agent.getAlias()==_agent.getAlias()) { if (g_lock.lock()) { agentElment->setState(Alias::AVAILABLE); agentElment->setLastCall(); agentElment->setLastTime(); agentElment->setCallId(""); backlog->checkPending((&(Agent)*agentElment),aliasList); //------> need test it agent in checkpending g_lock.unlock(); }// if lock }//if alias == }// for // check if we have pending calls for this now available agent //backlog->checkPending(&agent); //------> need test it agent in checkpending agent = agentByCallId(_epid, _callid); // find next alias } }
//##ModelId=424BB6470075 CString ACDX::getWaitQueue(CString queue) { return config->getWQID(queue); std::list<Agent>::iterator aliasElement; Agent agent; for(aliasElement = aliasList.begin(); aliasElement != aliasList.end(); ++aliasElement ) { agent = *aliasElement; if ( (agent.getAlias().Find(queue + "_wq")==0)/* && (agent.getState() == Endpoint::AVAILABLE) */) { return agent.getAlias(); } } return ""; }
//##ModelId=424BB6470067 void ACDX::logout(CString agent) { std::list<Agent>::iterator aliasElement; Agent ag; for(aliasElement = aliasList.begin(); aliasElement != aliasList.end(); ++aliasElement ) { ag = *aliasElement; if (agent==(H323Utils::extractAliasName(ag.getAlias()))) { if (g_lock.lock()) { aliasElement->setBlocked(TRUE); Logger::log("Logout agent " + agent); g_lock.unlock(); }// lock }// == }// for }
//##ModelId=424BB6470058 CString ACDX::dumpAgentStates() { //SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); //SYSTEMTIME systemtime; CString result = "Agent list\n"; std::list<Agent>::iterator aliasElement; Agent ag; for(aliasElement = aliasList.begin(); aliasElement != aliasList.end(); ++aliasElement ) { ag = *aliasElement; //systemtime.wMilliseconds = ag.getLastCall();//? here to h m s maybe case error struct tm * t = (struct tm *)ag.getLastTime(); //t->tm_mon+1 t->tm_hour; t->tm_min; t->tm_sec; char c_hour[sizeof(int)]; char c_min[sizeof(int)]; char c_sec[sizeof(int)]; itoa(t->tm_hour,c_hour,10); itoa(t->tm_min,c_min,10); itoa(t->tm_sec,c_sec,10); // agent last call time CString cs_time = CString(c_hour)+":"+CString(c_min)+":"+CString(c_sec); //t->tm_mon+1; //CTime t(systemtime); if (ag.isAgent()) { // agent list contains all GK registration, only list configured agents result += ag.getAlias() + " (" + ag.getEpid() + "):\t" + (ag.isBlocked() ? "NOT logged in" : " logged in") + "\tstate: " + (ag.getState()==0 ? "AVAILABLE" : "TALKING " ) + //"\tlast call: " + t.Format("%H:%M:%S") + "\tlast call: " + cs_time + "\n<br>"; } } return result; }
//##ModelId=42198D1803D5 // major route call for queue logic //##ModelId=424BB6470077 void ACDX::routeCall(CString queue, CString callerEndId, CString callRef, CString callerAlias, CString callerIp, CString callId) { Agent agent; if (distribution == ACDConfig::FIRST_FIT) { agent = firstFitRouter(queue);//give the call to the first suited agent that is //found (unfair, but fast) } else if (distribution == ACDConfig::ROUND_ROBIN) { agent = roundRobinRouter(queue);//give work to the next agent who is suited (fair) } else if (distribution == ACDConfig::LONGEST_IDLE) { agent = longestIdleRouter(queue);//choose an agent who is suited for this group, and //has been without a call the longest (fair) } // agent is not in list obj???-- if (agent.isOK) { std::list<Agent>::iterator agentElement; Agent _agent; for(agentElement = aliasList.begin(); agentElement != aliasList.end(); agentElement++) { _agent = *agentElement; //here use point to set list state is very important if (agent.getAlias() == _agent.getAlias()) { if (g_lock.lock()) { // (agentElement)->setState(Alias::TALKING); (agentElement)->setState(Alias::WAITTALKING); (agentElement)->setLastCall(); (agentElement)->setLastTime(); (agentElement)->setCallId(callId); (agentElement)->setRouteExpireTime(GetTickCount() + config->getRouteTimeout(queue)*1000); g_lock.unlock(); } //agent.setState(Agent::TALKING); //agent.setLastCall(); } } Logger::log("Routing call for " + queue + " to " + agent.getAlias()); gkclient->routeToAlias(agent.getAlias(), callerEndId, callRef, callId); } else { int queueingMode = config->getQueueingMode(queue); CString wqName; char qch[4]; itoa(queueingMode,qch,10); Logger::log("No agent available for call to " + queue + " (" + CString(qch) + ")"); if ( (queueingMode == ACDConfig::QUEUEING_MODE_RINGING) || (queueingMode == ACDConfig::QUEUEING_MODE_RINGANDTALK) ) { // store the request in the backlog, in case an agent becomes available before timeout backlog->store(queue, callerEndId, callRef, callerAlias, callerIp, PendingRequest::RINGING, callId); } else if ( (queueingMode == ACDConfig::QUEUEING_MODE_TALKING) && ((wqName = getWaitQueue(queue)) != "") ) { Logger::debug("*---acdx routecall-waiting queue name "+wqName);//test wqueue name gkclient->routeToAlias(wqName, callerEndId, callRef, callId); // store the request in the backlog, in case an agent becomes available before timeout backlog->store(queue, callerEndId, callRef, callerAlias, callerIp, PendingRequest::TALKING, callId); } else { // reject the call right away gkclient->routeReject(callerEndId, callRef, callId); } } }