| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- // TaskList.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "IVR.h"
- #include "InfoList.h"
- #include "IvrCore.h"
- #include "IvrFlowMgr.h"
- #include "NetworkIvr.h"
- // CTaskList
- IMPLEMENT_DYNAMIC(CInfoList, CListCtrl)
- CInfoList::CInfoList()
- {
- }
- CInfoList::~CInfoList()
- {
- }
- BEGIN_MESSAGE_MAP(CInfoList, CListCtrl)
- END_MESSAGE_MAP()
- /*****************************************************************
- **【函数名称】 __indexItem
- **【函数功能】 索引任务
- **【参数】
- **【返回值】
- *****************************************************************/
- int CInfoList::__indexItem( int id )
- {
- for (int i=0; i < GetItemCount(); i++)
- {
- if (GetItemData(i) == id)
- return i;
- }
- return -1;
- }
- /*****************************************************************
- **【函数名称】 __transState
- **【函数功能】 翻译状态
- **【参数】
- **【返回值】
- *****************************************************************/
- void CInfoList::__transState( IVR_FLOW_STATE State, CString& Data )
- {
- switch(State)
- {
- case IVR_FLOW_STATE_FREE:
- Data = _T("空闲");
- break;
- case IVR_FLOW_STATE_RUN:
- Data = _T("正在运行");
- break;
- default:
- ASSERT(FALSE);
- Data = _T("未知状态");
- break;
- }
- }
- /*****************************************************************
- **【函数名称】 __showTask
- **【函数功能】 显示任务
- **【参数】
- **【返回值】
- *****************************************************************/
- void CInfoList::__showInfo( Flow2Show& Info )
- {
- int Item = GetItemCount();
- CString Data;
- Data.Format(_T("%d"), Info.Id);
- InsertItem(Item, Data);
- __transState(Info.State, Data);
- SetItemText(Item, 1, Data);
- SetItemText(Item, 2, Info.NodeNote);
- SetItemData(Item, Info.Id);
- }
- /*****************************************************************
- **【函数名称】 __updateTaskState
- **【函数功能】 更新任务
- **【参数】
- **【返回值】
- *****************************************************************/
- void CInfoList::__updateState( int Item, Flow2Show& Info )
- {
- CString Data;
- __transState(Info.State, Data);
- SetItemText(Item, 1, Data);
- SetItemText(Item, 2, Info.NodeNote);
- /*if(State == IVR_FLOW_STATE_FREE)
- DeleteItem(Item);*/
- }
- /*****************************************************************
- **【函数名称】 format
- **【函数功能】 格式化控件
- **【参数】
- **【返回值】
- *****************************************************************/
- void CInfoList::format( void )
- {
- CRect mRect;
- GetClientRect(&mRect);
- int length = mRect.right - mRect.left - 150;
- //加载日志列表
- SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
- InsertColumn(1, (LPCTSTR)_T("流程ID"), LVCFMT_CENTER, 50, -1);
- InsertColumn(1, (LPCTSTR)_T("流程状态"), LVCFMT_CENTER, 100, -1);
- InsertColumn(2, (LPCTSTR)_T("节点名称"), LVCFMT_CENTER, length, -1);
- }
- /*****************************************************************
- **【函数名称】 onTaskStateUpdated
- **【函数功能】 任务状态变化处理函数
- **【参数】
- **【返回值】
- *****************************************************************/
- int LastWaiterNunber = 0;
- void CInfoList::onStateUpdated(int id)
- {
- Flow2Show Info;
- Info.Id = id;
- int Item = __indexItem(id);
- if(CIvrCore::GetInstance().ivrFLowMgr().getFlowInfo(Info))
- {
- if(Item != -1)
- __updateState(Item, Info);
- else
- __showInfo(Info);
- }
- else
- {
- if(Item != -1)
- DeleteItem(Item);
- }
- int CurrentWaiterNunber = 0;
- for (int x = 0; x < GetItemCount(); x++) //TJ计算当前排队数量 2017. 6.15
- {
- CString strItemText = GetItemText(x, 2);
- if (0 == strcmp(strItemText, "坐席全忙放音") || 0 == strcmp(strItemText, "继续排队节点"))
- {
- CurrentWaiterNunber += 1;
- }
- }
- if (CurrentWaiterNunber != LastWaiterNunber)
- {
- CIvrCore::GetInstance().SetCurrentWaiterNumber(CurrentWaiterNunber);
- ILogger::getInstance().log(LOG_CLASS_SOCKET, LOG_LEVEL_NORMAL, _T("{当前排队人数}:%d "), CurrentWaiterNunber);
- CPduEntity pdu(PDU_CMD_IVR_WAITER_COUNT);
- pdu.SetDataUInt(0, CurrentWaiterNunber);
- CNetworkIvr::GetInstance().send(pdu);
- }
- LastWaiterNunber = CurrentWaiterNunber;
- }
- // CTaskList 消息处理程序
|