/// <summary> /// Report download progress through the database if necessary. /// </summary> /// <param name="innerState"> /// The inner State. /// </param> private void ReportProgress(InnerState innerState) { long now = PolicyExtensions.GetCurrentMilliseconds(); if (innerState.BytesSoFar - innerState.BytesNotified > DownloaderService.MinimumProgressStep && now - innerState.TimeLastNotification > DownloaderService.MinimumProgressTime) { // we store progress updates to the database here this.downloadInfo.CurrentBytes = innerState.BytesSoFar; DownloadsDatabase.UpdateDownloadCurrentBytes(this.downloadInfo); innerState.BytesNotified = innerState.BytesSoFar; innerState.TimeLastNotification = now; long totalBytesSoFar = innerState.BytesThisSession + this.downloaderService.BytesSoFar; Debug.WriteLine( "DownloadThread : downloaded {0} out of {1}", this.downloadInfo.CurrentBytes, this.downloadInfo.TotalBytes); Debug.WriteLine( "DownloadThread : total {0} out of {1}", totalBytesSoFar, this.downloaderService.TotalLength); this.downloaderService.NotifyUpdateBytes(totalBytesSoFar); } }
/// <summary> /// The update download database. /// </summary> /// <param name="status"> /// The status. /// </param> /// <param name="countRetry"> /// The count retry. /// </param> /// <param name="retryAfter"> /// The retry after. /// </param> /// <param name="redirectCount"> /// The redirect count. /// </param> /// <param name="gotData"> /// The got data. /// </param> private void UpdateDownloadDatabase( ExpansionDownloadStatus status, bool countRetry, int retryAfter, int redirectCount, bool gotData) { this.downloadInfo.Status = status; this.downloadInfo.RetryAfter = retryAfter; this.downloadInfo.RedirectCount = redirectCount; this.downloadInfo.LastModified = PolicyExtensions.GetCurrentMilliseconds(); if (!countRetry) { this.downloadInfo.FailedCount = 0; } else if (gotData) { this.downloadInfo.FailedCount = 1; } else { this.downloadInfo.FailedCount++; } DownloadsDatabase.UpdateDownload(this.downloadInfo); }