Exemplo n.º 1
0
        private void DownloadByTime()
        {
            if (m_DownLoadFileHandle > 0)
            {
                timerDownload.Stop();
                XMSDK.H264_DVR_StopGetFile(m_DownLoadFileHandle);
                m_DownLoadFileHandle         = 0;
                progressBarDownloadPos.Value = 0;

                btnDownload.Text = "Download";

                return;
            }

            string strSaveName = "";

            //strSaveName.Format("c:\\record");
            strSaveName = BrowseForFolder(this.Handle);

            if (strSaveName == "")       //未选择路径时退出
            {
                return;
            }

            H264_DVR_FINDINFO info = new H264_DVR_FINDINFO();

            info.nChannelN0         = comboChannel.SelectedIndex;    //channel No.
            info.nFileType          = comboRecordType.SelectedIndex; //file type
            info.startTime.dwYear   = beginDate.Value.Year;
            info.startTime.dwMonth  = beginDate.Value.Month;
            info.startTime.dwDay    = beginDate.Value.Day;
            info.startTime.dwHour   = beginTime.Value.Hour;
            info.startTime.dwMinute = beginTime.Value.Minute;
            info.startTime.dwSecond = beginTime.Value.Second;
            info.endTime.dwYear     = endDate.Value.Year;
            info.endTime.dwMonth    = endDate.Value.Month;
            info.endTime.dwDay      = endDate.Value.Day;
            info.endTime.dwHour     = endTime.Value.Hour;
            info.endTime.dwMinute   = endTime.Value.Minute;
            info.endTime.dwSecond   = endTime.Value.Second;
            int nRecordFileType = comboRecordType.SelectedIndex;

            info.nFileType = (nRecordFileType <= (int)PlayBackFileType.SDK_RECORD_MANUAL) ? nRecordFileType : ((int)PlayBackFileType.SDK_PIC_ALL + nRecordFileType - (int)PlayBackFileType.SDK_RECORD_MANUAL - 1);

            m_DownLoadFileHandle = XMSDK.H264_DVR_GetFileByTime(m_lLoginID, ref info, strSaveName, false, null, 0);
            if (m_DownLoadFileHandle > 0)
            {
                progressBarDownloadPos.Value = 0;

                btnDownload.Text = "Stop";

                //update the progress control
                timerDownload.Start();
            }
            else
            {
                string sTemp;
                sTemp = string.Format("dowload fail ERROR = {0}", XMSDK.H264_DVR_GetLastError());
                MessageBox.Show(sTemp);
            }
        }