📄 agent.cpp
字号:
/*=============================================================
Function:
Author: Leon Wang <wlywly@sina.com giga2@tom.com>
==============================================================*/
// Agent.cpp: implementation of the Agent class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Agent.h"
#include "H323Utils.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//##ModelId=424BB64603B3
Agent::Agent()
{
appiniPath = getAppPath();// get acdx.ini path
blocked = FALSE;
}
/**
* Create an Agent object.
* @param _epid Endpoint ID
* @param _alias H.323 alias
*/
//##ModelId=424BB64603B4
Agent::Agent(CString _epid, CString _alias)
{
this->setAlias(_alias);
this->setEpid(_epid);
//super(_alias, _epid); father object
setLastCall(); // start counting free time from object creation
setLastTime();
appiniPath = getAppPath();// get acdx.ini path
blocked = FALSE;
}
//##ModelId=424BB64603C0
Agent::~Agent()
{
}
/**
* Set a specific time for the last call.
* @param lastCall the time (in milliseconds)
*/
//##ModelId=424BB64603C2
void Agent::setLastCall(long lastCall)
{
this->lastCall = lastCall;
}
/**
* Get the time since last call in milliseconds.
* @return elapsed time
*/
//##ModelId=424BB64603C4
long Agent::getLastCall()
{
return lastCall;
}
/**
* Set lastCall property to now.
*/
//##ModelId=424BB64603D0
void Agent::setLastCall()
{
//SYSTEMTIME systime;
//GetSystemTime(&systime);
//setLastCall(systime.wMilliseconds);
setLastCall(GetTickCount());
}
/**
* Query if agent is blocked for ACD work.
* @return T/F
*/
//##ModelId=424BB64603D1
BOOL Agent::isBlocked()
{
return blocked;
}
/**
* block / unblock agent from ACD work.
* @param blocked T/F
*/
//##ModelId=424BB64603D2
void Agent::setBlocked(BOOL blocked)
{
this->blocked = blocked;
}
/**
* isAgent checks if this is an agent that is mentioned in the ACD config.
* This is usefull, because the agent list also includes all other endpoints
* registered with the gatekeeper.
* @return true / false
*/
//##ModelId=424BB64603E1
BOOL Agent::isAgent()
{
CString configStr = "";
//appiniPath
//getQueues();---> read we support many queue
configStr = getConfigKey("Agent",H323Utils::extractAliasName(getAlias()), "");
//configStr = H323Utils::extractAliasName(getAlias());
//configStr = agentConfig.getString(H323Utils.extractAliasName(getAlias()));
return (configStr!="");//(configStr.length() > 0);
}
/**
* isAvailable checks if the Agent is not busy (talking) and is suited for
* this particular queue.
* @param queue the queue
* @return true / false
*/
//##ModelId=424BB64603E2
BOOL Agent::isAvailable(CString queue)
{
CString configStr = "";
// check if agent can work this queue
if ((getState() == Alias::AVAILABLE) && !isBlocked())
{
configStr = getConfigKey("Agent",H323Utils::extractAliasName(getAlias()), "");
//configStr = H323Utils::extractAliasName(getAlias());
if (configStr == "") {
return FALSE;
}
groups_v_t groups;
split_Groups(configStr,groups);
if (groups.empty()) {
return FALSE;
}
std::vector<CString>::iterator groupsElement;
CString _queue_temp;
for(groupsElement= groups.begin();groupsElement !=groups.end();groupsElement++)
{
_queue_temp = *groupsElement;
if (_queue_temp == queue) {
return TRUE;
}
}
/*
for(int i = 0 ; i<groups.size(); i++)
{
if (groups[i]==queue) {
return TRUE;
}
}
*/
}
return FALSE;
}
/**
* Split string entries at the comma and remove whitespace.
* @param aString string to split
* @return array of fields
*/
//##ModelId=424BB6470018
void Agent::split_Groups(CString aString,groups_v_t & groups)
{
// return aString.split(",");
int aPos = aString.Find(',');
do {
if (aPos ==-1) {
groups.push_back(aString);
break;
}
groups.push_back(aString.Left(aPos));
aString = aString.Mid(aPos);
aPos = aString.Find(',');
} while(true);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -