/// <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); }
public IActionResult Put(int id, [FromBody] CategoryDto dto, [FromServices] IUpdateCategory command) { var newCategory = new CategoryDto { Id = id, CategoryName = dto.CategoryName }; _executor.ExecuteCommand(command, newCategory); return(StatusCode(StatusCodes.Status204NoContent)); }
internal FrmUpdateWizard(Dictionary <Guid, Company> Companies, IUpdate updateToRevise) { Logger.EnteringMethod("FrmUpdateWizard"); InitializeComponent(); WsusWrapper _wsus = WsusWrapper.GetInstance(); Revising = true; this.Sdp = _wsus.GetMetaData(updateToRevise); this.Companies = Companies; IUpdateCategory productCategory = updateToRevise.GetUpdateCategories()[0]; IUpdateCategory companyCategory = productCategory.GetParentUpdateCategory(); InitializeComponent(this.Companies, Companies[companyCategory.Id], Companies[companyCategory.Id].Products[productCategory.Id], Sdp); }
private bool MakeLocallyPublished(IUpdateCategory productToDelete, IUpdateCategory vendorToDelete) { Logger.EnteringMethod("Product to Delete : " + productToDelete.Title + " and Vendor to delete : " + vendorToDelete.Title); try { List <Guid> Ids = new List <Guid>(); SqlHelper sqlHelper = SqlHelper.GetInstance(); sqlHelper.ServerName = GetServerName();; sqlHelper.DataBaseName = "SUSDB"; if (!sqlHelper.Connect(string.Empty, string.Empty)) { Logger.Write("Failed to connect to SQL"); return(false); } else { Logger.Write("Connected to SQL"); Logger.Write("ProductToDelete UpdateSource = " + productToDelete.UpdateSource.ToString()); if (productToDelete.UpdateSource == UpdateSource.MicrosoftUpdate) { Ids.Add(productToDelete.Id); sqlHelper.HideUpdatesInConsole(Ids); } Ids.Clear(); if (vendorToDelete.GetSubcategories().Count == 1) { Logger.Write("vendorToDelete UpdateSource = " + vendorToDelete.UpdateSource.ToString()); if (vendorToDelete.UpdateSource == UpdateSource.MicrosoftUpdate) { Ids.Add(vendorToDelete.Id); sqlHelper.HideUpdatesInConsole(Ids); } } sqlHelper.Disconnect(); Logger.Write("End of SQL session"); } } catch (Exception ex) { Logger.Write("**** " + ex.Message); return(false); } Logger.Write("Successfuly made LocallyPublished"); return(true); }
private void ChangeVisibiltyInWsusConsole(UpdateCollection updates, int status) { Logger.EnteringMethod(); SqlHelper sqlHelper = SqlHelper.GetInstance(); List <Guid> updateIDs = new List <Guid>(); string sqlServerName = _wsus.GetSqlServerName(); string sqlDataBaseName = _wsus.GetSqlDataBaseName(); System.Version wsusVersion = _wsus.GetServerVersion(); if (sqlServerName.Contains("MICROSOFT##SSEE") || sqlServerName.Contains("MICROSOFT##WID")) { if (wsusVersion.Major == 3) { sqlHelper.ServerName = @"\\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query"; } if (wsusVersion.Major == 6) { sqlHelper.ServerName = @"\\.\pipe\Microsoft##WID\tsql\query"; } sqlHelper.DataBaseName = "SUSDB"; } else { sqlHelper.ServerName = _wsus.GetSqlServerName(); sqlHelper.DataBaseName = _wsus.GetSqlDataBaseName(); } if (sqlHelper.Connect(string.Empty, string.Empty)) { foreach (IUpdate update in updates) { updateIDs.Add(update.Id.UpdateId); if (status == 0) { sqlHelper.ShowUpdatesInConsole(updateIDs); } if (status == 1) { sqlHelper.HideUpdatesInConsole(updateIDs); } } updateIDs.Clear(); foreach (IUpdate update in updates) { UpdateCategoryCollection categories = update.GetUpdateCategories(); foreach (IUpdateCategory category in categories) { if (!updateIDs.Contains(category.Id) && (status == 0 || NumberOfVisibleUpdate(category.GetUpdates()) == 0)) { updateIDs.Add(category.Id); if (category.ProhibitsSubcategories && !category.ProhibitsUpdates) { IUpdateCategory parentCategory = category.GetParentUpdateCategory(); if (!updateIDs.Contains(parentCategory.Id) && (status == 0 || NumberOfVisibleCategory(parentCategory.GetSubcategories()) == 1)) { updateIDs.Add(parentCategory.Id); } } } } } if (status == 0) { sqlHelper.ShowUpdatesInConsole(updateIDs); } if (status == 1) { sqlHelper.HideUpdatesInConsole(updateIDs); } sqlHelper.Disconnect(); } }
public IActionResult Put(int id, [FromBody] CategoryDto dto, [FromServices] IUpdateCategory command) { dto.Id = id; _executor.ExecuteCommand(command, dto); return(NoContent()); }