internal FeatureInfo(SqlFeatures feature, string[] installFiles, string[] uninstallFiles, string[] tablesRemovedInUninstall, int dataCheckBitMask)
 {
     this._feature                  = feature;
     this._installFiles             = installFiles;
     this._uninstallFiles           = uninstallFiles;
     this._tablesRemovedInUninstall = tablesRemovedInUninstall;
     this._dataCheckBitMask         = dataCheckBitMask;
 }
 private static void ApplicationServicesParamCheck(SqlFeatures features, ref string database)
 {
     if (features != SqlFeatures.None)
     {
         if ((features & SqlFeatures.All) != features)
         {
             throw new ArgumentException(System.Web.SR.GetString("SQL_Services_Invalid_Feature"));
         }
         CheckDatabaseName(ref database);
     }
 }
 private static void ApplicationServicesParamCheck(SqlFeatures features, ref string database)
 {
     if (features != SqlFeatures.None)
     {
         if ((features & SqlFeatures.All) != features)
         {
             throw new ArgumentException(System.Web.SR.GetString("SQL_Services_Invalid_Feature"));
         }
         CheckDatabaseName(ref database);
     }
 }
        public static string GenerateApplicationServicesScripts(bool install, SqlFeatures features, string database)
        {
            StringBuilder builder = new StringBuilder();

            ApplicationServicesParamCheck(features, ref database);
            foreach (string str2 in GetFiles(install, features))
            {
                string content = File.ReadAllText(Path.Combine(HttpRuntime.AspInstallDirectory, str2));
                builder.Append(FixContent(content, database, null, false, SessionStateType.Temporary));
            }
            return(builder.ToString());
        }
Exemplo n.º 5
0
        // Return a list of files based on install (bool) and features
        static ArrayList GetFiles(bool install, SqlFeatures features)
        {
            ArrayList results = new ArrayList();
            bool      installCommonProcessed = false;

            // Load and modify the sql file for each feature
            for (int i = 0; i < s_featureInfos.Length; i++)
            {
                string[] sqlFiles = null;

                if (((int)s_featureInfos[i]._feature & (int)features) == (int)s_featureInfos[i]._feature)
                {
                    // We found one feature
                    if (install)
                    {
                        sqlFiles = s_featureInfos[i]._installFiles;
                    }
                    else
                    {
                        sqlFiles = s_featureInfos[i]._uninstallFiles;
                    }
                }

                if (sqlFiles != null)
                {
                    for (int j = 0; j < sqlFiles.Length; j++)
                    {
                        string sqlFile = sqlFiles[j];
                        if (sqlFile != null)
                        {
                            // We only need to process InstallCommon.sql once
                            if (sqlFile == INSTALL_COMMON_SQL && installCommonProcessed)
                            {
                                continue;
                            }

                            results.Add(sqlFile);

                            if (!installCommonProcessed && sqlFile == INSTALL_COMMON_SQL)
                            {
                                installCommonProcessed = true;
                            }
                        }
                    }
                }
            }

            return(results);
        }
Exemplo n.º 6
0
        static void ApplicationServicesParamCheck(SqlFeatures features, ref string database)
        {
            if (features == SqlFeatures.None)
            {
                return;
            }

            if ((features & SqlFeatures.All) != features)
            {
                throw new ArgumentException(SR.GetString(SR.SQL_Services_Invalid_Feature));
            }

            // VSWhidbey 355946:
            // SQL will ignore trailing space of database names. It's easier to just
            // trim those spaces here than to fix all the SQL statements to handle
            // errors due to trailing space.
            CheckDatabaseName(ref database);
        }
Exemplo n.º 7
0
        public static string GenerateApplicationServicesScripts(bool install, SqlFeatures features, string database)
        {
            string        content;
            StringBuilder sb = new StringBuilder();
            ArrayList     files;

            ApplicationServicesParamCheck(features, ref database);

            files = GetFiles(install, features);

            foreach (string sqlFile in files)
            {
                string fullpath = Path.Combine(HttpRuntime.AspInstallDirectory, sqlFile);
                content = File.ReadAllText(fullpath);
                sb.Append(FixContent(content, database, null, false, SessionStateType.Temporary));
            }

            return(sb.ToString());
        }
        private static ArrayList GetFiles(bool install, SqlFeatures features)
        {
            ArrayList list = new ArrayList();
            bool      flag = false;

            for (int i = 0; i < s_featureInfos.Length; i++)
            {
                string[] strArray = null;
                if ((s_featureInfos[i]._feature & features) == s_featureInfos[i]._feature)
                {
                    if (install)
                    {
                        strArray = s_featureInfos[i]._installFiles;
                    }
                    else
                    {
                        strArray = s_featureInfos[i]._uninstallFiles;
                    }
                }
                if (strArray != null)
                {
                    for (int j = 0; j < strArray.Length; j++)
                    {
                        string str = strArray[j];
                        if ((str != null) && ((str != INSTALL_COMMON_SQL) || !flag))
                        {
                            list.Add(str);
                            if (!flag && (str == INSTALL_COMMON_SQL))
                            {
                                flag = true;
                            }
                        }
                    }
                }
            }
            return(list);
        }
Exemplo n.º 9
0
 public static void Uninstall(string server, string database, SqlFeatures features)
 {
 }
Exemplo n.º 10
0
 public static void Uninstall(string database, SqlFeatures features, string connectionString)
 {
 }
 public static string GenerateApplicationServicesScripts(bool install, SqlFeatures features, string database)
 {
     StringBuilder builder = new StringBuilder();
     ApplicationServicesParamCheck(features, ref database);
     foreach (string str2 in GetFiles(install, features))
     {
         string content = File.ReadAllText(Path.Combine(HttpRuntime.AspInstallDirectory, str2));
         builder.Append(FixContent(content, database, null, false, SessionStateType.Temporary));
     }
     return builder.ToString();
 }
Exemplo n.º 12
0
        // Return a list of files based on install (bool) and features
        static ArrayList GetFiles(bool install, SqlFeatures features) {
            ArrayList   results = new ArrayList();
            bool        installCommonProcessed = false;

            // Load and modify the sql file for each feature
            for (int i=0; i <  s_featureInfos.Length; i++) {
                string[] sqlFiles = null;

                if (((int)s_featureInfos[i]._feature & (int)features) == (int)s_featureInfos[i]._feature) {
                    // We found one feature
                    if (install) {
                        sqlFiles = s_featureInfos[i]._installFiles;
                    }
                    else {
                        sqlFiles = s_featureInfos[i]._uninstallFiles;
                    }
                }

                if (sqlFiles != null) {
                    for(int j = 0; j < sqlFiles.Length; j++) {
                        string sqlFile = sqlFiles[j];
                        if (sqlFile != null) {
                            // We only need to process InstallCommon.sql once
                            if (sqlFile == INSTALL_COMMON_SQL && installCommonProcessed) {
                                continue;
                            }

                            results.Add(sqlFile);

                            if (!installCommonProcessed && sqlFile == INSTALL_COMMON_SQL) {
                                installCommonProcessed = true;
                            }
                        }
                    }
                }
            }

            return results;
        }
Exemplo n.º 13
0
 // For connection using connection string
 public static void Uninstall(string database, SqlFeatures features, string connectionString) {
     SetupApplicationServices(null, null, null, true, connectionString, database, null, features, false);
 }
