RunEmbeddedFile() public static method

public static RunEmbeddedFile ( SqlConnection connection, SqlTransaction transaction, string resourceFileName ) : void
connection System.Data.SqlClient.SqlConnection
transaction System.Data.SqlClient.SqlTransaction
resourceFileName string
return void
Ejemplo n.º 1
0
 private void ReinstallStoredProcedures()
 {
     try
     {
         SortedDictionary <string, EmbeddedResourceName> storedProcedures = this.GetResourceNameUnderLocation(".Stored_Procedures");
         foreach (EmbeddedResourceName ern in storedProcedures.Values)
         {
             try
             {
                 SqlServers.RunEmbeddedFile(_connection, _transaction, ern.FullName);
             }
             catch (Exception ex)
             {
                 System.Windows.Forms.MessageBox.Show("Sp Fail: " + ern.FullName);
                 throw;
             }
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Ejemplo n.º 2
0
        private void UpgradeSchemaAndStaticData()
        {
            const string CREATE_SCHEMA_FILE       = ".Create_Scripts.Generated.CreateSchema.sql";
            const string STATIC_DATA_FILE         = ".Create_Scripts.Generated.CreateData.sql";
            const string UPGRADE_FOLDER           = ".Upgrade_Scripts";
            const string UPGRADE_GENERATED_FOLDER = ".Upgrade_Scripts.Generated.";
            const string CREATE_FOLDER            = ".Cre ate_Scripts";

            try
            {
                SortedDictionary <string, EmbeddedResourceName> upgradeSchemaScripts = this.GetResourceNameUnderLocation(UPGRADE_GENERATED_FOLDER);
                SortedDictionary <string, EmbeddedResourceName> sortByVersionScripts = new SortedDictionary <string, EmbeddedResourceName>(upgradeSchemaScripts, new UpgradeFileNameComparer());

                //Run the generated upgrades
                if (!_previousVersion.Equals(_def_Version))
                {
                    foreach (EmbeddedResourceName ern in sortByVersionScripts.Values)
                    {
                        if (new Version(ern.FileName).CompareTo(_previousVersion) > 0)
                        {
                            SqlServers.RunEmbeddedFile(_connection, _transaction, ern.FullName);
                        }
                    }
                }

                //Run the create schema
                SortedDictionary <string, EmbeddedResourceName> createSchemaScripts = this.GetResourceNameUnderLocation(CREATE_SCHEMA_FILE);
                foreach (EmbeddedResourceName ern in createSchemaScripts.Values)
                {
                    SqlServers.RunEmbeddedFile(_connection, _transaction, ern.FullName);
                }

                //Run the static data
                createSchemaScripts = this.GetResourceNameUnderLocation(STATIC_DATA_FILE);
                foreach (EmbeddedResourceName ern in createSchemaScripts.Values)
                {
                    SqlServers.RunEmbeddedFile(_connection, _transaction, ern.FullName);
                }

                //Run all other scripts
                SortedDictionary <string, EmbeddedResourceName> createDataScripts = this.GetResourceNameUnderLocation(CREATE_FOLDER);
                foreach (EmbeddedResourceName ern in createDataScripts.Values)
                {
                    //Make sure it is not the two defined scripts
                    if ((ern.AsmLocation != CREATE_SCHEMA_FILE) && (ern.AsmLocation != STATIC_DATA_FILE))
                    {
                        SqlServers.RunEmbeddedFile(_connection, _transaction, ern.FullName);
                    }
                }

                //Run the user-defined upgrades
                List <string> excludePathList = new List <string>();
                excludePathList.Add(UPGRADE_GENERATED_FOLDER);
                upgradeSchemaScripts = this.GetResourceNameUnderLocation(UPGRADE_FOLDER, excludePathList);
                sortByVersionScripts = new SortedDictionary <string, EmbeddedResourceName>(upgradeSchemaScripts, new UpgradeFileNameComparer());
                if (_previousVersion != null)
                {
                    foreach (EmbeddedResourceName ern in sortByVersionScripts.Values)
                    {
                        if (new Version(ern.FileName).CompareTo(_previousVersion) > 0)
                        {
                            SqlServers.RunEmbeddedFile(_connection, _transaction, ern.FullName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }