示例#1
0
        /// <summary>
        /// Convert <paramref name="version"/> to its string equivalent. Example: Return "2.4.1" when <paramref name="version"/>
        /// is <see cref="GalleryDataSchemaVersion.V2_4_1"/>. This is a lookup function and does not return the current version
        /// of the database or application schema requirements.
        /// </summary>
        /// <param name="version">The version of the gallery's data schema for which a string representation is to be returned.</param>
        /// <returns>Returns the string equivalent of the specified <see cref="GalleryDataSchemaVersion"/> value.</returns>
        public static string ConvertGalleryDataSchemaVersionToString(GalleryDataSchemaVersion version)
        {
            switch (version)
            {
            case GalleryDataSchemaVersion.V2_1_3162:
                return("2.1.3162");

            case GalleryDataSchemaVersion.V2_3_3421:
                return("2.3.3421");

            case GalleryDataSchemaVersion.V2_4_1:
                return("2.4.1");

            case GalleryDataSchemaVersion.V2_4_3:
                return("2.4.3");

            case GalleryDataSchemaVersion.V2_4_4:
                return("2.4.4");

            case GalleryDataSchemaVersion.V2_4_5:
                return("2.4.5");

            case GalleryDataSchemaVersion.V2_4_6:
                return("2.4.6");

            case GalleryDataSchemaVersion.V2_5_0:
                return("2.5.0");

            case GalleryDataSchemaVersion.V2_6_0:
                return("2.6.0");

            default:
                throw new InvalidEnumArgumentException(String.Format(CultureInfo.CurrentCulture, "The function GalleryServerPro.Business.ConvertGalleryDataSchemaVersionToString was not designed to handle the GalleryDataSchemaVersion enumeration value {0}. A developer must update this method to handle this value.", version));
            }
        }
        /// <summary>
        /// Upgrades the <paramref name="ds" /> from the 2.6 schema to the current schema. This is done by creating a new set of tables in the
        /// dataset that match the current schema, then populating them with data from the 2.6 tables that are already present. As the data
        /// is copied, it is converted into the required format. The <paramref name="dataStore" />, <paramref name="cn" />, and 
        /// <paramref name="tran" /> are used only for updating the UI templates to point to the template gallery in the data to be imported.
        /// </summary>
        /// <param name="ds">The DataSet.</param>
        /// <param name="targetSchema">The schema version to convert to. An <see cref="ArgumentException" /> if the value does not match
        /// the current schema of this application.</param>
        /// <param name="dataStore">The current data store.</param>
        /// <param name="cn">The connection being used to import the data.</param>
        /// <param name="tran">The transaction being used to import the data.</param>
        /// <exception cref="System.ArgumentException">Thrown when <paramref name="targetSchema" /> does not match the current schema of 
        /// this application.</exception>
        /// <exception cref="System.Exception">Thrown when the existing schema of the data in the <paramref name="ds" /> is not 
        /// <see cref="GalleryDataSchemaVersion.V2_6_0" />.</exception>
        public static void UpgradeData(DataSet ds, GalleryDataSchemaVersion targetSchema, ProviderDataStore dataStore, IDbConnection cn, IDbTransaction tran)
        {
            if (targetSchema != GalleryDb.DataSchemaVersion)
            {
                throw new ArgumentException(String.Format("This method is designed to upgrade only to version {0}.", GalleryDb.DataSchemaVersion), "targetSchema");
            }

            if (BackupFileController.GetDataSchemaVersion(ds) != GalleryDataSchemaVersion.V2_6_0)
            {
                throw new Exception(String.Format("This method is designed to upgrade from version {0} only.", GalleryDataSchemaVersion.V2_6_0));
            }

            var asm = Assembly.GetExecutingAssembly();
            using (var stream = asm.GetManifestResourceStream("GalleryServerPro.Data.Schema.GalleryServerProSchema.xml"))
            {
                // Read in the current schema. This creates new, empty tables we'll populate from the existing data.
                ds.ReadXmlSchema(stream);
            }

            MigrateApplications(ds);

            // Don't import profiles. Several columns have changed data types and GSP doesn't use it anyway.
            //ds.Tables["Profiles"].Merge(ds.Tables["aspnet_Profile"]);

            MigrateAspNetRoles(ds);

            MigrateUsers(ds);

            MigrateMemberships(ds);

            MigrateUsersInRoles(ds);

            MigrateAppSettings(ds);

            MigrateGalleries(ds);

            MigrateGallerySettings(ds);

            MigrateAlbums(ds);

            MigrateRoles(ds);

            MigrateRoleAlbums(ds);

            MigrateMediaObjects(ds);

            MigrateMetadata(ds);

            MigrateMimeTypeGalleries(ds, dataStore, cn, tran);

            MigrateTags(ds);

            MigrateUserGalleryProfiles(ds);

            MigrateGalleryControlSettings(ds);

            MigrateUiTemplates(ds, dataStore, cn, tran);
        }
