internal EmptyProductDeleterResult DeleteProduct(Guid productID)
        {
            Logger.EnteringMethod(productID.ToString());
            IUpdate                   updateToDelete  = null;
            IUpdateCategory           productToDelete = wsus.GetUpdateCategory(productID);
            IUpdateCategory           vendorToDelete  = productToDelete.GetParentUpdateCategory();
            EmptyProductDeleterResult result          = new EmptyProductDeleterResult();

            result.DeletedProduct = null;
            result.DeletedVendor  = null;
            StartWaitingForm(resMan.GetString("DeletingProduct") + productToDelete.Title);
            updateToDelete = PublishUpdate(productToDelete, vendorToDelete);

            if (updateToDelete != null && MakeLocallyPublished(productToDelete, vendorToDelete))
            {
                DeclineUpdate(updateToDelete);
                CleanUpdateRevision();
                DeleteUpdate(updateToDelete);
                System.Threading.Thread.Sleep(500);
                try
                {
                    IUpdateCategory deletedCategory = wsus.GetUpdateCategory(productToDelete.Id);
                    Logger.Write("Failed to delete : " + productToDelete.Title);
                }
                catch (Exception)
                {
                    Logger.Write("Successfuly deleted : " + productToDelete.Title);
                    result.DeletedProduct = productToDelete;
                    if (vendorToDelete.GetSubcategories().Count == 0)
                    {
                        try
                        {
                            IUpdateCategory deletedCategory = wsus.GetUpdateCategory(vendorToDelete.Id);
                            Logger.Write("Failed to delete : " + vendorToDelete.Title);
                        }
                        catch (Exception)
                        {
                            Logger.Write("Succesfully deleted : " + vendorToDelete.Title);
                            result.DeletedVendor = vendorToDelete;
                            StopWaitingForm();
                            _waitingForm.TopLevel = false;
                            return(result);
                        }
                    }
                }
            }
            else
            {
                StopWaitingForm();
                _waitingForm.TopLevel = false;
                return(result);
            }

            StopWaitingForm();
            _waitingForm.TopLevel = false;
            return(result);
        }
Example #2
0
        /// <summary>
        /// Gets a list of update categories by searching for the guids specified in the config
        /// </summary>
        /// <param name="server">
        /// wsus server connection
        /// </param>
        /// <param name="products">
        /// list of product guids from config
        /// </param>
        /// <returns>
        /// collection of update categories
        /// </returns>
        private static UpdateCategoryCollection GetUpdateCategoryCollection(
            IUpdateServer server,
            ProductCollection products)
        {
            if (products == null)
            {
                throw new ArgumentNullException("products");
            }

            if (products.Count < 1)
            {
                throw new ArgumentException("products has no product items.");
            }

            var result = new UpdateCategoryCollection();

            foreach (Product product in products)
            {
                IUpdateCategory category = server.GetUpdateCategory(product.Guid);

                result.Add(category);
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// Gets a list of update categories by searching for the guids specified in the config
        /// </summary>
        /// <param name="server">
        /// wsus server connection
        /// </param>
        /// <param name="products">
        /// list of product guids from config
        /// </param>
        /// <returns>
        /// collection of update categories
        /// </returns>
        private static UpdateCategoryCollection GetUpdateCategoryCollection(
            IUpdateServer server,
            ProductCollection products)
        {
            if (products == null)
            {
                throw new ArgumentNullException("products");
            }

            if (products.Count < 1)
            {
                throw new ArgumentException("products has no product items.");
            }

            var result = new UpdateCategoryCollection();

            foreach (Product product in products)
            {
                IUpdateCategory category = server.GetUpdateCategory(product.Guid);

                result.Add(category);
            }

            return result;
        }