Пример #1
0
        /// <summary>
        /// 得到门禁的播放时间
        /// </summary>
        /// <returns>返回播放时间</returns>
        public string GetFilePlayTimeHik()
        {
            string sRetStr = null;

            CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();
            CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData     = new CHCNetSDK.NET_DVR_FINDDATA_V30();
            struFileCond_V40.lChannel      = m_iChannel; //通道号 Channel number
            struFileCond_V40.dwFileType    = 0xff;       //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
            struFileCond_V40.dwIsLocked    = 0xff;       //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)
            struFileCond_V40.struStartTime = GetTimeObjectHik(m_sStartTime);
            struFileCond_V40.struStopTime  = GetTimeObjectHik(m_sEndTime);
            //开始录像文件查找 Start to search video files
            m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(m_iLoginHandle, ref struFileCond_V40);
            /*\ 失败 /*/
            if (m_lFindHandle < 0)
            {
                return(sRetStr);
            }
            while (true)
            {
                //逐个获取查找到的文件信息 Get file information one by one.
                int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);
                if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS)
                {
                    DateTime dateTime = new DateTime((int)struFileData.struStartTime.dwYear,
                                                     (int)struFileData.struStartTime.dwMonth,
                                                     (int)struFileData.struStartTime.dwDay,
                                                     (int)struFileData.struStartTime.dwHour,
                                                     (int)struFileData.struStartTime.dwMinute,
                                                     (int)struFileData.struStartTime.dwSecond);
                    DateTime DateStart = new DateTime(1970, 1, 1, 8, 0, 0);
                    return(Convert.ToString((dateTime - DateStart).TotalSeconds));
                }
                /*\ 未找到 /*/
                else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                {
                    return(sRetStr);
                }
            }
        }
