private void tbSearch_Search(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; if (string.IsNullOrEmpty(tbSearch.Text)) { tbSearch.Foreground = new SolidColorBrush(Colors.LightGray); tbSearch.Tag = "Search"; tbSearch.Text = "Search..."; ListCollectionView lcv = new ListCollectionView(lAllSoftware.Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList()); //ListCollectionView lcv = new ListCollectionView(oAPI.SWResults("", "").Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList()); PropertyGroupDescription PGD = new PropertyGroupDescription("", new ShortNameToCategory()); //PGD.GroupNames.Add(RZRestAPI.GetCategories(lAllSoftware)); foreach (var o in RZRestAPI.GetCategories(lAllSoftware)) { PGD.GroupNames.Add(o); } lcv.GroupDescriptions.Add(PGD); lvSW.ItemsSource = lcv; } else { tbSearch.Foreground = new SolidColorBrush(Colors.Black); tbSearch.Tag = null; try { var vResult = lAllSoftware.FindAll(t => t.ShortName.IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList(); vResult.AddRange(lAllSoftware.FindAll(t => t.ProductName.IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList()); vResult.AddRange(lAllSoftware.FindAll(t => t.Manufacturer.IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList()); if (vResult.Count <= 15) { vResult.AddRange(lAllSoftware.FindAll(t => (t.Description ?? "").IndexOf(tbSearch.Text, 0, StringComparison.InvariantCultureIgnoreCase) >= 0).ToList()); } lvSW.ItemsSource = vResult.Distinct().OrderBy(t => t.ShortName).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName); } catch { } } Mouse.OverrideCursor = null; }
//public event ChangedEventHandler onEdit; public InstallSwPanel() { InitializeComponent(); tSearch.Elapsed += TSearch_Elapsed; tSearch.Enabled = false; tSearch.AutoReset = false; Mouse.OverrideCursor = Cursors.Wait; try { if (string.IsNullOrEmpty(sAuthToken)) { sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken()); } RZRestAPI.Token = sAuthToken; RZScan oSCAN = new RZScan(false, false); Task.Run(() => oSCAN.GetSWRepository()).Wait(); lAllSoftware = oSCAN.SoftwareRepository; List <GetSoftware> oDBCat = new List <GetSoftware>(); PropertyGroupDescription PGD = new PropertyGroupDescription("", new ShortnameToCategory()); foreach (GetSoftware oSW in oSCAN.SoftwareRepository) { try { if (oSW.Categories.Count > 1) { foreach (string sCAT in oSW.Categories) { try { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName & t.ProductVersion == oSW.ProductVersion) != null) { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = true }; oDBCat.Add(oNew); } else { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = false }; oDBCat.Add(oNew); } } catch { } } } else { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName & t.ProductVersion == oSW.ProductVersion) != null) { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = true }); } else { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, Shortname = oSW.Shortname, isInstalled = false }); } } } catch { } } ListCollectionView lcv = new ListCollectionView(oDBCat.ToList()); foreach (var o in RZRestAPI.GetCategories(oSCAN.SoftwareRepository)) { PGD.GroupNames.Add(o); } lcv.GroupDescriptions.Add(PGD); lvSW.ItemsSource = lcv; } catch { } Mouse.OverrideCursor = null; }
private void btInstallSoftware_Click(object sender, RoutedEventArgs e) { Mouse.OverrideCursor = Cursors.Wait; try { if (oSCAN.SoftwareRepository.Count == 0) { try { oSCAN.GetSWRepository().Wait(2000); } catch { } } List <GetSoftware> oDBCat = new List <GetSoftware>(); PropertyGroupDescription PGD = new PropertyGroupDescription("", new ShortNameToCategory()); foreach (GetSoftware oSW in oSCAN.SoftwareRepository) { try { if (oSW.Categories.Count > 1) { foreach (string sCAT in oSW.Categories) { try { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName && t.ProductVersion == oSW.ProductVersion) != null) { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = true }; oDBCat.Add(oNew); } else { GetSoftware oNew = new GetSoftware() { Categories = new List <string> { sCAT }, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = false }; oDBCat.Add(oNew); } } catch { } } } else { //Check if SW is already installed if (lSoftware.FirstOrDefault(t => t.ProductName == oSW.ProductName && t.ProductVersion == oSW.ProductVersion) != null) { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = true }); } else { oDBCat.Add(new GetSoftware() { Categories = oSW.Categories, Description = oSW.Description, Downloads = oSW.Downloads, SWId = oSW.SWId, IconId = oSW.IconId, Manufacturer = oSW.Manufacturer, ProductName = oSW.ProductName, ProductURL = oSW.ProductURL, ProductVersion = oSW.ProductVersion, Quality = oSW.Quality, ShortName = oSW.ShortName, IconHash = oSW.IconHash, isInstalled = false }); } } } catch { } } ListCollectionView lcv = new ListCollectionView(oDBCat.ToList()); foreach (var o in RZRestAPI.GetCategories(oSCAN.SoftwareRepository)) { PGD.GroupNames.Add(o); } lcv.GroupDescriptions.Add(PGD); oInstPanel.lvSW.ItemsSource = lcv; oInstPanel.lSoftware = lSoftware; //var target = oSCAN.SoftwareRepository.Select(x => new GetSoftware() { Categories = x.Categories, Description = x.Description, Downloads = x.Downloads, IconId = x.IconId, Image = x.Image, Manufacturer = x.Manufacturer, ProductName = x.ProductName, ProductURL = x.ProductURL, ProductVersion = x.ProductVersion, Quality = x.Quality, ShortName = x.ShortName, isInstalled = false }).ToList(); oInstPanel.lAllSoftware = oSCAN.SoftwareRepository; //Mark all installed... oInstPanel.lAllSoftware.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName && t.ProductVersion == x.ProductVersion)) != null) { x.isInstalled = true; } }); /*if (!string.IsNullOrEmpty(tbURL.Text)) * oInstPanel.sInternalURL = tbURL.Text;*/ } finally { Mouse.OverrideCursor = null; } tabWizard.SelectedItem = tabInstallSW; }