acd_info.cpp
6.65 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
* 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 "acd_info.h"
#include "acd_tool.h"
#include "acd_data_collection.h"
CallDirectT::CallDirectT(int32_t value) : m_value(value) {
}
CallDirectT::~CallDirectT() {
}
void CallDirectT::set_value(int32_t value) {
m_value = value;
}
int32_t CallDirectT::get_value() {
return m_value;
}
bool CallDirectT::isValid() {
return m_value != UNKNOWN;
}
ReleaseCauseT::ReleaseCauseT(int32_t value) : m_value(value) {
}
ReleaseCauseT::~ReleaseCauseT() {
}
void ReleaseCauseT::set_value(int32_t value) {
m_value = value;
}
int32_t ReleaseCauseT::get_value() {
return m_value;
}
bool ReleaseCauseT::isValid() {
return m_value != UNKNOWN;
}
callinfo::callinfo() {
}
callinfo::~callinfo() {
}
void callinfo::Initial(ims::SessionIdT sessionId, const ims::CallIdT& callId, const string& agentId,
const string& agentDn, const string& skill, const string& caller, const string& callee,
time_t waitbegin, time_t waitend) {
m_sessionId = sessionId;
m_callId = callId;
m_agentId = agentId;
m_agentDn = agentDn;
m_skill = skill;
m_caller = caller;
m_callee = callee;
m_waitbegin = waitbegin;
m_waitend = waitend;
}
void callinfo::SetAniDnis(const string& caller, const string& callee) {
m_caller = caller;
m_callee = callee;
}
void callinfo::SetAckBegin(time_t t) {
m_ackbegin = t;
}
void callinfo::SetAckEnd(time_t t) {
if (0 != m_ackbegin && 0 == m_ackend) {
m_ackend = t;
}
}
void callinfo::SetConnectBegin(time_t t) {
_m_connectbegin = t;
}
void callinfo::SetConnectEnd(time_t t) {
if (0 != _m_connectbegin) {
_m_connectend = t;
}
}
void callinfo::SetCallBegin(time_t t) {
if (m_ackend == 0) {
m_ackend = t;
}
m_callbegin = t;
m_callend = t;
}
void callinfo::SetCallEnd(time_t t) {
if (0 != m_callbegin) {
m_callend = t;
}
}
void callinfo::SetCallType(const ims::PartyAttributeT& callType) {
m_callType = callType;
}
void callinfo::SetCallDirect(int32_t callDirect) {
m_callDirect.set_value(callDirect);
}
void callinfo::SetReleaseCause(int32_t releaseCause) {
m_releaseCause.set_value(releaseCause);
}
void callinfo::SetRecordFilename(const string& recordFilename) {
m_recordFilename = recordFilename;
}
void callinfo::SetRoutecall() {
m_routecall = true;
}
bool callinfo::GetRoutecall() {
return m_routecall;
}
bool callinfo::isValid() {
return m_sessionId != 0 && m_callId != "";
}
void callinfo::reset() {
m_sessionId = 0;
m_callId.clear();
m_agentId.clear();
m_agentDn.clear();
m_caller.clear();
m_callee.clear();
m_waitbegin = 0;
m_waitend = 0;
m_ackbegin = 0;
m_ackend = 0;
_m_connectbegin = 0;
_m_connectend = 0;
m_callbegin = 0;
m_callend = 0;
m_callType = ims::PartyAttributeT::P_Unknown;
m_callDirect = CallDirectT::UNKNOWN;
m_releaseCause = ReleaseCauseT::UNKNOWN;
m_recordFilename.clear();
m_routecall = false;
}
void callinfo::WriteCallLog() {
ostringstream strbuf;
strbuf << '1'
<< ',' << m_sessionId
<< ',' << m_callId
<< ',' << m_agentId
<< ',' << m_agentDn
<< ',' << m_skill
<< ',' << m_caller
<< ',' << m_callee
<< ',' << static_cast<int64_t>(m_waitbegin)
<< ',' << static_cast<int64_t>(m_waitend)
<< ',' << static_cast<int64_t>(m_ackbegin)
<< ',' << static_cast<int64_t>(m_ackend)
<< ',' << static_cast<int64_t>(m_callbegin)
<< ',' << static_cast<int64_t>(m_callend)
<< ',' << m_callType.get_value()
<< ',' << m_callDirect.get_value()
<< ',' << m_releaseCause.get_value()
<< ',' << m_recordFilename;
acd_tool::m_calllogger.WriteLog(strbuf.str().c_str());
AddDataToCollection();
}
/*void callinfo::WriteCallLog() {
ostringstream strbuf;
strbuf << '1'
<< ',' << m_sessionId
<< ',' << m_callId
<< ',' << m_agentId
<< ',' << m_agentDn
<< ',' << m_skill
<< ',' << m_caller
<< ',' << m_callee
<< ',' << static_cast<int64_t>(m_waitbegin)
<< ',' << static_cast<int64_t>(m_waitend)
<< ',' << static_cast<int64_t>(m_ackbegin)
<< ',' << static_cast<int64_t>(m_ackend)
<< ',' << static_cast<int64_t>(_m_connectbegin)
<< ',' << static_cast<int64_t>(_m_connectend)
<< ',' << static_cast<int64_t>(m_callbegin)
<< ',' << static_cast<int64_t>(m_callend)
<< ',' << m_callType.get_value()
<< ',' << m_callDirect.get_value()
<< ',' << m_releaseCause.get_value()
<< ',' << m_recordFilename;
acd_tool::m_calllogger.WriteLog(strbuf.str().c_str());
AddDataToCollection();
}*/
void callinfo::AddDataToCollection()
{
calldata_ptr p(new (std::nothrow) calldata(m_sessionId, m_callId, m_agentId,
m_agentDn, m_skill, m_caller, m_callee, m_waitbegin, m_waitend, m_ackbegin, m_ackend,
_m_connectbegin, _m_connectend, m_callbegin, m_callend, m_callType, m_callDirect,
m_releaseCause, m_recordFilename, m_routecall));
/*struct calldata *p = new (std::nothrow) calldata(m_sessionId, m_callId, m_agentId,
m_agentDn, m_skill, m_caller, m_callee, m_waitbegin, m_waitend, m_ackbegin, m_ackend,
_m_connectbegin, _m_connectend, m_callbegin, m_callend, m_callType, m_callDirect,
m_releaseCause, m_recordFilename, m_routecall);*/
if (p.get() == NULL) {
acd_tool::m_logger.WriteLog(LOG_LEVEL_DEBUG, __FILE__, __LINE__, __FUNCTION__,
"new failed: agentId(%s), sessionid(%d), callid(%s), skill(%s)",
m_agentId.c_str(), m_sessionId, m_callId.c_str(), m_skill.c_str());
return;
}
acd_tool::_acd_calldata.push_call_data(p);
acd_tool::m_logger.WriteLog(LOG_LEVEL_DEBUG, __FILE__, __LINE__, __FUNCTION__,
"push calldata to cached: agentId(%s), sessionid(%lu), callid(%s), skill(%s)in queue",
m_agentId.c_str(), m_sessionId, m_callId.c_str(), m_skill.c_str());
return;
}