123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- #include "stdafx.h"
- #include "uphonebox.h"
- #include "NotFindDlg.h"
- #include "AddClient.h"
- #include "UPhoneBoxDlg.h"
- #include "YesNoDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- NotFindDlg::NotFindDlg(CWnd* pParent )
- : CDialog(NotFindDlg::IDD, pParent)
- {
-
-
-
- m_bClosed = 0;
- m_linepos = 0;
- m_bSave = 0;
- m_bSaveToClient = -1;
- }
- void NotFindDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
-
-
- }
- BEGIN_MESSAGE_MAP(NotFindDlg, CDialog)
-
- ON_WM_LBUTTONDOWN()
- ON_WM_TIMER()
-
- ON_MESSAGE(WM_USER + 111, OnCloseWin)
- END_MESSAGE_MAP()
- BOOL NotFindDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
- g_hwnd[m_linepos] = this->m_hWnd;
-
- SetDlgItemText(IDC_STATIC2, m_phone);
-
- SetTimer(1, 1000, NULL);
- return TRUE;
-
- }
- LRESULT NotFindDlg::OnCloseWin(WPARAM wParam, LPARAM lParam)
- {
-
- m_bClosed = 1;
- m_bSave = wParam;
- if (m_bSaveToClient != -1)
- {
- if (::PathFileExists(g_recordpath[m_linepos]))
- m_frompath = g_recordpath[m_linepos];
- if (m_bSaveToClient)
- SaveToClient();
- else
- SaveToUnknown();
- DestroyWindow();
- return 1;
- }
- if (::PathFileExists(g_recordpath[m_linepos]))
- m_frompath = g_recordpath[m_linepos];
- CString newpath = m_frompath.Left(m_frompath.ReverseFind('\\') + 1);
- newpath += CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- newpath += ".mp3";
- try
- {
- CFile::Rename(m_frompath, newpath);
- }
- catch (...)
- {
- WriteLogin("改文件名时出错");
- }
- m_frompath = newpath;
- return 1;
- }
- void NotFindDlg::OnLButtonDown(UINT nFlags, CPoint point)
- {
-
- SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- CDialog::OnLButtonDown(nFlags, point);
- }
- void NotFindDlg::OnOK()
- {
-
- }
- void NotFindDlg::OnCancel()
- {
-
- }
- void NotFindDlg::OnTimer(UINT nIDEvent)
- {
-
- KillTimer(1);
-
- YesNoDlg yesnodlg;
- if (yesnodlg.DoModal() != IDOK)
- {
- m_bSaveToClient = 0;
- if (m_bClosed == 0)return;
- SaveToUnknown();
- DestroyWindow(); m_bSaveToClient = -1;
- return;
- }
- AddClient dlg;
- dlg.m_phone1 = this->m_phone;
- if (dlg.DoModal() == IDOK)
- {
- m_name = dlg.m_name1;
- m_bSaveToClient = 1;
- if (m_bClosed == 0)return;
- SaveToClient();
- DestroyWindow(); m_bSaveToClient = -1;
- return;
- }
- m_bSaveToClient = 0;
- if (m_bClosed == 0)return;
- SaveToUnknown();
- DestroyWindow(); m_bSaveToClient = -1;
- }
- extern int g_nYearpos;
- extern BOOL g_bReturned2;
- extern CUPhoneBoxDlg *g_pMainWnd;
- void NotFindDlg::SaveToUnknown()
- {
- if (m_bSave)
- {
- if (m_frompath.IsEmpty() == 0)
- {
- CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- CString sql, sql2;
- sql.Format("insert into [unknownphonerecord]([phone],[datetime])values(\
- '%s','%s')", m_phone, datetime);
- if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(90)))
- {
- CString content = g_cominfoarray.ElementAt(0).ElementAt(93);
- if (content != "" && CheckExist(m_phone) == 0)
- {
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- int count = GetLengthEx(content) / 70;
- if (GetLengthEx(content) % 70)
- count++;
- CString scount;
- scount.Format("%d", count);
- CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
- ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- sql += sql2;
- }
- }
- g_sendhead.bsql = 1;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- int i;
- for ( i = 0; i < 20; i++)
- {
- if (g_bReturned2)break;
- ::Sleep(500);
- }
- if (i >= 20)
- {
- nNeedConn2 = 1;
- return;
- }
- datetime.Replace(":", "");
- ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\未知电话", NULL);
- ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\未知电话\\" + m_phone, NULL);
- CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\未知电话\\" + m_phone + "\\" + datetime + ".mp3";
- if (::PathFileExists(m_frompath))
- {
- ::CopyFile(m_frompath, m_savepath, 0);
- }
- }
- }
- else
- {
- CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- CString sql, sql2;
- sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
- '%s','%s','%s','%s')", m_phone, datetime, "", "未知电话来电");
- if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(90)))
- {
- CString content = g_cominfoarray.ElementAt(0).ElementAt(93);
- if (content != "" && CheckExist(m_phone) == 0)
- {
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- int count = GetLengthEx(content) / 70;
- if (GetLengthEx(content) % 70)
- count++;
- CString scount;
- scount.Format("%d", count);
- CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
- ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- sql += sql2;
- }
- }
- g_sendhead.bsql = 1;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- int i;
- for ( i = 0; i < 20; i++)
- {
- if (g_bReturned2)break;
- ::Sleep(500);
- }
- if (i >= 20)
- {
- nNeedConn2 = 1;
- return;
- }
- }
- ::DeleteFile(m_frompath);
- }
- void NotFindDlg::SaveToClient()
- {
- if (m_bSave)
- {
- if (m_frompath.IsEmpty() == 0)
- {
- CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- CString sql, sql2;
- sql.Format("insert into [client2phonerecord]([phone],[datetime])values(\
- '%s','%s')", m_phone, datetime);
- if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
- {
- CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
- if (content != "" && CheckExist(m_phone) == 0)
- {
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- int count = GetLengthEx(content) / 70;
- if (GetLengthEx(content) % 70)
- count++;
- CString scount;
- scount.Format("%d", count);
- CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
- ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- sql += sql2;
- }
- }
- g_sendhead.bsql = 1;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- int i;
- for ( i = 0; i < 20; i++)
- {
- if (g_bReturned2)break;
- ::Sleep(500);
- }
- if (i >= 20)
- {
- nNeedConn2 = 1;
- return;
- }
- datetime.Replace(":", "");
- ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户", NULL);
- ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone, NULL);
- CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone + "\\" + datetime + ".mp3";
- if (::PathFileExists(m_frompath))
- {
- ::CopyFile(m_frompath, m_savepath, 0);
- }
- }
- }
- else
- {
- CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
- CString sql, sql2;
- sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
- '%s','%s','%s','%s')", m_phone, datetime, m_name, "意向客户来电");
- if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
- {
- CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
- if (content != "" && CheckExist(m_phone) == 0)
- {
- CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
- int count = GetLengthEx(content) / 70;
- if (GetLengthEx(content) % 70)
- count++;
- CString scount;
- scount.Format("%d", count);
- CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
- ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
- sql += sql2;
- }
- }
- g_sendhead.bsql = 1;
- g_nYearpos = -1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);
- int i;
- for ( i = 0; i < 20; i++)
- {
- if (g_bReturned2)break;
- ::Sleep(500);
- }
- if (i >= 20)
- {
- nNeedConn2 = 1;
- return;
- }
- }
- ::DeleteFile(m_frompath);
- }
|