protected virtual IEnumerable <string> GetSuitableFiles(Logger logger, ActivityFilter filter) { string[] files = GetFilesForLogger(logger); int[] suitableItems = FilterFileNames(files, filter); if (!suitableItems.Any()) { return(Enumerable.Empty <string>()); } int firstItemIndex = suitableItems.Min(x => x); int lastItemIndex = suitableItems.Max(x => x) + 1; var filesList = new List <string>(); if (!filter.DateRange.StartDate.HasValue) { filesList.Add(files[firstItemIndex]); } else { filesList.AddRange(files.Skip(firstItemIndex).Take(lastItemIndex - firstItemIndex + 1)); } return(filesList); }
public void ClearBy(ActivityFilter filter) { var logger = GetLogger(filter.Type); CloseAppendersFor(logger); _log4NetFileRepository.RemoveFilesFor(logger); }
private static int[] FilterFileNames(IEnumerable <string> files, ActivityFilter filter) { return(files.Select((x, i) => new { Item = x, Index = i }) .Where(x => filter.DateRange.IsInRangeIncludingEndDate(ActivityLogFile.GetDate(x.Item))) .Select(x => x.Index) .ToArray()); }
public virtual ActivityDto GetBy(ActivityFilter filter) { var logger = GetLogger(filter.Type); var records = _log4NetFileRepository.GetActivityRecordsFor(logger, filter); return new ActivityDto { Type = filter.Type, Records = records .Reverse() .ToList() }; }
public virtual ActivityDto GetBy(ActivityFilter filter) { var logger = GetLogger(filter.Type); var records = _log4NetFileRepository.GetActivityRecordsFor(logger, filter); return(new ActivityDto { Type = filter.Type, Records = records .Reverse() .ToList() }); }
protected virtual IEnumerable <ActivityLogRecord> GetRecordsFromFile(ActivityFilter filter, string file) { return(GetFromLog(file, Enumerable.Empty <ActivityLogRecord>(), (csvReader, defaultValue) => { var records = new List <ActivityLogRecord>(); while (csvReader.Read()) { ActivityLogRecord record = GetActivityRecord(csvReader); if (filter.DateRange.IsInRangeIncludingEndDate(record.DateTime)) { records.Add(record); } } return records; })); }
public override IEnumerable<ActivityLogRecord> GetActivityRecordsFor(Logger logger, ActivityFilter filter) { var filesList = GetSuitableFiles(logger, filter); var result = new List<ActivityLogRecord>(); var store = GetCurrentStorage(logger); foreach (var file in filesList) { result.AddRange(store.Where(x => x.FileName == file).SelectMany(x => x.ActivityDto.Records)); } return result; }
public virtual IEnumerable <ActivityLogRecord> GetActivityRecordsFor(Logger logger, ActivityFilter filter) { IEnumerable <string> filesList = GetSuitableFiles(logger, filter); var result = new List <ActivityLogRecord>(); foreach (string file in filesList) { result.AddRange(GetRecordsFromFile(filter, file)); } return(result); }
public void ClearBy(ActivityFilter filter) { }
public ActivityDto GetBy(ActivityFilter filter) { return(_activityDto); }