public string GetLink(string nodePath, DataRow row)
        {
            string[] path = nodePath.Split('\\');

            if (path.Length == 3 && path[0] == "Products" && path[2] == "Components")
            {
                string component = (string)row["ProductComponentsComponentID"];
                return(String.Format(@"Products\{0}\Components\{1}", path[1], component));
            }
            else if (path.Length == 4 && path[0] == "Products" && path[2] == "Features")
            {
                string component = (string)row["ProductFeatureComponentsComponentID"];
                return(String.Format(@"Products\{0}\Components\{1}", path[1], component));
            }
            else if (path.Length == 3 && path[0] == "Products" && path[2] == "Files")
            {
                string component = (string)row["ProductFilesComponentID"];
                return(String.Format(@"Products\{0}\Components\{1}", path[1], component));
            }
            else if (path.Length == 3 && path[0] == "Products" && path[2] == "Registry")
            {
                string component = (string)row["ProductRegistryComponentID"];
                return(String.Format(@"Products\{0}\Components\{1}", path[1], component));
            }
            else if (path.Length == 5 && path[0] == "Products" && path[2] == "Components" && path[4] == "Sharing")
            {
                string product = (string)row["ComponentProductsProductCode"];
                return(String.Format(@"Products\{0}\Components\{1}", MsiUtils.GetProductName(product), path[3]));
            }
            return(null);
        }
Beispiel #2
0
        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 DataView GetData(string nodePath)
        {
            string[] path = nodePath.Split('\\');

            if (path.Length == 4 && path[0] == "Products" && path[2] == "Features")
            {
                return(GetFeatureComponentsData(MsiUtils.GetProductCode(path[1]), path[3]));
            }
            else if (path.Length == 3 && path[0] == "Products" && path[2] == "Components")
            {
                return(GetProductComponentsData(MsiUtils.GetProductCode(path[1])));
            }
            else if (path.Length == 4 && path[0] == "Products" && path[2] == "Components")
            {
                return(GetComponentData(MsiUtils.GetProductCode(path[1]), path[3]));
            }
            else if (path.Length == 5 && path[0] == "Products" && path[2] == "Components" && path[4] == "Sharing")
            {
                return(GetComponentProductsData(path[3]));
            }
            else if (path.Length == 3 && path[0] == "Products" && path[2] == "Files")
            {
                return(GetProductFilesData(MsiUtils.GetProductCode(path[1])));
            }
            else if (path.Length == 3 && path[0] == "Products" && path[2] == "Registry")
            {
                return(GetProductRegistryData(MsiUtils.GetProductCode(path[1])));
            }
            return(null);
        }
Beispiel #4
0
        public string GetLink(string nodePath, DataRow row)
        {
            string[] path = nodePath.Split('\\');

            if (path.Length == 1 && path[0] == "Products")
            {
                return(String.Format(@"Products\{0}", MsiUtils.GetProductName((string)row["ProductsProductCode"])));
            }
            return(null);
        }
Beispiel #5
0
        public DataView GetData(string nodePath)
        {
            string[] path = nodePath.Split('\\');

            if (path.Length == 3 && path[0] == "Products" && path[2] == "Features")
            {
                return(GetProductFeaturesData(MsiUtils.GetProductCode(path[1])));
            }
            return(null);
        }
Beispiel #6
0
        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)));
        }
Beispiel #7
0
        public DataView GetData(string nodePath)
        {
            string[] path = nodePath.Split('\\');

            if (path.Length == 1 && path[0] == "Products")
            {
                return(this.GetAllProductsData());
            }
            else if (path.Length == 2 && path[0] == "Products")
            {
                return(this.GetProductData(MsiUtils.GetProductCode(path[1])));
            }
            return(null);
        }
Beispiel #8
0
        private DataView GetAllProductsData()
        {
            DataTable table = new DataTable("Products");

            table.Locale = CultureInfo.InvariantCulture;
            table.Columns.Add("ProductsProductName", typeof(string));
            table.Columns.Add("ProductsProductCode", typeof(string));

            foreach (ProductInstallation product in ProductInstallation.AllProducts)
            {
                string productName = MsiUtils.GetProductName(product.ProductCode);
                table.Rows.Add(new object[] { productName, product.ProductCode });
            }
            return(new DataView(table, "", "ProductsProductName ASC", DataViewRowState.CurrentRows));
        }
Beispiel #9
0
        public string GetLink(string nodePath, DataRow row)
        {
            string[] path = nodePath.Split('\\');

            if (path.Length == 3 && path[0] == "Products" && path[2] == "Patches")
            {
                return(String.Format(@"Patches\{0}", row["ProductPatchesPatchCode"]));
            }
            else if (path.Length == 1 && path[0] == "Patches")
            {
                return(String.Format(@"Patches\{0}", row["PatchesPatchCode"]));
            }
            else if (path.Length == 3 && path[0] == "Patches" && path[2] == "Patched Products")
            {
                return(String.Format(@"Products\{0}", MsiUtils.GetProductCode((string)row["PatchTargetsProductCode"])));
            }
            return(null);
        }
Beispiel #10
0
        private DataView GetPatchTargetData(string patchCode)
        {
            DataTable table = new DataTable("PatchTargets");

            table.Locale = CultureInfo.InvariantCulture;
            table.Columns.Add("PatchTargetsProductName", typeof(string));
            table.Columns.Add("PatchTargetsProductCode", typeof(string));

            foreach (PatchInstallation patch in PatchInstallation.GetPatches(patchCode, null, null, UserContexts.All, PatchStates.Applied))
            {
                if (patch.PatchCode == patchCode)
                {
                    string productName = MsiUtils.GetProductName(patch.ProductCode);
                    table.Rows.Add(new object[] { productName, patch.ProductCode });
                }
            }
            return(new DataView(table, "", "PatchTargetsProductName ASC", DataViewRowState.CurrentRows));
        }
        public DataView GetComponentProductsData(string componentCode)
        {
            DataTable table = new DataTable("ComponentProducts");

            table.Locale = CultureInfo.InvariantCulture;
            table.Columns.Add("ComponentProductsProductName", typeof(string));
            table.Columns.Add("ComponentProductsProductCode", typeof(string));
            table.Columns.Add("ComponentProductsComponentPath", typeof(string));

            if (this.componentProductsMap != null)
            {
                ArrayList componentProducts = (ArrayList)this.componentProductsMap[componentCode];
                foreach (string productCode in componentProducts)
                {
                    string productName   = MsiUtils.GetProductName(productCode);
                    string componentPath = new ComponentInstallation(componentCode, productCode).Path;
                    table.Rows.Add(new object[] { productName, productCode, componentPath });
                }
                return(new DataView(table, "", "ComponentProductsProductName ASC", DataViewRowState.CurrentRows));
            }
            return(null);
        }
        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)));
        }