示例#1
0
        /// <summary>
        /// Gets the migrator.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <returns></returns>
        private static ECM7.Migrator.Migrator GetMigrator(Assembly assembly)
        {
            IApplicationConfigurator applicationConfigurator = ServiceLocator.Current.GetInstance <IApplicationConfigurator>();

            ECM7.Migrator.Migrator migrator = null;
            if (applicationConfigurator != null && applicationConfigurator.DatabaseConfiguration != null)
            {
                migrator = new ECM7.Migrator.Migrator(MigratorUtility.GetDialect(applicationConfigurator.DatabaseConfiguration.Platform), applicationConfigurator.DatabaseConfiguration.GetConnectionString(), assembly);
            }
            return(migrator);
        }
示例#2
0
        /// <summary>
        /// When overridden in a derived class, executes the task.
        /// </summary>
        /// <returns>
        /// true if the task successfully executed; otherwise, false.
        /// </returns>
        public override bool Execute()
        {
            bool result = true;

            var application = ConfigureApplication();
            var configKey   = GetConfigKey();

            if (application.DatabaseConfiguration.ContainsKey(configKey))
            {
                var databaseConfiguration = application.DatabaseConfiguration[configKey];
                ConnectionString = databaseConfiguration.GetConnectionString();
                Dialect          = MigratorUtility.GetDialect(databaseConfiguration.Platform);
            }
            else
            {
                Log.LogError("Could not find database configuration for Environment = \"{0}\".", Environment);
                result = false;
            }

            return(result);
        }