Exemplo n.º 14
0
 public static void Install(string server, string user, string password, string database, SqlFeatures features) {
     SetupApplicationServices(server, user, password, false, null, database, null, features, true);
 }
 public static void Uninstall(string server, string database, SqlFeatures features)
 {
 }
        private static void SetupApplicationServices(string server, string user, string password, bool trusted, string connectionString, string database, string dbFileName, SqlFeatures features, bool install)
        {
            SqlConnection sqlConnection = null;

            ApplicationServicesParamCheck(features, ref database);
            ArrayList files = GetFiles(install, features);

            try
            {
                sqlConnection = GetSqlConnection(server, user, password, trusted, connectionString);
                if (!install)
                {
                    EnsureDatabaseExists(database, sqlConnection);
                    string databaseName = RemoveSquareBrackets(database);
                    if (sqlConnection.Database != databaseName)
                    {
                        sqlConnection.ChangeDatabase(databaseName);
                    }
                    int num = 0;
                    for (int i = 0; i < s_featureInfos.Length; i++)
                    {
                        if ((s_featureInfos[i]._feature & features) == s_featureInfos[i]._feature)
                        {
                            num |= s_featureInfos[i]._dataCheckBitMask;
                        }
                    }
                    SqlCommand command = new SqlCommand("dbo.aspnet_AnyDataInTables", sqlConnection);
                    command.Parameters.Add(new SqlParameter("@TablesToCheck", num));
                    command.CommandType = CommandType.StoredProcedure;
                    string str2 = null;
                    try
                    {
                        str2 = command.ExecuteScalar() as string;
                    }
                    catch (SqlException exception)
                    {
                        if (exception.Number != 0xafc)
                        {
                            throw;
                        }
                    }
                    if (!string.IsNullOrEmpty(str2))
                    {
                        throw new NotSupportedException(System.Web.SR.GetString("SQL_Services_Error_Cant_Uninstall_Nonempty_Table", new object[] { str2, database }));
                    }
                }
                foreach (string str3 in files)
                {
                    ExecuteFile(str3, server, database, dbFileName, sqlConnection, false, false, SessionStateType.Temporary);
                }
            }
            finally
            {
                if (sqlConnection != null)
                {
                    try
                    {
                        sqlConnection.Close();
                    }
                    catch
                    {
                    }
                    finally
                    {
                        sqlConnection = null;
                    }
                }
            }
        }
 public static void Install(string server, string database, SqlFeatures features)
 {
     SetupApplicationServices(server, null, null, true, null, database, null, features, true);
 }
