예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //if (this.btnOK.Text == "重试")
            //{
            //    setProgressPos = new fSetProgressPos(DownloadProgress);
            //}


            if (txtDirPath2.Text.Trim().Length > 0 && txtFileName2.Text.Trim().Length > 0)
            {
                string strFileName = txtFileName2.Text;

                strFileName = strFileName.ToLower();
                if (!strFileName.EndsWith(".dav"))
                {
                    strFileName += ".dav";
                }
                downloadfilepathstr = txtDirPath2.Text.Trim() + strFileName;
            }
            else
            {
                MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"),
                                       StringUtil.ConvertString(pMsgTitle));
            }
            string strTmStart = dtpStart.Text + " " + txtTimeStart.Text;
            string strTmEnd   = dtpEnd.Text + " " + txtTimeEnd.Text;

            try
            {
                tmStart = DateTime.Parse(strTmStart);
                tmEnd   = DateTime.Parse(strTmEnd);
            }
            catch (System.Exception ex)
            {
                MessageUtil.ShowMsgBox(StringUtil.ConvertString("请输入正确的时间格式!"));
                return;
            }

            if (tmStart >= tmEnd)
            {
                MessageUtil.ShowMsgBox(StringUtil.ConvertString("开始日期不在结束日期前!"));
                return;
            }

            //blnOKEnter = true;


            NET_RECORDFILE_INFO fileInfo = new NET_RECORDFILE_INFO();
            int  fileCount          = 0;
            bool blnQueryRecordFile = false;
            int  pPlayBackChannelID = 0;


            DateTime startTime = StartTime;
            DateTime endTime   = EndTime;

            //if (int.Parse(txtChannelID.Text.ToString()) == 5)
            //{
            //    for (int i = 0; i < 5; i++)
            //    {
            //        txtChannelID.Text = i.ToString();
            //        label7.Text = "正在下载通道0文件,还剩"+(5-i).ToString()+"个文件";
            //        btnOK_Click(null, null);


            //    }
            //}
            //else
            //{

            blnQueryRecordFile = DHClient.DHQueryRecordFile(pLoginID, int.Parse(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(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, DownLoadFilePathStr, 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));

                    //grbMain.Enabled = true;
                }
                //else
                //{
                //    MessageUtil.ShowMsgBox(StringUtil.ConvertString(DHClient.LastOperationInfo.errMessage, "ErrorMessage"),
                //                           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));
                }
            }
        }