public string[] GetNodes(InventoryDataLoadStatusCallback statusCallback) { ArrayList nodes = new ArrayList(); statusCallback(nodes.Count, @"Products\...\Patches"); foreach (ProductInstallation product in ProductInstallation.AllProducts) { string productName = MsiUtils.GetProductName(product.ProductCode); bool addedRoot = false; foreach (PatchInstallation productPatch in PatchInstallation.GetPatches(null, product.ProductCode, null, UserContexts.All, PatchStates.Applied)) { if (!addedRoot) { nodes.Add(String.Format(@"Products\{0}\Patches", productName)); } nodes.Add(String.Format(@"Products\{0}\Patches\{1}", productName, productPatch.PatchCode)); } } statusCallback(nodes.Count, "Patches"); string[] allPatches = GetAllPatchesList(); if (allPatches.Length > 0) { nodes.Add("Patches"); foreach (string patchCode in allPatches) { nodes.Add(String.Format(@"Patches\{0}", patchCode)); nodes.Add(String.Format(@"Patches\{0}\Patched Products", patchCode)); } statusCallback(nodes.Count, String.Empty); } return((string[])nodes.ToArray(typeof(string))); }
public string[] GetNodes(InventoryDataLoadStatusCallback statusCallback) { ArrayList nodes = new ArrayList(); statusCallback(nodes.Count, @"Products\...\Patches"); foreach (ProductInstallation product in ProductInstallation.AllProducts) { string productName = MsiUtils.GetProductName(product.ProductCode); bool addedRoot = false; foreach (PatchInstallation productPatch in PatchInstallation.GetPatches(null, product.ProductCode, null, UserContexts.All, PatchStates.Applied)) { if (!addedRoot) nodes.Add(String.Format(@"Products\{0}\Patches", productName)); nodes.Add(String.Format(@"Products\{0}\Patches\{1}", productName, productPatch.PatchCode)); } } statusCallback(nodes.Count, "Patches"); string[] allPatches = GetAllPatchesList(); if(allPatches.Length > 0) { nodes.Add("Patches"); foreach(string patchCode in allPatches) { nodes.Add(String.Format(@"Patches\{0}", patchCode)); nodes.Add(String.Format(@"Patches\{0}\Patched Products", patchCode)); } statusCallback(nodes.Count, String.Empty); } return (string[]) nodes.ToArray(typeof(string)); }
public string[] GetNodes(InventoryDataLoadStatusCallback statusCallback) { statusCallback(0, @"Products\...\Features"); ArrayList nodes = new ArrayList(); foreach (ProductInstallation product in ProductInstallation.AllProducts) { nodes.Add(String.Format(@"Products\{0}\Features", MsiUtils.GetProductName(product.ProductCode))); } statusCallback(nodes.Count, String.Empty); return (string[]) nodes.ToArray(typeof(string)); }
public string[] GetNodes(InventoryDataLoadStatusCallback statusCallback) { statusCallback(0, @"Products\...\Features"); ArrayList nodes = new ArrayList(); foreach (ProductInstallation product in ProductInstallation.AllProducts) { nodes.Add(String.Format(@"Products\{0}\Features", MsiUtils.GetProductName(product.ProductCode))); } statusCallback(nodes.Count, String.Empty); return((string[])nodes.ToArray(typeof(string))); }
public string[] GetNodes(InventoryDataLoadStatusCallback statusCallback) { ArrayList nodes = new ArrayList(); componentProductsMap = new Hashtable(); foreach(ProductInstallation product in ProductInstallation.AllProducts) { string productName = MsiUtils.GetProductName(product.ProductCode); statusCallback(nodes.Count, String.Format(@"Products\{0}", productName)); try { IntPtr hWnd = IntPtr.Zero; Installer.SetInternalUI(InstallUIOptions.Silent, ref hWnd); lock(syncRoot) // Only one Installer session can be active at a time { using (Session session = Installer.OpenProduct(product.ProductCode)) { statusCallback(nodes.Count, String.Format(@"Products\{0}\Features", productName)); IList<string> features = session.Database.ExecuteStringQuery("SELECT `Feature` FROM `Feature`"); string[] featuresArray = new string[features.Count]; features.CopyTo(featuresArray, 0); Array.Sort(featuresArray, 0, featuresArray.Length, StringComparer.OrdinalIgnoreCase); foreach (string feature in featuresArray) { nodes.Add(String.Format(@"Products\{0}\Features\{1}", productName, feature)); } statusCallback(nodes.Count, String.Format(@"Products\{0}\Components", productName)); nodes.Add(String.Format(@"Products\{0}\Components", productName)); IList<string> components = session.Database.ExecuteStringQuery("SELECT `ComponentId` FROM `Component`"); for (int i = 0; i < components.Count; i++) { string component = components[i]; if (component.Length > 0) { nodes.Add(String.Format(@"Products\{0}\Components\{1}", productName, component)); ArrayList sharingProducts = (ArrayList) componentProductsMap[component]; if (sharingProducts == null) { sharingProducts = new ArrayList(); componentProductsMap[component] = sharingProducts; } sharingProducts.Add(product.ProductCode); } if (i % 100 == 0) statusCallback(nodes.Count, null); } nodes.Add(String.Format(@"Products\{0}\Files", productName)); nodes.Add(String.Format(@"Products\{0}\Registry", productName)); statusCallback(nodes.Count, String.Empty); } } } catch(InstallerException) { } } statusCallback(nodes.Count, @"Products\...\Components\...\Sharing"); foreach (DictionaryEntry componentProducts in componentProductsMap) { string component = (string) componentProducts.Key; ArrayList products = (ArrayList) componentProducts.Value; if(products.Count > 1) { foreach(string productCode in products) { nodes.Add(String.Format(@"Products\{0}\Components\{1}\Sharing", MsiUtils.GetProductName(productCode), component)); } } } statusCallback(nodes.Count, String.Empty); return (string[]) nodes.ToArray(typeof(string)); }
public string[] GetNodes(InventoryDataLoadStatusCallback statusCallback) { ArrayList nodes = new ArrayList(); componentProductsMap = new Hashtable(); foreach (ProductInstallation product in ProductInstallation.AllProducts) { string productName = MsiUtils.GetProductName(product.ProductCode); statusCallback(nodes.Count, String.Format(@"Products\{0}", productName)); try { IntPtr hWnd = IntPtr.Zero; Installer.SetInternalUI(InstallUIOptions.Silent, ref hWnd); lock (syncRoot) // Only one Installer session can be active at a time { using (Session session = Installer.OpenProduct(product.ProductCode)) { statusCallback(nodes.Count, String.Format(@"Products\{0}\Features", productName)); IList <string> features = session.Database.ExecuteStringQuery("SELECT `Feature` FROM `Feature`"); string[] featuresArray = new string[features.Count]; features.CopyTo(featuresArray, 0); Array.Sort(featuresArray, 0, featuresArray.Length, StringComparer.OrdinalIgnoreCase); foreach (string feature in featuresArray) { nodes.Add(String.Format(@"Products\{0}\Features\{1}", productName, feature)); } statusCallback(nodes.Count, String.Format(@"Products\{0}\Components", productName)); nodes.Add(String.Format(@"Products\{0}\Components", productName)); IList <string> components = session.Database.ExecuteStringQuery("SELECT `ComponentId` FROM `Component`"); for (int i = 0; i < components.Count; i++) { string component = components[i]; if (component.Length > 0) { nodes.Add(String.Format(@"Products\{0}\Components\{1}", productName, component)); ArrayList sharingProducts = (ArrayList)componentProductsMap[component]; if (sharingProducts == null) { sharingProducts = new ArrayList(); componentProductsMap[component] = sharingProducts; } sharingProducts.Add(product.ProductCode); } if (i % 100 == 0) { statusCallback(nodes.Count, null); } } nodes.Add(String.Format(@"Products\{0}\Files", productName)); nodes.Add(String.Format(@"Products\{0}\Registry", productName)); statusCallback(nodes.Count, String.Empty); } } } catch (InstallerException) { } } statusCallback(nodes.Count, @"Products\...\Components\...\Sharing"); foreach (DictionaryEntry componentProducts in componentProductsMap) { string component = (string)componentProducts.Key; ArrayList products = (ArrayList)componentProducts.Value; if (products.Count > 1) { foreach (string productCode in products) { nodes.Add(String.Format(@"Products\{0}\Components\{1}\Sharing", MsiUtils.GetProductName(productCode), component)); } } } statusCallback(nodes.Count, String.Empty); return((string[])nodes.ToArray(typeof(string))); }