Esempio n. 1
0
        public void TestTimePeriodManager_Combine_Continuous()//测试连续情况
        {
            var combine = TimePeriodManager.Combine(tis.ToArray());

            Assert.AreEqual(1, combine.Length);
            assertEqual(new TimePeriodPacket(tis.First().BeginTime, tis.Last().EndTime), combine[0]);
        }
Esempio n. 2
0
        public VideoTimePeriodsPacket Search(DateTime beginTime, DateTime endTime, IVideoInfo videoInfo)
        {
            string path = GlobalData.VideoPath(videoInfo.VideoId, videoInfo.StreamId);

            DateTime[] dates            = VideoStoragerManager.GetFolderPaths(videoInfo.VideoId, videoInfo.StreamId, beginTime, endTime);
            List <TimePeriodPacket> tis = new List <TimePeriodPacket>();

            Parallel.ForEach(dates, date =>
            {
                string folder = Path.Combine(path, GlobalProcess.FolderPath(date));
                var array     = FolderManager.GetTimePeriods(folder);
                if (array.Length > 0)
                {
                    lock (tis)
                        tis.AddRange(array);
                }
            });
            if (endTime > DateTime.Now.Date)
            {
                tis.AddRange(findTodayLastest(path, endTime));
            }
            var timeCombines = TimePeriodManager.Combine(tis.ToArray());
            var validArray   = TimePeriodManager.GetIntersections(timeCombines, new TimePeriodPacket(beginTime, endTime));

            return(new VideoTimePeriodsPacket(videoInfo, validArray));
        }
Esempio n. 3
0
        public void TestTimePeriodManager_Combine_Segmentation()//测试被分段情况
        {
            tis.RemoveAt(10);
            tis.RemoveAt(20);
            var combine = TimePeriodManager.Combine(tis.ToArray());

            Assert.AreEqual(3, combine.Length);
            assertEqual(new TimePeriodPacket(beginTime, tis[9].EndTime), combine[0]);
            assertEqual(new TimePeriodPacket(tis[10].BeginTime, tis[19].EndTime), combine[1]);
            assertEqual(new TimePeriodPacket(tis[20].BeginTime, tis.Last().EndTime), combine[2]);
        }
Esempio n. 4
0
        TimePeriodPacket[] findTodayLastest(string path, DateTime end)
        {
            string folder = Path.Combine(path, GlobalProcess.FolderPath(DateTime.Now));
            var    array  = FolderManager.GetIndexesFiles(folder);

            if (array.Length > 0)
            {
                string file    = array.Max();
                var    packets = FileManager.GetIndexesPackets(file);
                return(TimePeriodManager.Combine(packets));
            }
            return(new TimePeriodPacket[0]);
        }
Esempio n. 5
0
 private void loadRecorder()
 {
     if (_baseRec.TimePeriods != null)
     {
         try
         {
             IndexesPacket[] indexesPackets = FolderManager.GetIndexesPackets(Path);
             var             downloadedTPPs = TimePeriodManager.Combine(indexesPackets);
             initRecorder(_baseRec.TimePeriods.TimePeriods, downloadedTPPs);
         }
         catch (Exception ex) { Console.WriteLine(ex); }
     }
 }
Esempio n. 6
0
 private static TimePeriodPacket[] getMissingTIs(TimePeriodPacket[] tisAll, TimePeriodPacket[] tisCompleted)
 {
     if (tisAll == null || tisAll.Length == 0)
     {
         return(new TimePeriodPacket[0]);
     }
     TimePeriodPacket[] subs = TimePeriodManager.Combine(tisAll);
     if (tisCompleted != null && tisCompleted.Length > 0)
     {
         tisCompleted = TimePeriodManager.Combine(tisCompleted);
         for (int i = 0; i < tisCompleted.Length; i++)
         {
             subs = TimePeriodManager.Subtracts(subs, tisCompleted[i]);
         }
     }
     return(subs);
 }
Esempio n. 7
0
        protected override void updateShortIndexes(TimePeriodPacket newTi)
        {
            List <TimePeriodPacket> shortIndexes = new List <TimePeriodPacket>();

            shortIndexes.Add(newTi);
            string simpleIndexesName = $"{GlobalProcess.FileNameFromDate(_fileStartTime)}{GlobalProcess.SimpleIndexesFormat()}";
            string fileName          = Path.Combine(_curFolder, simpleIndexesName);
            var    indexesDatas      = FileManager.GetTimePeriods(fileName);

            if (indexesDatas != null)
            {
                shortIndexes.AddRange(indexesDatas);
            }
            var newArray = TimePeriodManager.Combine(shortIndexes.ToArray());

            using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Read))
            {
                for (int i = 0; i < newArray.Length; i++)
                {
                    writeBuffer(fs, TimePeriodPacket.Encode(newArray[i]));
                }
            }
        }
Esempio n. 8
0
 public void TestTimePeriodManager_Combine_Empty()
 {
     Assert.AreEqual(0, TimePeriodManager.Combine(null).Length);
     Assert.AreEqual(0, TimePeriodManager.Combine(new TimePeriodPacket[0]).Length);
 }
Esempio n. 9
0
 private void updateDownloaded(TimePeriodPacket tpp)
 {
     _downloadedTimePeriods.Add(tpp);
     _downloadedTimePeriods = TimePeriodManager.Combine(_downloadedTimePeriods.ToArray()).ToList();
 }