Ejemplo n.º 1
0
        public override string InjectConfig(string command, Domain.Entities.PropertyCollection properties)
        {
            var regex = new Regex(@"\x24\x7B[a-zA-z0-9\-_]+\x7D");
            var match = regex.Match(command);
            while (match.Success)
            {
                var token = match.Value.Substring(2, match.Value.Length - 3);
                var property = properties.Find(token);
                if (property == null)
                {
                    throw new Domain.DatabaseScripterException(Domain.ErrorCode.CouldNotFindPropertyForScriptInEnvironmentConfiguration, "token");
                }

                command = command.Replace(match.Value, property.Value);
                log.DebugFormat(CultureInfo.InvariantCulture, "Injected configuration key {0} with value {1}", match.Value, property.Value);

                match = regex.Match(command);
            }

            return command;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationResult"/> class.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 /// <param name="configuration">The configuration.</param>
 /// <param name="executionPlan">The execution plan.</param>
 public ConfigurationResult(Domain.ErrorCode errorCode, Domain.Values.Configuration configuration)
     : base(errorCode)
 {
     Configuration = configuration;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Result"/> class.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 public Result(Domain.ErrorCode errorCode)
 {
     ErrorCode = errorCode;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the schema version in the database.
        /// </summary>
        /// <param name="version">The version.</param>
        /// <returns></returns>
        public override bool SetVersion(string databaseName, Domain.Values.Version version)
        {
            try
            {
                if (_server.Databases[databaseName].ExtendedProperties.Contains("SCHEMA_VERSION"))
                {
                    var extendedProperty = _server.Databases[databaseName].ExtendedProperties["SCHEMA_VERSION"];
                    extendedProperty.Value = version.ToString();
                    extendedProperty.Alter();
                }
                else
                {
                    var extendedProperty = new ExtendedProperty(_server.Databases[databaseName], "SCHEMA_VERSION", version.ToString());
                    extendedProperty.Create();

                    _server.Databases[databaseName].Alter();
                }
            }
            catch (ExecutionFailureException efeEx)
            {
                log.Error("An Exception occurred. See the debug information that follows.", efeEx);
                return false;
            }
            catch (SmoException smoEx)
            {
                log.Error("An Exception occurred. See the debug information that follows.", smoEx);
                return false;
            }

            return true;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Confirms the current version of the database matches the specified version.
        /// </summary>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="version">The version.</param>
        /// <param name="confirmed">if set to <c>true</c>, the database version has been confirmed.</param>
        /// <returns></returns>
        public override bool GetVersion(string databaseName, out Domain.Values.Version currentVersion)
        {
            currentVersion = null;

            try
            {
                var database = _server.Databases[databaseName];
                if (null == database)
                {
                    log.ErrorFormat("There is no database called '{0}' on the server.", databaseName);
                    return false;
                }

                var currentDatabaseVersion = new Domain.Values.Version(database.ExtendedProperties["SCHEMA_VERSION"].Value as string);
                log.InfoFormat(CultureInfo.InvariantCulture, "Current database version is {0}", currentDatabaseVersion);
                currentVersion = currentDatabaseVersion;
            }
            catch (ExecutionFailureException efeEx)
            {
                log.Error("An Exception occurred. See the debug information that follows.", efeEx);
                return false;
            }
            catch (SmoException smoEx)
            {
                log.Error("An Exception occurred. See the debug information that follows.", smoEx);
                return false;
            }

            return true;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Confirms the current version of the database matches the specified version.
        /// </summary>
        /// <param name="databaseName">Name of the database.</param>
        /// <param name="version">The version.</param>
        /// <param name="confirmed">if set to <c>true</c>, the database version has been confirmed.</param>
        /// <returns></returns>
        public override bool ConfirmVersion(string databaseName, Domain.Values.Version version, out bool confirmed)
        {
            confirmed = false;

            Domain.Values.Version currentVersion;
            if (!GetVersion(databaseName, out currentVersion))
            {
                return false;
            };

            confirmed = (version == currentVersion);
            return true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EnvironmentConfigurationFactoryResult"/> class.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 /// <param name="environmentConfiguration">The environment configuration.</param>
 public EnvironmentConfigurationFactoryResult(Domain.ErrorCode errorCode, Domain.Entities.EnvironmentConfiguration environmentConfiguration)
     : base(errorCode)
 {
     EnvironmentConfiguration = environmentConfiguration;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ManifestFactoryResult"/> class.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 /// <param name="manifest">The manifest.</param>
 public ManifestFactoryResult(Domain.ErrorCode errorCode, Domain.Values.Manifest manifest)
     : base(errorCode)
 {
     Manifest = manifest;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExecutionPlanResult"/> class.
 /// </summary>
 /// <param name="errorCode">The error code.</param>
 /// <param name="executionPlan">The execution plan.</param>
 public ExecutionPlanResult(Domain.ErrorCode errorCode, Domain.Values.ExecutionPlan executionPlan)
     : base(errorCode)
 {
     ExecutionPlan = executionPlan;
 }