示例#1
0
        static public void CheckAreValidProducts(
            Microsoft.UpdateServices.Administration.IUpdateServer server,
            ProductCollection products,
            System.String runSetName,
            System.String groupId,
            System.String classificationId
            )
        {
            //make sure we have at least one product
            if (products.Count < 1)
            {
                System.String groupPath = (groupId != null)
                                        ? "\\TargetGroups\\" + groupId :
                                          "\\AllTargetGroups";

                throw new System.Configuration.ConfigurationErrorsException(
                          "The products section in \"" + runSetName + groupPath + "\\Classifications\\" + classificationId + "\\\" must have at least 1 item."
                          );
            }

            foreach (Product product in products)
            {
                //make sure the product exists on wsus
                try
                {
                    server.GetUpdateCategory(product.Guid);
                }
                catch (System.Exception)
                {
                    throw new System.ArgumentException(
                              "The Product Guid \"" + product.Guid + "\" could not be found on the WSUS server. Run Set: " + runSetName
                              );
                }

                //todo: make sure the product doesn't appear in the list twice
                //todo: make sure the product parent hasn't already been added to the list
            }
        }