示例#1
0
        protected void btn_ok_Click(object sender, EventArgs e)
        {
            InstallSetting set = new InstallSetting();

            set.DB_Server = TextBox1.Text;
            set.DB_Name   = TextBox2.Text;
            set.DB_Uid    = TextBox3.Text;
            set.DB_Pwd    = TextBox4.Text;

            //AbstrctFactory dbo = DataFactory.CreateDataFactory("mssql", "server=" + set.DB_Server + ";database=" + set.DB_Name + ";uid=" + set.DB_Uid + ";pwd=" + set.DB_Pwd + ";");
            try
            {
                //序列化设置
                SinGooCMS.Install.InstallUtil.EditDBConfig(set.DB_Server, set.DB_Name, set.DB_Uid, set.DB_Pwd);
                System.IO.File.WriteAllText(Server.MapPath("/Install/setting.xml"), SinGooCMS.Utility.XmlSerializerUtils.Serialize <InstallSetting>(set));
                Response.Redirect("Step4.aspx");
            }
            catch
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('数据库配置无效,无法连接到数据库')</script>");
            }
        }
示例#2
0
        protected void btn_ok_Click(object sender, EventArgs e)
        {
            InstallSetting set = SinGooCMS.Utility.XmlSerializerUtils.Deserialize <InstallSetting>(System.IO.File.ReadAllText(Server.MapPath("/Install/setting.xml")));

            if (set.DB_Server.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('数据库服务器地址不为空')</script>");
            }
            else if (set.DB_Name.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('数据库名称不为空')</script>");
            }
            else if (set.DB_Uid.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('数据库登录名称不为空')</script>");
            }
            else if (set.DB_Pwd.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('数据库登录密码不为空')</script>");
            }
            else if (TextBox1.Text.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('请输入超级管理员密码')</script>");
            }
            else if (TextBox1.Text.Trim().Length < 6)
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('超级管理员密码不能少于6位')</script>");
            }
            else if (TextBox2.Text.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('请输入管理员账户')</script>");
            }
            else if (TextBox3.Text.IsNullOrEmpty())
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('请输入管理员密码')</script>");
            }
            else if (TextBox3.Text.Trim().Length < 6)
            {
                ClientScript.RegisterClientScriptBlock(GetType(), "alert", "<script>alert('管理员密码不能少于6位')</script>");
            }
            else
            {
                set.SuperManager    = "superadmin";
                set.SuperManagerPwd = SinGooCMS.Utility.DEncryptUtils.SHA512Encrypt(TextBox1.Text);
                set.ManagerName     = TextBox2.Text;
                set.ManagerPwd      = SinGooCMS.Utility.DEncryptUtils.SHA512Encrypt(TextBox3.Text);

                //安装数据表
                //在setp1.sql最前插入 use [database] GO
                string strStep1 = File.ReadAllText(Server.MapPath("/Install/script/setp1.sql"), Encoding.UTF8);
                strStep1 = "use " + set.DB_Name + " GO " + strStep1;
                strStep1 = Regex.Replace(strStep1, @"([\r\n])[\s]+", " ", RegexOptions.IgnoreCase);
                SinGooCMS.Install.InstallUtil.CreateTable(strStep1);
                //安装存储过程等可编程数据
                //在step2.sql最前插入 use [database] GO
                string strStep2 = File.ReadAllText(Server.MapPath("/Install/script/setp2.sql"), Encoding.UTF8);
                strStep2 = "use " + set.DB_Name + " GO " + strStep2;
                strStep2 = Regex.Replace(strStep2, @"([\r\n])[\s]+", " ", RegexOptions.IgnoreCase);
                SinGooCMS.Install.InstallUtil.CreateStorePocedure(strStep2);
                //初始化基本数据
                //在step3.sql最前插入 use [database] GO
                string strManagerSource = " SET IDENTITY_INSERT [dbo].[cms_Account] ON "
                                          + " INSERT [dbo].[cms_Account] ([AutoID], [AccountName], [Password], [Email], [Mobile], [IsSystem], [LoginCount], [LastLoginIP], [LastLoginArea], [LastLoginTime], [AutoTimeStamp]) VALUES (1, N'superadmin', N'" + set.SuperManagerPwd + "', N'*****@*****.**', N'13760195274', 1, 0, N'127.0.0.1', N'本机地址', CAST(0x0000A3D900F4F8F7 AS DateTime), CAST(0x0000A09E0118CE63 AS DateTime)) "
                                          + " INSERT [dbo].[cms_Account] ([AutoID], [AccountName], [Password], [Email], [Mobile], [IsSystem], [LoginCount], [LastLoginIP], [LastLoginArea], [LastLoginTime], [AutoTimeStamp]) VALUES (2, N'admin', N'" + set.ManagerPwd + "', N'您的电子邮箱', N'您的手机号码', 1, 0, N'127.0.0.1', N'本机地址', CAST(0x0000A3D900F0A9D4 AS DateTime), CAST(0x0000A3480135DEE4 AS DateTime)) "
                                          + " SET IDENTITY_INSERT [dbo].[cms_Account] OFF GO ";
                string strStep3 = File.ReadAllText(Server.MapPath("/Install/script/setp3.sql"), Encoding.UTF8);
                strStep3 = "use " + set.DB_Name + " GO " + strManagerSource + " " + strStep3;
                strStep3 = Regex.Replace(strStep3, @"([\r\n])[\s]+", " ", RegexOptions.IgnoreCase);
                SinGooCMS.Install.InstallUtil.InitialData(strStep3);

                System.IO.File.WriteAllText(Server.MapPath("/Install/setting.xml"), SinGooCMS.Utility.XmlSerializerUtils.Serialize <InstallSetting>(set));
                Response.Redirect("Success.aspx");
            }
        }
