Пример #1
0
        public void SaveData(string desc, string fileName)
        {
            this.description = desc;
            string data = OutputProcessor.DataContractSerializeToXML <SQLProductSum>(this);

            File.WriteAllText(fileName, data);
        }
Пример #2
0
        public static void LoadSQLProductFromSetupSrc()
        {
            LastSQLSetupSource = SQLSetupSource;
            //  string path = @"D:\SETUP Media\2016";
            //  path = @"\\sqlbuilds\Released\SQLServer2016\RTM\13.0.1601.5\release\editions\SQLFull_CHS";
            UpdateProgress("Scanning MSI/MSP packages from:" + SQLSetupSource, true);
            //   SQLProduct sql2016 = new SQLProduct("SQL2016", SQLSetupSource);
            //  sqlProducts.Add(sql2016);

            string folder = Utility.CleanFileName(SQLSetupSource);

            if (folder.Length > 20)
            {
                folder = folder.Substring(0, 10) + "..." + folder.Substring(folder.Length - 10);
            }

            string name = "Cached_" + folder + System.DateTime.Now.ToString("_yyyy-MM-dd_HH_mm_ss");

            SQLProduct sql = new SQLProduct(name, SQLSetupSource);


            try
            {
                //Save it temp folder so that we can copy it to data folder.
                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, "Cache");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                sumFromSetupSrc = new SQLProductSum(name, SQLSetupSource, "By SQLMsiMspScan.");
                sumFromSetupSrc.InitOrAddHashSet(sql);
                string file    = Path.Combine(path, name + ".sum.xml");
                string content = OutputProcessor.DataContractSerializeToXML <SQLProductSum>(sumFromSetupSrc);
                File.WriteAllText(file, content);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
            }
        }