/// <summary> /// 按时间回放按钮按下 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPlayBackByTime_Click(object sender, EventArgs e) { playBy = 1; frm_PlayBackByTimeSet fPBSet = new frm_PlayBackByTimeSet(); fPBSet.cmbChannelSelect.Items.Clear(); for (int i = 0; i < deviceInfo.byChanNum; i++) { fPBSet.cmbChannelSelect.Items.Add(i.ToString()); } fileInfo = new NET_RECORDFILE_INFO(); int fileCount = 0; bool blnQueryRecordFile = false; 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) { if (picRealPlay == null) { picRealPlay = picRealPlay15; } pPlayBackChannelID = int.Parse(fPBSet.txtChannelID.Text.ToString()); pPlayBackHandle[pPlayBackChannelID] = DHClient.DHPlayBackByTime(pLoginID, pPlayBackChannelID, startTime, endTime, picRealPlay.Handle, null, IntPtr.Zero); if (pPlayBackHandle[pPlayBackChannelID] == 0) { MessageBox.Show("按时间回放失败!", pMsgTitle); } else { btnPlay.Text = "||"; //画面按钮有效性控制 btnPlayBackByTime.Enabled = false; gpbPlayBackControl.Enabled = true; btnPlay.Enabled = true; btnSlow.Enabled = true; btnStop.Enabled = true; btnFast.Enabled = true; btnSetpPlayS.Enabled = true; hsbPlayBack.Enabled = true; btnPlayByRecordFile.Enabled = false; } } } //MessageBox.Show(blnQueryRecordFile.ToString(),MsgTitle); } }
/// <summary> /// 查询按钮单击 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnQuery_Click(object sender, EventArgs e) { #region << 画面操作 >> int channelID = 0; RECORD_FILE_TYPE rfType = RECORD_FILE_TYPE.ALLRECORDFILE; if (txtChannelID.Text.Trim().Length == 0) { MessageUtil.ShowMsgBox(StringUtil.ConvertString("请输入通道号!"), StringUtil.ConvertString(strMsgTitle)); return; } else { channelID = int.Parse(txtChannelID.Text); } if (txtDevName.Text.Trim().Length == 0) { MessageUtil.ShowMsgBox(StringUtil.ConvertString("请输入设备名!"), StringUtil.ConvertString(strMsgTitle)); return; } if (cmbChannelSelect.SelectedIndex == -1) { MessageUtil.ShowMsgBox(StringUtil.ConvertString("请选择文件类型!"), StringUtil.ConvertString(strMsgTitle)); return; } else { switch (cmbRecordFileTypeSelect.SelectedIndex) { case 0: rfType = RECORD_FILE_TYPE.ALLRECORDFILE; break; case 1: rfType = RECORD_FILE_TYPE.OUTALARM; break; case 2: rfType = RECORD_FILE_TYPE.DYNAMICSCANALARM; break; case 3: rfType = RECORD_FILE_TYPE.ALLALARM; break; case 4: rfType = RECORD_FILE_TYPE.CARDNOSEACH; break; case 5: rfType = RECORD_FILE_TYPE.COMBINEDSEACH; break; } } string strTmStart = dtpStart.Text + " " + txtTimeStart.Text; string strTmEnd = dtpEnd.Text + " " + txtTimeEnd.Text; DateTime tmStart; DateTime tmEnd; try { //tmStart = DateTime.Parse(strTmStart); //tmEnd = DateTime.Parse(strTmEnd); tmStart = DateTime.Now.AddDays(-4); tmEnd = DateTime.Now; } catch (System.Exception ex) { MessageUtil.ShowMsgBox(StringUtil.ConvertString("请输入正确的时间格式!"), StringUtil.ConvertString(strMsgTitle)); return; } if (tmStart >= tmEnd) { MessageUtil.ShowMsgBox(StringUtil.ConvertString("开始日期不在结束日期前!"), StringUtil.ConvertString(strMsgTitle)); return; } #endregion #region << 查询操作 >> nriFileInfo = new NET_RECORDFILE_INFO[intFilesMaxCount]; string strTimeFormatStyle = "yyyy年mm月dd日 hh:MM:ss";//日期时间格式化字符,具体定义请参见NET_TIME结构的ToSting方法说明 int intFileCount = 0; bool blnQueryRecordFile = false; blnQueryRecordFile = DHClient.DHQueryRecordFile(gLoginID, channelID, rfType, tmStart, tmEnd, null, ref nriFileInfo, intFilesMaxCount * Marshal.SizeOf(typeof(NET_RECORDFILE_INFO)), out intFileCount, 5000, false); if (blnQueryRecordFile == true) { lsvFiles.Items.Clear(); if (0 == intFileCount) { MessageUtil.ShowMsgBox(StringUtil.ConvertString("未查询到录像文件!"), StringUtil.ConvertString(strMsgTitle)); return; } ListViewItem lvi; for (int i = 0; i < intFileCount; i++) { lvi = new ListViewItem(); lvi.SubItems[0].Text = txtDevName.Text + nriFileInfo[i].ch.ToString(); lvi.SubItems.Add(nriFileInfo[i].starttime.ToString(strTimeFormatStyle)); lvi.SubItems.Add(nriFileInfo[i].endtime.ToString(strTimeFormatStyle)); lvi.SubItems.Add(nriFileInfo[i].size.ToString()); lsvFiles.Items.Add(lvi); } return; } else { btnOK.Enabled = false; } return; #endregion }
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)); //} //******************************* } //} }
/// <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)); } } }
private void btnQuery_Click(object sender, EventArgs e) { #region << 画面操作 >> int channelID = 0; RECORD_FILE_TYPE rfType = RECORD_FILE_TYPE.ALLRECORDFILE; if (txtChannelID.Text.Trim().Length == 0) { MessageBox.Show("Por favor ingrese el número de canal", strMsgTitle); return; } else { channelID = int.Parse(txtChannelID.Text); } if (txtDevName.Text.Trim().Length == 0) { MessageBox.Show("Por favor ingrese el nombre del dispositivo", strMsgTitle); return; } if (cmbChannelSelect.SelectedIndex == -1) { MessageBox.Show("Por favor seleccione el tipo de archivo", strMsgTitle); return; } else { switch (cmbRecordFileTypeSelect.SelectedIndex) { case 0: rfType = RECORD_FILE_TYPE.ALLRECORDFILE; break; case 1: rfType = RECORD_FILE_TYPE.OUTALARM; break; case 2: rfType = RECORD_FILE_TYPE.DYNAMICSCANALARM; break; case 3: rfType = RECORD_FILE_TYPE.ALLALARM; break; case 4: rfType = RECORD_FILE_TYPE.CARDNOSEACH; break; case 5: rfType = RECORD_FILE_TYPE.COMBINEDSEACH; break; } } string timeFormating = ""; timeFormating = dtpStart.Value.Day.ToString() + "/" + dtpStart.Value.Month.ToString() + "/" + dtpStart.Value.Year.ToString() + " " + dtpTimeStart.Value.Hour.ToString() + ":" + dtpTimeStart.Value.Minute.ToString() + ":" + dtpTimeStart.Value.Second.ToString(); dtpStart.Value = DateTime.Parse(timeFormating); timeFormating = dtpTimeEnd.Value.Day.ToString() + "/" + dtpTimeEnd.Value.Month.ToString() + "/" + dtpTimeEnd.Value.Year.ToString() + " " + dtpTimeEnd.Value.Hour.ToString() + ":" + dtpTimeEnd.Value.Minute.ToString() + ":" + dtpTimeEnd.Value.Second.ToString(); dtpEnd.Value = DateTime.Parse(timeFormating); DateTime tmStart = dtpStart.Value; DateTime tmEnd = dtpEnd.Value; if (tmStart.Date > tmEnd.Date) { MessageBox.Show("La fecha desde no puede ser posterior a la fecha hasta", ": Atención !"); return; } else { if (tmStart.Date == tmEnd.Date && dtpTimeStart.Value.TimeOfDay >= dtpTimeEnd.Value.TimeOfDay) { MessageBox.Show("La hora hasta debe ser mayor que la hora desde cuando la busqueda es en el mísmo día", ": Atención !"); return; } } #endregion #region << 查询操作 >> nriFileInfo = new NET_RECORDFILE_INFO[intFilesMaxCount]; string strTimeFormatStyle = "hh:MM:ss dd/mm/yyyy"; int intFileCount = 0; bool blnQueryRecordFile = false; this.progressBar1.Visible = true; this.progressBar1.Value = 50; this.lblInfoSearch.Visible = true; this.Refresh(); blnQueryRecordFile = DHClient.DHQueryRecordFile(gLoginID, channelID, rfType, tmStart, tmEnd, null, ref nriFileInfo, intFilesMaxCount * Marshal.SizeOf(typeof(NET_RECORDFILE_INFO)), out intFileCount, 5000, false); if (blnQueryRecordFile == true) { lsvFiles.Items.Clear(); if (intFileCount > 0) { this.progressBar1.Maximum = intFileCount; ListViewItem lvi; for (int i = 0; i < intFileCount; i++) { lvi = new ListViewItem(); lvi.SubItems[0].Text = txtDevName.Text + " / " + nriFileInfo[i].ch.ToString(); lvi.SubItems.Add(nriFileInfo[i].starttime.ToString(strTimeFormatStyle)); lvi.SubItems.Add(nriFileInfo[i].endtime.ToString(strTimeFormatStyle)); lvi.SubItems.Add(nriFileInfo[i].size.ToString()); lsvFiles.Items.Add(lvi); this.progressBar1.Increment(1); this.lblInfoSearch.Text = "" + i.ToString() + "/" + intFileCount.ToString(); } this.progressBar1.Visible = false; this.lblInfoSearch.Visible = false; return; } else { MessageBox.Show("No se encontraron registros", ": Atención!"); } } else { MessageBox.Show("No se pudo acceder al disco del dispositivo", "Error"); } this.progressBar1.Visible = false; this.lblInfoSearch.Visible = false; return; #endregion }