Esempio n. 1
0
void CCallThread::OnCall(CallerCmd& callerCmd)
{
	SLZData callingData;//正在呼叫的data
	if(m_rCalledQueData.GetCalledQueData(callerCmd.GetWindowId(),callingData))//有一条数据在正在呼叫队列没有处理完(包括评价)
	{
		if(callingData.GetIsOpenEva()==TRUE &&  callingData.GetIsFinshEva()==FALSE)
			//打开了评价但还没有评价,流程没完等待用户评价,如15秒后没有评价自动发送未评价消息
		{
			return;//评价没有结束不能呼叫
		}
		else if(!callingData.GetIsFinshEva())//没有开启评价
		{
			m_rCalledQueData.DeleteCalledQueData(callingData);//删除正在呼叫的那条数据
			///加入完成队列
			CTime curTime = CTime::GetCurrentTime();
			callingData.SetFinishTime(curTime);//设置完成时间
			m_rFinshQueData.Add(callingData);//添加到完成队列
		}
	}
	///////////////////////呼叫
	//首先判断该窗口下有没有等候的人,如果有呼叫等候队列的那条数据
	//没有从排队队列中取出新的数据
	SLZData data;
	if(m_rWaitQueData.IsHaveWaitQueData(callerCmd.GetWindowId()))
	{
		if(m_rWaitQueData.GetWaitQueData(callerCmd.GetWindowId(),data))
		{
			cyclock.lock();//崔,我加的
			//加入正在呼叫队列
			m_rCalledQueData.Add(data);
			cyclock.unlock();//崔,我加的
		}
	}
	else
	{
		///得到排队队列的下一个数据
		if(!theApp.IsLocal())//客户机
		{
			/////如果是客户机呼叫则需要向服务端发送一条请求删除队列中的一条客户机数据
			CComplSocketClient client;
			CStringArray queSerialIDArray,queManNumArray;
			CString callStaffID,queManNum;
			BOOL bIsUsePower = FALSE;
			m_rInlineQueData.GetWindowCanDoQue(callerCmd.GetWindowId(),queSerialIDArray,callStaffID,&bIsUsePower);
			
			for(int i=0;i<queSerialIDArray.GetCount();i++)
			{
				theApp.m_Controller.GetManQueNumByQueSerialID(queSerialIDArray.GetAt(i),queManNum);
				queManNumArray.Add(queManNum);
			}

			string sendMsg,recvMsg;
			int actRecvSize = 0;
			CDealInterMsg::ProduceSendCallMsg(queManNumArray,sendMsg,theApp.m_logicVariables.strOrganID,bIsUsePower);
			if(client.SendData(INTERPORT,theApp.m_logicVariables.strInterIP,
				sendMsg,sendMsg.size(),recvMsg,actRecvSize) && actRecvSize)
			{
				BOOL isSucced;
				CDealInterMsg::AnaRetCallMsg(recvMsg,&isSucced,&data);
				if(isSucced)
				{
					data.SetCallTime(CTime::GetCurrentTime());
					data.SetStaffId(callStaffID);
					data.SetWindowId(callerCmd.GetWindowId());
					CString queSerialID;
					theApp.m_Controller.GetQueSerialIDByManQueNum(queSerialID,data.GetQueSerialID());
					data.SetBussinessType(queSerialID);
				}
				else
				{
					return;
				}
			}
		}
		else
		{
			m_rInlineQueData.GetInlineQueData(callerCmd.GetWindowId(),data);
		}
	}
	if(!data.GetBussinessType().IsEmpty())
	{
		cyclock.lock();//崔,我加的
		m_rCalledQueData.Add(data);//添加到正在呼叫队列
		cyclock.unlock();//崔,我加的
		
		//界面剩余人数更新
			//theApp.m_pView->ShowWaitNum(data.GetBussinessType(),m_rInlineQueData.GetBussCount(data.GetBussinessType()));
		ShowViewWaitNum(data.GetBussinessType(),data,callerCmd);
		
		//playsound,显示
		theApp.m_Controller.m_pPlaySound->DataPlay(data);

		//发短信
 		if (!data.GetPhoneNum().IsEmpty())
 		{
 			m_pShortMsg->ClearSendBox();
 			m_pShortMsg->SendMsg(data.GetPhoneNum(),data.GetSendMsg());
 		}
	}
	if(theApp.IsLocal())
		///重新写file,保存没处理(呼叫)的数据
		theApp.m_Controller.WriteInlineDataToFile();
}