public async Task <bool> GetSWRepository() { //var tGetSWRepo = bool bResult = await Task.Run(() => { try { //var oDB = RZRestAPI.SWResults("").Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList(); var oDB = RZRestAPIv2.GetCatalog().Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList(); lock (SoftwareRepository) { SoftwareRepository = oDB.Select(item => new GetSoftware() { Categories = item.Categories ?? new List <string>(), Description = item.Description, Downloads = item.Downloads, //IconId = item.IconId, SWId = item.SWId, //Image = item.Image, Manufacturer = item.Manufacturer, ProductName = item.ProductName, ProductURL = item.ProductURL, ProductVersion = item.ProductVersion, ShortName = item.ShortName, IconHash = item.IconHash }).ToList(); } } catch (Exception ex) { Debug.WriteLine(ex.Message.ToString()); } OnSWRepoLoaded(this, new EventArgs()); return(true); }); return(bResult); }
internal async void _CheckUpdates(List <AddSoftware> aSWCheck) { try { if (aSWCheck == null || aSWCheck.Count() == 0) { aSWCheck = InstalledSoftware.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList(); } var vSWCheck = aSWCheck.Select(t => new AddSoftware() { ProductName = t.ProductName, ProductVersion = t.ProductVersion, Manufacturer = t.Manufacturer }).ToList(); //we do not have to check for updates if it's in the Catalog foreach (var oSW in SoftwareRepository) { vSWCheck.RemoveAll(t => t.ProductName.ToLower().Trim() == oSW.ProductName.ToLower().Trim() && t.Manufacturer.ToLower().Trim() == oSW.Manufacturer.ToLower().Trim() && t.ProductVersion.ToLower().Trim() == oSW.ProductVersion.ToLower().Trim()); } List <AddSoftware> lCheckResult = (RZRestAPIv2.CheckForUpdateAsync(vSWCheck).Result).ToList(); var lResult = lCheckResult.Select(item => new AddSoftware() { Architecture = item.Architecture, Category = item.Category, Description = item.Description, Manufacturer = item.Manufacturer, ProductName = item.ProductName, ProductURL = item.ProductURL, ProductVersion = item.ProductVersion, MSIProductID = item.MSIProductID, ShortName = item.ShortName, SWId = item.SWId, IconHash = item.IconHash }).ToList(); //Only take updated Versions var lNew = lResult.Where(t => t.ShortName != "new").ToList(); //Remove Update if new Version is already installed foreach (var oSW in InstalledSoftware) { lNew.RemoveAll(t => t.ProductName.ToLower().Trim() == oSW.ProductName.ToLower().Trim() && t.Manufacturer.ToLower().Trim().TrimEnd('.') == oSW.Manufacturer.ToLower().Trim().TrimEnd('.') && t.ProductVersion.ToLower().Trim() == oSW.ProductVersion.ToLower().Trim()); } lock (NewSoftwareVersions) { //Store new Versions of existing SW NewSoftwareVersions.AddRange(lNew); //Remove duplicates NewSoftwareVersions = NewSoftwareVersions.GroupBy(x => x.ShortName).Select(y => y.First()).ToList(); } if (lNew.Count > 0) { OnUpdatesDetected(lNew, new EventArgs()); } } catch (Exception ex) { ex.ToString(); } OnUpdScanCompleted(this, new EventArgs()); }