Ejemplo n.º 1
0
        protected override void ProcessRecord()
        {
            var configurationFile = this.ToAbsolutePath(ConfigurationFile);
            this.deltasDirectory = this.ToAbsolutePath(DeltasDirectory);

            if (!string.IsNullOrEmpty(configurationFile) && File.Exists(configurationFile))
            {
                var configurationManager = new DbDeployConfigurationManager();
                this.config = configurationManager.ReadConfiguration(configurationFile).Deployments.FirstOrDefault();

                if (string.IsNullOrEmpty(this.DatabaseType) || this.DatabaseType == DbDeployDefaults.Dbms)
                    this.DatabaseType = this.config.Dbms;

                if (string.IsNullOrEmpty(this.ConnectionString))
                    this.ConnectionString = this.config.ConnectionString;

                if (string.IsNullOrEmpty(this.TableName) || this.TableName == DbDeployDefaults.ChangeLogTableName)
                    this.TableName = this.config.ChangeLogTableName;
            }

            if (string.IsNullOrEmpty(this.ConnectionString))
            {
                throw new InvalidDataException(
                    "Missing connection string. It must either be in the config file or passed as a parameter");
            }
        }
Ejemplo n.º 2
0
        protected override void ProcessRecord()
        {
            var configurationFile = this.ToAbsolutePath(ConfigurationFile);

            this.deltasDirectory = this.ToAbsolutePath(DeltasDirectory);

            if (!string.IsNullOrEmpty(configurationFile) && File.Exists(configurationFile))
            {
                var configurationManager = new DbDeployConfigurationManager();
                this.config = configurationManager.ReadConfiguration(configurationFile).Deployments.FirstOrDefault();

                if (string.IsNullOrEmpty(this.DatabaseType) || this.DatabaseType == DbDeployDefaults.Dbms)
                {
                    this.DatabaseType = this.config.Dbms;
                }

                if (string.IsNullOrEmpty(this.ConnectionString))
                {
                    this.ConnectionString = this.config.ConnectionString;
                }

                if (string.IsNullOrEmpty(this.TableName) || this.TableName == DbDeployDefaults.ChangeLogTableName)
                {
                    this.TableName = this.config.ChangeLogTableName;
                }
            }

            if (string.IsNullOrEmpty(this.ConnectionString))
            {
                throw new InvalidDataException(
                          "Missing connection string. It must either be in the config file or passed as a parameter");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Parses the specified args into a deployments configuration.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>
        /// Configuration set.
        /// </returns>
        /// <exception cref="UsageException">Throws when unknown or invalid parameters are found.</exception>
        public static DbDeploymentsConfig ParseOptions(string[] args)
        {
            // Initialize configuration with a single deployment.
            var deploymentsConfig = new DbDeploymentsConfig();

            try
            {
                var       configFile = new ConfigFileInfo();
                var       config     = new DbDeployConfig();
                OptionSet options    = Initialize(config, configFile);
                deploymentsConfig.Deployments.Add(config);

                List <string> unknown = options.Parse(args);

                if (unknown != null && unknown.Count != 0)
                {
                    foreach (var s in unknown)
                    {
                        // empty "unkown" parameters are allowed
                        if (s != null && !string.IsNullOrEmpty(s.Trim()))
                        {
                            throw new UsageException("Unkown parameter(s): " + string.Join(", ", unknown.ToArray()));
                        }
                    }
                }

                // If a configuration file was specified in the command, use that instead of options.
                if (configFile.FileInfo != null)
                {
                    var configurationManager = new DbDeployConfigurationManager();
                    deploymentsConfig = configurationManager.ReadConfiguration(configFile.FileInfo.FullName);
                }
            }
            catch (OptionException e)
            {
                throw new UsageException(e.Message, e);
            }

            return(deploymentsConfig);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Parses the specified args into a deployments configuration.
        /// </summary>
        /// <param name="args">The args.</param>
        /// <returns>
        /// Configuration set.
        /// </returns>
        /// <exception cref="UsageException">Throws when unknown or invalid parameters are found.</exception>
        public static DbDeploymentsConfig ParseOptions(string[] args)
        {
            // Initialize configuration with a single deployment.
            var deploymentsConfig = new DbDeploymentsConfig();
            try
            {
                var configFile = new ConfigFileInfo();
                var config = new DbDeployConfig();
                OptionSet options = Initialize(config, configFile);
                deploymentsConfig.Deployments.Add(config);

                List<string> unknown = options.Parse(args);

                if (unknown != null && unknown.Count != 0)
                {
                    foreach (var s in unknown)
                    {
                        // empty "unkown" parameters are allowed
                        if (s != null && !string.IsNullOrEmpty(s.Trim()))
                        {
                            throw new UsageException("Unkown parameter(s): " + string.Join(", ", unknown.ToArray()));
                        }
                    }
                }

                // If a configuration file was specified in the command, use that instead of options.
                if (configFile.FileInfo != null)
                {
                    var configurationManager = new DbDeployConfigurationManager();
                    deploymentsConfig = configurationManager.ReadConfiguration(configFile.FileInfo.FullName);
                }
            }
            catch (OptionException e)
            {
                throw new UsageException(e.Message, e);
            }

            return deploymentsConfig;
        }
 protected void SetUp()
 {
     this.configurationManager = new DbDeployConfigurationManager();
 }