Exemplo n.º 18
0
        // Add/Remove all requested general features
        static void SetupApplicationServices(
            string server,
            string user,
            string password,
            bool trusted,
            string connectionString,
            string database,
            string dbFileName,
            SqlFeatures features,
            bool install)
        {
            SqlConnection sqlConnection = null;
            ArrayList     files;

            Debug.Trace("SqlServices",
                        "SetupApplicationServices called: server=" + server + ", database=" +
                        database + ", user="******", password="******", trusted=" + trusted + ", connectionString=" + connectionString +
                        ", features=" + features + ", install=" + install);

            ApplicationServicesParamCheck(features, ref database);

            files = GetFiles(install, features);

            try {
                sqlConnection = GetSqlConnection(server, user, password, trusted, connectionString);

                // If uninstall, make sure all the asp.net tables are empty
                if (!install)
                {
                    EnsureDatabaseExists(database, sqlConnection);
                    string databaseNoSquareBrackets = RemoveSquareBrackets(database);
                    if (sqlConnection.Database != databaseNoSquareBrackets)
                    {
                        sqlConnection.ChangeDatabase(databaseNoSquareBrackets);
                    }
                    int itablesToCheck = 0;
                    for (int i = 0; i < s_featureInfos.Length; i++)
                    {
                        if (((int)s_featureInfos[i]._feature & (int)features) == (int)s_featureInfos[i]._feature)
                        {
                            itablesToCheck |= s_featureInfos[i]._dataCheckBitMask;
                        }
                    }
                    SqlCommand cmd = new SqlCommand("dbo.aspnet_AnyDataInTables", sqlConnection);
                    cmd.Parameters.Add(new SqlParameter("@TablesToCheck", itablesToCheck));
                    cmd.CommandType = CommandType.StoredProcedure;
                    string table = null;
                    try {
                        table = cmd.ExecuteScalar() as string;
                    } catch (SqlException e) {
                        if (e.Number != 2812)
                        {
                            throw;
                        }
                    }
                    if (!string.IsNullOrEmpty(table))
                    {
                        throw new NotSupportedException(
                                  SR.GetString(SR.SQL_Services_Error_Cant_Uninstall_Nonempty_Table,
                                               table, database));
                    }
                }

                // Load and run the sql file for each feature
                foreach (string sqlFile in files)
                {
                    ExecuteFile(sqlFile, server, database, dbFileName, sqlConnection, false, false, SessionStateType.Temporary);
                }
            }
            finally {
                if (sqlConnection != null)
                {
                    try {
                        sqlConnection.Close();
                    }
                    catch {
                    }
                    finally {
                        sqlConnection = null;
                    }
                }
            }
        }
 private static void SetupApplicationServices(string server, string user, string password, bool trusted, string connectionString, string database, string dbFileName, SqlFeatures features, bool install)
 {
     SqlConnection sqlConnection = null;
     ApplicationServicesParamCheck(features, ref database);
     ArrayList files = GetFiles(install, features);
     try
     {
         sqlConnection = GetSqlConnection(server, user, password, trusted, connectionString);
         if (!install)
         {
             EnsureDatabaseExists(database, sqlConnection);
             string databaseName = RemoveSquareBrackets(database);
             if (sqlConnection.Database != databaseName)
             {
                 sqlConnection.ChangeDatabase(databaseName);
             }
             int num = 0;
             for (int i = 0; i < s_featureInfos.Length; i++)
             {
                 if ((s_featureInfos[i]._feature & features) == s_featureInfos[i]._feature)
                 {
                     num |= s_featureInfos[i]._dataCheckBitMask;
                 }
             }
             SqlCommand command = new SqlCommand("dbo.aspnet_AnyDataInTables", sqlConnection);
             command.Parameters.Add(new SqlParameter("@TablesToCheck", num));
             command.CommandType = CommandType.StoredProcedure;
             string str2 = null;
             try
             {
                 str2 = command.ExecuteScalar() as string;
             }
             catch (SqlException exception)
             {
                 if (exception.Number != 0xafc)
                 {
                     throw;
                 }
             }
             if (!string.IsNullOrEmpty(str2))
             {
                 throw new NotSupportedException(System.Web.SR.GetString("SQL_Services_Error_Cant_Uninstall_Nonempty_Table", new object[] { str2, database }));
             }
         }
         foreach (string str3 in files)
         {
             ExecuteFile(str3, server, database, dbFileName, sqlConnection, false, false, SessionStateType.Temporary);
         }
     }
     finally
     {
         if (sqlConnection != null)
         {
             try
             {
                 sqlConnection.Close();
             }
             catch
             {
             }
             finally
             {
                 sqlConnection = null;
             }
         }
     }
 }
 // Methods
 public static void Install(string server, string user, string password, string database, SqlFeatures features)
 {
 }
 public static string GenerateApplicationServicesScripts(bool install, SqlFeatures features, string database)
 {
 }
 public static void Uninstall(string database, SqlFeatures features, string connectionString)
 {
     SetupApplicationServices(null, null, null, true, connectionString, database, null, features, false);
 }
 public static void Uninstall(string database, SqlFeatures features, string connectionString)
 {
 }
 public static void Uninstall(string server, string user, string password, string database, SqlFeatures features)
 {
     SetupApplicationServices(server, user, password, false, null, database, null, features, false);
 }
Exemplo n.º 25
0
 // For trusted connection
 public static void Uninstall(string server, string database, SqlFeatures features) {
     SetupApplicationServices(server, null, null, true, null, database, null, features, false);
 }
Exemplo n.º 26
0
        public static string GenerateApplicationServicesScripts(bool install, SqlFeatures features, string database) {
            string          content;
            StringBuilder   sb = new StringBuilder();
            ArrayList       files;

            ApplicationServicesParamCheck(features, ref database);

            files = GetFiles(install, features);

            foreach (string sqlFile in files) {
                string fullpath = Path.Combine(HttpRuntime.AspInstallDirectory, sqlFile);
                content = File.ReadAllText(fullpath);
                sb.Append(FixContent(content, database, null, false, SessionStateType.Temporary));
            }

            return sb.ToString();
        }
Exemplo n.º 27
0
 internal FeatureInfo(SqlFeatures feature, string[] installFiles,
     string[] uninstallFiles, string[] tablesRemovedInUninstall, int dataCheckBitMask) {
     _feature = feature;
     _installFiles = installFiles;
     _uninstallFiles = uninstallFiles;
     _tablesRemovedInUninstall = tablesRemovedInUninstall;
     _dataCheckBitMask = dataCheckBitMask;
 }
Exemplo n.º 28
0
 public static void Install(string server, string user, string password, string database, SqlFeatures features)
 {
 }
