/// <summary>
        /// Discovers Current and Completed Downloads.
        /// </summary>
        public async Task DiscoverDownloadsAsync()
        {
            CurrentDownloads.Clear();
            CompletedDownloads.Clear();
            var currentDownloads = await _downloader.DiscoverBackgroundDownloadsAsync();

            foreach (var download in currentDownloads)
            {
                var status = download.Progress.Status;
                if (status == BackgroundTransferStatus.Canceled)
                {
                    continue;
                }

                var appDownloadItem = GetAppDownloadItem(download);
                appDownloadItem.Tag = download;

                if (status == BackgroundTransferStatus.Completed)
                {
                    CompletedDownloads.Add(appDownloadItem);
                }
                else
                {
                    CurrentDownloads.Add(appDownloadItem);
                }
            }
        }
Esempio n. 2
0
 private void SetTileDownloading(TileSpecifier specifier)
 {
     lock (CurrentDownloads)
     {
         CurrentDownloads.Add(specifier);
     }
 }
        public async Task StartDownloadAsync(AppDownloadItem appDownloadItem)
        {
            await InitializeAsync();

            if (FindAppInCurrentDownloads(appDownloadItem.AppGuid) != null)
            {
                return;
            }

            // Start Download
            CurrentDownloads.Add(appDownloadItem);
            appDownloadItem.StorageFile = await CurrentApplication.AppDownloadFolder.CreateFileAsync(
                $"{appDownloadItem.AppGuid}.pstl",
                CreationCollisionOption.ReplaceExisting);

            var downloadOperation = await _downloader.StartDownloadAsync(
                ServerUri.GetAppDownloadUri(appDownloadItem.AppGuid),
                appDownloadItem.StorageFile);

            appDownloadItem.StartDate    = DateTime.Now;
            appDownloadItem.DownloadGuid = downloadOperation.Guid;
            appDownloadItem.Tag          = downloadOperation;

            // update collections
            _downloadsHistory.Add(appDownloadItem);
            await SaveDownloadsHistoryToFileAsync();
        }
Esempio n. 4
0
        public static MapsetDownload Download(int id)
        {
            // Require login in order to download.
            if (!OnlineManager.Connected)
            {
                NotificationManager.Show(NotificationLevel.Error, "You must be logged in to download mapsets!");
                return(null);
            }

            if (CurrentDownloads.Count >= MAX_CONCURRENT_DOWNLOADS)
            {
                NotificationManager.Show(NotificationLevel.Error, $"Slow down! You can only download {MAX_CONCURRENT_DOWNLOADS} at a time!");
                return(null);
            }

            var download = new MapsetDownload(id);

            CurrentDownloads.Add(download);

            return(download);
        }