Пример #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            listViewFile.Items.Clear();//清空文件列表

            CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();

            struFileCond_V40.lChannel   = iChannelNum[(int)iSelIndex]; //通道号 Channel number
            struFileCond_V40.dwFileType = 0xff;                        //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
            struFileCond_V40.dwIsLocked = 0xff;                        //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)

            //设置录像查找的开始时间 Set the starting time to search video files
            struFileCond_V40.struStartTime.dwYear   = (uint)dateTimeStart.Value.Year;
            struFileCond_V40.struStartTime.dwMonth  = (uint)dateTimeStart.Value.Month;
            struFileCond_V40.struStartTime.dwDay    = (uint)dateTimeStart.Value.Day;
            struFileCond_V40.struStartTime.dwHour   = (uint)dateTimeStart.Value.Hour;
            struFileCond_V40.struStartTime.dwMinute = (uint)dateTimeStart.Value.Minute;
            struFileCond_V40.struStartTime.dwSecond = (uint)dateTimeStart.Value.Second;

            //设置录像查找的结束时间 Set the stopping time to search video files
            struFileCond_V40.struStopTime.dwYear   = (uint)dateTimeEnd.Value.Year;
            struFileCond_V40.struStopTime.dwMonth  = (uint)dateTimeEnd.Value.Month;
            struFileCond_V40.struStopTime.dwDay    = (uint)dateTimeEnd.Value.Day;
            struFileCond_V40.struStopTime.dwHour   = (uint)dateTimeEnd.Value.Hour;
            struFileCond_V40.struStopTime.dwMinute = (uint)dateTimeEnd.Value.Minute;
            struFileCond_V40.struStopTime.dwSecond = (uint)dateTimeEnd.Value.Second;

            //开始录像文件查找 Start to search video files
            m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(m_lUserID, ref struFileCond_V40);

            if (m_lFindHandle < 0)
            {
                iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                str      = "NET_DVR_FindFile_V40 failed, error code= " + iLastErr; //预览失败,输出错误号
                MessageBox.Show(str);
                return;
            }
            else
            {
                CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30();;
                while (true)
                {
                    //逐个获取查找到的文件信息 Get file information one by one.
                    int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);

                    if (result == CHCNetSDK.NET_DVR_ISFINDING)  //正在查找请等待 Searching, please wait
                    {
                        continue;
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
                    {
                        str1 = struFileData.sFileName;

                        str2 = Convert.ToString(struFileData.struStartTime.dwYear) + "-" +
                               Convert.ToString(struFileData.struStartTime.dwMonth) + "-" +
                               Convert.ToString(struFileData.struStartTime.dwDay) + " " +
                               Convert.ToString(struFileData.struStartTime.dwHour) + ":" +
                               Convert.ToString(struFileData.struStartTime.dwMinute) + ":" +
                               Convert.ToString(struFileData.struStartTime.dwSecond);

                        str3 = Convert.ToString(struFileData.struStopTime.dwYear) + "-" +
                               Convert.ToString(struFileData.struStopTime.dwMonth) + "-" +
                               Convert.ToString(struFileData.struStopTime.dwDay) + " " +
                               Convert.ToString(struFileData.struStopTime.dwHour) + ":" +
                               Convert.ToString(struFileData.struStopTime.dwMinute) + ":" +
                               Convert.ToString(struFileData.struStopTime.dwSecond);

                        listViewFile.Items.Add(new ListViewItem(new string[] { str1, str2, str3 }));//将查找的录像文件添加到列表中
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                    {
                        break; //未查找到文件或者查找结束,退出   No file found or no more file found, search is finished
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
        private async Task <List <Recording> > SearchRecordings(DateTime lastRecordingEndTime)
        {
            List <Recording> recordings = new List <Recording>();

            CHCNetSDK.NET_DVR_FILECOND_V40 struFileCondV40 = new CHCNetSDK.NET_DVR_FILECOND_V40();

            struFileCondV40.lChannel   = _iChannelNum[(int)iSelIndex]; //Channel number
            struFileCondV40.dwFileType = 0xff;                         //0xff-All,0-Timing record,1-Motion detection,2-Alarm trigger,...
            struFileCondV40.dwIsLocked =
                0xff;                                                  //0-unfixed file,1-fixed file,0xff means all files(including fixed and unfixed files)

            DateTime today = DateTime.Now;

            //Set the starting time to search video files
            struFileCondV40.struStartTime.dwYear   = (uint)today.Year;
            struFileCondV40.struStartTime.dwMonth  = (uint)today.Month;
            struFileCondV40.struStartTime.dwDay    = (uint)today.Day;
            struFileCondV40.struStartTime.dwHour   = 0;
            struFileCondV40.struStartTime.dwMinute = 0;
            struFileCondV40.struStartTime.dwSecond = 0;

            //Set the stopping time to search video files
            struFileCondV40.struStopTime.dwYear   = (uint)today.Year;
            struFileCondV40.struStopTime.dwMonth  = (uint)today.Month;
            struFileCondV40.struStopTime.dwDay    = (uint)today.Day;
            struFileCondV40.struStopTime.dwHour   = 23; // This most likely will miss files when day changes
            struFileCondV40.struStopTime.dwMinute = 59;
            struFileCondV40.struStopTime.dwSecond = 59;

            //Start to search video files
            _mLFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(_mLUserId, ref struFileCondV40);

            if (_mLFindHandle < 0)
            {
                _iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                _errorMsg = "NET_DVR_FindFile_V40 failed, error code= " +
                            _iLastErr; // find files failed,print error code
                Console.WriteLine(_errorMsg);
            }
            else
            {
                CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30();
                while (true)
                {
                    //Get file information one by one.
                    int result = CHCNetSDK.NET_DVR_FindNextFile_V30(_mLFindHandle, ref struFileData);

                    if (result == CHCNetSDK.NET_DVR_ISFINDING) //Searching, please wait
                    {
                        // continue;
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //Get the file information successfully
                    {
                        var str1 = struFileData.sFileName;

                        var sDYear   = Convert.ToString(struFileData.struStartTime.dwYear);
                        var sDMonth  = Convert.ToString(struFileData.struStartTime.dwMonth);
                        var sDDAy    = Convert.ToString(struFileData.struStartTime.dwDay);
                        var sDHour   = Convert.ToString(struFileData.struStartTime.dwHour);
                        var sDMinute = Convert.ToString(struFileData.struStartTime.dwMinute);
                        var sDSecond = Convert.ToString(struFileData.struStartTime.dwSecond);

                        var str2 = sDYear + "-" + sDMonth + "-" + sDDAy + " " +
                                   sDHour + ":" + sDMinute + ":" + sDSecond;

                        var eDYear   = Convert.ToString(struFileData.struStopTime.dwYear);
                        var eDMonth  = Convert.ToString(struFileData.struStopTime.dwMonth);
                        var eDDAy    = Convert.ToString(struFileData.struStopTime.dwDay);
                        var eDHour   = Convert.ToString(struFileData.struStopTime.dwHour);
                        var eDMinute = Convert.ToString(struFileData.struStopTime.dwMinute);
                        var eDSecond = Convert.ToString(struFileData.struStopTime.dwSecond);

                        var str3 = eDYear + "-" + eDMonth + "-" + eDDAy + " " +
                                   eDHour + ":" + eDMinute + ":" + eDSecond;

                        DateTime recordingStartDate =
                            DateTime.ParseExact(str2, "yyyy-M-d H:m:s", CultureInfo.InvariantCulture);

                        DateTime recordingEndDate =
                            DateTime.ParseExact(str3, "yyyy-M-d H:m:s", CultureInfo.InvariantCulture);

                        if (DateTime.Compare(recordingEndDate, lastRecordingEndTime) == 1)
                        {
                            Recording recording = new Recording(_cameraName, 0, str1, str2, str3);
                            recording.SetDtStartTime(recordingStartDate);
                            recording.SetDtEndTime(recordingEndDate);
                            recordings.Add(recording);
                            Console.WriteLine("Found non existing: " + str1 + " - " + str2);
                        }
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                    {
                        break; //No file found or no more file found, searching is finished
                    }
                    else
                    {
                        break;
                    }
                }

                return(recordings);
            }

            return(null);
        }
Пример #4
0
        /// <summary>
        /// 录像查询
        /// </summary>
        /// <param name="session"></param>
        /// <param name="cha"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        List <DATA_PAIR> NvrInterface.searchHistory(int session, int cha, DateTime start, DateTime end)
        {
            // 查询结果句柄
            Int32 m_lFindHandle = -1;

            // 查询结果
            List <DATA_PAIR> resultArray = new List <DATA_PAIR>();

            // 查询出的一个时间
            DateTime  oneStart, oneEnd;
            DATA_PAIR onePair;

            // 查询结构体
            CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();
            struFileCond_V40.lChannel   = cha;  //通道号 Channel number
            struFileCond_V40.dwFileType = 0xff; //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
            struFileCond_V40.dwIsLocked = 0xff; //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)


            //设置录像查找的开始时间 Set the starting time to search video files
            struFileCond_V40.struStartTime.dwYear   = (uint)start.Year;
            struFileCond_V40.struStartTime.dwMonth  = (uint)start.Month;
            struFileCond_V40.struStartTime.dwDay    = (uint)start.Day;
            struFileCond_V40.struStartTime.dwHour   = (uint)start.Hour;
            struFileCond_V40.struStartTime.dwMinute = (uint)start.Minute;
            struFileCond_V40.struStartTime.dwSecond = (uint)start.Second;

            //设置录像查找的结束时间 Set the stopping time to search video files
            struFileCond_V40.struStopTime.dwYear   = (uint)end.Year;
            struFileCond_V40.struStopTime.dwMonth  = (uint)end.Month;
            struFileCond_V40.struStopTime.dwDay    = (uint)end.Day;
            struFileCond_V40.struStopTime.dwHour   = (uint)end.Hour;
            struFileCond_V40.struStopTime.dwMinute = (uint)end.Minute;
            struFileCond_V40.struStopTime.dwSecond = (uint)end.Second;

            //开始录像文件查找 Start to search video files
            m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(session - 1, ref struFileCond_V40);

            if (m_lFindHandle < 0)
            {
                // 没有录像,或者是出错
                return(null);
            }
            else
            {
                CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30();;
                while (true)
                {
                    //逐个获取查找到的文件信息 Get file information one by one.
                    int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);

                    if (result == CHCNetSDK.NET_DVR_ISFINDING)  //正在查找请等待 Searching, please wait
                    {
                        continue;
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
                    {
                        oneStart = new DateTime(
                            (int)struFileData.struStartTime.dwYear,
                            (int)struFileData.struStartTime.dwMonth,
                            (int)struFileData.struStartTime.dwDay,
                            (int)struFileData.struStartTime.dwHour,
                            (int)struFileData.struStartTime.dwMinute,
                            (int)struFileData.struStartTime.dwSecond
                            );
                        oneEnd = new DateTime(
                            (int)struFileData.struStopTime.dwYear,
                            (int)struFileData.struStopTime.dwMonth,
                            (int)struFileData.struStopTime.dwDay,
                            (int)struFileData.struStopTime.dwHour,
                            (int)struFileData.struStopTime.dwMinute,
                            (int)struFileData.struStopTime.dwSecond
                            );
                        onePair       = new DATA_PAIR();
                        onePair.start = oneStart;
                        onePair.end   = oneEnd;

                        resultArray.Add(onePair);
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                    {
                        break; //未查找到文件或者查找结束,退出   No file found or no more file found, search is finished
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(resultArray);
        }
Пример #5
0
        private OResult <IEnumerable <CameraPlaybackRecordTimeRange> > GetDayRecordTimeRanges(Int32 channelNo, DateTime date)
        {
            try
            {
                CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();

                struFileCond_V40.lChannel   = channelNo; //通道号
                struFileCond_V40.dwFileType = 0xff;      //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
                struFileCond_V40.dwIsLocked = 0xff;      //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)

                //设置录像查找的开始时间
                struFileCond_V40.struStartTime.dwYear   = (UInt32)date.Year;
                struFileCond_V40.struStartTime.dwMonth  = (UInt32)date.Month;
                struFileCond_V40.struStartTime.dwDay    = (UInt32)date.Day;
                struFileCond_V40.struStartTime.dwHour   = 0;
                struFileCond_V40.struStartTime.dwMinute = 0;
                struFileCond_V40.struStartTime.dwSecond = 0;

                //设置录像查找的结束时间
                struFileCond_V40.struStopTime.dwYear   = (UInt32)date.Year;
                struFileCond_V40.struStopTime.dwMonth  = (UInt32)date.Month;
                struFileCond_V40.struStopTime.dwDay    = (UInt32)date.Day;
                struFileCond_V40.struStopTime.dwHour   = 23;
                struFileCond_V40.struStopTime.dwMinute = 59;
                struFileCond_V40.struStopTime.dwSecond = 59;

                //开始录像文件查找 Start to search video files
                var m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(_userId, ref struFileCond_V40);

                if (m_lFindHandle < 0)
                {
                    return(new OResult <IEnumerable <CameraPlaybackRecordTimeRange> >(null, HkvsErrorCode.GetLastErrorCode(), $"查找录像文件失败:{HkvsErrorCode.GetLastErrorMessage()}"));
                }
                else
                {
                    CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30();

                    var ranges = new List <CameraPlaybackRecordTimeRange>();

                    while (true)
                    {
                        //逐个获取查找到的文件信息
                        var result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);
                        if (result == CHCNetSDK.NET_DVR_ISFINDING)  //正在查找请等待
                        {
                            continue;
                        }
                        else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功
                        {
                            var startTime = new DateTime((Int32)struFileData.struStartTime.dwYear, (Int32)struFileData.struStartTime.dwMonth, (Int32)struFileData.struStartTime.dwDay, (Int32)struFileData.struStartTime.dwHour, (Int32)struFileData.struStartTime.dwMinute, (Int32)struFileData.struStartTime.dwSecond);
                            var endTime   = new DateTime((Int32)struFileData.struStopTime.dwYear, (Int32)struFileData.struStopTime.dwMonth, (Int32)struFileData.struStopTime.dwDay, (Int32)struFileData.struStopTime.dwHour, (Int32)struFileData.struStopTime.dwMinute, (Int32)struFileData.struStopTime.dwSecond);
                            ranges.Add(new CameraPlaybackRecordTimeRange()
                            {
                                StartTime = startTime,
                                EndTime   = endTime
                            });
                        }
                        else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                        {
                            break; //未查找到文件或者查找结束,退出
                        }
                        else
                        {
                            break;
                        }
                    }

                    MergetRanges(ref ranges);

                    return(new OResult <IEnumerable <CameraPlaybackRecordTimeRange> >(ranges.Any() ? ranges : null));
                }
            }
            catch (Exception ex)
            {
                return(new OResult <IEnumerable <CameraPlaybackRecordTimeRange> >(null, ex));
            }
        }
Пример #6
0
        public List <SMVideoRecordFile> SearchRecordFile(string devIp, int devPort, string userName, string password, int channel, DateTime beginTime, DateTime endTime)
        {
            int userId = -1;

            DevLoginModel devLoginModel = DeviceLogin(devIp, devPort, userName, password);

            if (devLoginModel != null)
            {
                userId = devLoginModel.LoginId;
            }

            if (userId < 0)
            {
                return(null);
            }

            CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();

            struFileCond_V40.lChannel   = channel; //通道号 Channel number
            struFileCond_V40.dwFileType = 0xff;    //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
            struFileCond_V40.dwIsLocked = 0xff;    //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)

            //设置录像查找的开始时间 Set the starting time to search video files
            struFileCond_V40.struStartTime = beginTime.ToHCDeviceTime();

            //设置录像查找的结束时间 Set the stopping time to search video files
            struFileCond_V40.struStopTime = endTime.ToHCDeviceTime();

            //开始录像文件查找 Start to search video files
            int m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(userId, ref struFileCond_V40);

            if (m_lFindHandle < 0)
            {
                uint iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                return(null);
            }
            else
            {
                CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData        = new CHCNetSDK.NET_DVR_FINDDATA_V30();
                List <SMVideoRecordFile>       videoRecordFileList = new List <SMVideoRecordFile>();
                while (true)
                {
                    //逐个获取查找到的文件信息 Get file information one by one.
                    int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);

                    if (result == CHCNetSDK.NET_DVR_ISFINDING)  //正在查找请等待 Searching, please wait
                    {
                        continue;
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
                    {
                        SMVideoRecordFile videoRecord = new SMVideoRecordFile();
                        videoRecord.FileName  = struFileData.sFileName;
                        videoRecord.FileSize  = (int)struFileData.dwFileSize;
                        videoRecord.BeginTime = struFileData.struStartTime.ToDateTime();
                        videoRecord.EndTime   = struFileData.struStopTime.ToDateTime();
                        videoRecordFileList.Add(videoRecord);
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                    {
                        //未查找到文件或者查找结束,退出
                        break;
                    }
                    else
                    {
                        break;
                    }
                }
                return(videoRecordFileList);
            }
        }
Пример #7
0
        public List <DateTime> SearchRecordDate(string devIp, int devPort, string userName, string password, int channel, DateTime beginTime, DateTime endTime)
        {
            int userId = -1;

            DevLoginModel devLoginModel = DeviceLogin(devIp, devPort, userName, password);

            if (devLoginModel != null)
            {
                userId = devLoginModel.LoginId;
            }

            List <DateTime> dateList = new List <DateTime>();

            if (userId < 0)
            {
                return(dateList);
            }

            int queryDayCount = (int)(endTime.Date - beginTime.Date).TotalDays + 1;

            for (int i = 0; i < queryDayCount; i++)
            {
                CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();
                struFileCond_V40.lChannel   = channel; //通道号 Channel number
                struFileCond_V40.dwFileType = 0xff;    //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
                struFileCond_V40.dwIsLocked = 0xff;    //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)

                struFileCond_V40.struStartTime = beginTime.Date.AddDays(i).ToHCDeviceTime();
                struFileCond_V40.struStopTime  = beginTime.Date.AddDays(i + 1).AddSeconds(-1).ToHCDeviceTime();

                int m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(userId, ref struFileCond_V40);
                if (m_lFindHandle < 0)
                {
                    uint iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                    continue;
                }
                else
                {
                    CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30();
                    while (true)
                    {
                        //逐个获取查找到的文件信息 Get file information one by one.
                        int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);
                        if (result == CHCNetSDK.NET_DVR_ISFINDING)  //正在查找请等待 Searching, please wait
                        {
                            continue;
                        }
                        else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
                        {
                            dateList.Add(beginTime.Date.AddDays(i));
                            break;
                        }
                        else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                        {
                            break;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }

            return(dateList);
        }
Пример #8
0
        public string[] findfile(uint y1, uint m1, uint d1, uint h1, uint min1, uint s1, uint y2, uint m2, uint d2, uint h2, uint min2, uint s2)
        {
            Int32 m_lFindHandle = -1;

            CHCNetSDK.NET_DVR_FILECOND_V40 struFileCond_V40 = new CHCNetSDK.NET_DVR_FILECOND_V40();
            string[] filelist = new string[1000];

            struFileCond_V40.lChannel   = 1;    //通道号 Channel number
            struFileCond_V40.dwFileType = 0xff; //0xff-全部,0-定时录像,1-移动侦测,2-报警触发,...
            struFileCond_V40.dwIsLocked = 0xff; //0-未锁定文件,1-锁定文件,0xff表示所有文件(包括锁定和未锁定)

            //设置录像查找的开始时间 Set the starting time to search video files
            struFileCond_V40.struStartTime.dwYear   = y1;
            struFileCond_V40.struStartTime.dwMonth  = m1;
            struFileCond_V40.struStartTime.dwDay    = d1;
            struFileCond_V40.struStartTime.dwHour   = h1;
            struFileCond_V40.struStartTime.dwMinute = min1;
            struFileCond_V40.struStartTime.dwSecond = s1;

            //设置录像查找的结束时间 Set the stopping time to search video files
            struFileCond_V40.struStopTime.dwYear   = y2;
            struFileCond_V40.struStopTime.dwMonth  = m2;
            struFileCond_V40.struStopTime.dwDay    = d2;
            struFileCond_V40.struStopTime.dwHour   = h2;
            struFileCond_V40.struStopTime.dwMinute = min2;
            struFileCond_V40.struStopTime.dwSecond = s2;

            //开始录像文件查找 Start to search video files
            m_lFindHandle = CHCNetSDK.NET_DVR_FindFile_V40(UserId, ref struFileCond_V40);

            if (m_lFindHandle < 0)
            {
                var iLastErr = NET_DVR_GetLastError();
                throw new Exception("NET_DVR_FindFile_V40 failed, error code= " + iLastErr);
            }
            else
            {
                int i = 0;
                CHCNetSDK.NET_DVR_FINDDATA_V30 struFileData = new CHCNetSDK.NET_DVR_FINDDATA_V30();;
                while (true)
                {
                    //逐个获取查找到的文件信息 Get file information one by one.
                    int result = CHCNetSDK.NET_DVR_FindNextFile_V30(m_lFindHandle, ref struFileData);

                    if (result == CHCNetSDK.NET_DVR_ISFINDING)  //正在查找请等待 Searching, please wait
                    {
                        continue;
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_SUCCESS) //获取文件信息成功 Get the file information successfully
                    {
                        string str1 = struFileData.sFileName;

                        string str2 = Convert.ToString(struFileData.struStartTime.dwYear) + "-" +
                                      Convert.ToString(struFileData.struStartTime.dwMonth) + "-" +
                                      Convert.ToString(struFileData.struStartTime.dwDay) + " " +
                                      Convert.ToString(struFileData.struStartTime.dwHour) + ":" +
                                      Convert.ToString(struFileData.struStartTime.dwMinute) + ":" +
                                      Convert.ToString(struFileData.struStartTime.dwSecond);

                        string str3 = Convert.ToString(struFileData.struStopTime.dwYear) + "-" +
                                      Convert.ToString(struFileData.struStopTime.dwMonth) + "-" +
                                      Convert.ToString(struFileData.struStopTime.dwDay) + " " +
                                      Convert.ToString(struFileData.struStopTime.dwHour) + ":" +
                                      Convert.ToString(struFileData.struStopTime.dwMinute) + ":" +
                                      Convert.ToString(struFileData.struStopTime.dwSecond);

                        filelist.SetValue(str1, i++);//将查找的录像文件添加到列表中
                        filelist.SetValue(str2, i++);
                        filelist.SetValue(str3, i++);
                    }
                    else if (result == CHCNetSDK.NET_DVR_FILE_NOFIND || result == CHCNetSDK.NET_DVR_NOMOREFILE)
                    {
                        break; //未查找到文件或者查找结束,退出   No file found or no more file found, search is finished
                    }
                    else
                    {
                        break;
                    }
                }

                return(filelist);
            }
        }
Пример #9
0
        private void SearchPlayBackFile()
        {
            int m_lChannel = CurVideo.ChannelNo;

            m_struFileCond.lChannel               = m_lChannel;
            m_struFileCond.dwFileType             = 0xff;
            m_struFileCond.struStartTime.dwYear   = dtStart.Year;
            m_struFileCond.struStartTime.dwMonth  = dtStart.Month;
            m_struFileCond.struStartTime.dwDay    = dtStart.Day;
            m_struFileCond.struStartTime.dwHour   = dtStart.Hour;
            m_struFileCond.struStartTime.dwMinute = dtStart.Minute;
            m_struFileCond.struStartTime.dwSecond = dtStart.Second;

            m_struFileCond.struStopTime.dwYear   = dtEnd.Year;
            m_struFileCond.struStopTime.dwMonth  = dtEnd.Month;
            m_struFileCond.struStopTime.dwDay    = dtEnd.Day;
            m_struFileCond.struStopTime.dwHour   = dtEnd.Hour;
            m_struFileCond.struStopTime.dwMinute = dtEnd.Minute;
            m_struFileCond.struStopTime.dwSecond = dtEnd.Second;

            m_struFileCond.dwUseCardNo  = 0;
            m_struFileCond.dwVolumeNum  = 0;
            m_struFileCond.byFindType   = 0;
            m_struFileCond.byStreamType = 0;

            m_struFileCond.byAudioFile = 0;
            m_struFileCond.dwIsLocked  = 0xff;
            for (int i = 0; i < m_struFileCond.byWorkingDeviceGUID.Length; i++)
            {
                m_struFileCond.byWorkingDeviceGUID[i] = 0;
            }
            byte[] byTemp = new byte[CHCNetSDK.GUID_LEN];
            byTemp = System.Text.Encoding.UTF8.GetBytes("0000000000000000");
            byTemp.CopyTo(m_struFileCond.byWorkingDeviceGUID, 0);

            m_struFileCond.dwUseCardNo = 0;
            byte[] byTemp2 = new byte[CHCNetSDK.CARDNUM_LEN_OUT];
            byTemp2 = System.Text.Encoding.UTF8.GetBytes("");
            byTemp2.CopyTo(m_struFileCond.sCardNumber, 0);
            if (m_struFileCond.dwUseCardNo > 0)
            {
                m_struFileCond.bySpecialFindInfoType = 1;
                m_struFileCond.uSpecialFindInfo.struATMFindInfo.byTransactionType  = 0;
                m_struFileCond.uSpecialFindInfo.struATMFindInfo.dwTransationAmount = byte.Parse("");
            }

            int dwSize        = Marshal.SizeOf(m_struFileCond);
            int m_lFileHandle = CHCNetSDK.NET_DVR_FindFile_V40(m_lUserID, ref m_struFileCond);

            if (m_lFileHandle < 0)
            {
                string strTemp = string.Format("NET_DVR_FindFile_V40 FAIL, ERROR CODE {0}", CHCNetSDK.NET_DVR_GetLastError());
                return;
            }
            //处理查找到的文件
            CHCNetSDK.NET_DVR_FINDDATA_V40 struFileInfo = new CHCNetSDK.NET_DVR_FINDDATA_V40();
            int    lRet = -1;
            string filestarttime = "", fileendtime;

            while (true)
            {
                lRet = CHCNetSDK.NET_DVR_FindNextFile_V40(m_lFileHandle, ref struFileInfo);
                if (lRet == CHCNetSDK.NET_DVR_FILE_SUCCESS)
                {
                    filestarttime = struFileInfo.struStartTime.dwYear.ToString("D4") + "-" + struFileInfo.struStartTime.dwMonth.ToString("D2") + "-" +
                                    struFileInfo.struStartTime.dwDay.ToString("D2") + " " + struFileInfo.struStartTime.dwHour.ToString("D2") + ":" +
                                    struFileInfo.struStartTime.dwMinute.ToString("D2") + ":" + struFileInfo.struStartTime.dwSecond.ToString("D2");
                    fileendtime = struFileInfo.struStopTime.dwYear.ToString("D4") + "-" + struFileInfo.struStopTime.dwMonth.ToString("D2") + "-" +
                                  struFileInfo.struStopTime.dwDay.ToString("D2") + " " + struFileInfo.struStopTime.dwHour.ToString("D2") + ":" +
                                  struFileInfo.struStopTime.dwMinute.ToString("D2") + ":" + struFileInfo.struStopTime.dwSecond.ToString("D2");
                    DateTime         dtfile  = Convert.ToDateTime(filestarttime);
                    DateTime         endfile = Convert.ToDateTime(fileendtime);
                    PlayBackFileInfo pbfi    = new PlayBackFileInfo()
                    {
                        DtStart = dtfile, DtEnd = endfile
                    };
                    ListPlayBackFileTime.Add(pbfi);
                }
                else
                {
                    if (lRet == CHCNetSDK.NET_DVR_ISFINDING)
                    {
                        Thread.Sleep(5);
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            GetPlayBackTime();
            CHCNetSDK.NET_DVR_FindClose_V30(m_lFileHandle);
        }