Beispiel #1
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));
        }
Beispiel #2
0
        public VideoTimePeriodsPacket GetCompletedTimePeriods()
        {
            IndexesPacket[] indexesPackets = FolderManager.GetIndexesPackets(_path);
            var             downloadedTPPs = TimePeriodManager.GetIntersections(indexesPackets, GetVideoTimePeriods()?.TimePeriods);

            return(new VideoTimePeriodsPacket(_loadInfo.Info, downloadedTPPs));
        }
Beispiel #3
0
        public void TestTimePeriodManager_GetIntersections()
        {
            TimePeriodPacket ti1 = new TimePeriodPacket(beginTime.AddMinutes(5), beginTime.AddMinutes(40));

            TimePeriodPacket[] results = TimePeriodManager.GetIntersections(tis.ToArray(), ti1);
            Assert.AreEqual(3, results.Length);
            TimePeriodPacket[] results2 = TimePeriodManager.GetIntersections(new TimePeriodPacket[0], ti1);
            Assert.AreEqual(0, results2.Length);
        }
Beispiel #4
0
        public void TestTimePeriodManager_GetIntersectionsArray()
        {
            List <TimePeriodPacket> tis = new List <TimePeriodPacket>();

            tis.Add(new TimePeriodPacket(beginTime, beginTime.AddMinutes(15)));
            for (int i = 0; i < 40; i++)
            {
                tis.Add(new TimePeriodPacket(tis.Last().EndTime.AddSeconds(1), tis.Last().EndTime.AddMinutes(15)));
            }

            TimePeriodPacket[] results = TimePeriodManager.GetIntersections(tis.ToArray(), new TimePeriodPacket[0]);
            Assert.AreEqual(0, results.Length);
            results = TimePeriodManager.GetIntersections(tis.ToArray(), tis.ToArray());
            Assert.AreEqual(tis.Count, results.Length);
        }