Beispiel #1
0
        public UpdateTask(IAppParser appParser, IAppIndexer indexer, IUpdateNotifier notifier,
            IKernel kernel, ProgramSettings settings)
            : base(settings) {
            this.appParser = appParser;
            this.indexer = indexer;
            this.notifier = notifier;
            this.kernel = kernel;

            limit = settings.BatchSize / 200 * 200; // 因为Search API是200一批,找个最接近的200的倍数,以免浪费
        }
Beispiel #2
0
        public void Download(IUpdateNotifier updateNotifier)
        {
            lock (_LockObject)
            {
                _UpdateNotifier = updateNotifier;

                log.Debug("Determining if '" + DestinationName + "' requires downloading...");
                if (RequiresDownload())
                {
                    log.Info("Downloading '" + DestinationName + "'...");

                    // Setup a web client to download the latest
                    // version of this file
                    _WebClient = new WebClient();

                    if (Username != null &&
                        Password != null)
                    {
                        _WebClient.Credentials = new NetworkCredential(Username, Password, Domain);
                    }

                    _WebClient.DownloadDataCompleted   += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
                    _WebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);

                    // Notify that an update is about to begin!
                    if (_UpdateNotifier != null)
                    {
                        _UpdateNotifier.BeginFileDownload(DownloadUri, Size);
                    }

                    // Download the file!
                    _WebClient.DownloadDataAsync(DownloadUri);

                    // Start the timeout timer
                    StartTimer();
                }
                else
                {
                    log.Debug("No download required.");

                    // NOTE: partial fix for bug #2021741 - Application Hangs
                    // ======================================================
                    // Ensure our download data is null.
                    // Fixes a bug where the object is attempted to be saved,
                    // even though it doesn't need to be.
                    DownloadData = null;

                    // Notify that the file has effectively finished downloading,
                    // and is saved
                    OnCompleted();
                    OnSaved();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Tries to determine an update notifier via the configuration file.
        /// </summary>
        static private void EnsureUpdateNotifier()
        {
            DDayUpdateConfigurationSection cfg = ConfigurationManager.GetSection("DDay.Update")
                                                 as DDayUpdateConfigurationSection;

            // Determine the update notifier that will be used to handle
            // update GUI display.
            if (cfg != null)
            {
                _UpdateNotifier = cfg.UpdateNotifier;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Tries to determine an update notifier via the configuration file.
        /// </summary>
        static private void EnsureUpdateNotifier()
        {
            DDayUpdateConfigurationSection cfg = ConfigurationManager.GetSection("DDay.Update")
                as DDayUpdateConfigurationSection;

            // Determine the update notifier that will be used to handle
            // update GUI display.
            if (cfg != null)
            {
                _UpdateNotifier = cfg.UpdateNotifier;
            }
        }
Beispiel #5
0
        public void Download(IUpdateNotifier updateNotifier)
        {
            lock (_LockObject)
            {
                _UpdateNotifier = updateNotifier;

                log.Debug("Determining if '" + DestinationName + "' requires downloading...");
                if (RequiresDownload())
                {
                    log.Info("Downloading '" + DestinationName + "'...");

                    // Setup a web client to download the latest
                    // version of this file
                    _WebClient = new WebClient();

                    if (Username != null &&
                        Password != null)
                        _WebClient.Credentials = new NetworkCredential(Username, Password, Domain);

                    _WebClient.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
                    _WebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);

                    // Notify that an update is about to begin!
                    if (_UpdateNotifier != null)
                        _UpdateNotifier.BeginFileDownload(DownloadUri, Size);

                    // Download the file!
                    _WebClient.DownloadDataAsync(DownloadUri);

                    // Start the timeout timer
                    StartTimer();
                }
                else
                {
                    log.Debug("No download required.");
                                        
                    // NOTE: partial fix for bug #2021741 - Application Hangs
                    // ======================================================                    
                    // Ensure our download data is null.
                    // Fixes a bug where the object is attempted to be saved,
                    // even though it doesn't need to be.
                    DownloadData = null;
                    
                    // Notify that the file has effectively finished downloading,
                    // and is saved
                    OnCompleted();
                    OnSaved();
                }
            }
        }