private string EstimateTotalTimeRemaining( NotificationDetails last, double rate) { var bytesRemaining = last.TotalBytes - last.TotalBytesTransferred; var secondsRemaining = (int)Math.Round(bytesRemaining / rate); return(HumanReadableTimeFor(secondsRemaining)); }
public void NotifyOverall( NotificationDetails details ) { if (string.IsNullOrWhiteSpace(details.Label)) { return; } var s = details.TotalItems == 1 ? "" : "s"; if (details.IsStarting && !_notifiedStart) { _notifiedStart = true; _messageWriter.Write(details.Label); _messageWriter.Write( $@"Overall transfer: { details.TotalItems } file{ s }, { HumanReadableSizeFor( details.TotalBytes ) }"); _started = DateTime.Now; } else if (details.IsComplete && _started != null) { var timeTaken = DateTime.Now - _started.Value; _messageWriter.Write(details.Label); _messageWriter.Write( $@"Transferred { details.TotalItems } file{ s }, { HumanReadableSizeFor(details.TotalBytes) }, { HumanReadableTimeFor((int) timeTaken.TotalSeconds) }, avg { HumanReadableRateFor( details.TotalBytes / timeTaken.TotalSeconds ) }"); _started = null; } }
public void NotifyCurrent( NotificationDetails details) { var label = details.Label ?? "(unknown)"; var isStart = details.CurrentBytesTransferred == 0; var isEnd = details.CurrentBytesTransferred == details.CurrentTotalBytes; if (isStart) { NotifyStart(label); } else if (isEnd) { NotifyComplete(label); } else { ReportIntermediateState(details); } }
protected override void ReportIntermediateState( NotificationDetails details) { _notificationDetailHistory.Enqueue(details); if (_notificationDetailHistory.Count > HISTORY_SIZE) { _notificationDetailHistory.Dequeue(); } if (ShouldWaitToOutput()) { return; } var last = _notificationDetailHistory.Last(); var rate = EstimateRate(); var itemEtr = EstimateItemTimeRemaining(last, rate); var totalEtr = EstimateTotalTimeRemaining(last, rate); var readableRate = HumanReadableRateFor(rate); Rewrite( details.Label, string.Join(" · ", new[] { readableRate, itemEtr, totalEtr, BrailleProgressBarGenerator.CompositeProgressBarFor( details.CurrentPercentageCompleteBySize, details.TotalPercentageCompleteBySize ) + " " }.Where(s => s != "") ) ); }
protected virtual void ReportIntermediateState( NotificationDetails details) { // intentionally left blank - this reporter is quiet }
public void NotifyError(NotificationDetails details) { Write(details.Label, FAIL); Write(details.Exception.Message, ""); Write(details.Exception.StackTrace, ""); }