SetClient.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. // SetClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "SetClient.h"
  6. #include "SetClientRecordPlan.h"
  7. #include "Global.h"
  8. #include "mdlProject.h"
  9. #include "DBConnection.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CSetClient dialog
  17. extern void WriteClientConfig();
  18. BOOL DeleteDirectory(LPCTSTR DirName);
  19. int nUseCard;
  20. CSetClient::CSetClient(CWnd* pParent /*=NULL*/)
  21. : CDialog(CSetClient::IDD, pParent)
  22. , m_nComb_VideoMaxTime(0)
  23. , m_nComb_NoMotionTime(0)
  24. {
  25. //{{AFX_DATA_INIT(CSetClient)
  26. m_bAutoRecord = FALSE;
  27. m_bCyclePlay = FALSE;
  28. m_bCycleRecord = FALSE;
  29. m_bUseCard = FALSE;
  30. m_iCycleTime = 0;
  31. m_iFileInterVal = 0;
  32. m_csLoadPath = _T("");
  33. m_csLogPath = _T("");
  34. m_csPICPath = _T("");
  35. m_ctCheckServerTime = 0;
  36. m_bCheckServerTime = FALSE;
  37. //}}AFX_DATA_INIT
  38. }
  39. void CSetClient::DoDataExchange(CDataExchange* pDX)
  40. {
  41. CDialog::DoDataExchange(pDX);
  42. //{{AFX_DATA_MAP(CSetClient)
  43. DDX_Control(pDX, IDC_COMBOVIDEOFORMAT, m_VideoFormatCombo);
  44. DDX_Control(pDX, IDC_COMBO2, m_StopRecordDriverCtrl);
  45. DDX_Control(pDX, IDC_COMBO1, m_StartRecordDriverCtrl);
  46. DDX_Control(pDX, IDC_CHKUSECARD, m_UseCardCtrl);
  47. DDX_Control(pDX, IDC_CHKCYCLERECORD, m_CycleRecordCtrl);
  48. DDX_Control(pDX, IDC_CHKCYCLEPLAY, m_CyclePlayCtrl);
  49. DDX_Control(pDX, IDC_CHKAUTORECORD, m_AutoRecordCtrl);
  50. DDX_Check(pDX, IDC_CHKAUTORECORD, m_bAutoRecord);
  51. DDX_Check(pDX, IDC_CHKCYCLEPLAY, m_bCyclePlay);
  52. DDX_Check(pDX, IDC_CHKCYCLERECORD, m_bCycleRecord);
  53. DDX_Check(pDX, IDC_CHKUSECARD, m_bUseCard);
  54. DDX_Text(pDX, IDC_EDITCYCLETIME, m_iCycleTime);
  55. DDX_Text(pDX, IDC_EDITFILEINTERVAL, m_iFileInterVal);
  56. DDX_Text(pDX, IDC_EDITLOADPATH, m_csLoadPath);
  57. DDX_Text(pDX, IDC_EDITLOGPATH, m_csLogPath);
  58. DDX_Text(pDX, IDC_EDITPICPATH, m_csPICPath);
  59. DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER, m_ctCheckServerTime);
  60. DDX_Check(pDX, IDC_CHECKSYSTIME, m_bCheckServerTime);
  61. //}}AFX_DATA_MAP
  62. DDX_CBIndex(pDX, IDC_COMBO_VIDEOMAXTIME, m_nComb_VideoMaxTime);
  63. DDX_CBIndex(pDX, IDC_COMBO_NOMOTIONTIME, m_nComb_NoMotionTime);
  64. DDX_Control(pDX, IDC_COMBO_VIDEOMAXTIME, m_Comb_VideoMaxTime);
  65. DDX_Control(pDX, IDC_COMBO_NOMOTIONTIME, m_Comb_NoMotionTime);
  66. }
  67. BEGIN_MESSAGE_MAP(CSetClient, CDialog)
  68. //{{AFX_MSG_MAP(CSetClient)
  69. ON_BN_CLICKED(IDC_BUTSELFILEPATH, OnButselfilepath)
  70. ON_BN_CLICKED(IDC_BUTSELLOGPATH, OnButsellogpath)
  71. ON_BN_CLICKED(IDC_BUTSELPICPATH, OnButselpicpath)
  72. ON_BN_CLICKED(IDC_BUTTONSETTIME, OnButtonsettime)
  73. ON_BN_CLICKED(IDC_CHKAUTORECORD, OnChkautorecord)
  74. ON_BN_CLICKED(IDC_CHKCYCLEPLAY, OnChkcycleplay)
  75. ON_BN_CLICKED(IDC_CHECKSYSTIME, OnChecksystime)
  76. ON_BN_CLICKED(IDCLOCALOK, OnClocalok)
  77. ON_BN_CLICKED(IDC_CHKUSECARD, OnChkusecard)
  78. //}}AFX_MSG_MAP
  79. END_MESSAGE_MAP()
  80. /////////////////////////////////////////////////////////////////////////////
  81. // CSetClient message handlers
  82. BOOL CSetClient::OnInitDialog()
  83. {
  84. CDialog::OnInitDialog();
  85. // TODO: Add extra initialization here
  86. int i, j;
  87. CRect rc(0, 0, 0, 0);
  88. GetParent()->GetClientRect(&rc);
  89. ((CTabCtrl*)GetParent())->AdjustRect(FALSE, &rc);
  90. MoveWindow(&rc);
  91. CString csHardDriver;
  92. CStoneU_HC_OCXApp* pApp = (CStoneU_HC_OCXApp*)AfxGetApp();
  93. for(i = 0; i < (int)(pApp->m_iDriverNum); i++)
  94. {
  95. csHardDriver.Format("%c%s", pApp->m_cHardDriver[i], ":\\");
  96. m_StartRecordDriverCtrl.AddString(csHardDriver);
  97. m_StopRecordDriverCtrl.AddString(csHardDriver);
  98. }
  99. m_bCyclePlay = g_pNewclientDlg->m_ClientParam.m_bCyclePlay;
  100. if(m_bCyclePlay)
  101. {
  102. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
  103. }
  104. else
  105. {
  106. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
  107. }
  108. m_iCycleTime = g_pNewclientDlg->m_ClientParam.m_iCycleTime;
  109. m_bUseCard = g_pNewclientDlg->m_ClientParam.m_bUseCard;
  110. m_VideoFormatCombo.SetCurSel(g_pNewclientDlg->m_ClientParam.m_bNTSC);
  111. UpdateData(FALSE);
  112. OnChkusecard();
  113. m_bAutoRecord = g_pNewclientDlg->m_ClientParam.m_bAutoRecord;
  114. if(m_bAutoRecord)
  115. GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
  116. m_bCycleRecord = g_pNewclientDlg->m_ClientParam.m_bCycleRecord;
  117. m_iFileInterVal = g_pNewclientDlg->m_ClientParam.m_iRecordFileInterval;
  118. i = g_pNewclientDlg->m_ClientParam.m_iStartRecordDriver;
  119. m_StartRecordDriverCtrl.SetCurSel(i);
  120. j = g_pNewclientDlg->m_ClientParam.m_iEndRecordDriver;
  121. m_StopRecordDriverCtrl.SetCurSel(j);
  122. m_csLoadPath = g_pNewclientDlg->m_ClientParam.m_csDownLoadPath;
  123. m_csPICPath = g_pNewclientDlg->m_ClientParam.m_csPictureSavePath;
  124. m_csLogPath = g_pNewclientDlg->m_ClientParam.m_csLogSavePath;
  125. m_bCheckServerTime = g_pNewclientDlg->m_ClientParam.m_bCheckServerTime;
  126. CTime ctTime(2000, 1, 1, g_pNewclientDlg->m_ClientParam.m_iCheckServerTime/10000, (g_pNewclientDlg->m_ClientParam.m_iCheckServerTime%10000)/100, g_pNewclientDlg->m_ClientParam.m_iCheckServerTime%100);
  127. m_ctCheckServerTime = ctTime;
  128. if(m_bCheckServerTime)
  129. {
  130. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
  131. }
  132. else
  133. {
  134. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
  135. }
  136. UpdateData(FALSE);
  137. m_Comb_VideoMaxTime.InsertString(0,"3分钟" );
  138. m_Comb_VideoMaxTime.InsertString(1,"5分钟");
  139. m_Comb_VideoMaxTime.InsertString(2,"10分钟");
  140. m_Comb_VideoMaxTime.InsertString(3,"20分钟");
  141. m_Comb_VideoMaxTime.InsertString(4,"30分钟");
  142. m_Comb_VideoMaxTime.InsertString(5,"1小时");
  143. m_Comb_VideoMaxTime.SetCurSel(0);
  144. m_Comb_NoMotionTime.InsertString(0,"10秒" );
  145. m_Comb_NoMotionTime.InsertString(1,"20秒");
  146. m_Comb_NoMotionTime.InsertString(2,"30秒");
  147. m_Comb_NoMotionTime.InsertString(3,"50秒");
  148. m_Comb_NoMotionTime.SetCurSel(0);
  149. m_nComb_VideoMaxTime = g_nVideoMaxTime;
  150. m_nComb_NoMotionTime = g_nNoMotionTime;
  151. UpdateData( false );
  152. return TRUE; // return TRUE unless you set the focus to a control
  153. // EXCEPTION: OCX Property Pages should return FALSE
  154. }
  155. void CSetClient::OnButselfilepath()
  156. {
  157. // TODO: Add your control notification handler code here
  158. CString Str = F_GetDirectoryPath();
  159. if(Str != "")
  160. {
  161. m_csLoadPath = Str;
  162. UpdateData(FALSE);
  163. }
  164. }
  165. void CSetClient::OnButsellogpath()
  166. {
  167. // TODO: Add your control notification handler code here
  168. CString Str = F_GetDirectoryPath();
  169. if(Str != "")
  170. {
  171. m_csLogPath = Str;
  172. UpdateData(FALSE);
  173. }
  174. }
  175. void CSetClient::OnButselpicpath()
  176. {
  177. // TODO: Add your control notification handler code here
  178. CString Str = F_GetDirectoryPath();
  179. if(Str != "")
  180. {
  181. m_csPICPath = Str;
  182. UpdateData(FALSE);
  183. }
  184. }
  185. void CSetClient::OnButtonsettime()
  186. {
  187. // TODO: Add your control notification handler code here
  188. CSetClientRecordPlan SetClientRecordPlanDlg;
  189. SetClientRecordPlanDlg.DoModal();
  190. }
  191. void CSetClient::OnChkautorecord()
  192. {
  193. // TODO: Add your control notification handler code here
  194. UpdateData(TRUE);
  195. if(m_AutoRecordCtrl.GetCheck() == 1)
  196. GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(TRUE);
  197. else
  198. GetDlgItem(IDC_BUTTONSETTIME)->EnableWindow(FALSE);
  199. }
  200. CString CSetClient::F_GetDirectoryPath()
  201. {
  202. LPITEMIDLIST pidlRoot=NULL;
  203. SHGetSpecialFolderLocation(m_hWnd,CSIDL_DRIVES,&pidlRoot);
  204. BROWSEINFO bi; //必须传入的参数,下面就是这个结构的参数的初始化
  205. CString strDisplayName; //用来得到,你选择的活页夹路径,相当于提供一个缓冲区
  206. bi.hwndOwner=GetSafeHwnd(); //得到父窗口Handle值
  207. bi.pidlRoot=pidlRoot; //这个变量就是我们在上面得到的.
  208. bi.pszDisplayName=strDisplayName.GetBuffer(MAX_PATH+1); //得到缓冲区指针
  209. bi.lpszTitle="文件夹"; //设置标题
  210. bi.ulFlags=BIF_RETURNONLYFSDIRS; //设置标志
  211. bi.lpfn=NULL;
  212. bi.lParam=0;
  213. bi.iImage=0; //上面这个是一些无关的参数的设置,最好设置起来,
  214. LPITEMIDLIST lpIDList= SHBrowseForFolder(&bi); //打开对话框
  215. strDisplayName.ReleaseBuffer(); //和上面的GetBuffer()相对应
  216. char pPath[MAX_PATH];
  217. CString Str;
  218. if(lpIDList)
  219. {
  220. SHGetPathFromIDList (lpIDList, pPath);
  221. Str=pPath;
  222. }
  223. return Str;
  224. }
  225. void CSetClient::OnChkcycleplay()
  226. {
  227. // TODO: Add your control notification handler code here
  228. UpdateData(TRUE);
  229. if(m_CyclePlayCtrl.GetCheck() == 1)
  230. {
  231. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(TRUE);
  232. }
  233. else
  234. {
  235. GetDlgItem(IDC_EDITCYCLETIME)->EnableWindow(FALSE);
  236. }
  237. UpdateData(FALSE);
  238. }
  239. void CSetClient::OnChecksystime()
  240. {
  241. // TODO: Add your control notification handler code here
  242. UpdateData(TRUE);
  243. if(m_bCheckServerTime)
  244. {
  245. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(TRUE);
  246. }
  247. else
  248. {
  249. GetDlgItem(IDC_DATETIMEPICKER)->EnableWindow(FALSE);
  250. }
  251. UpdateData(FALSE);
  252. }
  253. void CSetClient::OnClocalok()
  254. {
  255. // TODO: Add your control notification handler code here
  256. int i, j;
  257. UpdateData(TRUE);
  258. if( (m_iFileInterVal < 1) || (m_iFileInterVal > 60) )
  259. {
  260. MessageBox("非法的文件打包时间!", "温馨提示", MB_ICONINFORMATION);
  261. return;
  262. }
  263. if( (m_csLoadPath == "") || (m_csPICPath == "") || (m_csLogPath == "") )
  264. {
  265. MessageBox("请选择文件保存路径!", "温馨提示", MB_ICONINFORMATION);
  266. return;
  267. }
  268. i = m_StartRecordDriverCtrl.GetCurSel();
  269. j = m_StopRecordDriverCtrl.GetCurSel();
  270. if(i > j)
  271. {
  272. MessageBox("起始驱动器和终止驱动器不匹配!", "温馨提示", MB_ICONINFORMATION);
  273. return;
  274. }
  275. m_csLoadPath.Replace( "\\","\\\\" );
  276. m_csPICPath.Replace( "\\","\\\\" );
  277. m_csLogPath.Replace( "\\","\\\\" );
  278. CleanTable( "t_video_localsetting" );
  279. InsertLocalSetting( (char *)(LPCTSTR)m_csLoadPath,(char *)(LPCTSTR)m_csPICPath,(char *)(LPCTSTR)m_csLogPath,m_nComb_VideoMaxTime,m_nComb_NoMotionTime,i,j );
  280. if(m_iCycleTime < 5)
  281. m_iCycleTime = 5;
  282. g_pNewclientDlg->m_ClientParam.m_bCyclePlay = m_bCyclePlay;
  283. g_pNewclientDlg->m_ClientParam.m_iCycleTime = m_iCycleTime;
  284. if(g_pNewclientDlg->m_ClientParam.m_bUseCard != m_bUseCard)
  285. {
  286. if(!g_pNewclientDlg->m_ClientParam.m_bUseCard)
  287. {
  288. nUseCard = 1;
  289. }
  290. else
  291. {
  292. nUseCard = 2;
  293. }
  294. }
  295. g_pNewclientDlg->m_ClientParam.m_bUseCard = m_bUseCard;
  296. g_pNewclientDlg->m_ClientParam.m_bNTSC = m_VideoFormatCombo.GetCurSel();
  297. g_pNewclientDlg->m_ClientParam.m_bAutoRecord = m_bAutoRecord;
  298. g_pNewclientDlg->m_ClientParam.m_bCycleRecord = m_bCycleRecord;
  299. g_pNewclientDlg->m_ClientParam.m_iRecordFileInterval = m_iFileInterVal;
  300. g_pNewclientDlg->m_ClientParam.m_iStartRecordDriver = i;
  301. g_pNewclientDlg->m_ClientParam.m_iEndRecordDriver = j;
  302. g_pNewclientDlg->m_ClientParam.m_csDownLoadPath = m_csLoadPath;
  303. g_pNewclientDlg->m_ClientParam.m_csPictureSavePath = m_csPICPath;
  304. g_pNewclientDlg->m_ClientParam.m_csLogSavePath = m_csLogPath;
  305. g_pNewclientDlg->m_ClientParam.m_bCheckServerTime = m_bCheckServerTime;
  306. g_pNewclientDlg->m_ClientParam.m_iCheckServerTime = m_ctCheckServerTime.GetHour()*10000 + m_ctCheckServerTime.GetMinute()*100 + m_ctCheckServerTime.GetSecond();
  307. CreateDirectory(m_csLoadPath, NULL);
  308. CreateDirectory(m_csPICPath, NULL);
  309. CreateDirectory(m_csLogPath, NULL);
  310. //WriteClientConfig();
  311. //g_strVideoPath = m_sEdit_VideoPath;
  312. //g_nDiskVolume = m_nComb_Velume;
  313. //g_nOperateType = m_nComb_OperateType;
  314. g_nVideoMaxTime = m_nComb_VideoMaxTime;
  315. g_nNoMotionTime = m_nComb_NoMotionTime;
  316. //g_IniFile.SetVarStr(_T("video"),_T("VideoPath"),g_strVideoPath);
  317. //g_IniFile.SetVarInt(_T("video"),_T("DiskVelume"),g_nDiskVolume);
  318. //g_IniFile.SetVarInt(_T("video"),_T("OperateType"),g_nOperateType);
  319. //g_IniFile.SetVarInt(_T("video"),_T("VideoMaxTime"),g_nVideoMaxTime);
  320. //g_IniFile.SetVarInt(_T("video"),_T("NoMotionTime"),g_nNoMotionTime);
  321. //if (!SetCurrentDirectory(g_strVideoPath))
  322. // CreateDirectory(g_strVideoPath, NULL);
  323. }
  324. void CSetClient::OnCancel()
  325. {
  326. // TODO: Add extra cleanup here
  327. //CDialog::OnCancel();
  328. }
  329. void CSetClient::OnChkusecard()
  330. {
  331. // TODO: Add your control notification handler code here
  332. UpdateData(TRUE);
  333. if (m_bUseCard)
  334. {
  335. GetDlgItem(IDC_COMBOVIDEOFORMAT)->EnableWindow(TRUE);
  336. }
  337. else
  338. {
  339. GetDlgItem(IDC_COMBOVIDEOFORMAT)->EnableWindow(FALSE);
  340. }
  341. UpdateData(FALSE);
  342. }