Пример #1
0
        //load processed data from PreData folder
        public static SQLProductSum LoadSQLProductFromMetaData()
        {
            SQLProductSum sum  = null;
            string        path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            //string path2 = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            path = Path.Combine(path, "MetaData");
            if (!Directory.Exists(path))
            {
                Logger.LogMsg("[LoadSQLProductFromMetaData]Data folder doesn't exist:" + path);
                return(null);
            }

            UpdateProgress("Loading MSI/MSP meta data from:" + path + ", may take minutes...", true);

            List <string> xmlFiles = Utility.GetFilesFromFolder(path, new string[] { "*.xml" });
            SQLProductSum totalSum = new SQLProductSum("All-Pre-Sum", "Pre-MetaData", "Merge All sum in predata folder into one");

            foreach (string f in xmlFiles)
            {
                try
                {
                    UpdateProgress("Reading MSI/MSP meta data from pre-processed data:" + Path.GetFileName(f) + ", may take minutes...", true);
                    sum = OutputProcessor.DataContractDeSerializeToXML <SQLProductSum>(f);
                    totalSum.AddProductSum(sum);
                }
                catch (Exception ex)
                {
                    Logger.LogError("[LoadSQLProductFromMetaData]:" + ex.Message);
                }
            }

            return(totalSum);
        }
Пример #2
0
        public static void ScanSQLRegistry()
        {
            UpdateProgress("Scan starts...", true);

            // var m=LoadSQLProductFromPreData();
            //  m.name = "SQL2008-2017RTM_AllLang";
            //  m.source = "";
            //  m.SaveData("SQL2008-2017RTM_AllLang", @"c:\temp\SQL2008-SQL2017_AllLang.sum.xml");

            ////  LoadSQLProductFromSetupSrc();


            if (sumSQLProduct != null)
            {
                sumSQLProduct.Reset();
            }

            //  SQLProduct sql = new SQLProduct("SQL2012", @"D:\SETUP Media\2016\2016 SQLFull_ENU");
            // SQLProduct sql = new SQLProduct("SQL2012", @"\\shlabprod01\Products\Applications\Server\SQL\SQL Server 2012\SQLFULL");
            //    string data = OutputProcessor.SerializeToXML<SQLProduct>(sql);

            /*
             * string f = @"c:\temp\SQL2016RTM_ENU.xml";
             * //  File.WriteAllText(f, data);
             * SQLProduct sql0 = new SQLProduct(f);
             * sqlProducts.Add(sql0);
             */

            Thread sourceTD = null;

            if (SQLSetupSource != "")
            {
                sourceTD = new Thread(new ThreadStart(LoadSQLProductFromSetupSrc));
                sourceTD.Start();
            }


            //start thread to load registry keys first.
            regHives.Clear();
            normalThreads = LoadRegHives();

            //and also load big Items
            bigThreads = LoadBigItems();

            //Load pre-processed data;
            sumSQLProduct = LoadSQLProductFromMetaData();

            if (!string.IsNullOrEmpty(cachedMetaDataFile))
            {
                sumSQLProduct.AddProductSumFromFile(cachedMetaDataFile);
            }

            if (sourceTD != null)
            {
                sourceTD.Join();
            }


            //Time to merge it.
            if (sumFromSetupSrc != null)
            {
                sumSQLProduct.AddProductSum(sumFromSetupSrc);
            }

            ////Now need to add products to gProduct
            //foreach (SQLProduct sql in Controller.products)
            //{
            //    sumSQLProduct.InitOrAddHashSet(sql);
            //}
            //Time to get SQL related keys
            sqlRegKeys.Clear();

            //wait for all thread loading is completed.
            foreach (Thread th in normalThreads)
            {
                th.Join();
            }

            //If closing
            if (Controller.shouldAbort)
            {
                return;
            }


            Analysis.KnownKeys.Add();
            Analysis.Installer.Add();

            Analysis.Services.Add();
            Analysis.Uninstall.Add();//need to call after Installer.Add because it will reference data geot from installer.Add function
            Analysis.COMClass.Add();

            Analysis.FromMSI.Add();
            //Now generate nodes for treeview

            Logger.LogMsg("Total found SQL related keys:" + sqlRegKeys.Count);
            GenerateRegNodes();

            Logger.LogMsg("UpdateNodeTextWithNodeCount started.");
            RegNode.UpdateNodeTextWithNodeCount(Controller.rootNode);
            Logger.LogMsg("UpdateNodeTextWithNodeCount done.");


            UpdateProgress("Scan done.", true);
            DoneCallBack();
        }