NotFindDlg.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. // NotFindDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "uphonebox.h"
  5. #include "NotFindDlg.h"
  6. #include "AddClient.h"
  7. #include "UPhoneBoxDlg.h"
  8. #include "YesNoDlg.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // NotFindDlg dialog
  16. NotFindDlg::NotFindDlg(CWnd* pParent /*=NULL*/)
  17. : CDialog(NotFindDlg::IDD, pParent)
  18. {
  19. //{{AFX_DATA_INIT(NotFindDlg)
  20. // NOTE: the ClassWizard will add member initialization here
  21. //}}AFX_DATA_INIT
  22. m_bClosed = 0;
  23. m_linepos = 0;
  24. m_bSave = 0;
  25. m_bSaveToClient = -1;
  26. }
  27. void NotFindDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(NotFindDlg)
  31. // NOTE: the ClassWizard will add DDX and DDV calls here
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(NotFindDlg, CDialog)
  35. //{{AFX_MSG_MAP(NotFindDlg)
  36. ON_WM_LBUTTONDOWN()
  37. ON_WM_TIMER()
  38. //}}AFX_MSG_MAP
  39. ON_MESSAGE(WM_USER + 111, OnCloseWin)
  40. END_MESSAGE_MAP()
  41. /////////////////////////////////////////////////////////////////////////////
  42. // NotFindDlg message handlers
  43. BOOL NotFindDlg::OnInitDialog()
  44. {
  45. CDialog::OnInitDialog();
  46. SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
  47. g_hwnd[m_linepos] = this->m_hWnd;
  48. // TODO: Add extra initialization here
  49. SetDlgItemText(IDC_STATIC2, m_phone);
  50. // ::SetForegroundWindow (m_hWnd);
  51. SetTimer(1, 1000, NULL);
  52. return TRUE; // return TRUE unless you set the focus to a control
  53. // EXCEPTION: OCX Property Pages should return FALSE
  54. }
  55. LRESULT NotFindDlg::OnCloseWin(WPARAM wParam, LPARAM lParam)
  56. {
  57. // TODO: Add your message handler code here and/or call default
  58. m_bClosed = 1;
  59. m_bSave = wParam;
  60. if (m_bSaveToClient != -1)
  61. {
  62. if (::PathFileExists(g_recordpath[m_linepos]))
  63. m_frompath = g_recordpath[m_linepos];
  64. if (m_bSaveToClient)
  65. SaveToClient();
  66. else
  67. SaveToUnknown();
  68. DestroyWindow();
  69. return 1;
  70. }
  71. if (::PathFileExists(g_recordpath[m_linepos]))
  72. m_frompath = g_recordpath[m_linepos];
  73. CString newpath = m_frompath.Left(m_frompath.ReverseFind('\\') + 1);
  74. newpath += CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  75. newpath += ".mp3";
  76. try
  77. {
  78. CFile::Rename(m_frompath, newpath);
  79. }
  80. catch (...)
  81. {
  82. WriteLogin("改文件名时出错");
  83. }
  84. m_frompath = newpath;
  85. return 1;
  86. }
  87. void NotFindDlg::OnLButtonDown(UINT nFlags, CPoint point)
  88. {
  89. // TODO: Add your message handler code here and/or call default
  90. SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
  91. CDialog::OnLButtonDown(nFlags, point);
  92. }
  93. void NotFindDlg::OnOK()
  94. {
  95. // TODO: Add extra validation here
  96. }
  97. void NotFindDlg::OnCancel()
  98. {
  99. // TODO: Add extra cleanup here
  100. }
  101. void NotFindDlg::OnTimer(UINT nIDEvent)
  102. {
  103. // TODO: Add your message handler code h ere and/or call default
  104. KillTimer(1);
  105. //AfxMessageBox("7");return;
  106. YesNoDlg yesnodlg;
  107. if (yesnodlg.DoModal() != IDOK)
  108. {
  109. m_bSaveToClient = 0;
  110. if (m_bClosed == 0)return;
  111. SaveToUnknown();
  112. DestroyWindow(); m_bSaveToClient = -1;
  113. return;
  114. }
  115. AddClient dlg;
  116. dlg.m_phone1 = this->m_phone;
  117. if (dlg.DoModal() == IDOK)
  118. {
  119. m_name = dlg.m_name1;
  120. m_bSaveToClient = 1;
  121. if (m_bClosed == 0)return;
  122. SaveToClient();
  123. DestroyWindow(); m_bSaveToClient = -1;
  124. return;
  125. }
  126. m_bSaveToClient = 0;
  127. if (m_bClosed == 0)return;
  128. SaveToUnknown();
  129. DestroyWindow(); m_bSaveToClient = -1;
  130. }
  131. extern int g_nYearpos;
  132. extern BOOL g_bReturned2;
  133. extern CUPhoneBoxDlg *g_pMainWnd;
  134. void NotFindDlg::SaveToUnknown()
  135. {
  136. if (m_bSave)
  137. {
  138. if (m_frompath.IsEmpty() == 0)
  139. {
  140. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  141. CString sql, sql2;
  142. sql.Format("insert into [unknownphonerecord]([phone],[datetime])values(\
  143. '%s','%s')", m_phone, datetime);
  144. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(90)))
  145. {
  146. CString content = g_cominfoarray.ElementAt(0).ElementAt(93);
  147. if (content != "" && CheckExist(m_phone) == 0)
  148. {
  149. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  150. int count = GetLengthEx(content) / 70;
  151. if (GetLengthEx(content) % 70)
  152. count++;
  153. CString scount;
  154. scount.Format("%d", count);
  155. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  156. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  157. sql += sql2;
  158. }
  159. }
  160. g_sendhead.bsql = 1;
  161. g_nYearpos = -1;
  162. g_pMainWnd->ProcessChatMessageRequest2(sql);
  163. int i;
  164. for ( i = 0; i < 20; i++)
  165. {
  166. if (g_bReturned2)break;
  167. ::Sleep(500);
  168. }
  169. if (i >= 20)
  170. {
  171. nNeedConn2 = 1;
  172. return;
  173. }
  174. datetime.Replace(":", "");
  175. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\未知电话", NULL);
  176. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\未知电话\\" + m_phone, NULL);
  177. CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\未知电话\\" + m_phone + "\\" + datetime + ".mp3";
  178. if (::PathFileExists(m_frompath))
  179. {
  180. ::CopyFile(m_frompath, m_savepath, 0);
  181. }
  182. }
  183. }
  184. else
  185. {
  186. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  187. CString sql, sql2;
  188. sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
  189. '%s','%s','%s','%s')", m_phone, datetime, "", "未知电话来电");
  190. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(90)))
  191. {
  192. CString content = g_cominfoarray.ElementAt(0).ElementAt(93);
  193. if (content != "" && CheckExist(m_phone) == 0)
  194. {
  195. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  196. int count = GetLengthEx(content) / 70;
  197. if (GetLengthEx(content) % 70)
  198. count++;
  199. CString scount;
  200. scount.Format("%d", count);
  201. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  202. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  203. sql += sql2;
  204. }
  205. }
  206. g_sendhead.bsql = 1;
  207. g_nYearpos = -1;
  208. g_pMainWnd->ProcessChatMessageRequest2(sql);
  209. int i;
  210. for ( i = 0; i < 20; i++)
  211. {
  212. if (g_bReturned2)break;
  213. ::Sleep(500);
  214. }
  215. if (i >= 20)
  216. {
  217. nNeedConn2 = 1;
  218. return;
  219. }
  220. }
  221. ::DeleteFile(m_frompath);
  222. }
  223. void NotFindDlg::SaveToClient()
  224. {
  225. if (m_bSave)
  226. {
  227. if (m_frompath.IsEmpty() == 0)
  228. {
  229. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  230. CString sql, sql2;
  231. sql.Format("insert into [client2phonerecord]([phone],[datetime])values(\
  232. '%s','%s')", m_phone, datetime);
  233. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  234. {
  235. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  236. if (content != "" && CheckExist(m_phone) == 0)
  237. {
  238. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  239. int count = GetLengthEx(content) / 70;
  240. if (GetLengthEx(content) % 70)
  241. count++;
  242. CString scount;
  243. scount.Format("%d", count);
  244. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  245. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  246. sql += sql2;
  247. }
  248. }
  249. g_sendhead.bsql = 1;
  250. g_nYearpos = -1;
  251. g_pMainWnd->ProcessChatMessageRequest2(sql);
  252. int i;
  253. for ( i = 0; i < 20; i++)
  254. {
  255. if (g_bReturned2)break;
  256. ::Sleep(500);
  257. }
  258. if (i >= 20)
  259. {
  260. nNeedConn2 = 1;
  261. return;
  262. }
  263. datetime.Replace(":", "");
  264. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户", NULL);
  265. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone, NULL);
  266. CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone + "\\" + datetime + ".mp3";
  267. if (::PathFileExists(m_frompath))
  268. {
  269. ::CopyFile(m_frompath, m_savepath, 0);
  270. }
  271. }
  272. }
  273. else
  274. {
  275. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  276. CString sql, sql2;
  277. sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
  278. '%s','%s','%s','%s')", m_phone, datetime, m_name, "意向客户来电");
  279. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  280. {
  281. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  282. if (content != "" && CheckExist(m_phone) == 0)
  283. {
  284. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  285. int count = GetLengthEx(content) / 70;
  286. if (GetLengthEx(content) % 70)
  287. count++;
  288. CString scount;
  289. scount.Format("%d", count);
  290. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  291. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  292. sql += sql2;
  293. }
  294. }
  295. g_sendhead.bsql = 1;
  296. g_nYearpos = -1;
  297. g_pMainWnd->ProcessChatMessageRequest2(sql);
  298. int i;
  299. for ( i = 0; i < 20; i++)
  300. {
  301. if (g_bReturned2)break;
  302. ::Sleep(500);
  303. }
  304. if (i >= 20)
  305. {
  306. nNeedConn2 = 1;
  307. return;
  308. }
  309. }
  310. ::DeleteFile(m_frompath);
  311. }