Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlDataTarget" /> class.
        /// </summary>
        /// <param name="connectionFactory">The connection.</param>
        /// <param name="bulkCopyFactory">The bulk copy factory.</param>
        /// <param name="watermarkService">The watermark service.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="highWatermarkColumn">The high watermark column.</param>
        /// <param name="truncateBeforeLoad">If set to <c>true</c> [truncate before load].</param>
        /// <exception cref="System.ArgumentNullException">If any parameters are null.</exception>
        public SqlDataTarget(IConnectionFactory connectionFactory, IBulkCopyFactory bulkCopyFactory, IHighWatermarkService watermarkService, string tableName, string highWatermarkColumn, bool truncateBeforeLoad)
        {
            if (connectionFactory == null)
            {
                throw new ArgumentNullException("connectionFactory");
            }

            this.connectionFactory = connectionFactory;

            if (bulkCopyFactory == null)
            {
                throw new ArgumentNullException("bulkCopyFactory");
            }

            this.bulkCopyFactory = bulkCopyFactory;

            if (tableName == null)
            {
                throw new ArgumentNullException("tableName");
            }

            this.tableName = tableName;

            if (watermarkService == null)
            {
                throw new ArgumentNullException("watermarkService");
            }

            this.watermarkService = watermarkService;

            this.highWatermarkColumn = highWatermarkColumn;
            this.truncateBeforeLoad  = truncateBeforeLoad;

            this.targetSchema = new Lazy <DataTable>(() => this.GetSchemaTable());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlDataTargetFacts"/> class.
        /// </summary>
        public SqlDataTargetFacts()
        {
            this.bulkCopyFactory  = Substitute.For <IBulkCopyFactory>();
            this.watermarkService = Substitute.For <IHighWatermarkService>();

            this.nonWatermarkTarget = new SqlDataTarget(this.ConnectionFactory, this.bulkCopyFactory, this.watermarkService, TargetTableName, string.Empty, true);
            this.watermarkedTarget  = new SqlDataTarget(this.ConnectionFactory, this.bulkCopyFactory, this.watermarkService, TargetTableName, "WATERMARK COLUMN", true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the script.
        /// </summary>
        /// <param name="script">The script.</param>
        /// <param name="environment">The environment.</param>
        /// <param name="watermarkService">The watermark service.</param>
        /// <param name="targetConnectionString">The target connection string.</param>
        /// <returns>
        /// A data script to execute.
        /// </returns>
        private static DataScript LoadScript(string script, string environment, IHighWatermarkService watermarkService, string targetConnectionString)
        {
            DittoEventSource.Log.ParsingScriptFile(script, environment);

            using (var config = new StreamReader(script))
            {
                var parser = new DataScriptParser(watermarkService, environment, targetConnectionString);
                return(parser.Parse(config));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataScriptParserFacts"/> class.
 /// </summary>
 public DataScriptParserFacts()
 {
     this.watermarkService = Substitute.For <IHighWatermarkService>();
     this.target           = new DataScriptParser(this.watermarkService, "UnitTest", TargetConnectionString);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataScriptParser" /> class.
 /// </summary>
 /// <param name="highWatermarkService">The high watermark service.</param>
 /// <param name="currentEnvironment">The current environment.</param>
 /// <param name="targetConnectionString">The target connection string.</param>
 /// <exception cref="System.ArgumentNullException">If any arguments are null.</exception>
 public DataScriptParser(IHighWatermarkService highWatermarkService, string currentEnvironment, string targetConnectionString)
     : base(currentEnvironment, targetConnectionString)
 {
     this.highWatermarkService = highWatermarkService ?? throw new ArgumentNullException("highWatermarkService");
 }