Esempio n. 1
0
        private void btApproval_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                tSearch.Stop();
                var badSW = RZRestAPI.SWResults("--APPROVE--").Distinct().Select(x => new GetSoftware()
                {
                    Categories = x.Categories.ToList(), 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();
                tbSearch.Text = "";

                //Mark all installed...
                badSW.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName & t.ProductVersion == x.ProductVersion)) != null)
                                     {
                                         x.isInstalled = true;
                                     }
                              });


                ListCollectionView lcv = new ListCollectionView(badSW.ToList());

                lvSW.ItemsSource = lcv;
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
Esempio n. 2
0
        private void btNew_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            try
            {
                tSearch.Stop();
                var badSW = RZRestAPI.SWResults("--NEW--").ToList();
                tbSearch.Text = "";

                //Mark all installed...
                badSW.ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName & t.ProductVersion == x.ProductVersion)) != null)
                                     {
                                         x.isInstalled = true;
                                     }
                              });


                ListCollectionView lcv = new ListCollectionView(badSW.ToList());

                lvSW.ItemsSource = lcv;
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
        }
Esempio n. 3
0
 private void tbSearch_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     tSearch.Stop();
     lAllSoftware = RZRestAPI.SWResults("").Distinct().OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).Select(x => new GetSoftware()
     {
         isInstalled = false
     }).ToList();
     //Mark all installed...
     lAllSoftware.ToList().ForEach(x => { if (lSoftware.FirstOrDefault(t => (t.ProductName == x.ProductName & t.ProductVersion == x.ProductVersion)) != null)
                                          {
                                              x.isInstalled = true;
                                          }
                                   });
 }
Esempio n. 4
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                List <GetSoftware> oSW = RZRestAPI.SWResults(tbProductName.Text).ToList();
                if (oSW.FirstOrDefault() != null)
                {
                    tbProductURL.Text  = oSW.FirstOrDefault().ProductURL;
                    tbDescription.Text = oSW.FirstOrDefault().Description;
                }

                btUpload.IsEnabled = true;
            }
            catch { }
        }
Esempio n. 5
0
        private void tabWizard_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (tabWizard.SelectedItem != tabNewSWSMI & e.Source == tabWizard)
            {
                oNewPanel.unload();
            }

            if (tabWizard.SelectedItem == tabNewSWARP & e.Source == tabWizard)
            {
                Mouse.OverrideCursor = Cursors.Wait;
                try
                {
                    arpGrid2.AutoGenerateColumns = false;
                    List <GetSoftware> lServer = new List <GetSoftware>();
                    if (oInstPanel.lvSW.ItemsSource == null)
                    {
                        lServer = RZRestAPI.SWResults("").OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList();
                    }
                    else
                    {
                        lServer = oInstPanel.lvSW.ItemsSource as List <GetSoftware>;
                    }

                    if (lServer == null)
                    {
                        lServer = RZRestAPI.SWResults("").OrderBy(t => t.Shortname).ThenByDescending(t => t.ProductVersion).ThenByDescending(t => t.ProductName).ToList();
                    }

                    if (Keyboard.Modifiers == ModifierKeys.Shift)
                    {
                        arpGrid2.ItemsSource = lSoftware.OrderBy(t => t.ProductName).ThenBy(t => t.ProductVersion).ThenBy(t => t.Manufacturer).ToList();
                    }
                    else
                    {
                        arpGrid2.ItemsSource = lSoftware.Where(t => lServer.Count(x => x.ProductName == t.ProductName & x.Manufacturer == t.Manufacturer & x.ProductVersion == t.ProductVersion) == 0).OrderBy(t => t.ProductName).ThenBy(t => t.ProductVersion).ThenBy(t => t.Manufacturer).ToList();
                    }
                }
                finally
                {
                    Mouse.OverrideCursor = null;
                }
            }
        }
Esempio n. 6
0
        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();
                    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);
        }
