Пример #1
0
        /// <summary>
        /// Gets the list of update classifications from WSUS
        /// </summary>
        /// <param name="server">
        /// Object representing the WSUS server
        /// </param>
        /// <returns>
        /// Object representing the list of classifications
        /// </returns>
        public static UpdateClassificationCollection GetUpdateClassifications(IUpdateServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            return(server.GetUpdateClassifications());
        }
Пример #2
0
        public static void PopulateUpdateResults(IUpdateServer server, UpdateResults resultobject)
        {
            Console.WriteLine("Reading update information. This may take several minutes. Please wait...");
            List <UpdateCollection> collections = new List <UpdateCollection>();
            var approvedstates = Enum.GetValues(typeof(ApprovedStates));

            //This breaks the query up. If we use a straight GetUpdates() it is likely to timeout. This
            //allows the query to be filtered to give more control.
            foreach (IUpdateClassification classification in server.GetUpdateClassifications())
            {
                //Drivers cause timeouts so we skip them
                if (classification.Title == "Drivers")
                {
                    continue;
                }
                Console.Write("Processing " + classification.Title);
                UpdateClassificationCollection classcol = new UpdateClassificationCollection();
                classcol.Add(classification);
                foreach (ApprovedStates state in approvedstates)
                {
                    //Console.WriteLine(state);
                    Console.Write(".");
                    collections.Add(server.GetUpdates(state, DateTime.MinValue, DateTime.MaxValue, null, classcol));
                }
                Console.WriteLine();
            }

            foreach (UpdateCollection col in collections)
            {
                foreach (IUpdate update in col)
                {
                    resultobject.Updates.Add(Update.GetUpdateObject(update));
                    if (update.IsSuperseded)
                    {
                        List <object> supersededmappings = GetRelatedUpdates(update, UpdateRelationship.UpdatesThatSupersedeThisUpdate);
                        resultobject.SupersededUpdates.AddRange(supersededmappings);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Gets the list of update classifications from WSUS
        /// </summary>
        /// <param name="server">
        /// Object representing the WSUS server
        /// </param>
        /// <returns>
        /// Object representing the list of classifications
        /// </returns>
        public static UpdateClassificationCollection GetUpdateClassifications(IUpdateServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            return server.GetUpdateClassifications();
        }