コード例 #1
0
        /// <summary>
        /// Performs an install of a database
        /// </summary>
        public void Install(InstallSetup setup)
        {
            //The connection string must reference an existing database
            if (!DatabaseServer.TestConnectionString(setup.ConnectionString))
            {
                throw new Exception("The connection string does not reference a valid database.");
            }

            try
            {
                UpgradeInstaller.UpgradeDatabase(setup);
            }
            catch (InvalidSQLException ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine();
                sb.AppendLine("BEGIN ERROR SQL");
                sb.AppendLine(ex.SQL);
                sb.AppendLine("END ERROR SQL");
                sb.AppendLine();
                Log.Verbose(sb.ToString());
                UpgradeInstaller.LogError(ex, sb.ToString());
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
ファイル: SqlErrorForm.cs プロジェクト: mjl68/nHydrate
        public void SetupGeneric(Exception exception)
        {
            try
            {
                this.Text = "Error";
                this.splitter1.Visible = false;
                this.panel3.Dock       = DockStyle.None;
                this.panel3.Visible    = false;
                this.panel1.Dock       = DockStyle.Fill;
                this.panel1.BringToFront();
                var errorText = exception.ToString();
                if (exception is InvalidSQLException)
                {
                    errorText = "FileName: '" + ((InvalidSQLException)exception).FileName + "'" + errorText;
                }

                UpgradeInstaller.LogError(exception.InnerException, "[ERROR]\r\n" + errorText);
                if (exception.InnerException != null)
                {
                    txtError.Text = exception.InnerException.ToString();
                }
                else
                {
                    txtError.Text = exception.ToString();
                }
                cmdSkip.Visible = false;
            }
            catch (Exception ex)
            {
                //Do Nothing
            }
        }
コード例 #3
0
 public void Setup(InvalidSQLException exception, bool allowSkip)
 {
     UpgradeInstaller.LogError(exception.InnerException, "[ERROR SCRIPT]\r\n" + exception.SQL);
     txtError.Text   = exception.InnerException.ToString();
     txtSql.Text     = exception.SQL;
     cmdSkip.Visible = allowSkip;
 }
コード例 #4
0
ファイル: SqlErrorForm.cs プロジェクト: mjl68/nHydrate
 public void Setup(InvalidSQLException exception, bool allowSkip)
 {
     UpgradeInstaller.LogError(exception.InnerException, "[ERROR]\r\n" + "FileName: '" + ((InvalidSQLException)exception).FileName + "'\r\n" + exception.SQL);
     txtError.Text   = "FileName: '" + exception.FileName + "'\r\n" + exception.InnerException.ToString();
     txtSql.Text     = exception.SQL;
     cmdSkip.Visible = allowSkip;
 }
コード例 #5
0
        /// <summary>
        /// Performs an install of a database
        /// </summary>
        public void Install(InstallSetup setup)
        {
            if (setup.InstallStatus == InstallStatusConstants.Create)
            {
                //Connection cannot reference an existing database
                if (SqlServers.TestConnectionString(setup.ConnectionString))
                {
                    throw new Exception("The connection string references an existing database.");
                }

                //The new database name must be specified
                if (string.IsNullOrEmpty(setup.NewDatabaseName))
                {
                    throw new Exception("A new database name was not specified.");
                }

                //The connection string and the new database name must be the same
                var builder = new SqlConnectionStringBuilder(setup.ConnectionString);
                if (builder.InitialCatalog.ToLower() != setup.NewDatabaseName.ToLower())
                {
                    throw new Exception("A new database name does not match the specified connection string.");
                }

                SqlServers.CreateDatabase(setup);
            }
            else if (setup.InstallStatus == InstallStatusConstants.Upgrade)
            {
                //The connection string must reference an existing database
                if (!SqlServers.TestConnectionString(setup.ConnectionString))
                {
                    throw new Exception("The connection string does not reference a valid database.");
                }
            }

            try
            {
                UpgradeInstaller.UpgradeDatabase(setup);
            }
            catch (InvalidSQLException ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine();
                sb.AppendLine("BEGIN ERROR SQL");
                sb.AppendLine(ex.SQL);
                sb.AppendLine("END ERROR SQL");
                sb.AppendLine();
                System.Diagnostics.Trace.WriteLine(sb.ToString());
                UpgradeInstaller.LogError(ex, sb.ToString());
                throw;
            }
            catch (Exception ex)
            {
                throw;
            }
        }