Esempio n. 1
0
        public List <AddSoftware> getInstalledSW()
        {
            lSoftware = new List <AddSoftware>();

            if (oScan.bInitialScan)
            {
                oScan = new RZUpdate.RZScan(false, false);
                oScan.SWScan().Wait();
            }

            return(oScan.InstalledSoftware);
        }
Esempio n. 2
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();
            }
        }