public void AddProgress(TransferProgressTracker progressTracker) { this.AddBytesTransferred(progressTracker.BytesTransferred); this.AddNumberOfFilesFailed(progressTracker.NumberOfFilesFailed); this.AddNumberOfFilesSkipped(progressTracker.NumberOfFilesSkipped); this.AddNumberOfFilesTransferred(progressTracker.NumberOfFilesTransferred); }
/// <summary> /// Initializes a new instance of the <see cref="TransferProgressTracker" /> class. /// </summary> private TransferProgressTracker(TransferProgressTracker other) { this.bytesTransferred = other.BytesTransferred; this.numberOfFilesTransferred = other.NumberOfFilesTransferred; this.numberOfFilesSkipped = other.NumberOfFilesSkipped; this.numberOfFilesFailed = other.NumberOfFilesFailed; }
private void OnSerializingCallback(StreamingContext context) { if (!IsStreamJournal) { this.progressTracker = this.ProgressTracker; } }
/// <summary> /// Initializes a new instance of the <see cref="TransferProgressTracker" /> class. /// </summary> private TransferProgressTracker(TransferProgressTracker other) { this.bytesTransferred = other.bytesTransferred; this.numberOfFilesTransferred = other.numberOfFilesTransferred; this.numberOfFilesSkipped = other.numberOfFilesSkipped; this.numberOfFilesFailed = other.numberOfFilesFailed; }
private void OnDeserializedCallback(StreamingContext context) { // DCS doesn't invoke ctors, so all initialization must be done here transfers = new ConcurrentDictionary <TransferKey, Transfer>(); overallProgressTracker = new TransferProgressTracker(); foreach (Transfer t in serializedTransfers) { this.AddTransfer(t); } foreach (Transfer transfer in this.transfers.Values) { this.OverallProgressTracker.AddProgress(transfer.ProgressTracker); } }
public IEnumerable <SingleObjectTransfer> ListSubTransfers() { long currentOffset = this.usedChunkHead; bool shouldBreak = false; while (true) { SingleObjectTransfer transfer = null; lock (this.journalLock) { if (0 == this.usedChunkHead) { shouldBreak = true; } else { this.stream.Position = currentOffset; long previousUsedChunk = this.ReadLong(); long nextUsedChunk = this.ReadLong(); if (0 == previousUsedChunk) { if (this.usedChunkHead != currentOffset) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } } else { if (this.usedChunkHead == currentOffset) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } } try { #if BINARY_SERIALIZATION transfer = this.formatter.Deserialize(this.stream) as SingleObjectTransfer; #else transfer = this.ReadObject(this.transferSerializer) as SingleObjectTransfer; if (transfer.Source is FileLocation) { (transfer.Source as FileLocation).SetDirectoryPath(this.DirectoryPath); } else if (transfer.Destination is FileLocation) { (transfer.Destination as FileLocation).SetDirectoryPath(this.DirectoryPath); } #endif } catch (Exception) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } if (null == transfer) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } transfer.StreamJournalOffset = currentOffset + 2 * sizeof(long); transfer.Journal = this; this.stream.Position = transfer.StreamJournalOffset + TransferItemContentSize; TransferProgressTracker progressTracker = null; try { #if BINARY_SERIALIZATION progressTracker = this.formatter.Deserialize(this.stream) as TransferProgressTracker; #else progressTracker = this.ReadObject(this.progressCheckerSerializer) as TransferProgressTracker; #endif } catch (Exception) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } if (null == progressTracker) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } transfer.ProgressTracker.AddProgress(progressTracker); transfer.ProgressTracker.StreamJournalOffset = transfer.StreamJournalOffset + TransferItemContentSize; transfer.ProgressTracker.Journal = this; if (0 == nextUsedChunk) { if (this.usedChunkTail != currentOffset) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } shouldBreak = true; } else { if (this.usedChunkTail == currentOffset) { #if !NO_FILEFORMAT_EX throw new FileFormatException(Resources.RestartableLogCorrupted); #else throw new InvalidOperationException(Resources.RestartableLogCorrupted); #endif } } currentOffset = nextUsedChunk; } } if (null != transfer) { yield return(transfer); } if (shouldBreak) { yield break; } } }