ivr_callinfo.cpp
4.31 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
// ivr_callinfo.cpp: implement IvrCallInfo
#include "ivr_callinfo.h"
namespace ivr {
Logger IvrCallInfo::_m_logger;
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;
}
void IvrCallInfo::initial(ivr_session_id_t sessionId, const string& callid, const string& caller, const string& callee)
{
_m_sessionid = sessionId;
_m_caller = caller;
_m_callee = callee;
_m_callid = callid;
}
IvrCallInfo::IvrCallInfo() : _m_skill(""), _m_route_list(""), _m_agentnum(""), _m_cust_ans_time(0), _m_agt_ans_time(0)
, _m_agt_alert_time(0), _m_connected_time(0), _m_callee(""), _m_caller(""), _m_exit_flow_time(0)
, _m_flowbegin_time(0), _m_hangup_time(0), _m_inboundbegin_time(0), _m_recordFilename("")
, _m_releaseCause(ReleaseCauseT::UNKNOWN), _m_sessionid(0), _m_trans_time(0), _is_update(true)
{
}
IvrCallInfo::~IvrCallInfo()
{
}
void IvrCallInfo::set_inbound_begin_time(time_t t)
{
_m_inboundbegin_time = t;
}
time_t IvrCallInfo::get_inbound_begin_time()
{
return _m_inboundbegin_time;
}
void IvrCallInfo::set_flow_begin_time(time_t t)
{
_m_flowbegin_time = t;
}
void IvrCallInfo::set_cust_ans_time(time_t t)
{
_m_cust_ans_time = t;
}
void IvrCallInfo::set_agt_ans_time(time_t t)
{
_m_agt_ans_time = t;
}
void IvrCallInfo::set_agt_alert_time(time_t t)
{
_m_agt_alert_time = t;
}
void IvrCallInfo::set_connected_time(time_t t)
{
_m_connected_time = t;
}
void IvrCallInfo::set_trans_time(time_t t)
{
_m_trans_time = t;
}
void IvrCallInfo::set_hangup_time(time_t t)
{
_m_hangup_time = t;
if (!_is_update && _m_route_list != "") {
std::ostringstream oss;
oss << "#";
oss << t;
_m_route_list+= oss.str();
}
}
void IvrCallInfo::set_exit_flow_time(time_t t)
{
_m_exit_flow_time = t;
}
void IvrCallInfo::set_release_cause(int32_t releaseCause)
{
_m_releaseCause.set_value(releaseCause);
}
void IvrCallInfo::set_record_filename(const string &recordFilename)
{
_m_recordFilename = recordFilename;
}
void IvrCallInfo::set_skill(time_t t, const std::string &skill)
{
std::ostringstream oss;
if (_m_route_list != "") {
if (!_is_update) {
oss << "#";
oss << t;
}
oss << "|";
}
oss << skill;
oss << "#";
oss << t;
_m_route_list+= oss.str();
_m_skill = skill;
_is_update = false;
}
void IvrCallInfo::update_skill(time_t t, const std::string& skill) {
std::ostringstream oss;
oss << "#";
oss << t;
_m_route_list += oss.str();
_is_update = true;
}
void IvrCallInfo::set_appdata(const std::string& appdata) {
_m_appdata = appdata;
}
std::string IvrCallInfo::get_skill()
{
return _m_skill;
}
std::string IvrCallInfo::get_callee()
{
return _m_callee;
}
void IvrCallInfo::set_agent_num(const string &agentnum)
{
_m_agentnum = agentnum;
}
void IvrCallInfo::reset()
{
_m_agentnum.clear();
_m_cust_ans_time = 0;
_m_connected_time = 0;
_m_agt_ans_time = 0;
_m_agt_alert_time = 0;
_m_callee.clear();
_m_caller.clear();
_m_exit_flow_time = 0;
_m_flowbegin_time = 0;
_m_hangup_time = 0;
_m_inboundbegin_time = 0;
_m_recordFilename.clear();
_m_releaseCause = ReleaseCauseT::UNKNOWN;
_m_sessionid = 0;
_m_skill.clear();
_m_trans_time = 0;
}
void IvrCallInfo::write_call_log()
{
char buffer[20480] = {0};
snprintf(
buffer,
20480,
"%s,%s,%s,%lu,%lu,%lu,%lu,%lu,%lu,%lu,%d,%s,%s,%s",
_m_callid.c_str(),
_m_caller.c_str(),
_m_callee.c_str(),
_m_flowbegin_time,
_m_agt_ans_time,
_m_hangup_time,
_m_trans_time,
_m_agt_alert_time,
_m_agt_ans_time,
_m_exit_flow_time,
_m_releaseCause.get_value(),
_m_skill.c_str(),
_m_route_list.c_str(),
_m_appdata.c_str());
//std::cout << "buffer " << buffer << std::endl;
IVR_NOTICE("write callinfo, sessionid(%lu), callid(%s)", _m_sessionid, _m_callid.c_str());
_m_logger.WriteLog(buffer);
}
};