Exemplo n.º 29
0
        static void ApplicationServicesParamCheck(SqlFeatures features, ref string database) {
            if (features == SqlFeatures.None) {
                return;
            }

            if ((features & SqlFeatures.All) != features) {
                throw new ArgumentException(SR.GetString(SR.SQL_Services_Invalid_Feature));
            }

            // VSWhidbey 355946:
            // SQL will ignore trailing space of database names. It's easier to just
            // trim those spaces here than to fix all the SQL statements to handle
            // errors due to trailing space.
            CheckDatabaseName(ref database);
        }
 private static ArrayList GetFiles(bool install, SqlFeatures features)
 {
     ArrayList list = new ArrayList();
     bool flag = false;
     for (int i = 0; i < s_featureInfos.Length; i++)
     {
         string[] strArray = null;
         if ((s_featureInfos[i]._feature & features) == s_featureInfos[i]._feature)
         {
             if (install)
             {
                 strArray = s_featureInfos[i]._installFiles;
             }
             else
             {
                 strArray = s_featureInfos[i]._uninstallFiles;
             }
         }
         if (strArray != null)
         {
             for (int j = 0; j < strArray.Length; j++)
             {
                 string str = strArray[j];
                 if ((str != null) && ((str != INSTALL_COMMON_SQL) || !flag))
                 {
                     list.Add(str);
                     if (!flag && (str == INSTALL_COMMON_SQL))
                     {
                         flag = true;
                     }
                 }
             }
         }
     }
     return list;
 }
Exemplo n.º 31
0
        // Add/Remove all requested general features
        static void SetupApplicationServices(
            string server,
            string user,
            string password,
            bool trusted,
            string connectionString,
            string database,
            string dbFileName,
            SqlFeatures features,
            bool install )
        {
            SqlConnection   sqlConnection   = null;
            ArrayList       files;

            Debug.Trace("SqlServices",
                            "SetupApplicationServices called: server=" + server + ", database=" +
                            database  + ", user="******", password="******", trusted=" + trusted + ", connectionString=" + connectionString +
                            ", features=" + features + ", install=" + install);

            ApplicationServicesParamCheck(features, ref database);

            files = GetFiles(install, features);

            try {
                sqlConnection = GetSqlConnection(server, user, password, trusted, connectionString);

                // If uninstall, make sure all the asp.net tables are empty
                if (!install) {
                    EnsureDatabaseExists(database, sqlConnection);
                    string databaseNoSquareBrackets = RemoveSquareBrackets(database);
                    if (sqlConnection.Database != databaseNoSquareBrackets)
                        sqlConnection.ChangeDatabase(databaseNoSquareBrackets);
                    int itablesToCheck = 0;
                    for (int i=0; i <  s_featureInfos.Length; i++)
                        if (((int)s_featureInfos[i]._feature & (int)features) == (int)s_featureInfos[i]._feature)
                            itablesToCheck |= s_featureInfos[i]._dataCheckBitMask;
                    SqlCommand cmd = new SqlCommand("dbo.aspnet_AnyDataInTables", sqlConnection);
                    cmd.Parameters.Add(new SqlParameter("@TablesToCheck", itablesToCheck));
                    cmd.CommandType = CommandType.StoredProcedure;
                    string table = null;
                    try {
                        table = cmd.ExecuteScalar() as string;
                    } catch (SqlException e) {
                        if (e.Number != 2812)
                            throw;
                    }
                    if (!string.IsNullOrEmpty(table))
                        throw new NotSupportedException(
                                    SR.GetString(SR.SQL_Services_Error_Cant_Uninstall_Nonempty_Table,
                                        table, database));
                }

                // Load and run the sql file for each feature
                foreach (string sqlFile in files) {
                    ExecuteFile(sqlFile, server, database, dbFileName, sqlConnection, false, false, SessionStateType.Temporary);
                }
            }
            finally {
                if (sqlConnection != null) {
                    try {
                        sqlConnection.Close();
                    }
                    catch {
                    }
                    finally {
                        sqlConnection = null;
                    }
                }
            }

        }
Exemplo n.º 32
0
 public static string GenerateApplicationServicesScripts(bool install, SqlFeatures features, string database)
 {
     return(default(string));
 }