Exemple #1
0
        private void FrmPrerequisiteSubscribers_Shown(object sender, EventArgs e)
        {
            Logger.EnteringMethod();
            this.Cursor = Cursors.WaitCursor;

            if (updateToDelete != null)
            {
                dgvUpdates.Rows.Clear();
                WsusWrapper wsus  = WsusWrapper.GetInstance();
                UpdateScope scope = new UpdateScope();
                scope.UpdateSources = UpdateSources.All;
                UpdateCollection allUpdates = wsus.GetAllUpdates(scope);

                foreach (IUpdate update in allUpdates)
                {
                    if (update.IsEditable)
                    {
                        SoftwareDistributionPackage sdp = wsus.GetMetaData(update);
                        if (sdp != null)
                        {
                            IList <PrerequisiteGroup> prerequisites = sdp.Prerequisites;

                            if (wsus.PrerequisitePresent(prerequisites, updateToDelete.Id.UpdateId))
                            {
                                Logger.Write("adding update : " + update.Title);
                                AddRow(update);
                            }
                        }
                    }
                }
            }
            this.Cursor = Cursors.Default;
        }
Exemple #2
0
        public WSUS()
        {
            // I use impersonation to use other logon than mine. Remove the following "using" if not needed
            using (Impersonation.LogonUser("mydomain.local", "admin_account_wsus", "Password", LogonType.Batch))
            {
                ComputerTargetScope      scope   = new ComputerTargetScope();
                IUpdateServer            server  = AdminProxy.GetUpdateServer("wsus_server.mydomain.local", false, 80);
                ComputerTargetCollection targets = server.GetComputerTargets(scope);
                // Search
                targets = server.SearchComputerTargets("any_server_name_or_ip");

                // To get only on server FindTarget method
                IComputerTarget target = FindTarget(targets, "any_server_name_or_ip");
                Console.WriteLine(target.FullDomainName);
                IUpdateSummary summary      = target.GetUpdateInstallationSummary();
                UpdateScope    _updateScope = new UpdateScope();
                // See in UpdateInstallationStates all other properties criteria
                _updateScope.IncludedInstallationStates = UpdateInstallationStates.Downloaded;
                UpdateInstallationInfoCollection updatesInfo = target.GetUpdateInstallationInfoPerUpdate(_updateScope);

                int updateCount = updatesInfo.Count;

                foreach (IUpdateInstallationInfo updateInfo in updatesInfo)
                {
                    Console.WriteLine(updateInfo.GetUpdate().Title);
                }
            }
        }
Exemple #3
0
 /// <summary>
 ///     Requests a Animat Studio Update.
 /// </summary>
 /// <param name="scope">Scope of the update; default value is UpdateScope.All</param>
 public void RequestUpdate(UpdateScope scope = UpdateScope.All)
 {
     if (onUpdateRequest != null)
     {
         onUpdateRequest(this, new UpdateEventArgs(scope));
     }
 }
Exemple #4
0
        /// <summary>
        /// Checks a classification for needed updates
        /// </summary>
        /// <param name="server">
        /// Object representing the WSUS server
        /// </param>
        /// <param name="classification">
        /// a single update classification
        /// </param>
        /// <param name="rootGroup">
        /// the "all computers" group
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        /// <param name="alreadyProcessed">
        /// List of target groups that have already been processed
        /// </param>
        private static void CheckClassification(
            IUpdateServer server,
            IUpdateClassification classification,
            IComputerTargetGroup rootGroup,
            bool isTest,
            List <IComputerTargetGroup> alreadyProcessed)
        {
            Console.Out.WriteLine("Getting list of updates for : " + classification.Title);

            var searchScope = new UpdateScope {
                IncludedInstallationStates = UpdateInstallationStates.NotInstalled
            };

            searchScope.Classifications.Add(classification);
            UpdateCollection updates = server.GetUpdates(searchScope);

            if (updates.Count > 0)
            {
                DoClassificationUpdates(updates, rootGroup, isTest, alreadyProcessed);
            }
            else
            {
                Console.Out.WriteLine(" No updates required.");
            }
        }