示例#3
0
        public void WriteTestSettings()
        {
            var testAlgBuildSettings =
                new AlgBuildSetting
            {
                RegeditFrameworkPath = @"SOFTWARE\Microsoft\MSBuild\ToolsVersions\2.0",
                RegeditFrameworkKey  = "MSBuildToolsPath",

                AlgMsBuildSetting = new AlgMsBuildSetting
                {
                    SolutionPath      = @"Algoritm 2\Algoritm 2.sln",
                    BaseMsBuildParams = "/p:Configuration=Release /t:Rebuild /clp:ErrorsOnly",
                    FinalExePath      = @"Algoritm 2\Slot\bin\Release",
                },


                BuildSettingItems = new List <AlgBuildSettingItem>
                {
                    new AlgBuildSettingItem
                    {
                        VersionType      = VersionType.Free,
                        Lang             = Lang.Ru,
                        AddMsBuilsParams = "/p:DefineConstants=\"Ver=Free;Lang=Ru\""
                    }
                }
            };

            var testPathSettings = new PathSetting()
            {
                PathSettings =
                    new List <PathSettingItem>
                {
                    new PathSettingItem
                    {
                        Name        = "CompilExe",
                        VersionType = VersionType.All,
                        Lang        = Lang.Ru,
                        SourcePath  = "sf",
                        TargetPath  = "",
                        Directories = new List <string> {
                            "a", "b"
                        },
                        Files = new List <string> {
                            "dfa", "bdf"
                        },
                    }
                }
            };

            var testInstallSettings = new InstallSetting()
            {
                InnoSetupCompilerPath = @"C:\Program Files (x86)\Inno Setup 5"
            };

            var testPublishSettings = new PublishSetting
            {
                PublishFtpSetting = new PublishFtpSetting
                {
                    FtpUrl      = "ftp://algoritm2.ru/www/algoritm2.ru",
                    FtpUsername = "******",
                    FtpPassword = "******",
                },

                PublishSettings =
                    new List <PublishSettingItem>
                {
                    new PublishSettingItem
                    {
                        VersionType = VersionType.Free,
                        Lang        = Lang.Ru,
                        TargetPath  = "download",
                        TargetName  = "Algoritm2RuLastTest.exe"
                    },
                }
            };


            var testSettingPath = Path.Combine(_rootPath, Constants.SettingFolderName, "Test{0}");

            SettingsIO.WriteSetting(string.Format(testSettingPath, Constants.AlgBuildSettingFileName), testAlgBuildSettings);
            SettingsIO.WriteSetting(string.Format(testSettingPath, Constants.PathSettingFileName), testPathSettings);
            SettingsIO.WriteSetting(string.Format(testSettingPath, Constants.InstallSettingFileName), testInstallSettings);
            SettingsIO.WriteSetting(string.Format(testSettingPath, Constants.PublishSettingFileName), testPublishSettings);
        }
 public CustomInstallSettingExecutor(CustomInstallSetting customInstallSetting, PublishSetting publishSetting, InstallSetting installSetting)
 {
     _customInstallSetting = customInstallSetting;
     _publishSetting       = publishSetting;
     _installSetting       = installSetting;
 }
示例#5
0
        public static void CreateInstall(string rootPath, string installSetupScriptName, InstallSetting installSetting)
        {
            var installSetupScript = Path.Combine(rootPath, Constants.InstallsScriptFolderName,
                                                  installSetupScriptName);

            var processStartInfo = new ProcessStartInfo(installSetting.InnoSetupCompilerPath, installSetupScript);
            var process          = Process.Start(processStartInfo);

            process.WaitForExit();

            if (process.ExitCode == 1)
            {
                throw new Exception("command line parameters were invalid: " + installSetupScript);
            }

            if (process.ExitCode == 2)
            {
                throw new Exception("the compile failed: " + installSetupScript);
            }
        }
示例#6
0
 public InstallSettingExecutor(InstallSetting installSetting)
 {
     _installSetting = installSetting;
 }