protected override void doInstallSql()
        {
            string targetDir=Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.FullName;
            string installUtilDir=Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
            InstallSql instSql=new InstallSql();

            //Analysis Services SP3 -----------------------------------------------------------------

            // DBSALESPP sql scripts -----------------------------------------------------------------
            instSql.Connect(_sqlServer , "DBSALESPP" , "sa" , this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBSALESPP_settings.txt" , false); //do not throw errors, in case of reinstall
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBSALESPP_tables.txt" , true);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBSALESPP_views.txt" , true);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBSALESPP_sprocs.txt" , true);
            instSql.Disconnect();

            // DBFINF sql create dabase -----------------------------------------------------------------
            instSql.Connect(_sqlServer , "master" , "sa" , this.SqlSaPassword);
            if(this._DBFINFCreate.ToUpper()=="TRUE")
            {
                if(this._DBFINFDbPath!="")
                    instSql.ExecuteSql(@"CREATE DATABASE [DBFINF]  ON (NAME = N'DBFINF_Data', FILENAME = N'" + this._DBFINFDbPath + @"\DBFINF_Data.MDF') LOG ON (NAME = N'DBFINF_Log', FILENAME = N'" + this._DBFINFLogPath + @"\DBFINF_Log.LDF')", true);
                else
                    instSql.ExecuteSql(@"CREATE DATABASE [DBFINF]" , true); //default values
            }
            instSql.Disconnect();

            // DBFINF sql scripts -----------------------------------------------------------------
            instSql.Connect(_sqlServer , "DBFINF" , "sa" , this.SqlSaPassword);

            string msgs=instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBFINF_tables.txt" , false); // do not show errors, log them (in case of reinstall)
            if(msgs!="")
                this.Log(msgs);

            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBFINF_views.txt" , true);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBFINF_sprocs.txt" , true);

            //--
            string filePath=installUtilDir + @"\Version_1_0\sql\sql_scripts\DBFINF_settings.txt";
            System.IO.StreamReader sr=new StreamReader(filePath);
            string strCode=sr.ReadToEnd();
            sr.Close();

            strCode=strCode.Replace("###OLAP_SERVER###" , this._olapServer);

            System.IO.StreamWriter sw=new StreamWriter(filePath , false); //not append
            sw.Write(strCode);
            sw.Close();

            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "DBFINF_settings.txt" , true);
            //--

            instSql.Disconnect();

            // DBSALESPP DSN must exist, do not create -----------------------------------------------------------------

            // NIGHTLY JOB DTS (edit and run vbs file) -----------------------------------------------------------------
            filePath=installUtilDir + @"\Version_1_0\sql\FI_nightly_job.vbs";
            sr=new StreamReader(filePath);
            strCode=sr.ReadToEnd();
            sr.Close();

            strCode=strCode.Replace("###SA_PASS###" , this.SqlSaPassword);
            strCode=strCode.Replace("###SPP_PASS###" , "spp" );
            strCode=strCode.Replace("###SPP_INI_PATH###" , this._salesppIniPath);
            strCode=strCode.Replace("###OLAP_SERVER###" , this._olapServer);
            strCode=strCode.Replace("###HIDE_HIERARCHIES###" , this._olapHideHierarchies);

            sw=new StreamWriter(filePath , false); //not append
            sw.Write(strCode);
            sw.Close();

            System.Diagnostics.Process process=System.Diagnostics.Process.Start(filePath);
            process.WaitForExit();
            process.Close();

            // COPY CS.EXE -----------------------------------------------------------------
            filePath=installUtilDir + @"\Version_1_0\sql\SC.EXE";
            System.IO.File.Copy(filePath , System.Environment.SystemDirectory + @"\SC.EXE", true); //copy sc.exe

            // NIGHTLY JOB SCHEDULE (edit and run sql script) -----------------------------------------------------------------
            filePath=installUtilDir+ @"\Version_1_0\sql\sql_scripts\JOB.txt";
            sr=new StreamReader(filePath);
            strCode=sr.ReadToEnd();
            sr.Close();

            strCode=strCode.Replace("###BCK_PATH###" , this._DBFINFBackupPath);
            strCode=strCode.Replace("###SYSDIR###" , System.Environment.SystemDirectory);
            strCode=strCode.Replace("###CLIENT_PATH###" , targetDir);
            if(this._olapServer.ToUpper()!="LOCALHOST")
                strCode=strCode.Replace("###OLAP_SERVER###" , @"\\" + this._olapServer);
            else
                strCode=strCode.Replace("###OLAP_SERVER###" , "");
            strCode=strCode.Replace("###ROUTING_CONSOLE_PATH###" , this._routingConsolePath);
            strCode=strCode.Replace("###JOB_START###" , this._sqlJobStart);

            sw=new StreamWriter(filePath , false); //not append
            sw.Write(strCode);
            sw.Close();

            instSql.Connect(_sqlServer , "master" , "sa" , this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts" , "JOB.txt" , true);
            instSql.Disconnect();

            // ConoleClient CONFIG -----------------------------------------------------------------
            filePath=targetDir + @"\UI.ConsoleClient.exe.config";

            XmlDocument doc=new XmlDocument();
            doc.Load(filePath);
            XmlElement confEl=(XmlElement)doc.GetElementsByTagName("FIConfig")[0];
            foreach(XmlElement el in confEl.ChildNodes)
            {
                if(el.Name.ToUpper()=="ADD")
                {
                    if (el.GetAttribute("key").ToUpper()=="DistributionServiceURL".ToUpper())
                        el.SetAttribute("value", this._distrServiceUrl);
                    else if (el.GetAttribute("key").ToUpper()=="DistributionServiceUser".ToUpper())
                        el.SetAttribute("value", this._distrServiceUser);
                    else if (el.GetAttribute("key").ToUpper()=="DistributionServicePassword".ToUpper())
                        el.SetAttribute("value", this._distrServicePassword);
                    else if (el.GetAttribute("key").ToUpper()=="DistributionServiceTimeout".ToUpper())
                        el.SetAttribute("value", this._distrServiceTimeout.ToString());
                }
            }
            doc.Save(filePath);
        }