Esempio n. 7
0
        private void PSCode_Load(object sender, EventArgs e)
        {
            string sCurrentDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                ToolStripMenuItem tsm = new ToolStripMenuItem();
                if (string.IsNullOrEmpty(sAuthToken))
                {
                    sAuthToken = RZRestAPI.GetAuthToken("FreeRZ", GetTimeToken());
                }

                RZRestAPI.Token = sAuthToken;


                lAllSoftware = RZRestAPI.SWResults("");

                dataGridView1.DataSource = lAllSoftware.ToList().OrderBy(t => t.Shortname).ToList();
            }
            catch (Exception ex)
            {
                ex.Message.ToString();
            }
        }
Esempio n. 8
0
        private void _getInstalledPackages(string name, string requiredVersion, string minimumVersion, string maximumVersion, Request request)
        {
            _reAuthenticate(request); //Check if AuthToken is still valid

            try
            {
                List <AddSoftware> lResult = getInstalledSW().ToList();

                List <GetSoftware> lServer = RZRestAPI.SWResults(name).OrderBy(t => t.Shortname).ToList();
                request.Debug("Items Found: " + lServer.Count().ToString());

                List <AddSoftware> lLocal = lResult.Where(t => lServer.Count(x => x.ProductName == t.ProductName & x.Manufacturer == t.Manufacturer & x.ProductVersion == t.ProductVersion) != 0).OrderBy(t => t.ProductName).ThenBy(t => t.ProductVersion).ThenBy(t => t.Manufacturer).ToList();


                if (!string.IsNullOrEmpty(name))
                {
                    string sProdName = "";
                    try
                    {
                        sProdName = lServer.FirstOrDefault(p => string.Equals(p.Shortname, name, StringComparison.OrdinalIgnoreCase)).ProductName;
                    }
                    catch { }
                    lLocal = lLocal.Where(p => String.Equals(p.ProductName, name, StringComparison.OrdinalIgnoreCase) | String.Equals(p.ProductName, sProdName, StringComparison.OrdinalIgnoreCase)).OrderBy(t => t.ProductName).ToList();
                }

                if (requiredVersion != null)
                {
                    lLocal = lLocal.Where(p => p.ProductVersion.ToLowerInvariant() == requiredVersion.ToLowerInvariant()).ToList();
                }
                if (minimumVersion != null)
                {
                    try
                    {
                        lLocal = lLocal.Where(p => Version.Parse(p.ProductVersion) >= Version.Parse(minimumVersion)).ToList();
                    }
                    catch
                    {
                        lLocal = lLocal.Where(p => p.ProductVersion == minimumVersion).ToList();
                    }
                }
                if (maximumVersion != null)
                {
                    try
                    {
                        lLocal = lLocal.Where(p => Version.Parse(p.ProductVersion) <= Version.Parse(maximumVersion)).ToList();
                    }
                    catch
                    {
                        lLocal = lLocal.Where(p => p.ProductVersion == maximumVersion).ToList();
                    }
                }

                foreach (var SW in lLocal)
                {
                    request.YieldSoftwareIdentity(SW.ProductName + ";" + SW.ProductVersion, SW.ProductName, SW.ProductVersion, "", "", RZRestAPI.sURL, name ?? "", "", SW.Shortname);
                    //request.YieldSoftwareIdentity(SW.Shortname, SW.ProductName, SW.ProductVersion, "", SW.Description, "Local", "", SW.ProductURL, SW.ContentID.ToString());
                }
            }
            catch
            {
                dLastTokenRefresh = new DateTime();
            }
        }
