private int GetSqlServerSecurityMode(string connectionString) { return(SqlUtils.GetSqlServerSecurityMode(connectionString)); }
private string GetSqlServerVersion(string connectionString) { return(SqlUtils.GetSqlServerVersion(connectionString)); }
protected internal override void OnBeforeMoveNext(CancelEventArgs e) { try { if (!CheckFields()) { e.Cancel = true; return; } string connectionString = CreateConnectionString(); string component = SetupVariables.ComponentFullName; if (CheckConnection(connectionString)) { // check SQL server version string sqlVersion = GetSqlServerVersion(connectionString); if (!sqlVersion.StartsWith("9.") && !sqlVersion.StartsWith("10.") && !sqlVersion.StartsWith("11.") && !sqlVersion.StartsWith("12.")) { // SQL Server 2005 engine required e.Cancel = true; ShowWarning("This program can be installed on SQL Server 2005/2008/2012/2014 only."); return; } int securityMode = GetSqlServerSecurityMode(connectionString); if (securityMode != 0) { // mixed mode required e.Cancel = true; ShowWarning("Please switch SQL Server authentication to mixed SQL Server and Windows Authentication mode."); return; } } else { e.Cancel = true; ShowWarning("SQL Server does not exist or access denied"); return; } string database = this.txtDatabase.Text; if (SqlUtils.DatabaseExists(connectionString, database)) { e.Cancel = true; ShowWarning(string.Format("{0} database already exists.", database)); return; } string server = this.txtSqlServer.Text; Log.WriteInfo(string.Format("Sql server \"{0}\" selected for {1}", server, component)); SetupVariables.Database = database; SetupVariables.DatabaseServer = server; SetupVariables.DbInstallConnectionString = connectionString; //AppConfig.SetComponentSettingStringValue(SetupVariables.ComponentId, "Database", database); //AppConfig.SetComponentSettingStringValue(SetupVariables.ComponentId, "DatabaseServer", server); //AppConfig.SetComponentSettingStringValue(SetupVariables.ComponentId, "InstallConnectionString", connectionString); } catch { e.Cancel = true; ShowError("Unable to configure the database server."); return; } base.OnBeforeMoveNext(e); }
private bool CheckConnection(string connectionString) { return(SqlUtils.CheckSqlConnection(connectionString)); }
internal static object InstallBase(object obj, string minimalInstallerVersion) { var args = Utils.GetSetupParameters(obj); //check CS version var shellVersion = Utils.GetStringSetupParameter(args, "ShellVersion"); var shellMode = Utils.GetStringSetupParameter(args, Global.Parameters.ShellMode); var version = new Version(shellVersion); var setupVariables = new SetupVariables { ConnectionString = Global.EntServer.AspNetConnectionStringFormat, DatabaseServer = Global.EntServer.DefaultDbServer, Database = Global.EntServer.DefaultDatabase, CreateDatabase = true, WebSiteIP = Global.EntServer.DefaultIP, WebSitePort = Global.EntServer.DefaultPort, WebSiteDomain = String.Empty, NewWebSite = true, NewVirtualDirectory = false, ConfigurationFile = "web.config", UpdateServerAdminPassword = true, ServerAdminPassword = "", }; // InitInstall(args, setupVariables); // var eam = new EntServerActionManager(setupVariables); // eam.PrepareDistributiveDefaults(); // if (shellMode.Equals(Global.SilentInstallerShell, StringComparison.OrdinalIgnoreCase)) { if (version < new Version(minimalInstallerVersion)) { Utils.ShowConsoleErrorMessage(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion); // return(false); } try { var success = true; // setupVariables.ServerAdminPassword = Utils.GetStringSetupParameter(args, Global.Parameters.ServerAdminPassword); setupVariables.Database = Utils.GetStringSetupParameter(args, Global.Parameters.DatabaseName); setupVariables.DatabaseServer = Utils.GetStringSetupParameter(args, Global.Parameters.DatabaseServer); // setupVariables.DbInstallConnectionString = SqlUtils.BuildDbServerMasterConnectionString( setupVariables.DatabaseServer, Utils.GetStringSetupParameter(args, Global.Parameters.DbServerAdmin), Utils.GetStringSetupParameter(args, Global.Parameters.DbServerAdminPassword) ); // eam.ActionError += new EventHandler <ActionErrorEventArgs>((object sender, ActionErrorEventArgs e) => { Utils.ShowConsoleErrorMessage(e.ErrorMessage); // Log.WriteError(e.ErrorMessage); // success = false; }); // eam.Start(); // return(success); } catch (Exception ex) { Log.WriteError("Failed to install the component", ex); // return(false); } } else { if (version < new Version(minimalInstallerVersion)) { MessageBox.Show(string.Format(Global.Messages.InstallerVersionIsObsolete, minimalInstallerVersion), "Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(DialogResult.Cancel); } InstallerForm form = new InstallerForm(); Wizard wizard = form.Wizard; wizard.SetupVariables = setupVariables; wizard.ActionManager = eam; //Unattended setup LoadSetupVariablesFromSetupXml(wizard.SetupVariables.SetupXml, wizard.SetupVariables); //create wizard pages var introPage = new IntroductionPage(); var licPage = new LicenseAgreementPage(); var page1 = new ConfigurationCheckPage(); // ConfigurationCheck check1 = new ConfigurationCheck(CheckTypes.OperationSystem, "Operating System Requirement"); ConfigurationCheck check2 = new ConfigurationCheck(CheckTypes.IISVersion, "IIS Requirement"); ConfigurationCheck check3 = new ConfigurationCheck(CheckTypes.ASPNET, "ASP.NET Requirement"); // page1.Checks.AddRange(new ConfigurationCheck[] { check1, check2, check3 }); // var page2 = new InstallFolderPage(); var page3 = new WebPage(); var page4 = new UserAccountPage(); var page5 = new DatabasePage(); var passwordPage = new ServerAdminPasswordPage(); // var page6 = new ExpressInstallPage2(); // var page7 = new FinishPage(); wizard.Controls.AddRange(new Control[] { introPage, licPage, page1, page2, page3, page4, page5, passwordPage, page6, page7 }); wizard.LinkPages(); wizard.SelectedPage = introPage; //show wizard IWin32Window owner = args[Global.Parameters.ParentForm] as IWin32Window; return(form.ShowModal(owner)); } }