public void AddReport(CountReport _report) { lock (this.syncRoot) { List <CountReport> reports = null; if (this.items.TryGetValue(_report.CountFlag, out reports)) { reports.Add(_report); } } }
public CountReport CountArchivedItems() { var stopWatch = new Stopwatch(); stopWatch.Start(); var progressReport = new CountReport() { TotalElapsedTime = stopWatch.Elapsed }; //progressReport.TotalFiles = Directory.EnumerateFiles(Destination, "*.*", SearchOption.AllDirectories) //.Count(fn => !Path.GetFileName(fn).StartsWith(".", StringComparison.InvariantCultureIgnoreCase)); //var filesToCheck = Directory.EnumerateFiles(Destination, "[arc]*.*", SearchOption.AllDirectories); var filesToCheck = Directory.EnumerateFiles(Destination, "*.*", SearchOption.AllDirectories) .Where(fn => !Path.GetFileName(fn).StartsWith(".", StringComparison.InvariantCultureIgnoreCase)); foreach (var fn in filesToCheck) { var fInfo = new FileInfo(fn); if (!Path.GetFileName(fn).StartsWith("[arc]", StringComparison.InvariantCultureIgnoreCase)) { progressReport.SignalNonValidFile(fInfo.Length); continue; } var fileExtension = Path.GetExtension(fn).ToLowerInvariant(); if (ValidImageExtensions.Contains(fileExtension)) { progressReport.SignalImageFile(fInfo.Length); } else if (ValidVideoExtensions.Contains(fileExtension)) { progressReport.SignalVideoFile(fInfo.Length); } else { progressReport.SignalOtherFile(fInfo.Length, fileExtension); } } stopWatch.Stop(); progressReport.TotalElapsedTime = stopWatch.Elapsed; return(progressReport); }