Esempio n. 9
0
        private void _findPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request)
        {
            _reAuthenticate(request); //Check if AuthToken is still valid

            try
            {
                bool exactSearch = true;
                if (request.OptionKeys.Contains("Contains"))
                {
                    name = request.GetOptionValue("Contains");
                    request.Message("exact search disabled.");
                    exactSearch = false;
                }

                //Search all if no name is specified
                if (string.IsNullOrEmpty(name))
                {
                    exactSearch = false;
                }

                bool bUpdate = false;
                if (request.OptionKeys.Contains("Updates"))
                {
                    request.Message("check updates for installed Software.");
                    bUpdate = true;
                }

                List <GetSoftware> lResult = new List <GetSoftware>();

                //Get all installed SW
                if (bUpdate)
                {
                    oScan.CheckForUpdates = false;
                    oScan.SWScan().Wait();
                    oScan.CheckUpdates(null).Wait();
                    lSoftware = oScan.InstalledSoftware;


                    List <AddSoftware> RequiredUpdates = oScan.NewSoftwareVersions; // RZApi.CheckForUpdate(lSoftware.ToArray()).ToList().Where(t => t.Architecture != "new").ToList();
                    foreach (var SW in RequiredUpdates)
                    {
                        try
                        {
                            if (string.IsNullOrEmpty(name))
                            {
                                lResult.Add(new GetSoftware()
                                {
                                    ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Description = SW.Description, ProductURL = SW.ProductURL
                                });
                            }
                            else
                            {
                                if ((SW.ProductName.ToLowerInvariant() == name.ToLowerInvariant() | SW.Shortname.ToLowerInvariant() == name.ToLowerInvariant()) & exactSearch)
                                {
                                    lResult.Add(new GetSoftware()
                                    {
                                        ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Description = SW.Description, ProductURL = SW.ProductURL
                                    });
                                }
                                if ((SW.ProductName.ToLowerInvariant().Contains(name.ToLowerInvariant()) | SW.Shortname.ToLowerInvariant().Contains(name.ToLowerInvariant())) & !exactSearch)
                                {
                                    lResult.Add(new GetSoftware()
                                    {
                                        ProductName = SW.ProductName, ProductVersion = SW.ProductVersion, Manufacturer = SW.Manufacturer, Shortname = SW.Shortname, Description = SW.Description, ProductURL = SW.ProductURL
                                    });
                                }
                            }
                        }
                        catch { }
                    }
                    if (lResult.Count == 0)
                    {
                        request.Warning("No updates found...");
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(requiredVersion))
                    {
                        //Find by Shortname
                        if (exactSearch)
                        {
                            lResult = RZRestAPI.SWGet(name).OrderBy(t => t.Shortname).ToList();

                            if (lResult.Count == 0)
                            {
                                //Find any
                                lResult = RZRestAPI.SWResults(name).Where(t => t.ProductName == name).OrderBy(t => t.ProductName).ToList();
                            }
                        }
                        else
                        {
                            lResult = RZRestAPI.SWGet(name).OrderBy(t => t.Shortname).ToList();

                            if (lResult.Count == 0)
                            {
                                //Find any
                                lResult = RZRestAPI.SWResults(name).OrderBy(t => t.Shortname).ToList();
                            }
                        }
                    }
                    else
                    {
                        //Find by Shortname
                        if (exactSearch)
                        {
                            lResult = RZRestAPI.SWGet(name, requiredVersion).OrderBy(t => t.Shortname).ToList();
                        }
                        else
                        {
                            //Find any
                            lResult = RZRestAPI.SWResults(name).Where(t => t.ProductVersion == requiredVersion).OrderBy(t => t.Shortname).ToList();
                        }
                    }
                }


                if (minimumVersion != null)
                {
                    try
                    {
                        lResult = lResult.Where(p => Version.Parse(p.ProductVersion) >= Version.Parse(minimumVersion)).ToList();
                    }
                    catch
                    {
                        lResult = lResult.Where(p => p.ProductVersion == minimumVersion).ToList();
                    }
                }
                if (maximumVersion != null)
                {
                    try
                    {
                        lResult = lResult.Where(p => Version.Parse(p.ProductVersion) <= Version.Parse(maximumVersion)).ToList();
                    }
                    catch
                    {
                        lResult = lResult.Where(p => p.ProductVersion == maximumVersion).ToList();
                    }
                }


                foreach (var SW in lResult.OrderBy(t => t.Shortname))
                {
                    request.YieldSoftwareIdentity(SW.ProductName + ";" + SW.ProductVersion + ";" + SW.Manufacturer, SW.ProductName, SW.ProductVersion, "", SW.Description, Properties.Settings.Default.Location, name, SW.IconId.ToString(), SW.Shortname);
                    //Trust the original RucKZuck source
                    if (string.Equals(Properties.Settings.Default.Location, WebServiceURL, StringComparison.InvariantCultureIgnoreCase))
                    {
                        request.AddMetadata("FromTrustedSource", "True");
                    }
                }
            }
            catch (Exception ex)
            {
                request.Debug("E334:" + ex.Message);
                dLastTokenRefresh = new DateTime();
            }
        }