Exemplo n.º 1
0
        public void TestFileManager_GetTimePeriods()
        {
            BaseInfo.AddData_videoId_003_2_20160330();
            DateTime time     = new DateTime(2016, 03, 30);
            string   fileName = Path.Combine(GlobalData.Path, @"videoID_003_2", GlobalProcess.FolderPath(time), $"{GlobalProcess.FileNameFromDate(time)}{GlobalProcess.SimpleIndexesFormat()}");

            Assert.IsNotNull(FileManager.GetTimePeriods(fileName));
            using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                Assert.IsNotNull(FileManager.GetTimePeriods(fileName));
        }
Exemplo n.º 2
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]));
                }
            }
        }