Ejemplo n.º 1
0
        public static InstalledSoftware GetInstalledSoftwareInfo()
        {
            InstalledSoftware     dev  = new InstalledSoftware();
            List <SoftwareDetail> list = new List <SoftwareDetail>();

            AddHarwareDevices(ref list);
            dev.ListSoftware = list;

            return(dev);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            InstalledSoftware installedSoftware = await db.InstalledSoftware.FindAsync(id);

            if (installedSoftware.ApplicationUserId != User.Identity.GetUserId() && !User.IsInRole("Admin"))
            {
                return(RedirectToAction("Delete", new { id = id }));
            }

            db.InstalledSoftware.Remove(installedSoftware);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index", new { selectedComputer = Session["selectedComputer"] }));
        }
        public async Task <ActionResult> Create([Bind(Include = "InstalledSoftwareId,RecordDate,ComputersId,SoftwareId,ApplicationUserId")] InstalledSoftware installedSoftware)
        {
            if (ModelState.IsValid)
            {
                db.InstalledSoftware.Add(installedSoftware);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ComputersId       = new SelectList(db.Computers, "ComputersId", "Name", installedSoftware.ComputersId);
            ViewBag.SoftwareId        = new SelectList(db.Software, "SoftwareId", "Manufacturer", installedSoftware.SoftwareId);
            ViewBag.ApplicationUserId = new SelectList(db.Users, "Id", "FirstName", installedSoftware.ApplicationUserId);

            return(View(installedSoftware));
        }
        // GET: InstalledSoftware/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            InstalledSoftware installedSoftware = await db.InstalledSoftware.FindAsync(id);

            if (installedSoftware == null)
            {
                return(HttpNotFound());
            }

            return(View(installedSoftware));
        }
