Example #1
0
        /// <summary>
        /// Check the current version of the database schema, upgrading if necessary. This function is useful when the administrator
        /// upgrades Gallery Server Pro to a newer version which requires a database upgrade. This is the function that executes the
        /// necessary SQL script to upgrade the database. If the version required by this provider does not match the database version,
        /// and the database cannot be upgraded to the desired version, this function logs a message to the error log and returns
        /// without taking any action.
        /// </summary>
        private static void VerifySchemaVersion()
        {
            const GalleryDataSchemaVersion requiredDataSchemaVersion = _databaseSchemaVersion;
            GalleryDataSchemaVersion       dataSchemaVersionOfDb     = Util.ConvertGalleryDataSchemaVersionToEnum(GetDataSchemaVersionString());

            if (requiredDataSchemaVersion == dataSchemaVersionOfDb)
            {
                return;
            }

            if (dataSchemaVersionOfDb == GalleryDataSchemaVersion.Unknown)
            {
                string msg = String.Format("The database structure has a version ({0}) that is not one of the recognized schema versions included in a Gallery Server Pro release. Because of this, Gallery Server Pro cannot determine whether or how to upgrade the data schema, so it will not make an attempt. This is an information message only and does not necessarily represent a problem. This version of Gallery Server Pro is designed to work with data schema version {1}.", GetDataSchemaVersionString(), Util.ConvertGalleryDataSchemaVersionToString(requiredDataSchemaVersion));

                ErrorHandler.CustomExceptions.DataException ex = new ErrorHandler.CustomExceptions.DataException(msg);
                try { ErrorHandler.Error.Record(ex); } catch { }
                return;
            }

            if (requiredDataSchemaVersion < dataSchemaVersionOfDb)
            {
                string msg = String.Format("The database structure is a more recent version ({0}) than the application is designed for {1}. Gallery Server Pro will attempt to ignore this difference, and hopefully it will not cause an issue.", GetDataSchemaVersionString(), Util.ConvertGalleryDataSchemaVersionToString(requiredDataSchemaVersion));

                ErrorHandler.CustomExceptions.DataException ex = new ErrorHandler.CustomExceptions.DataException(msg);
                try { ErrorHandler.Error.Record(ex); } catch { }
                return;
            }

            switch (dataSchemaVersionOfDb)
            {
            case GalleryDataSchemaVersion.V2_1_3162:
                if (requiredDataSchemaVersion == GalleryDataSchemaVersion.V2_3_3421)
                {
                    if (Util.GetSqlVersion() <= SqlVersion.Sql2000)
                    {
                        ExecuteSqlUpgrade(GalleryDataSchemaUpgradeScript.SqlUpgrade_2_1_3162_to_2_3_3421_SqlServer2000);
                    }
                    else
                    {
                        ExecuteSqlUpgrade(GalleryDataSchemaUpgradeScript.SqlUpgrade_2_1_3162_to_2_3_3421_SqlServer2005);
                    }
                }
                break;

            default:
                string msg = String.Format("The database structure cannot be upgraded from version {0} to version {1}. This is an information message only and does not necessarily represent a problem.", GetDataSchemaVersionString(), Util.ConvertGalleryDataSchemaVersionToString(requiredDataSchemaVersion));

                ErrorHandler.CustomExceptions.DataException ex = new ErrorHandler.CustomExceptions.DataException(msg);
                try { ErrorHandler.Error.Record(ex); } catch { }
                break;
            }
        }
Example #2
0
		/// <summary>
		/// Check the current version of the database schema, upgrading if necessary. This function is useful when the administrator
		/// upgrades Gallery Server Pro to a newer version which requires a database upgrade. This is the function that executes the
		/// necessary SQL script to upgrade the database. If the version required by this provider does not match the database version, 
		/// and the database cannot be upgraded to the desired version, this function logs a message to the error log and returns
		/// without taking any action.
		/// </summary>
		private static void VerifySchemaVersion()
		{
			const GalleryDataSchemaVersion requiredDataSchemaVersion = _databaseSchemaVersion;
			GalleryDataSchemaVersion dataSchemaVersionOfDb = Util.ConvertGalleryDataSchemaVersionToEnum(GetDataSchemaVersionString());

			if (requiredDataSchemaVersion == dataSchemaVersionOfDb)
				return;

			if (dataSchemaVersionOfDb == GalleryDataSchemaVersion.Unknown)
			{
				string msg = String.Format("The database structure has a version ({0}) that is not one of the recognized schema versions included in a Gallery Server Pro release. Because of this, Gallery Server Pro cannot determine whether or how to upgrade the data schema, so it will not make an attempt. This is an information message only and does not necessarily represent a problem. This version of Gallery Server Pro is designed to work with data schema version {1}.", GetDataSchemaVersionString(), Util.ConvertGalleryDataSchemaVersionToString(requiredDataSchemaVersion));

				ErrorHandler.CustomExceptions.DataException ex = new ErrorHandler.CustomExceptions.DataException(msg);
				try { ErrorHandler.Error.Record(ex); } catch { }
				return;
			}

			if (requiredDataSchemaVersion < dataSchemaVersionOfDb)
			{
				string msg = String.Format("The database structure is a more recent version ({0}) than the application is designed for {1}. Gallery Server Pro will attempt to ignore this difference, and hopefully it will not cause an issue.", GetDataSchemaVersionString(), Util.ConvertGalleryDataSchemaVersionToString(requiredDataSchemaVersion));

				ErrorHandler.CustomExceptions.DataException ex = new ErrorHandler.CustomExceptions.DataException(msg);
				try { ErrorHandler.Error.Record(ex); } catch { }
				return;
			}

			switch (dataSchemaVersionOfDb)
			{
				case GalleryDataSchemaVersion.V2_1_3162:
					if (requiredDataSchemaVersion == GalleryDataSchemaVersion.V2_3_3421)
					{
						if (Util.GetSqlVersion() <= SqlVersion.Sql2000)
						{
							ExecuteSqlUpgrade(GalleryDataSchemaUpgradeScript.SqlUpgrade_2_1_3162_to_2_3_3421_SqlServer2000);
						}
						else
						{
							ExecuteSqlUpgrade(GalleryDataSchemaUpgradeScript.SqlUpgrade_2_1_3162_to_2_3_3421_SqlServer2005);
						}
					}
					break;
				default:
					string msg = String.Format("The database structure cannot be upgraded from version {0} to version {1}. This is an information message only and does not necessarily represent a problem.", GetDataSchemaVersionString(), Util.ConvertGalleryDataSchemaVersionToString(requiredDataSchemaVersion));

					ErrorHandler.CustomExceptions.DataException ex = new ErrorHandler.CustomExceptions.DataException(msg);
					try { ErrorHandler.Error.Record(ex); } catch { }
					break;
			}
		}