DataMgr.cpp
4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/*
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* CC/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "StdAfx.h"
#include ".\datamgr.h"
CDataMgr* CDataMgr::m_dataMgr = NULL;
CString m_showSkill = "";//需要显示的技能
bool m_ifShowSysInfo = false;//是否显示sysinfo信息标志位
CDataMgr::CDataMgr(void)
{
this->m_pMainFormView = NULL;
::InitializeCriticalSection(&m_csForAgents);
::InitializeCriticalSection(&m_csForQueue);
memset(&this->m_sysInfo,0,sizeof(SysInfoT));
this->m_pThread = NULL;
this->m_hAgentDetailWnd = NULL;
this->m_hQueueDetailWnd = NULL;
this->m_hSysInfoWnd = NULL;
this->m_hSkillGroupTreeView = NULL;
this->m_privQueueColumn = -1;
//this->m_ifShowSysInfo = false;
//this->m_showSkill = "";
}
CDataMgr::~CDataMgr(void)
{
this->m_hAgentDetailWnd = NULL;
this->m_hQueueDetailWnd = NULL;
}
void CDataMgr::createSkillAgentsMap(CString skill, Agents* pAgentList)
{
m_skillAgentsMap[skill] = pAgentList;
}
void CDataMgr::createSkillQueueMap(CString skill, CString strQueue)
{
m_skillQueueMap[skill] = strQueue;
}
CDataMgr* CDataMgr::getInstance()
{
if(!m_dataMgr)
m_dataMgr = new CDataMgr();
return m_dataMgr;
}
Agents* CDataMgr::getAgentsBySkill(CString skill)
{
Agents* pList = m_skillAgentsMap[skill];
return pList;
}
CString CDataMgr::getQueueStringBySkill(CString skill)
{
CString strQueue = m_skillQueueMap[skill];
return strQueue;
}
void CDataMgr::setQueueStringForSkill(CString skill, CString queueStr)
{
m_skillQueueMap[skill]=queueStr;
}
void CDataMgr::setAgentInfo(CString agentId, AgentInfo* pAgentInfo)
{
m_agentMap[agentId] = pAgentInfo;
}
AgentInfo* CDataMgr::getAgentInfo(CString agentId)
{
AgentInfo* ai = m_agentMap[agentId];
return ai;
}
AgentInfo* CDataMgr::getAgentInfoOrCreate(CString agentId)
{
AgentInfo* ai = m_agentMap[agentId];
if(ai==NULL)
{
ai = new AgentInfo;
memset(ai,0,sizeof(AgentInfo));
m_agentMap[agentId] = ai;
}
return ai;
}
void CDataMgr::startGetAgentsDataThread()
{
this->m_pThread = ::AfxBeginThread(this->ThreadGetAgentsAndQueueData,NULL);
}
UINT CDataMgr::ThreadGetAgentsAndQueueData(LPVOID param) // 线程函数,此后台线程通过AgentBar控件从ACD SERVER获取监控数据
{
while(1)
{
if(CDataMgr::getInstance()->m_pMainFormView->m_bStartGettingData)
{
//CString oriStr = CDataMgr::getInstance()->m_pMainFormView->m_strSkillList;
//std::vector<CString> strVec;
//while (true)
//{
// CString n = oriStr.SpanExcluding(",");
// strVec.push_back(n);
// oriStr = oriStr.Right(oriStr.GetLength()-n.GetLength()-1);
// if (oriStr.IsEmpty())
// {
// break;
// }
//}
//for (std::vector<CString>::const_iterator it = strVec.begin();it != strVec.end();it++)
//{
// CDataMgr::getInstance()->m_pMainFormView->getAgentListBySkill(*it); //得到技能组的座席列表
// CDataMgr::getInstance()->m_pMainFormView->getQueueBySkill(*it); //得到技能组的排队队列
//}
if(m_showSkill!="")
{
CDataMgr::getInstance()->m_pMainFormView->getAgentListBySkill(m_showSkill); //得到技能组的座席列表
CDataMgr::getInstance()->m_pMainFormView->getQueueBySkill(m_showSkill); //得到技能组的排队队列
::SendMessage(CDataMgr::getInstance()->m_hAgentDetailWnd,WM_DATACHANGED,NULL,NULL); //通知CAgentDetailFormView
::SendMessage(CDataMgr::getInstance()->m_hQueueDetailWnd,WM_DATACHANGED,NULL,NULL); //通知CQueueInfoFormView
}
if(m_ifShowSysInfo)
{
CDataMgr::getInstance()->m_pMainFormView->getSysInfo();
::SendMessage(CDataMgr::getInstance()->m_hSysInfoWnd,WM_DATACHANGED,NULL,NULL); // 通知CSysInfoFormView
}
}
Sleep(1000);
}
return 0;
}
void CDataMgr::beginGetSysInfo()
{
m_ifShowSysInfo = true;
m_showSkill = "";
}
void CDataMgr::beginGetBySkill(CString skill)
{
m_ifShowSysInfo = false;
m_showSkill = skill;
}