Ejemplo n.º 5
0
        private static InstalledSoftware GetInstalledSoftwareInfoByRegistry(RegistryKey key, int bits)
        {
            var installedSoftware = new InstalledSoftware();

            try
            {
                if (key.GetValue("DisplayName") != null)
                {
                    var displayName = key.GetValue("DisplayName").ToString();
                    if (!string.IsNullOrEmpty(displayName))
                    {
                        installedSoftware.Bits        = bits;
                        installedSoftware.ProductName = displayName.Trim();
                        if (key.GetValue("Publisher") != null)
                        {
                            installedSoftware.Publisher = key.GetValue("Publisher").ToString();
                        }
                        if (key.GetValue("DisplayVersion") != null)
                        {
                            installedSoftware.VersionString = key.GetValue("DisplayVersion").ToString();
                        }
                        if (key.GetValue("InstallLocation") != null)
                        {
                            installedSoftware.InstallLocation = key.GetValue("InstallLocation").ToString();
                        }
                        if (key.GetValue("InstallDate") != null)
                        {
                            installedSoftware.InstallDateString = key.GetValue("InstallDate").ToString();
                        }
                        if (key.GetValue("Size") != null)
                        {
                            installedSoftware.Size = Convert.ToInt32(key.GetValue("Size").ToString());
                        }
                        return(installedSoftware);
                    }
                }

                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        private static List <InstalledSoftware> GetMsiInstalledSoftwareList()
        {
            var list = new List <InstalledSoftware>();

            try
            {
                int index = 0;
                var productGuidStrBlder = new StringBuilder(39);
                while (0 == MsiEnumProducts(index++, productGuidStrBlder))
                {
                    var installedSoftware = new InstalledSoftware();
                    //InstallLocation 1024
                    foreach (string property in new string[] { "ProductName", "Publisher", "VersionString" })
                    {
                        int charCount = 512;
                        var value     = new StringBuilder(charCount);
                        if (MsiGetProductInfo(productGuidStrBlder.ToString(), property, value, ref charCount) == 0)
                        {
                            value.Length = charCount;
                            if (property == "ProductName")
                            {
                                installedSoftware.ProductName = value.ToString().Trim();
                            }
                            else if (property == "Publisher")
                            {
                                installedSoftware.Publisher = value.ToString();
                            }
                            else if (property == "VersionString")
                            {
                                installedSoftware.VersionString = value.ToString();
                            }
                        }
                    }

                    list.Add(installedSoftware);
                }
            }
            catch
            {
                return(list);
            }

            return(list);
        }
        // GET: InstalledSoftware/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            InstalledSoftware installedSoftware = await db.InstalledSoftware.FindAsync(id);

            if (installedSoftware == null)
            {
                return(HttpNotFound());
            }

            ViewBag.ComputersId = new SelectList(db.Computers, "ComputersId", "Name", installedSoftware.ComputersId);
            ViewBag.SoftwareId  = new SelectList(db.Software, "SoftwareId", "Name", installedSoftware.SoftwareId);

            return(View(installedSoftware));
        }
Ejemplo n.º 8
0
 private static void getInstalledSoftwareFromKey(RegistryKey rk, ref Dictionary <string, InstalledSoftware> softwareList)
 {
     foreach (string skName in rk.GetSubKeyNames())
     {
         using (RegistryKey sk = rk.OpenSubKey(skName))
         {
             if (!softwareList.ContainsKey(skName))
             {
                 try
                 {
                     var item = new InstalledSoftware();
                     item.Name        = (string)sk.GetValue("DisplayName");
                     item.RegistryKey = skName;
                     item.Version     = (string)sk.GetValue("DisplayVersion");
                     item.InstallDate = (string)sk.GetValue("InstallDate");
                     softwareList.Add(skName, item);
                 }
                 catch (Exception ex)
                 { }
             }
         }
     }
 }
Ejemplo n.º 9
0
        internal void scan(Intune_API oAPI)
        {
            try
            {
                var lIDs = oAPI.getRZIDs();
                //File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\dbg.txt"), new string[] { "Repository-Items:" + SoftwareRepository.Count.ToString() });

#if DEBUG
                System.IO.File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\RZDebug.txt"), new string[] { DateTime.Now.ToString() + ";S0;" + "RZItems detected: ", lIDs.Count.ToString() });
#endif
#if DEBUG
                System.IO.File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\RZDebug.txt"), new string[] { DateTime.Now.ToString() + ";S0;" + "Repository Items: ", SoftwareRepository.Count().ToString() });
#endif

                foreach (Intune_API.GraphRZ RZSW in lIDs)
                {
                    try
                    {
                        if (SoftwareRepository.Count(t => t.SWId == RZSW.RZID) == 0)
                        {
                            //File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\dbg.txt"), new string[] { "not match, IconId:" + SQLRZ.RZID.ToString() });

                            var oSW = SoftwareRepository.FirstOrDefault(t => t.ShortName == RZSW.Shortname);

                            if (oSW != null)
                            {
                                AddSoftware oNew = new AddSoftware()
                                {
                                    ProductName    = oSW.ProductName,
                                    ProductVersion = oSW.ProductVersion,
                                    Manufacturer   = oSW.Manufacturer,
                                    ShortName      = oSW.ShortName,
                                    Description    = oSW.Description,
                                    SWId           = oSW.SWId,
                                    IconHash       = oSW.IconHash,
                                    MSIProductID   = RZSW.Version
                                };

                                //if (RZSW.Bootstrap)
                                //    oNew.Author = "BootstrapTrue";
                                //else
                                //    oNew.Author = "BootstrapFalse";

#if DEBUG
                                System.IO.File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\RZDebug.txt"), new string[] { DateTime.Now.ToString() + ";S1;" + "New SWVersion: ", oNew.ProductName, oNew.ProductVersion, oNew.MSIProductID });
#endif
                                NewSoftwareVersions.Add(oNew);
                            }
                        }
                        else
                        {
                            try
                            {
                                var oSW = SoftwareRepository.FirstOrDefault(t => t.SWId == RZSW.RZID);
                                if (oSW != null)
                                {
                                    try
                                    {
                                        AddSoftware oExisting = new AddSoftware()
                                        {
                                            ProductName    = oSW.ProductName,
                                            ProductVersion = oSW.ProductVersion,
                                            Manufacturer   = oSW.Manufacturer,
                                            ShortName      = oSW.ShortName,
                                            Description    = oSW.Description,
                                            IconHash       = oSW.IconHash,
                                            SWId           = oSW.SWId
                                        };

                                        //if (RZSW.Bootstrap)
                                        //    oExisting.Author = "BootstrapTrue";
                                        //else
                                        //    oExisting.Author = "BootstrapFalse";

#if DEBUG
                                        System.IO.File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\RZDebug.txt"), new string[] { DateTime.Now.ToString() + ";S2;" + "Installed SWVersion: ", oExisting.ProductName, oExisting.ProductVersion });
#endif
                                        InstalledSoftware.Add(oExisting);
                                    }
                                    catch { }
                                }
                            }
                            catch { }
                        }
                    }
                    catch (Exception ex)
                    {
                        System.IO.File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\RZError.txt"), new string[] { DateTime.Now.ToString() + ";F1814E1" + ex.Message });
                    }
                }

                //Cleanup SW where new Version already exists
                foreach (var oSW in InstalledSoftware)
                {
                    NewSoftwareVersions.RemoveAll(t => t.ShortName == oSW.ShortName);
                }
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllLines(Environment.ExpandEnvironmentVariables("%TEMP%\\RZError.txt"), new string[] { DateTime.Now.ToString() + ";F1845E1" + ex.Message });
            }
            OnUpdScanCompleted(this, new EventArgs());
            OnSWScanCompleted(this, new EventArgs());
        }