Exemple #5
0
 /// <summary>
 /// Request UI to be updated.
 /// </summary>
 public static void RequestUiUpdate(UpdateScope scope)
 {
     if (requestUiUpdate != null)
     {
         requestUiUpdate(instance, new UpdatedEventArgs {
             Scope = scope
         });
     }
 }
Exemple #6
0
        /// <summary>
        /// checks for superseded updates and approves the new revision
        /// </summary>
        /// <param name="server">
        /// The WSUS Server
        /// </param>
        /// <param name="approveLicenseAgreement">
        /// Whether to approve any license agreement
        /// </param>
        /// <param name="computerTargetGroup">
        /// The target group to check
        /// </param>
        /// <param name="classification">
        /// Classification to process
        /// </param>
        /// <param name="products">
        /// Collection of products to process
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        /// <param name="shouldApproveUninstalledSupersededUpdate">
        /// The should Approve Uninstalled Superseded Update.
        /// </param>
        private static void CheckSupersededUpdates(
            IUpdateServer server,
            bool approveLicenseAgreement,
            IComputerTargetGroup computerTargetGroup,
            IUpdateClassification classification,
            UpdateCategoryCollection products,
            bool isTest,
            bool shouldApproveUninstalledSupersededUpdate)
        {
            var searchScope = new UpdateScope {
                ApprovedStates = ApprovedStates.HasStaleUpdateApprovals
            };

            if (computerTargetGroup != null)
            {
                searchScope.ApprovedComputerTargetGroups.Add(computerTargetGroup);
            }

            if (classification != null)
            {
                searchScope.Classifications.Add(classification);
            }

            if (products != null)
            {
                searchScope.Categories.AddRange(products);
            }

            UpdateCollection updates = server.GetUpdates(searchScope);

            if (updates.Count <= 0)
            {
                return;
            }

            var recentlyApproved = new List <Guid>();

            if (updates.Count == 0)
            {
                Console.Out.WriteLine(" No updates required.");
                return;
            }

            foreach (IUpdate update in updates)
            {
                if (update.IsSuperseded)
                {
                    CheckSupersededUpdate(
                        update,
                        approveLicenseAgreement,
                        isTest,
                        recentlyApproved,
                        shouldApproveUninstalledSupersededUpdate);
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Resuest update of a specifiv UI component with a message
 /// containing informationg about updating.
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="target"></param>
 /// <param name="message"></param>
 public void RequestUpdate(UpdateScope scope, Guid target, Object message)
 {
     if (onUpdateRequest != null)
     {
         onUpdateRequest(this, new UpdateEventArgs(scope)
         {
             Target = target, UpdateMessage = message
         });
     }
 }
Exemple #8
0
        public Controller(DiagramView view, FlowchartModel model)
        {
            _view  = view;
            _model = model;
            _model.Nodes.CollectionChanged += NodesCollectionChanged;
            _model.Links.CollectionChanged += LinksCollectionChanged;
            _updateScope = new UpdateScope(this);

            foreach (var t in _model.Nodes)
            {
                t.PropertyChanged += NodePropertyChanged;
            }

            UpdateView();
        }
Exemple #9
0
        public static List <string> GetWSUSlist(params string[] list)
        {
            List <string> result = new List <string>(200); //не забудь изменить количество

            string namehost   = list[0];                   //имя Пк, на котором будем искать string  = "example1";
            string servername = list[1];                   //имя сервера string  = "WIN-E1U41FA6E55";
            string Username   = list[2];
            string Password   = list[3];

            try
            {
                ComputerTargetScope      scope   = new ComputerTargetScope();
                IUpdateServer            server  = AdminProxy.GetUpdateServer(servername, false, 8530);
                ComputerTargetCollection targets = server.GetComputerTargets(scope);
                // Search
                targets = server.SearchComputerTargets(namehost);

                // To get only on server FindTarget method
                IComputerTarget target = FindTarget(targets, namehost);
                result.Add("Имя ПК: " + target.FullDomainName);

                IUpdateSummary summary      = target.GetUpdateInstallationSummary();
                UpdateScope    _updateScope = new UpdateScope();
                // See in UpdateInstallationStates all other properties criteria

                //_updateScope.IncludedInstallationStates = UpdateInstallationStates.Downloaded;
                UpdateInstallationInfoCollection updatesInfo = target.GetUpdateInstallationInfoPerUpdate(_updateScope);

                int updateCount = updatesInfo.Count;

                result.Add("Кол -во найденных обновлений - " + updateCount);

                foreach (IUpdateInstallationInfo updateInfo in updatesInfo)
                {
                    result.Add(updateInfo.GetUpdate().Title);
                }
            }

            catch (Exception ex)
            {
                result.Add("Что-то пошло не так: " + ex.Message);
            }

            return(result);
        }
Exemple #10
0
        internal void PopulateRelevantWithUpdates()
        {
            UMClassifications classes    = UMContext.Context.GetUpdateClassifications();
            UMCategories      categories = UMContext.Context.GetUpdateCategories();

            var upScope = new UpdateScope()
            {
                ApprovedStates             = ApprovedStates.Any,
                UpdateSources              = UpdateSources.All,
                IncludedInstallationStates = UpdateInstallationStates.All,
                UpdateTypes           = UpdateTypes.All,
                UpdateApprovalActions = UpdateApprovalActions.All
            };

            upScope.Classifications.AddRange(classes);
            upScope.Categories.AddRange(categories);
            UMContext.AllUpdates = UMContext.Context.GetUpdates(upScope);
        }
Exemple #11
0
        /// <summary>
        /// Checks for updates that may have a new revision
        /// </summary>
        /// <param name="server">
        /// The WSUS Server
        /// </param>
        /// <param name="approveLicenseAgreement">
        /// Whether to approve any license agreement
        /// </param>
        /// <param name="computerTargetGroup">
        /// The target group to check
        /// </param>
        /// <param name="classifications">
        /// Classification to process
        /// </param>
        /// <param name="products">
        /// Collection of products to process
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        private static void CheckStaleUpdates(
            IUpdateServer server,
            bool approveLicenseAgreement,
            IComputerTargetGroup computerTargetGroup,
            IUpdateClassification classifications,
            UpdateCategoryCollection products,
            bool isTest)
        {
            var searchScope = new UpdateScope {
                ApprovedStates = ApprovedStates.HasStaleUpdateApprovals
            };

            if (computerTargetGroup != null)
            {
                searchScope.ApprovedComputerTargetGroups.Add(computerTargetGroup);
            }

            if (classifications != null)
            {
                searchScope.Classifications.Add(classifications);
            }

            if (products != null)
            {
                searchScope.Categories.AddRange(products);
            }

            UpdateCollection updates = server.GetUpdates(searchScope);

            if (updates.Count > 0)
            {
                foreach (IUpdate update in updates)
                {
                    CheckStaleUpdate(update, isTest, approveLicenseAgreement);
                }
            }
            else
            {
                Console.Out.WriteLine(" No updates required.");
            }
        }
Exemple #12
0
        private static UpdateCollection getUpdates()
        {
            Console.WriteLine("Getting updates from WSUS..");
            IUpdateServer            server     = AdminProxy.GetUpdateServer("localhost", false, 8530);
            UpdateScope              scope      = new UpdateScope();
            UpdateCategoryCollection categories = server.GetUpdateCategories();

            foreach (IUpdateCategory cat in categories)
            {
                if (cat.Description.Contains("10"))
                {
                    Console.WriteLine(cat.Description);
                    scope.Categories.Add(cat);
                }
            }

            int updateCount = server.GetUpdateCount(scope);

            Console.WriteLine($"Updates found: {updateCount}");

            UpdateCollection updates = server.GetUpdates(scope);

            return(updates);
        }
Exemple #13
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="scope">Scope of the update.</param>
 public UpdateEventArgs(UpdateScope scope = UpdateScope.All)
 {
     Scope = scope;
 }
        private void getUpdateStatus()
        {
            if (cbxWsusServer.Text == "")
            {
                MessageBox.Show("Bitte wählen Sie einen WSUS Server aus.", "Kein WSUS Server ausgewählt.");
            }
            else
            {
                if (groups.Text == "")
                {
                    MessageBox.Show("Bitte wählen Sie eine WSUS Gruppe aus.", "Keine WSUS Gruppe ausgewählt.");
                }
                else
                {
                    disableGUI();

                    IUpdateServer UpdateServer = getUpdateServer(cbxWsusServer.SelectedItem.ToString());

                    //Zu suchende Updates definieren
                    UpdateScope updtScope = new UpdateScope();
                    updtScope.FromCreationDate = dateFrom.Value.Date;
                    updtScope.ToCreationDate = dateTo.Value.Date;
                    //updtScope.UpdateSources = UpdateSources.All;
                    //updtScope.UpdateApprovalActions = UpdateApprovalActions.All;
                    updtScope.ApprovedStates = ApprovedStates.HasStaleUpdateApprovals | ApprovedStates.LatestRevisionApproved | ApprovedStates.NotApproved;
                    updtScope.TextIncludes = txtUpdateFilter.Text;
                    //updtScope.ApprovedComputerTargetGroups.Add(((WSUSGroup)groups.SelectedItem).getWSUSGroup());

                    UpdateCollection UpdatesCol = new UpdateCollection();
                    UpdateSummaryCollection SumCol = new UpdateSummaryCollection();

                    try
                    {
                        UpdatesCol = UpdateServer.GetUpdates(updtScope);

                        foreach (IUpdate updt in UpdatesCol)
                        {
                            IUpdateSummary updtsum = updt.GetSummaryForComputerTargetGroup(((WSUSGroup)groups.SelectedItem).getWSUSGroup());

                            double countUpdates = 0.0;
                            countUpdates = (100.0 / (updtsum.InstalledCount + updtsum.FailedCount + updtsum.NotInstalledCount + updtsum.UnknownCount + updtsum.NotApplicableCount)) * (updtsum.InstalledCount + updtsum.NotApplicableCount);

                            string secbul = String.Empty;

                            if (updt.SecurityBulletins.Count > 0)
                            {
                                foreach (string str in updt.SecurityBulletins)
                                {
                                    secbul += str + ";";
                                }

                                secbul = secbul.Remove(secbul.Length - 1);
                            }

                            resultsUpdates.Rows.Add(updt.Title, Math.Round(countUpdates, 2), secbul, "Details", updt.Id.UpdateId.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Es trat folgender Fehler auf: " + ex);
                    }

                    enableGUI();
                    resultsUpdates.Visible = true;
                    pnlUpdates.Visible = true;

                }
            }
        }
Exemple #15
0
 /// <summary>
 ///     Constructor.
 /// </summary>
 /// <param name="scope">Scope of the update.</param>
 public UpdateEventArgs(UpdateScope scope = UpdateScope.All)
 {
     Scope = scope;
 }
        private DataTable getUpdatesPerClient(string wsusServer, string client)
        {
            DataTable data = new DataTable();
            data = new DataTable();

            data.Columns.Add("Updatename");
            data.Columns.Add("Erscheinungsdatum");
            data.Columns.Add("Status");
            data.Columns.Add("Produktfamilie");
            data.Columns.Add("Kategorie");
            data.Columns.Add("id");
            data.Columns.Add("SB");

            IUpdateServer UpdateServer = getUpdateServer(wsusServer);

            //get ComputerTarget
            IComputerTarget computer = UpdateServer.GetComputerTargetByName(client);

            //define Updatescope
            UpdateScope updtScopeClientUpdates = new UpdateScope();
            updtScopeClientUpdates.FromCreationDate = dateFrom.Value;
            updtScopeClientUpdates.ToCreationDate = dateTo.Value.Date;
            updtScopeClientUpdates.ExcludedInstallationStates = UpdateInstallationStates.NotApplicable;
            updtScopeClientUpdates.IncludedInstallationStates = UpdateInstallationStates.Installed | UpdateInstallationStates.InstalledPendingReboot | UpdateInstallationStates.Failed | UpdateInstallationStates.NotInstalled | UpdateInstallationStates.Unknown | UpdateInstallationStates.Downloaded;

            if (cbxInstalled.Checked)
            {
                if (cbxFailed.Checked)
                {
                    updtScopeClientUpdates.IncludedInstallationStates = UpdateInstallationStates.Installed | UpdateInstallationStates.InstalledPendingReboot | UpdateInstallationStates.Failed | UpdateInstallationStates.NotInstalled | UpdateInstallationStates.Unknown | UpdateInstallationStates.Downloaded;
                } else {
                    updtScopeClientUpdates.IncludedInstallationStates = UpdateInstallationStates.Installed | UpdateInstallationStates.InstalledPendingReboot;
                }
            } else {
                if (cbxFailed.Checked)
                {
                    updtScopeClientUpdates.IncludedInstallationStates = UpdateInstallationStates.Failed | UpdateInstallationStates.NotInstalled | UpdateInstallationStates.Unknown | UpdateInstallationStates.Downloaded;
                }
            }

            //get all updates
            UpdateInstallationInfoCollection installStatus = computer.GetUpdateInstallationInfoPerUpdate(updtScopeClientUpdates);

            // loop through the updates in the install info collection and output the
            // name of the update and it's install state on this computer

            foreach (IUpdateInstallationInfo updateStatus in installStatus)
            {
                Boolean addRow = false;
                IUpdate update = updateStatus.GetUpdate();

                //if (update.Approve(UpdateApprovalAction.Install))
                string prodTitle = "";
                string famTitle = "";

                foreach (string title in update.ProductTitles)
                {
                    prodTitle += title + ", ";
                }
                prodTitle = prodTitle.Remove((prodTitle.Length - 2));

                foreach (string title in update.ProductFamilyTitles)
                {
                    famTitle += title + ", ";
                }
                famTitle = famTitle.Remove((famTitle.Length - 2));

                //if (cbxInstallPending.Checked)
                //{
                //    if (updateStatus.UpdateInstallationState == UpdateInstallationState.InstalledPendingReboot)
                //    {
                //        addRow = true;
                //    }
                //}

                if (cbxInstalled.Checked)
                {
                    if (updateStatus.UpdateInstallationState == UpdateInstallationState.Installed ||
                        updateStatus.UpdateInstallationState == UpdateInstallationState.InstalledPendingReboot)
                    {
                        addRow = true;
                    }
                }

                //if (cbxNotInstalled.Checked)
                //{
                //    if (updateStatus.UpdateInstallationState == UpdateInstallationState.NotInstalled ||
                //        updateStatus.UpdateInstallationState == UpdateInstallationState.Downloaded ||
                //        updateStatus.UpdateInstallationState == UpdateInstallationState.Unknown)
                //    {
                //        addRow = true;
                //    }
                //}

                if (cbxFailed.Checked)
                {
                    if (updateStatus.UpdateInstallationState == UpdateInstallationState.Failed ||
                        updateStatus.UpdateInstallationState == UpdateInstallationState.NotInstalled ||
                        updateStatus.UpdateInstallationState == UpdateInstallationState.Downloaded ||
                        updateStatus.UpdateInstallationState == UpdateInstallationState.Unknown)
                    {
                        addRow = true;
                    }
                }

                if (addRow)
                {

                    string secbul = String.Empty;

                    if (update.SecurityBulletins.Count > 0)
                    {
                        foreach (string str in update.SecurityBulletins)
                        {
                            secbul += str + ";";
                        }

                        secbul = secbul.Remove(secbul.Length - 1);
                    }

                    data.Rows.Add(update.Title, update.CreationDate.ToString("yyy/MM/dd - HH:mm"), updateStatus.UpdateInstallationState.ToString(),
                        //prodTitle,
                    famTitle,
                    update.UpdateClassificationTitle, update.Id.UpdateId.ToString(), secbul);

                }
            }
            return data;
        }
Exemple #17
0
        /// <summary>
        /// Checks for updates that may have a new revision
        /// </summary>
        /// <param name="server">
        /// The WSUS Server
        /// </param>
        /// <param name="approveLicenseAgreement">
        /// Whether to approve any license agreement
        /// </param>
        /// <param name="computerTargetGroup">
        /// The target group to check
        /// </param>
        /// <param name="classifications">
        /// Classification to process
        /// </param>
        /// <param name="products">
        /// Collection of products to process
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        private static void CheckStaleUpdates(
            IUpdateServer server,
            bool approveLicenseAgreement,
            IComputerTargetGroup computerTargetGroup,
            IUpdateClassification classifications,
            UpdateCategoryCollection products,
            bool isTest)
        {
            var searchScope = new UpdateScope { ApprovedStates = ApprovedStates.HasStaleUpdateApprovals };

            if (computerTargetGroup != null)
            {
                searchScope.ApprovedComputerTargetGroups.Add(computerTargetGroup);
            }

            if (classifications != null)
            {
                searchScope.Classifications.Add(classifications);
            }

            if (products != null)
            {
                searchScope.Categories.AddRange(products);
            }

            UpdateCollection updates = server.GetUpdates(searchScope);

            if (updates.Count > 0)
            {
                foreach (IUpdate update in updates)
                {
                    CheckStaleUpdate(update, isTest, approveLicenseAgreement);
                }
            }
            else
            {
                Console.Out.WriteLine(" No updates required.");
            }
        }
Exemple #18
0
 /// <summary>
 /// Request UI to be updated.
 /// </summary>
 public static void RequestUiUpdate(UpdateScope scope)
 {
     if (requestUiUpdate != null)
         requestUiUpdate(instance, new UpdatedEventArgs { Scope = scope });
 }
Exemple #19
0
 /// <summary>
 /// Resuest update of a specifiv UI component with a message
 /// containing informationg about updating.
 /// </summary>
 /// <param name="scope"></param>
 /// <param name="target"></param>
 /// <param name="message"></param>
 public void RequestUpdate(UpdateScope scope, Guid target, Object message)
 {
     if (onUpdateRequest != null)
         onUpdateRequest(this, new UpdateEventArgs(scope) { Target = target, UpdateMessage = message });
 }
Exemple #20
0
 /// <summary>
 ///     Requests a Animat Studio Update.
 /// </summary>
 /// <param name="scope">Scope of the update; default value is UpdateScope.All</param>
 public void RequestUpdate(UpdateScope scope = UpdateScope.All)
 {
     if (onUpdateRequest != null)
         onUpdateRequest(this, new UpdateEventArgs(scope));
 }
Exemple #21
0
        /// <summary>
        /// Checks a classification for needed updates
        /// </summary>
        /// <param name="server">
        /// Object representing the WSUS server
        /// </param>
        /// <param name="classification">
        /// a single update classification
        /// </param>
        /// <param name="rootGroup">
        /// the "all computers" group
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        /// <param name="alreadyProcessed">
        /// List of target groups that have already been processed
        /// </param>
        private static void CheckClassification(
            IUpdateServer server,
            IUpdateClassification classification,
            IComputerTargetGroup rootGroup,
            bool isTest,
            List<IComputerTargetGroup> alreadyProcessed)
        {
            Console.Out.WriteLine("Getting list of updates for : " + classification.Title);

            var searchScope = new UpdateScope { IncludedInstallationStates = UpdateInstallationStates.NotInstalled };

            searchScope.Classifications.Add(classification);
            UpdateCollection updates = server.GetUpdates(searchScope);

            if (updates.Count > 0)
            {
                DoClassificationUpdates(updates, rootGroup, isTest, alreadyProcessed);
            }
            else
            {
                Console.Out.WriteLine(" No updates required.");
            }
        }
        public void Update(UpdateScope scope)
        {
            IEnumerable<BackgroundTransferRequest> newBGRequests = null;
            IEnumerable<ForegroundTransferRequest> newFGRequests = null;

            if (scope == UpdateScope.All || scope == UpdateScope.Background)
            {
                newBGRequests = BackgroundTransferService.Requests.ToList();
            }
            if (scope == UpdateScope.All || scope == UpdateScope.Foreground)
            {
                newFGRequests = ForegroundTransferService.Requests;
            }

            if (this.Requests != null)
            {
                if (newBGRequests != null)
                {
                    foreach (var newBGRequest in newBGRequests)
                    {
                        if (!this.Requests.Any(r => r.RequestId == newBGRequest.RequestId))
                        {
                            this.Requests.Add(new DownloadItemBackgroundViewModel(newBGRequest));
                        }
                        else
                        {
                            // The Requests property returns new references, so make sure that you dispose of the old references to avoid memory leaks.
                            newBGRequest.Dispose();
                        }
                    }
                }
                if (newFGRequests != null)
                {
                    foreach (var newFGRequest in newFGRequests)
                    {
                        if (!this.Requests.Any(r => r.RequestId == newFGRequest.RequestId))
                        {
                            this.Requests.Add(new DownloadItemForegroundViewModel(newFGRequest));
                        }
                    }
                }
            }
            else
            {
                this.Requests = new ObservableCollection<BaseDownloadItemViewModel>();
                if (newBGRequests != null)
                {
                    newBGRequests.Aggregate(this.Requests, (list, r) =>
                    {
                        this.Requests.Add(new DownloadItemBackgroundViewModel(r));
                        return list;
                    });
                }
                if (newFGRequests != null)
                {
                    newFGRequests.Aggregate(this.Requests, (list, r) =>
                    {
                        this.Requests.Add(new DownloadItemForegroundViewModel(r));
                        return list;
                    });
                }
            }
            this.CheckEmptyness();
        }
Exemple #23
0
        /// <summary>
        /// checks for superseded updates and approves the new revision
        /// </summary>
        /// <param name="server">
        /// The WSUS Server
        /// </param>
        /// <param name="approveLicenseAgreement">
        /// Whether to approve any license agreement
        /// </param>
        /// <param name="computerTargetGroup">
        /// The target group to check
        /// </param>
        /// <param name="classification">
        /// Classification to process
        /// </param>
        /// <param name="products">
        /// Collection of products to process
        /// </param>
        /// <param name="isTest">
        /// Whether we are in test mode
        /// </param>
        /// <param name="shouldApproveUninstalledSupersededUpdate">
        /// The should Approve Uninstalled Superseded Update.
        /// </param>
        private static void CheckSupersededUpdates(
            IUpdateServer server,
            bool approveLicenseAgreement,
            IComputerTargetGroup computerTargetGroup,
            IUpdateClassification classification,
            UpdateCategoryCollection products,
            bool isTest,
            bool shouldApproveUninstalledSupersededUpdate)
        {
            var searchScope = new UpdateScope { ApprovedStates = ApprovedStates.HasStaleUpdateApprovals };

            if (computerTargetGroup != null)
            {
                searchScope.ApprovedComputerTargetGroups.Add(computerTargetGroup);
            }

            if (classification != null)
            {
                searchScope.Classifications.Add(classification);
            }

            if (products != null)
            {
                searchScope.Categories.AddRange(products);
            }

            UpdateCollection updates = server.GetUpdates(searchScope);

            if (updates.Count <= 0)
            {
                return;
            }

            var recentlyApproved = new List<Guid>();

            if (updates.Count == 0)
            {
                Console.Out.WriteLine(" No updates required.");
                return;
            }

            foreach (IUpdate update in updates)
            {
                if (update.IsSuperseded)
                {
                    CheckSupersededUpdate(
                        update,
                        approveLicenseAgreement,
                        isTest,
                        recentlyApproved,
                        shouldApproveUninstalledSupersededUpdate);
                }
            }
        }
        private void getClientStatus()
        {
            if (cbxWsusServer.Text == "")
            {
                MessageBox.Show("Bitte wählen Sie einen WSUS Server aus.", "Kein WSUS Server ausgewählt.");
            }
            else
            {
                if (groups.Text == "")
                {
                    MessageBox.Show("Bitte wählen Sie eine WSUS Gruppe aus.", "Keine WSUS Gruppe ausgewählt.");
                }
                else
                {
                    disableGUI();

                    IUpdateServer UpdateServer = getUpdateServer(cbxWsusServer.SelectedItem.ToString());

                    //Zu suchende Updates definieren
                    UpdateScope updtScope = new UpdateScope();
                    updtScope.FromCreationDate = dateFrom.Value;
                    updtScope.ToCreationDate = dateTo.Value.Date;
                    //updtScope.ExcludedInstallationStates = UpdateInstallationStates.NotApplicable;
                    //updtScope.IncludedInstallationStates = UpdateInstallationStates.Installed | UpdateInstallationStates.InstalledPendingReboot | UpdateInstallationStates.Failed | UpdateInstallationStates.NotInstalled | UpdateInstallationStates.Unknown | UpdateInstallationStates.Downloaded;
                    updtScope.ApprovedStates = ApprovedStates.HasStaleUpdateApprovals | ApprovedStates.LatestRevisionApproved | ApprovedStates.NotApproved;

                    ComputerTargetScope searchRange = new ComputerTargetScope();
                    searchRange.ComputerTargetGroups.Add(((WSUSGroup)groups.SelectedItem).getWSUSGroup());
                    searchRange.IncludeDownstreamComputerTargets = true;
                    searchRange.NameIncludes = txtClientFilter.Text;

                    ComputerTargetCollection myClients = UpdateServer.GetComputerTargets(searchRange);

                    foreach (IComputerTarget client in myClients)
                    {
                        int countInstalledUpdates = 0;
                        int countAllUpdates = 0;

                        IUpdateSummary updtsum = client.GetUpdateInstallationSummary(updtScope);
                        countInstalledUpdates = updtsum.InstalledCount;
                        countAllUpdates = updtsum.InstalledCount + updtsum.UnknownCount + updtsum.NotInstalledCount + updtsum.FailedCount;

                        //ermittle zugewiesene wsus gruppe des clients
                        string clientWsusGroup = "";

                        foreach (IComputerTargetGroup gp in client.GetComputerTargetGroups())
                        {
                            clientWsusGroup += gp.Name + " / ";
                        }
                        clientWsusGroup = clientWsusGroup.Remove((clientWsusGroup.Length - 3));

                        double state = 0.0;

                        if (countAllUpdates > 0 | countInstalledUpdates > 0)
                        {
                            state = ((100.0 / (double)countAllUpdates) * (double)countInstalledUpdates);
                        }

                        resultsClients.Rows.Add(client.FullDomainName.ToString(), Math.Round(state, 2), client.ComputerRole, client.LastReportedStatusTime.ToString("yyy/MM/dd - HH:mm"), clientWsusGroup, client.OSDescription + ", " + client.OSArchitecture, "Updatedetails", "Detailansicht");
                    }

                    enableGUI();
                }
            }

            resultsClients.Visible = true;
        }