📄 gxrecorddlg.cpp
字号:
int i;
int ChState = -1; //用于临时存放通道状态
int reGetChType; //硬件通道类型
int reChkRecToFile; //文件录音任务执行的情况
char recFile[256]; //path
char recFile1[256]; //path2
char cTmp;
CString strTmp;
CString pathname;
CString pathname1;
SYSTEMTIME m_tDialEndTime;
CString mysql;
for(i=0; i<MaxLine; i++)
{
reGetChType = SsmGetChType(i); //本函数取得指定通道编号对应的硬件通道类型 -1:失败
if(reGetChType == -1)
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
}
CString bb;
if(reGetChType == 3) //12:代表数字电话录音通道
{
ChState = SsmGetChState(i); //获取通道状态 -1:失败
if(ChState == -1)
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
}
if(SsmGet1stDtmfClr(i,&cTmp)==1)
{
switch(cTmp)
{
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
ChannelState[i].Number.TrimLeft();
ChannelState[i].Number.TrimRight();
strTmp.Format("%c",cTmp);
//ClientInfo[i].TelCalledMobilenum = ClientInfo[i].TelCalledMobilenum+ strTmp;
ChannelState[i].Number=ChannelState[i].Number+ strTmp;
//得到用户输入的手机号码
break;
case '*':
if(ChannelState[i].Number.GetLength()<7)
{
if(SsmCheckRecord(i)==0)
{
SsmStopRecToFile(i);
}
ChannelState[i].Number="";
ChannelState[i].IsRecord = UNRECORD;
break;
}
if(SsmCheckRecord(i)==0)
{
// break;
SsmStopRecToFile(i);
}
SsmSetRecAGC(i,1);
SsmSetRecVolume(i,6);
SsmSetHangupStopRecFlag(i,TRUE);
SsmSetRecMixer(i,1,6);
GetLocalTime(&m_tDialEndTime);
strTmp.Format("%d%d%d%d%d%d",m_tDialEndTime.wYear,m_tDialEndTime.wMonth,m_tDialEndTime.wDay,m_tDialEndTime.wHour,m_tDialEndTime.wMinute,m_tDialEndTime.wSecond);
//添加代码
_snprintf(recFile1, 256, "%s/%s-%d-%s.wav", VirtualPath,ChannelState[i].Number,i,strTmp);
_snprintf(recFile, 256, "%s\\%s-%d-%s.wav",RecordPath,ChannelState[i].Number,i,strTmp);
if(SsmRecToFile(i, recFile, -1, 0, 0xffffffff, 0, 0) == -1) //启动指定通道上的文件录音任务 -1:失败
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
AfxMessageBox("ERR");
}
ChannelState[i].IsRecord = RECORD;
mysql.Format("insert into files (chunnel,telphone,callerid,path,path2) values (%d,'%s','%s','%s','%s')",i,ChannelState[i].Number,ChannelState[i].ZJNumber,recFile,recFile1);
try
{
_variant_t var;
m_pConnection->Execute( _bstr_t ((LPCTSTR)mysql), &var, 0 );
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("新增失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
}
// ChannelState[i].WorkState=CH_RECORDs;
break;
default:
break;
}
}
switch(ChannelState[i].WorkState)
{
case CH_IDLE: //"空闲"状态
switch(ChState)
{
case S_CALL_RINGING:
ChannelState[i].Dir = DOWN;
ChannelState[i].WorkState = CH_RING;
break;
case S_CALL_PICKUPED:
ChannelState[i].WorkState=CH_PICKUPED;
break;
case S_CALL_STANDBY:
break;
case S_CALL_TALKING:
ChannelState[i].WorkState = CH_TALKING;
break;
case S_DTRC_ACTIVE:
ChannelState[i].Dir = UP;
ChannelState[i].WorkState = CH_ACTIVE;
break;
case S_CALL_OFFLINE:
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_OUTLINE;
break;
default:
break;
}
break;
case CH_PICKUPED: //"
switch(ChState)
{
case S_CALL_RINGING:
ChannelState[i].Dir = DOWN;
ChannelState[i].WorkState = CH_RING;
break;
case S_CALL_PICKUPED:
ChannelState[i].WorkState=CH_PICKUPED;
break;
case S_CALL_STANDBY:
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_IDLE;
ChannelState[i].IsRecord = UNRECORD;
ChannelState[i].Number="";
break;
case S_DTRC_ACTIVE:
ChannelState[i].Dir = UP;
ChannelState[i].WorkState = CH_ACTIVE;
break;
case S_CALL_OFFLINE:
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_OUTLINE;
break;
default:
break;
}
break;
case CH_RING: //"振铃"状态
bb.Format("%d",ChState);
// AfxMessageBox(bb);
switch(ChState)
{
case S_CALL_STANDBY:
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_IDLE;
break;
//case S_DTRC_ACTIVE:
case S_CALL_PICKUPED://呼入
//AfxMessageBox("S_CALL_PICKUPED");
SsmStopRecToFile(i);
SsmSetRecAGC(i,1);
SsmSetRecVolume(i,6);
SsmSetRecMixer(i,1,6);
SsmSetHangupStopRecFlag(i,TRUE);
GetLocalTime(&m_tDialEndTime);
SsmGetCallerId(i, ChannelState[i].pCallerId);
strTmp.Format("%d%d%d%d%d%d",m_tDialEndTime.wYear,m_tDialEndTime.wMonth,m_tDialEndTime.wDay,m_tDialEndTime.wHour,m_tDialEndTime.wMinute,m_tDialEndTime.wSecond);
_snprintf(recFile1, 256, "%s/%s-%d-%s.wav", VirtualPath,ChannelState[i].ZJNumber,i,strTmp);
_snprintf(recFile, 256, "%s\\%s-%d-%s.wav",RecordPath,ChannelState[i].ZJNumber,i,strTmp);
if(SsmRecToFile(i, recFile, -1, 0, 0xffffffff, 0, 0) == -1) //启动指定通道上的文件录音任务 -1:失败
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
AfxMessageBox(ChannelState[i].pErrMsg);
}
ChannelState[i].IsRecord = RECORD;
mysql.Format("insert into files (chunnel,callerid,telphone,path,path2) values (99,'%s','%s','%s','%s')", ChannelState[i].pCallerId,ChannelState[i].ZJNumber,recFile,recFile1);
try
{
_variant_t var;
m_pConnection->Execute( _bstr_t ((LPCTSTR)mysql), &var, 0 );
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
errormessage.Format("新增失败!\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);///显示错误信息
}
ChannelState[i].Dir = DOWN;
ChannelState[i].WorkState=CH_ACTIVE;
ChannelState[i].IsRecord = RECORD;
break;
case S_DTRC_ACTIVE:
break;
case S_CALL_OFFLINE:
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_OUTLINE;
ChannelState[i].IsRecord=UNRECORD;
break;
default:
break;
}
break;
case CH_ACTIVE: //"ACTIVE"状态
switch(ChState)
{
ChannelState[i].dwTimeOutCounter = 0;
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_OUTLINE;
reChkRecToFile = SsmChkRecToFile(i); //取得文件录音任务执行的情况 -1:失败
if(reChkRecToFile == -1)
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
}
if(reChkRecToFile == 1) //1:正在录音
{
if(SsmStopRecToFile(i) == -1)
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
}
}
break;
case S_CALL_STANDBY:
ChannelState[i].Dir = UNKNOWN;
ChannelState[i].WorkState = CH_IDLE;
ChannelState[i].IsRecord=UNRECORD;
break;
default:
break;
}
break;
case CH_OUTLINE: //"断线"状态
if(ChState == S_CALL_STANDBY)
{
ChannelState[i].WorkState = CH_IDLE;
}
break;
default:
break;
}// end switch(ChannelState[i].WorkState)
} //end if(reGetChType == 3)
}
}//ScanChannelState End
//描述:更新通道信息
void CGXRecordDlg::UpdateChannelState()
{
CString StateTrk;
CString ControlState;
CString strtemp;
char getitemtextstr[50];
int num; //行标记
int i;
int reGetChType;
num=0;
for(i=0; i<MaxLine; i++)
{
reGetChType = SsmGetChType(i); //本函数取得指定通道编号对应的硬件通道类型 -1:失败
if(reGetChType == -1)
{
SsmGetLastErrMsg(ChannelState[i].pErrMsg);
WriteLog(ChannelState[i].pErrMsg);
}
if(reGetChType == 3)
{
//通道状态
switch(ChannelState[i].WorkState)
{
case CH_IDLE: strtemp = "空闲"; break;
case CH_RING: strtemp = "振铃"; break;
case CH_ACTIVE: strtemp = "Active"; break;
case CH_OUTLINE: strtemp = "断线"; break;
case CH_PICKUPED: strtemp="摘机"; break;
case CH_RECORDs: strtemp="录音"; break;
case CH_TALKING: strtemp="通话";break;
}
m_ListCh.GetItemText(num, 1, getitemtextstr, 29);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 1, strtemp);
}
//监听状态
switch(ChannelState[i].IsListen)
{
case LISTEN: strtemp = "监听"; break;
case UNLISTEN: strtemp = "未监听"; break;
}
m_ListCh.GetItemText(num, 2, getitemtextstr, 29);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 2, strtemp);
}
//录音状态
switch(ChannelState[i].IsRecord)
{
case UNRECORD: strtemp = "未录音"; break;
case RECORD: strtemp = "录音"; break;
}
m_ListCh.GetItemText(num, 3, getitemtextstr, 29);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 3, strtemp);
}
//号码
strtemp = "";
m_ListCh.GetItemText(num, 4, getitemtextstr, 29);
strtemp.Format("%s", ChannelState[i].Number);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 4, strtemp);
}
//LCD信息
strtemp = "";
m_ListCh.GetItemText(num, 5, getitemtextstr, 29);
strtemp.Format("%s", ChannelState[i].Lcd);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 5, strtemp);
}
//呼叫方向
switch(ChannelState[i].Dir)
{
case UNKNOWN: strtemp = "未知"; break;
case UP: strtemp = "呼出"; break;
case DOWN: strtemp = "呼入"; break;
}
m_ListCh.GetItemText(num, 6, getitemtextstr, 29);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 6, strtemp);
}
//音量
m_ListCh.GetItemText(num, 7, getitemtextstr, 29);
strtemp.Format("%d", ChannelState[i].Volume);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 7, strtemp);
}
//时间
m_ListCh.GetItemText(num, 8, getitemtextstr, 29);
strtemp.Format("%d", ChannelState[i].dwTimeOutCounter);
if(getitemtextstr != strtemp)
{
m_ListCh.SetItemText(num, 8, strtemp);
}
num++;
}
}
}//UpdateChannelState End
void CGXRecordDlg::OnBUTTONSetListen()
{
int Cur_Line ;
Cur_Line = m_CurLine.GetCurSel();
if(ListenChannel != Cur_Line)
{
ChannelState[Cur_Line].IsListen = LISTEN;
PlayListen(0, Cur_Line); //监听
if(ListenChannel < MaxLine)
{
ChannelState[ListenChannel].IsListen = UNLISTEN;
StopListen(0); //停止监听
}
ListenChannel = Cur_Line;
}
UpdateData(FALSE);
}
void CGXRecordDlg::OnBUTTONUnSetListen()
{
ChannelState[ListenChannel].IsListen = UNLISTEN;
ListenChannel = MaxLine;
StopListen(0);
}
void CGXRecordDlg::OnCancel()
{
// TODO: Add extra cleanup here
int a;
a=AfxMessageBox("是否确认关闭本录音系统",MB_YESNO,0);
if(a==IDYES)
{
SsmCloseCti();
CDialog::OnCancel();
}
}
BOOL CGXRecordDlg::DestroyWindow()
{
SsmCloseCti();
return CDialog::DestroyWindow();
}
void CGXRecordDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
SsmCloseCti();
CDialog::OnClose();
}
void CGXRecordDlg::OnDestroy()
{
SsmCloseCti();
CDialog::OnDestroy();
}
void CGXRecordDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
}
void CGXRecordDlg::OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnDeleteItem(nIDCtl, lpDeleteItemStruct);
}
void CGXRecordDlg::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{ // storing code
}
else
{ // loading code
}
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -