Ejemplo n.º 1
0
        public async void CheckForUpdates(bool online = true)
        {
            try
            {
                DebugLog("Checking for updates...");
                updateSession = new UpdateSession();

                updateSearcher        = updateSession.CreateUpdateSearcher();
                updateSearcher.Online = online;


                DebugLog("Update searcher params are: " + Dump(updateSearcher));



                searchJob_ = updateSearcher.BeginSearch("IsInstalled=0  and IsHidden = 0 and BrowseOnly=0", this, null);
            }
            catch (Exception ex)
            {
                VMManagementTool.Log.Error("WinUpdatesManager.CheckForUpdates", ex.ToString());
                await Task.Yield();

                CheckCompleted?.Invoke(false);
            }
        }
Ejemplo n.º 2
0
        private IResult DownloadUpdates(IUpdateSession3 session, UpdateCollection updates)
        {
            IDownloadJob downloadJob = null;
            try
            {
                var downloader = session.CreateUpdateDownloader();
                downloader.Updates = updates;
                downloader.Priority = DownloadPriority.dpHigh;
                downloader.IsForced = true;
                downloader.ClientApplicationID = AppearanceManager.ApplicationTitle;

                var displayManager = new UpdateDisplayManager(
                    SettingsManager,
                    AppearanceManager,
                    ProgressTextOutputKey,
                    DownloadProgressText,
                    ProgressTitleOutputKey,
                    DownloadProgressTitle,
                    DeferTitleUpdates,
                    DeferTextUpdates);

                if (string.IsNullOrWhiteSpace(ProgressTextOutputKey))
                    displayManager = null;

                if (string.IsNullOrWhiteSpace(InstallProgressText))
                    displayManager = null;

                downloadJob = downloader.BeginDownload(displayManager, displayManager, null);
                while (!downloadJob.IsCompleted)
                {
                    System.Threading.Thread.Sleep(5);
                    Application.Current.DoEvents();

                    if (DialogsManager.CancelRequested)
                    {
                        downloadJob.RequestAbort();
                    }
                }

                var result = downloader.EndDownload(downloadJob);
                LogDownloadResults(updates, result);
                return ConvertToResult(result);

            }
            catch (Exception e)
            {
                return new ExceptionOccurred(e);
            }
            finally
            {
                if (downloadJob != null)
                    downloadJob.CleanUp();
            }
        }
Ejemplo n.º 3
0
        private IResult InstallUpdates(IUpdateSession3 session, UpdateCollection updates)
        {
            IInstallationJob installJob = null;
            try
            {
                SetPreInstallTitle();
                SetPreInstallText();

                var installer = session.CreateUpdateInstaller();
                installer.Updates = updates;
                installer.AllowSourcePrompts = false;
                installer.IsForced = true;
                installer.ClientApplicationID = AppearanceManager.ApplicationTitle;

                var displayManager = new UpdateDisplayManager(
                    SettingsManager,
                    AppearanceManager,
                    ProgressTextOutputKey,
                    InstallProgressText,
                    ProgressTitleOutputKey,
                    InstallProgressTitle,
                    DeferTitleUpdates,
                    DeferTextUpdates);

                if (string.IsNullOrWhiteSpace(ProgressTextOutputKey))
                    displayManager = null;

                if (string.IsNullOrWhiteSpace(InstallProgressText))
                    displayManager = null;

                installJob = installer.BeginInstall(displayManager, displayManager, null);
                SetCreepTimer(displayManager);
                while (!installJob.IsCompleted)
                {
                    System.Threading.Thread.Sleep(5);
                    Application.Current.DoEvents();

                    if (DialogsManager.CancelRequested)
                    {
                        installJob.RequestAbort();
                    }
                }

                var result = installer.EndInstall(installJob);
                SetInstalledUpdatesObject(result, updates);
                LogInstallResult(updates, result);
                return ConvertToResult(result, updates);
            }
            catch (Exception e)
            {
                return new ExceptionOccurred(e);
            }
            finally
            {
                if (installJob != null)
                    installJob.CleanUp();

                ClearCreepTimer();
            }
        }
 public WindowsUpdateClient(UpdateServer updateServerSelection, IUpdateSession3 session)
 {
     this.session = session;
     this.UpdateServerSelection = updateServerSelection;
 }