示例#1
0
        private IList <DateTimeRangeArchive> GetArchives(LoadArgs args)
        {
            var begin = DateTime.MinValue;
            var end   = DateTime.MaxValue;

            if (args != null)
            {
                if (args.Begin.HasValue)
                {
                    begin = args.Begin.Value;
                }
                if (args.End.HasValue)
                {
                    end = args.End.Value;
                }
            }

            var folderPath = AppDomain.CurrentDomain.Combine("Trace");

            if (!Directory.Exists(folderPath))
            {
                return(new List <DateTimeRangeArchive>());
            }
            var logs       = Directory.GetFiles(folderPath, "*.log");
            var archiveIds = logs.Select(x => Path.GetFileNameWithoutExtension(new FileInfo(x).Name)).ToList();
            var archives   = ParseArchives(archiveIds).FilterOverlaps(begin, end).ToList();

            return(archives);
        }
示例#2
0
        public async Task <IList <IClientSpan> > Read(LoadArgs args)
        {
            var archives = GetArchives(args);

            var results = new List <IClientSpan>();

            foreach (var archive in archives)
            {
                var filePath  = CreateFilePath(archive.ArchiveId);
                var jsonLines = await _asyncFile.ReadAllLines(filePath).ConfigureAwait(false);

                if (jsonLines != null)
                {
                    foreach (var jsonLine in jsonLines)
                    {
                        var result = jsonLine.FromJson <IList <ClientSpan> >(null);
                        if (result != null)
                        {
                            results.AddRange(result);
                        }
                    }
                }
            }
            return(results);
        }
示例#3
0
        public Task Clear(LoadArgs args)
        {
            var archives = GetArchives(args);

            var tasks = new List <Task>();

            foreach (var archive in archives)
            {
                var filePath = CreateFilePath(archive.ArchiveId);
                tasks.Add(_asyncFile.Delete(filePath));
            }
            return(Task.WhenAll(tasks));
        }