コード例 #1
0
        private void GetEditionListCallBack(object state)
        {
            try
            {
                HasJob = false;

                while (Editions.Count > 0)
                {
                    EditionInfoViewModel editionInfoViewModel = Editions[0];
                    editionInfoViewModel.PropertyChanged -= EditionInfoViewModelPropertyChanged;
                    Editions.Remove(editionInfoViewModel);
                }

                foreach (EditionInfoWithBlock editionInfoWithBlock in DownloadManager.GetEditionList(DownloadManager.BaseEditionUrl).Where(s => !s.Edition.Completed))
                {
                    EditionInfoViewModel editionInfoViewModel = new EditionInfoViewModel(DownloadManager.BaseEditionUrl, editionInfoWithBlock);
                    editionInfoViewModel.PropertyChanged += EditionInfoViewModelPropertyChanged;
                    Editions.Add(editionInfoViewModel);
                }
                if (Editions.Count == 0)
                {
                    SetMessage("Not any new edition");
                }
            }
            catch (Exception ex)
            {
                SetMessage(ex.Message);
            }
            JobFinished();
        }
コード例 #2
0
        private void FeedEditionsCallBack(object state)
        {
            DownloadReporter.Reset();
            _downloadManagerEdition           = new DownloadManagerEdition(DownloadManager, DownloadReporter);
            _downloadManagerEdition.Finished += DownloadManagerEditionFinished;
            _downloadManagerEdition.Error    += DownloadManagerEditionError;

            foreach (EditionInfoViewModel editionInfoViewModel in Editions.Where(s => s.Active))
            {
                Interlocked.Increment(ref CountDown);
                string[] cardInfos = DownloadManager.GetCardUrls(editionInfoViewModel.Url);

                editionInfoViewModel.DownloadReporter.Total = cardInfos.Length;
                DownloadReporter.Total += cardInfos.Length;

                EditionInfoViewModel model = editionInfoViewModel;
                if (model.CardNumber.HasValue)
                {
                    if (cardInfos.Length != model.CardNumber.Value)
                    {
                        AppendMessage(string.Format("{0}: {1} urls while cardnumber is set to {2}", model.Name, cardInfos.Length, model.CardNumber.Value), false);
                    }
                }

                _downloadManagerEdition.AddRange(cardInfos.Select(s => WebAccess.ToAbsoluteUrl(model.Url, s)), model.EditionId, model.DownloadReporter);
            }

            _downloadManagerEdition.Start();
        }