-
Notifications
You must be signed in to change notification settings - Fork 10
/
LogoutNode.cpp
162 lines (145 loc) · 3.54 KB
/
LogoutNode.cpp
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
#include "StdAfx.h"
#include "LogoutNode.h"
#include "Channel.h"
LogoutNode::LogoutNode(void)
{
state = CH_LOGOUT;
}
LogoutNode::~LogoutNode(void)
{
}
void LogoutNode::Run(int LineNo,Channel &channel)
{
yzDoWork(LineNo,channel);
}
void LogoutNode::yzDoWork(int LineNo,Channel &channel)
{
LPTSTR VoicePath1 = "";
CString strState = "";
CString tmpState = "";
switch(channel.nType)
{
case CHTYPE_USER:
if( !OffHookDetect(LineNo) && channel.UsableFlag != TRUE )
{
pList1->SetItemText(LineNo,4,_T(""));
pList1->SetItemText(LineNo,5,_T(""));
TRACE0("\n|");
switch(state)
{
case CH_LOGOUT:
case CH_WAITONHOOK:
StopPlayFile(LineNo);
StartPlaySignal(LineNo,SIG_STOP);
ResetLine(LineNo,channel);
return;
default:
break;
}
}
break;
case CHTYPE_TRUNK:
if( Sig_CheckBusy(LineNo) && channel.UsableFlag != TRUE )
{
pList1->SetItemText(LineNo,4,_T(""));
pList1->SetItemText(LineNo,5,_T(""));
switch(state)
{
case CH_LOGOUT:
case CH_WAITONHOOK:
StopPlayFile(LineNo);
StartPlaySignal(LineNo,SIG_STOP);
ResetLine(LineNo,channel);
return;
default:
break;
}
break;
}
}//end switch
switch(state)
{
case CH_LOGOUT:
channel.nTimeElapse = 0;
strState = _T("播放语音");
tmpState = pList1->GetItemText(LineNo,2);
if( tmpState != strState )
pList1->SetItemText(LineNo,2,strState);
if( channel.IsLogin )
{
if( myXml.findVoiceNameByNodeId(channel.CurrNodeId,_T("Logout"),VoicePath1) )
{
StartPlayFile(LineNo,VoicePath1,0L);
}
//更新坐席人员注销时间
CTime tm;
CString strTime;
tm=CTime::GetCurrentTime();
strTime = tm.Format(_T("%Y-%m-%d %X"));
mySql.updateUserRecentLogoutTime( (LPCTSTR)channel.UserId,strTime,pConn );
//更新坐席人员状态界面
int itemCount = pList2->GetItemCount();
for(int i=0; i<itemCount; i++)
{
if(pList2->GetItemText(i,1) == (LPCTSTR)channel.UserId)
{
pList2->SetItemText(i,3,_T(""));
pList2->SetItemText(i,4,_T(""));
pList2->SetItemText(i,6,strTime);
break;
}
}
//写日志,注销成功。
CString strDetails;
strDetails = strTime + CString(_T("座席")) + (LPCTSTR)channel.UserId + CString(_T("注销成功;"));
myXml.insertTextToLogItem(channel.strItemId,strDetails,_T("Details"),channel.ctStartTime);
channel.IsLogin = FALSE;
channel.UserId[0] = NULL;
}
else
{
if( myXml.findVoiceNameByNodeId(channel.CurrNodeId,_T("NotLogin"),VoicePath1) )
{
StartPlayFile(LineNo,VoicePath1,0L);
}
}
state = CH_WAITONHOOK;
break;
case CH_WAITONHOOK:
strState = _T("等待挂机");
tmpState = pList1->GetItemText(LineNo,2);
if( tmpState != strState )
pList1->SetItemText(LineNo,2,strState);
if(CheckPlayEnd(LineNo))
{
StopPlayFile(LineNo);
StartPlaySignal(LineNo,SIG_BUSY1);
}
break;
default:
break;
}//end switch
}
void LogoutNode::ResetLine(int LineNo,Channel &channel)
{
if( channel.nType == CHTYPE_TRUNK )
{
}
else if( channel.nType == CHTYPE_USER )
{
}
InitDtmfBuf(LineNo);
channel.UsableFlag = TRUE;
channel.ConnectToLine = -1;
channel.State = CH_FREE;
channel.TelLength = 0;
channel.DTMFCode[0] = NULL;
channel.nTimeElapse = 0;
state = CH_LOGOUT;
//写日志
CTime tm;
CString strTime;
tm=CTime::GetCurrentTime();
strTime = tm.Format(_T("%Y-%m-%d %X"));
myXml.insertTextToLogItem(channel.strItemId,strTime,_T("EndTime"),channel.ctStartTime);
}