Client2Dlg.cpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. // Client2Dlg.cpp : implementatio n file
  2. //
  3. #include "stdafx.h"
  4. #include "uphonebox.h"
  5. #include "Client2Dlg.h"
  6. #include "UPhoneBoxDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // Client2Dlg dialog
  14. Client2Dlg::Client2Dlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(Client2Dlg::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(Client2Dlg)
  18. m_phone = _T("");
  19. m_name = _T("");
  20. m_sex = _T("");
  21. m_addr = _T("");
  22. m_qq = _T("");
  23. m_bz = _T("");
  24. //}}AFX_DATA_INIT
  25. m_linepos = 0;
  26. m_bCanClose = 0;
  27. m_nSecond = 0;
  28. }
  29. void Client2Dlg::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(Client2Dlg)
  33. DDX_Text(pDX, IDC_EDIT1, m_phone);
  34. DDX_Text(pDX, IDC_EDIT2, m_name);
  35. DDX_Text(pDX, IDC_EDIT3, m_sex);
  36. DDX_Text(pDX, IDC_EDIT4, m_addr);
  37. DDX_Text(pDX, IDC_EDIT5, m_qq);
  38. DDX_Text(pDX, IDC_EDIT6, m_bz);
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(Client2Dlg, CDialog)
  42. //{{AFX_MSG_MAP(Client2Dlg)
  43. ON_WM_LBUTTONDOWN()
  44. ON_WM_TIMER()
  45. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  46. //}}AFX_MSG_MAP
  47. ON_MESSAGE(WM_USER + 111, OnCloseWin)
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Client2Dlg message handlers
  51. BOOL Client2Dlg::OnInitDialog()
  52. {
  53. CDialog::OnInitDialog();
  54. SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
  55. g_hwnd[m_linepos] = this->m_hWnd;
  56. // TODO: Add extra initialization here
  57. ::SetForegroundWindow(m_hWnd);
  58. return TRUE; // return TRUE unless you set the focus to a control
  59. // EXCEPTION: OCX Property Pages should return FALSE
  60. }
  61. extern int g_nYearpos;
  62. extern BOOL g_bReturned2;
  63. extern CUPhoneBoxDlg *g_pMainWnd;
  64. LRESULT Client2Dlg::OnCloseWin(WPARAM wParam, LPARAM lParam)
  65. {
  66. // TODO: Add your message handler code here and/or call default
  67. if (wParam)
  68. {
  69. if (::PathFileExists(g_recordpath[m_linepos]))
  70. {
  71. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  72. CString sql, sql2;
  73. sql.Format("insert into [client2phonerecord]([phone],[datetime])values(\
  74. '%s','%s')", m_phone, datetime);
  75. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  76. {
  77. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  78. if (content != "" && CheckExist(m_phone) == 0)
  79. {
  80. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  81. int count = GetLengthEx(content) / 70;
  82. if (GetLengthEx(content) % 70)
  83. count++;
  84. CString scount;
  85. scount.Format("%d", count);
  86. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  87. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  88. sql += sql2;
  89. }
  90. }
  91. g_sendhead.bsql = 1;
  92. g_nYearpos = -1;
  93. g_pMainWnd->ProcessChatMessageRequest2(sql);
  94. int i;
  95. for ( i = 0; i < 20; i++)
  96. {
  97. if (g_bReturned2)break;
  98. ::Sleep(500);
  99. }
  100. if (i >= 20)
  101. {
  102. nNeedConn2 = 1;
  103. // CDialog::OnCancel ();
  104. DestroyWindow();
  105. return 1;
  106. }
  107. datetime.Replace(":", "");
  108. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户", NULL);
  109. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone, NULL);
  110. CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone + "\\" + datetime + ".mp3";
  111. if (::PathFileExists(g_recordpath[m_linepos]))
  112. {
  113. ::CopyFile(g_recordpath[m_linepos], m_savepath, 0);
  114. ::DeleteFile(g_recordpath[m_linepos]);
  115. }
  116. SetTimer(1, 1000, NULL);
  117. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  118. m_bCanClose = 1;
  119. return 1;
  120. }
  121. }
  122. else
  123. {
  124. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  125. CString sql, sql2;
  126. sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
  127. '%s','%s','%s','%s')", m_phone, datetime, m_name, "意向客户来电");
  128. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  129. {
  130. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  131. if (content != "" && CheckExist(m_phone) == 0)
  132. {
  133. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  134. int count = GetLengthEx(content) / 70;
  135. if (GetLengthEx(content) % 70)
  136. count++;
  137. CString scount;
  138. scount.Format("%d", count);
  139. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  140. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  141. sql += sql2;
  142. }
  143. }
  144. g_sendhead.bsql = 1;
  145. g_nYearpos = -1;
  146. g_pMainWnd->ProcessChatMessageRequest2(sql);
  147. int i;
  148. for ( i = 0; i < 20; i++)
  149. {
  150. if (g_bReturned2)break;
  151. ::Sleep(500);
  152. }
  153. if (i >= 20)
  154. {
  155. nNeedConn2 = 1;
  156. // CDialog::OnCancel ();
  157. DestroyWindow();
  158. return 1;
  159. }
  160. }
  161. // CDialog::OnCancel ();
  162. DestroyWindow();
  163. }
  164. void Client2Dlg::OnLButtonDown(UINT nFlags, CPoint point)
  165. {
  166. // TODO: Add your message handler code here and/or call default
  167. SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
  168. CDialog::OnLButtonDown(nFlags, point);
  169. }
  170. void Client2Dlg::OnOK()
  171. {
  172. // TODO: Add extra hevalidationre
  173. }
  174. void Client2Dlg::OnCancel()
  175. {
  176. // TODO: Add extra cleanup here
  177. }
  178. void Client2Dlg::OnTimer(UINT nIDEvent)
  179. {
  180. // TODO: Add your message handler code here and/or call default
  181. m_nSecond++;
  182. CString str;
  183. str.Format("关闭(%d)", 300 - m_nSecond);
  184. GetDlgItem(IDC_BUTTON2)->SetWindowText(str);
  185. if (m_nSecond >= 300)
  186. {
  187. KillTimer(1);
  188. DestroyWindow();
  189. }
  190. }
  191. void Client2Dlg::OnButton1()
  192. {
  193. // TODO: Add your control notification handler code here
  194. UpdateData();
  195. CString sql;
  196. sql.Format("update [client2] set [bz]='%s' where [phone]='%s'", m_bz, m_phone);
  197. g_sendhead.bsql = 1;
  198. g_nYearpos = -1;
  199. g_pMainWnd->ProcessChatMessageRequest2(sql);
  200. int i;
  201. for ( i = 0; i < 20; i++)
  202. {
  203. if (g_bReturned2)break;
  204. ::Sleep(500);
  205. }
  206. if (i >= 20)
  207. {
  208. nNeedConn2 = 1;
  209. AfxMessageBox("保存失败!", MB_ICONINFORMATION);
  210. return;
  211. }
  212. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  213. if (m_bCanClose)CDialog::OnOK();
  214. }