コード例 #1
0
ファイル: frm_Main.cs プロジェクト: doksec/bykom_dahuaDotNet
        /// <summary>
        /// 按时间下载按钮按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDownLoad2_Click(object sender, EventArgs e)
        {
            frm_PlayBackByTimeSet fPBSet = new frm_PlayBackByTimeSet();
            NET_RECORDFILE_INFO            fileInfo = new NET_RECORDFILE_INFO();
            int fileCount = 0;
            bool blnQueryRecordFile = false;
            int pPlayBackChannelID=0;
            fPBSet.txtDevName.Text = strUserName;
            fPBSet.cmbChannelSelect.Items.Clear();
            for (int i = 1; i <= deviceInfo.byChanNum; i++ )
            {
                fPBSet.cmbChannelSelect.Items.Add(i);
            }
            fPBSet.ShowDialog();
            if (fPBSet.blnOKEnter == true)
            {
                DateTime startTime = fPBSet.StartTime;
                DateTime endTime = fPBSet.EndTime;

                blnQueryRecordFile = DHClient.DHQueryRecordFile(pLoginID, int.Parse(fPBSet.txtChannelID.Text.ToString()), RECORD_FILE_TYPE.ALLRECORDFILE,
                                                                startTime, endTime, null, ref fileInfo, Marshal.SizeOf(typeof(NET_RECORDFILE_INFO)), out  fileCount, 5000, false);//按时间回放
                if (blnQueryRecordFile == true)
                {
                    //**********按文件下载**********
                    pPlayBackChannelID = int.Parse(fPBSet.txtChannelID.Text.ToString());
                    if (txtDirPath2.Text.Trim().Length > 0 && txtFileName2.Text.Trim().Length > 0)
                    {
                        string strFileName = txtFileName2.Text;
                        strFileName = strFileName.ToLower();
                        if (!strFileName.EndsWith(".dav"))
                            strFileName += ".dav";

                        // 关闭上次上次下载有关资源
                        if (pDownloadHandleByTime != 0)
                        {
                            DHClient.DHStopDownload(pDownloadHandleByTime);
                            pDownloadHandle = 0;
                        }

                        pDownloadHandleByTime = DHClient.DHDownloadByTime(pLoginID, pPlayBackChannelID, 0, startTime
                            , endTime, txtDirPath2.Text + @"\" + strFileName, timeDownLoadFun, IntPtr.Zero);
                        if (pDownloadHandleByTime != 0)
                        {
                            btnDownLoad2.Tag = "下载中";
                            pDownloadHandle = pDownloadHandleByTime;
                            btnDownLoad2.Enabled = false;
                            btnDownLoad1.Enabled = false;
                            btnStopDownLoad2.Enabled = true;
                            MessageUtil.ShowMsgBox(StringUtil.ConvertString("开始下载!"),
                                                   StringUtil.ConvertString(pMsgTitle));
                        }
                        else
                        {
                            MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                                   StringUtil.ConvertString(pMsgTitle));
                        }
                    }
                    else
                    {
                        MessageUtil.ShowMsgBox(StringUtil.ConvertString("请输入有效的录像保存目录和文件名!"),
                                               StringUtil.ConvertString(pMsgTitle));
                    }
                    //*******************************
                }
                else
                {
                    MessageUtil.ShowMsgBox(StringUtil.ConvertString("这个时间段里没有录像文件供下载!"),
                                           StringUtil.ConvertString(pMsgTitle));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// 按时间下载按钮按下
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDownLoad2_Click(object sender, EventArgs e)
        {
            frm_PlayBackByTimeSet fPBSet   = new frm_PlayBackByTimeSet();
            NET_RECORDFILE_INFO   fileInfo = new NET_RECORDFILE_INFO();
            int  fileCount          = 0;
            bool blnQueryRecordFile = false;
            int  pPlayBackChannelID = 0;

            fPBSet.txtDevName.Text = strUserName;
            fPBSet.cmbChannelSelect.Items.Clear();
            for (int i = 0; i < 5; i++)
            {
                fPBSet.cmbChannelSelect.Items.Add(i);
            }
            fPBSet.ShowDialog();
            if (fPBSet.blnOKEnter == true)
            {
                DateTime startTime = fPBSet.StartTime;
                DateTime endTime   = fPBSet.EndTime;

                blnQueryRecordFile = DHClient.DHQueryRecordFile(pLoginID, int.Parse(fPBSet.txtChannelID.Text.ToString()), RECORD_FILE_TYPE.ALLRECORDFILE,
                                                                startTime, endTime, null, ref fileInfo, Marshal.SizeOf(typeof(NET_RECORDFILE_INFO)), out fileCount, 5000, false); //按时间回放
                if (blnQueryRecordFile == true)
                {
                    //**********按文件下载**********
                    pPlayBackChannelID = int.Parse(fPBSet.txtChannelID.Text.ToString());
                    if (txtDirPath2.Text.Trim().Length > 0 && txtFileName2.Text.Trim().Length > 0)
                    {
                        string strFileName = txtFileName2.Text;
                        strFileName = strFileName.ToLower();
                        if (!strFileName.EndsWith(".dav"))
                        {
                            strFileName += ".dav";
                        }

                        // 关闭上次上次下载有关资源
                        if (pDownloadHandleByTime != 0)
                        {
                            DHClient.DHStopDownload(pDownloadHandleByTime);
                            pDownloadHandle = 0;
                        }

                        pDownloadHandleByTime = DHClient.DHDownloadByTime(pLoginID, pPlayBackChannelID, 0, startTime
                                                                          , endTime, txtDirPath2.Text + @"\" + strFileName, timeDownLoadFun, IntPtr.Zero);
                        if (pDownloadHandleByTime != 0)
                        {
                            btnDownLoad2.Tag         = "下载中";
                            pDownloadHandle          = pDownloadHandleByTime;
                            btnDownLoad2.Enabled     = false;
                            btnDownLoad1.Enabled     = false;
                            btnStopDownLoad2.Enabled = true;
                            MessageUtil.ShowMsgBox(StringUtil.ConvertString("开始下载!"),
                                                   StringUtil.ConvertString(pMsgTitle));
                        }
                        else
                        {
                            MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                                   StringUtil.ConvertString(pMsgTitle));
                        }
                    }
                    else
                    {
                        MessageUtil.ShowMsgBox(StringUtil.ConvertString("请输入有效的录像保存目录和文件名!"),
                                               StringUtil.ConvertString(pMsgTitle));
                    }
                    //*******************************
                }
                else
                {
                    MessageUtil.ShowMsgBox(StringUtil.ConvertString("这个时间段里没有录像文件供下载!"),
                                           StringUtil.ConvertString(pMsgTitle));
                }
            }
        }
コード例 #3
0
ファイル: frm_Main.cs プロジェクト: dalinhuang/demodemo
 /// <summary>
 /// 按时间下载按钮按下
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDownLoad2_Click(object sender, EventArgs e)
 {
     frm_PlayBackByTimeSet fPBSet = new frm_PlayBackByTimeSet();
     fPBSet.cmbChannelSelect.Items.Clear();
     for (int i = 0; i < 16; i++)
     {
         fPBSet.cmbChannelSelect.Items.Add(i.ToString());
     }
     NET_RECORDFILE_INFO            fileInfo = new NET_RECORDFILE_INFO();
     int fileCount = 0;
     bool blnQueryRecordFile = false;
     int pPlayBackChannelID=0;
     fPBSet.ShowDialog();
     if (fPBSet.blnOKEnter == true)
     {
         DateTime startTime = fPBSet.dtpStart.Value;
         DateTime endTime = fPBSet.dtpEnd.Value;
         if (startTime.Date >= endTime.Date)
         {
             MessageBox.Show("开始日期不在结束日期设置前,请重新设置!", pMsgTitle);
         }
         else
         {
             blnQueryRecordFile = DHClient.DHQueryRecordFile(pLoginID, int.Parse(fPBSet.txtChannelID.Text.ToString()), RECORD_FILE_TYPE.ALLRECORDFILE,
                                                             startTime, endTime, null, ref fileInfo, Marshal.SizeOf(typeof(NET_RECORDFILE_INFO)), out  fileCount, 5000, false);//按时间回放
             if (blnQueryRecordFile == true)
             {
                 //**********按文件下载**********
                 pPlayBackChannelID = int.Parse(fPBSet.txtChannelID.Text.ToString());
                 if (txtDirPath2.Text.Trim().Length > 0 && txtFileName2.Text.Trim().Length > 0)
                 {
                     pDownloadHandleByTime = DHClient.DHDownloadByTime(pLoginID, pPlayBackChannelID, 0, startTime, endTime, txtDirPath1.Text + @"\" + txtFileName2.Text, downLoadFun, IntPtr.Zero);
                     if (pDownloadHandleByTime != 0)
                     {
                         btnDownLoad2.Tag = "下载中";
                         pDownloadHandle = pDownloadHandleByTime;
                         MessageBox.Show("开始下载!", pMsgTitle);
                     }
                     else
                     {
                         MessageBox.Show(DHClient.LastOperationInfo.ToString(pErrInfoFormatStyle), pMsgTitle);
                     }
                 }
                 else
                 {
                     MessageBox.Show("请输入有效的录像保存目录和文件名!", pMsgTitle);
                 }
                 //*******************************
             }
             else
             {
                 MessageBox.Show("这个时间段里没有录像文件供下载!", pMsgTitle);
             }
         }
         //MessageBox.Show(blnQueryRecordFile.ToString(),MsgTitle);
     }
 }
コード例 #4
0
ファイル: frm_Main.cs プロジェクト: zhoujiechj/Scan
        /// <summary>
        /// press the button of downloading according the time
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDownLoad2_Click(object sender, EventArgs e)
        {
            frm_PlayBackByTimeSet fPBSet   = new frm_PlayBackByTimeSet();
            NET_RECORDFILE_INFO   fileInfo = new NET_RECORDFILE_INFO();
            int  fileCount          = 0;
            bool blnQueryRecordFile = false;
            int  pPlayBackChannelID = 0;

            fPBSet.txtDevName.Text = strUserName;
            fPBSet.cmbChannelSelect.Items.Clear();
            for (int i = 1; i <= deviceInfo.byChanNum; i++)
            {
                fPBSet.cmbChannelSelect.Items.Add(i);
            }
            fPBSet.ShowDialog();
            if (fPBSet.blnOKEnter == true)
            {
                DateTime startTime = fPBSet.StartTime;
                DateTime endTime   = fPBSet.EndTime;

                blnQueryRecordFile = NETClient.NETQueryRecordFile(pLoginID, int.Parse(fPBSet.txtChannelID.Text.ToString()), RECORD_FILE_TYPE.ALLRECORDFILE,
                                                                  startTime, endTime, null, ref fileInfo, Marshal.SizeOf(typeof(NET_RECORDFILE_INFO)), out fileCount, 5000, false);//按时间回放
                if (blnQueryRecordFile == true)
                {
                    //**********download according the file**********
                    pPlayBackChannelID = int.Parse(fPBSet.txtChannelID.Text.ToString());
                    if (txtDirPath2.Text.Trim().Length > 0 && txtFileName2.Text.Trim().Length > 0)
                    {
                        string strFileName = txtFileName2.Text;
                        strFileName = strFileName.ToLower();
                        if (!strFileName.EndsWith(".dav"))
                        {
                            strFileName += ".dav";
                        }

                        // close the related resource downloaded last time
                        if (pDownloadHandleByTime != 0)
                        {
                            NETClient.NETStopDownload(pDownloadHandleByTime);
                            pDownloadHandle = 0;
                        }

                        pDownloadHandleByTime = NETClient.NETDownloadByTime(pLoginID, pPlayBackChannelID, 0, startTime
                                                                            , endTime, txtDirPath2.Text + @"\" + strFileName, timeDownLoadFun, IntPtr.Zero);
                        if (pDownloadHandleByTime != 0)
                        {
                            btnDownLoad2.Tag         = "in the download";
                            pDownloadHandle          = pDownloadHandleByTime;
                            btnDownLoad2.Enabled     = false;
                            btnDownLoad1.Enabled     = false;
                            btnStopDownLoad2.Enabled = true;
                            MessageUtil.ShowMsgBox(StringUtil.ConvertString("begin to download!"),
                                                   StringUtil.ConvertString(pMsgTitle));
                        }
                        else
                        {
                            MessageUtil.ShowMsgBox(StringUtil.ConvertString(NETClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                                   StringUtil.ConvertString(pMsgTitle));
                        }
                    }
                    else
                    {
                        MessageUtil.ShowMsgBox(StringUtil.ConvertString("please input the valid video-saving dierectory and file name!"),
                                               StringUtil.ConvertString(pMsgTitle));
                    }
                    //*******************************
                }
                else
                {
                    MessageUtil.ShowMsgBox(StringUtil.ConvertString("no video file is available during the time!"),
                                           StringUtil.ConvertString(pMsgTitle));
                }
            }
        }