SerializedPathsResult
using System;
using System.Collections.Generic;
using System.Linq;
namespace Relativity.Transfer
{
public sealed class SerializedPathsResult
{
public IList<SerializedBatch> Batches { get; }
public bool LocalPaths { get; }
public TimeSpan Elapsed { get; }
public IEnumerable<ErrorPath> ErrorPaths { get; }
public long MinSourcePathId { get; set; }
public long MaxSoucePathId { get; set; }
public IEnumerable<string> SearchPaths { get; }
public double SearchRateFps => PathEnumeratorHelper.CalculateSearchRateFps(TotalFileCount, Elapsed.TotalSeconds);
public long TotalByteCount { get; }
public long TotalDirectoryCount { get; set; }
public long TotalFileCount { get; }
public SerializedPathsResult(IEnumerable<string> searchPaths, IEnumerable<SerializedBatch> batches, IEnumerable<ErrorPath> errorPaths, bool localPaths, TimeSpan elapsed)
{
if (searchPaths == null)
throw new ArgumentNullException("searchPaths");
if (batches == null)
throw new ArgumentNullException("batches");
if (errorPaths == null)
throw new ArgumentNullException("errorPaths");
SearchPaths = new List<string>(searchPaths);
Elapsed = elapsed;
ErrorPaths = new List<ErrorPath>(errorPaths);
List<SerializedBatch> list = batches.ToList();
LocalPaths = localPaths;
Batches = (from x in list
orderby x.BatchNumber
select x).ToList();
foreach (SerializedBatch batch in Batches) {
batch.TotalBatchCount = list.Count;
}
if (list.Count > 0) {
TotalByteCount = list.Sum((SerializedBatch x) => x.TotalByteCount);
TotalDirectoryCount = list.Sum((SerializedBatch x) => x.TotalDirectoryCount);
TotalFileCount = list.Sum((SerializedBatch x) => x.TotalFileCount);
MinSourcePathId = list.Min((SerializedBatch x) => x.MinSourcePathId);
MaxSoucePathId = list.Max((SerializedBatch x) => x.MaxSourcePathId);
}
}
}
}