Exemple #2
0
        protected override void doInstallSql()
        {
            // prev version
            if (base.ValidateInstall(false))
            {
                base.doInstallSql();
            }

            string     targetDir      = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.FullName;
            string     installUtilDir = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
            InstallSql instSql        = new InstallSql();

            // DBSALESPP sql scripts -----------------------------------------------------------------
            instSql.Connect(_sqlServer, "DBSALESPP", "sa", this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBSALESPP_settings.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBSALESPP_tables.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBSALESPP_views.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBSALESPP_sprocs.txt", true);
            instSql.Disconnect();

            // DBFINF sql scripts -----------------------------------------------------------------
            instSql.Connect(_sqlServer, "DBFINF", "sa", this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBFINF_tables.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBFINF_views.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "DBFINF_sprocs.txt", true);
            instSql.Disconnect();


            // NIGHTLY JOB DTS (edit and run vbs file) -----------------------------------------------------------------
            string       filePath = installUtilDir + @"\Version_1_2\sql\FI_nightly_job.vbs";
            StreamReader sr       = new StreamReader(filePath);
            string       strCode  = sr.ReadToEnd();

            sr.Close();

            strCode = strCode.Replace("###SA_PASS###", this.SqlSaPassword);
            strCode = strCode.Replace("###SPP_PASS###", "spp");
            strCode = strCode.Replace("###SPP_INI_PATH###", this._salesppIniPath);
            strCode = strCode.Replace("###OLAP_SERVER###", this._olapServer);
            strCode = strCode.Replace("###HIDE_HIERARCHIES###", this._olapHideHierarchies);

            StreamWriter sw = new StreamWriter(filePath, false);            //not append

            sw.Write(strCode);
            sw.Close();

            System.Diagnostics.Process process = System.Diagnostics.Process.Start(filePath);
            process.WaitForExit();
            process.Close();


            // NIGHTLY JOB SCHEDULE (edit and run sql script) -----------------------------------------------------------------
            filePath = installUtilDir + @"\Version_1_2\sql\sql_scripts\JOB.txt";
            sr       = new StreamReader(filePath);
            strCode  = sr.ReadToEnd();
            sr.Close();

            strCode = strCode.Replace("###BCK_PATH###", this._DBFINFBackupPath);
            strCode = strCode.Replace("###SYSDIR###", System.Environment.SystemDirectory);
            strCode = strCode.Replace("###CLIENT_PATH###", targetDir);
            if (this._olapServer.ToUpper() != "LOCALHOST")
            {
                strCode = strCode.Replace("###OLAP_SERVER###", @"\\" + this._olapServer);
            }
            else
            {
                strCode = strCode.Replace("###OLAP_SERVER###", "");
            }
            strCode = strCode.Replace("###ROUTING_CONSOLE_PATH###", this._routingConsolePath);
            strCode = strCode.Replace("###RESTORE_DB_ON_ERROR###", this._olapRestoreDbOnError);
            strCode = strCode.Replace("###JOB_START###", this._sqlJobStart);

            sw = new StreamWriter(filePath, false);            //not append
            sw.Write(strCode);
            sw.Close();

            instSql.Connect(_sqlServer, "master", "sa", this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_2\sql\sql_scripts", "JOB.txt", true);
            instSql.Disconnect();
        }
        protected override void doInstallSql()
        {
            string     targetDir      = Directory.GetParent(Assembly.GetExecutingAssembly().Location).Parent.FullName;
            string     installUtilDir = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
            InstallSql instSql        = new InstallSql();

            //Analysis Services SP3 -----------------------------------------------------------------


            // DBSALESPP sql scripts -----------------------------------------------------------------
            instSql.Connect(_sqlServer, "DBSALESPP", "sa", this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBSALESPP_settings.txt", false);               //do not throw errors, in case of reinstall
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBSALESPP_tables.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBSALESPP_views.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBSALESPP_sprocs.txt", true);
            instSql.Disconnect();


            // DBFINF sql create dabase -----------------------------------------------------------------
            instSql.Connect(_sqlServer, "master", "sa", this.SqlSaPassword);
            if (this._DBFINFCreate.ToUpper() == "TRUE")
            {
                if (this._DBFINFDbPath != "")
                {
                    instSql.ExecuteSql(@"CREATE DATABASE [DBFINF]  ON (NAME = N'DBFINF_Data', FILENAME = N'" + this._DBFINFDbPath + @"\DBFINF_Data.MDF') LOG ON (NAME = N'DBFINF_Log', FILENAME = N'" + this._DBFINFLogPath + @"\DBFINF_Log.LDF')", true);
                }
                else
                {
                    instSql.ExecuteSql(@"CREATE DATABASE [DBFINF]", true);                      //default values
                }
            }
            instSql.Disconnect();


            // DBFINF sql scripts -----------------------------------------------------------------
            instSql.Connect(_sqlServer, "DBFINF", "sa", this.SqlSaPassword);

            string msgs = instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBFINF_tables.txt", false);             // do not show errors, log them (in case of reinstall)

            if (msgs != "")
            {
                this.Log(msgs);
            }

            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBFINF_views.txt", true);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBFINF_sprocs.txt", true);

            //--
            string filePath = installUtilDir + @"\Version_1_0\sql\sql_scripts\DBFINF_settings.txt";

            System.IO.StreamReader sr = new StreamReader(filePath);
            string strCode            = sr.ReadToEnd();

            sr.Close();

            strCode = strCode.Replace("###OLAP_SERVER###", this._olapServer);

            System.IO.StreamWriter sw = new StreamWriter(filePath, false);            //not append
            sw.Write(strCode);
            sw.Close();

            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "DBFINF_settings.txt", true);
            //--

            instSql.Disconnect();


            // DBSALESPP DSN must exist, do not create -----------------------------------------------------------------


            // NIGHTLY JOB DTS (edit and run vbs file) -----------------------------------------------------------------
            filePath = installUtilDir + @"\Version_1_0\sql\FI_nightly_job.vbs";
            sr       = new StreamReader(filePath);
            strCode  = sr.ReadToEnd();
            sr.Close();

            strCode = strCode.Replace("###SA_PASS###", this.SqlSaPassword);
            strCode = strCode.Replace("###SPP_PASS###", "spp");
            strCode = strCode.Replace("###SPP_INI_PATH###", this._salesppIniPath);
            strCode = strCode.Replace("###OLAP_SERVER###", this._olapServer);
            strCode = strCode.Replace("###HIDE_HIERARCHIES###", this._olapHideHierarchies);

            sw = new StreamWriter(filePath, false);            //not append
            sw.Write(strCode);
            sw.Close();

            System.Diagnostics.Process process = System.Diagnostics.Process.Start(filePath);
            process.WaitForExit();
            process.Close();


            // COPY CS.EXE -----------------------------------------------------------------
            filePath = installUtilDir + @"\Version_1_0\sql\SC.EXE";
            System.IO.File.Copy(filePath, System.Environment.SystemDirectory + @"\SC.EXE", true);              //copy sc.exe


            // NIGHTLY JOB SCHEDULE (edit and run sql script) -----------------------------------------------------------------
            filePath = installUtilDir + @"\Version_1_0\sql\sql_scripts\JOB.txt";
            sr       = new StreamReader(filePath);
            strCode  = sr.ReadToEnd();
            sr.Close();

            strCode = strCode.Replace("###BCK_PATH###", this._DBFINFBackupPath);
            strCode = strCode.Replace("###SYSDIR###", System.Environment.SystemDirectory);
            strCode = strCode.Replace("###CLIENT_PATH###", targetDir);
            if (this._olapServer.ToUpper() != "LOCALHOST")
            {
                strCode = strCode.Replace("###OLAP_SERVER###", @"\\" + this._olapServer);
            }
            else
            {
                strCode = strCode.Replace("###OLAP_SERVER###", "");
            }
            strCode = strCode.Replace("###ROUTING_CONSOLE_PATH###", this._routingConsolePath);
            strCode = strCode.Replace("###JOB_START###", this._sqlJobStart);

            sw = new StreamWriter(filePath, false);            //not append
            sw.Write(strCode);
            sw.Close();

            instSql.Connect(_sqlServer, "master", "sa", this.SqlSaPassword);
            instSql.ExecuteSqlFile(@"Version_1_0\sql\sql_scripts", "JOB.txt", true);
            instSql.Disconnect();


            // ConoleClient CONFIG -----------------------------------------------------------------
            filePath = targetDir + @"\UI.ConsoleClient.exe.config";

            XmlDocument doc = new XmlDocument();

            doc.Load(filePath);
            XmlElement confEl = (XmlElement)doc.GetElementsByTagName("FIConfig")[0];

            foreach (XmlElement el in confEl.ChildNodes)
            {
                if (el.Name.ToUpper() == "ADD")
                {
                    if (el.GetAttribute("key").ToUpper() == "DistributionServiceURL".ToUpper())
                    {
                        el.SetAttribute("value", this._distrServiceUrl);
                    }
                    else if (el.GetAttribute("key").ToUpper() == "DistributionServiceUser".ToUpper())
                    {
                        el.SetAttribute("value", this._distrServiceUser);
                    }
                    else if (el.GetAttribute("key").ToUpper() == "DistributionServicePassword".ToUpper())
                    {
                        el.SetAttribute("value", this._distrServicePassword);
                    }
                    else if (el.GetAttribute("key").ToUpper() == "DistributionServiceTimeout".ToUpper())
                    {
                        el.SetAttribute("value", this._distrServiceTimeout.ToString());
                    }
                }
            }
            doc.Save(filePath);
        }