Exemplo n.º 1
0
        private async Task FindAllDownloadsAsync()
        {
            activeDownloads = new List <DownloadOperation>();
            IReadOnlyList <DownloadOperation> downloads = null;

            try
            {
                downloads = await BackgroundDownloader.GetCurrentDownloadsAsync();
            }
            catch (Exception ex)
            {
                if (!IsExceptionHandled("Discovery error", ex))
                {
                    ACDEBUG.Print(ex.Message);
                }
                return;
            }

            if (downloads.Count > 0)
            {
                List <Task> tasks = new List <Task>();
                foreach (var download in downloads)
                {
                    this.activeDownloads.Add(download);
                    tasks.Add(HandleDownload(download, false));
                }
                UpdateDownloadData();

                await Task.WhenAll(tasks);
            }
        }
Exemplo n.º 2
0
 private void AddMainBanner()
 {
     try
     {
         if (_dic.Count <= 0)
         {
             return;
         }
         MainPageFunc.BannerFunc(MainFlipView, _dic["轮播图"].Contents);
     }
     catch (Exception ex)
     {
         ACDEBUG.Print(ex.Message);
     }
 }
Exemplo n.º 3
0
        private void DownloadProgress(DownloadOperation download)
        {
            BackgroundDownloadProgress currentProgress = download.Progress;

            double percent = 100;

            if (currentProgress.TotalBytesToReceive > 0)
            {
                percent = currentProgress.BytesReceived * 100 / currentProgress.TotalBytesToReceive;
                Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    ParseProgress();
                });
                ACDEBUG.Print("下载:" + percent);
            }
        }
Exemplo n.º 4
0
        private async void AddToday()
        {
            try
            {
                if (_dic.Count <= 0)
                {
                    return;
                }
                _dic["活动banner"] = await GetSingleDicData("活动banner");

                TodyImg.Source = new BitmapImage(new Uri(_dic["活动banner"].Contents[0].Cover));
            }
            catch (Exception ex)
            {
                ACDEBUG.Print(ex.Message);
            }
        }
Exemplo n.º 5
0
        private async void AddSpecailImg()
        {
            try
            {
                if (_dic.Count <= 0)
                {
                    return;
                }
                _dic["二次元日历"] = await GetSingleDicData("二次元日历");

                CalendarImg.Source = new BitmapImage(new Uri(_dic["二次元日历"].Contents[0].Cover));
            }
            catch (Exception ex)
            {
                ACDEBUG.Print(ex.Message);
            }
        }
Exemplo n.º 6
0
        private bool IsExceptionHandled(string title, Exception ex, DownloadOperation download = null)
        {
            WebErrorStatus error = BackgroundTransferError.GetStatus(ex.HResult);

            if (error == WebErrorStatus.Unknown)
            {
                return(false);
            }

            if (download == null)
            {
                ACDEBUG.Print(String.Format(CultureInfo.CurrentCulture, "Error: {0}: {1}", title, error));
            }
            else
            {
                ACDEBUG.Print(String.Format(CultureInfo.CurrentCulture, "Error: {0} - {1}: {2}", download.Guid, title,
                                            error));
            }

            return(true);
        }