示例#3
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;
            }
        }
示例#4
0
        /// <summary>
        /// Convert <paramref name="version"/> to its string equivalent. Example: Return "2.1.3162" when <paramref name="version"/>
        /// is <see cref="GalleryDataSchemaVersion.V2_1_3162"/>. This is a lookup function and does not return the current version
        /// of the database or application schema requirements.
        /// </summary>
        /// <param name="version">The version of the gallery's data schema for which a string representation is to be returned.</param>
        /// <returns>Returns the string equivalent of the specified <see cref="GalleryDataSchemaVersion"/> value.</returns>
        internal static string ConvertGalleryDataSchemaVersionToString(GalleryDataSchemaVersion version)
        {
            switch (version)
            {
            case GalleryDataSchemaVersion.V2_1_3162:
                return("2.1.3162");

                break;

            case GalleryDataSchemaVersion.V2_3_3421:
                return("2.3.3421");

                break;

            default:
                throw new InvalidEnumArgumentException(String.Format("The function GalleryServerPro.Data.SQLite.SQLiteGalleryServerProProvider.ConvertGalleryDataSchemaVersionToString was not designed to handle the GalleryDataSchemaVersion enumeration value {0}. A developer must update this method to handle this value.", version));
            }
        }
示例#5
0
文件: Util.cs 项目: haimon74/KanNaim
		/// <summary>
		/// Convert <paramref name="version"/> to its string equivalent. Example: Return "2.1.3162" when <paramref name="version"/> 
		/// is <see cref="GalleryDataSchemaVersion.V2_1_3162"/>. This is a lookup function and does not return the current version 
		/// of the database or application schema requirements.
		/// </summary>
		/// <param name="version">The version of the gallery's data schema for which a string representation is to be returned.</param>
		/// <returns>Returns the string equivalent of the specified <see cref="GalleryDataSchemaVersion"/> value.</returns>
		internal static string ConvertGalleryDataSchemaVersionToString(GalleryDataSchemaVersion version)
		{
			switch (version)
			{
				case GalleryDataSchemaVersion.V2_1_3162:
					return "2.1.3162";
					break;
				case GalleryDataSchemaVersion.V2_3_3421:
					return "2.3.3421";
					break;
				default:
					throw new InvalidEnumArgumentException(String.Format("The function GalleryServerPro.Data.SQLite.SQLiteGalleryServerProProvider.ConvertGalleryDataSchemaVersionToString was not designed to handle the GalleryDataSchemaVersion enumeration value {0}. A developer must update this method to handle this value.", version));
			}
		}
示例#6
0
 /// <summary>
 /// Convert <paramref name="version"/> to its string equivalent. Example: Return "2.4.1" when <paramref name="version"/> 
 /// is <see cref="GalleryDataSchemaVersion.V2_4_1"/>. This is a lookup function and does not return the current version 
 /// of the database or application schema requirements.
 /// </summary>
 /// <param name="version">The version of the gallery's data schema for which a string representation is to be returned.</param>
 /// <returns>Returns the string equivalent of the specified <see cref="GalleryDataSchemaVersion"/> value.</returns>
 public static string ConvertGalleryDataSchemaVersionToString(GalleryDataSchemaVersion version)
 {
     switch (version)
     {
         case GalleryDataSchemaVersion.V2_1_3162:
             return "2.1.3162";
         case GalleryDataSchemaVersion.V2_3_3421:
             return "2.3.3421";
         case GalleryDataSchemaVersion.V2_4_1:
             return "2.4.1";
         case GalleryDataSchemaVersion.V2_4_3:
             return "2.4.3";
         case GalleryDataSchemaVersion.V2_4_4:
             return "2.4.4";
         case GalleryDataSchemaVersion.V2_4_5:
             return "2.4.5";
         case GalleryDataSchemaVersion.V2_4_6:
             return "2.4.6";
         case GalleryDataSchemaVersion.V2_5_0:
             return "2.5.0";
         default:
             throw new InvalidEnumArgumentException(String.Format(CultureInfo.CurrentCulture, "The function GalleryServerPro.Business.ConvertGalleryDataSchemaVersionToString was not designed to handle the GalleryDataSchemaVersion enumeration value {0}. A developer must update this method to handle this value.", version));
     }
 }