private static ISyncChannel NullProcessorMethod(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel, SyncProcessDelegate next)
        {
            ISyncChannel newChannel;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            Console.WriteLine("{1} (before next) processor: '{0}'", nameof(NullProcessor), nameof(NullProcessorMethod));

            if ((object)next != null)
            {
                newChannel = next(context, configuration, channel);
            }
            else
            {
                newChannel = channel;
            }

            Console.WriteLine("{1} (after next) processor: '{0}'", nameof(NullProcessor), nameof(NullProcessorMethod));

            return(newChannel);
        }
Ejemplo n.º 2
0
        protected override ISyncChannel ProduceInternal(ISyncContext context, RecordConfiguration configuration)
        {
            ISyncChannel channel = null;
            ISchema      schema;

            IEnumerable <IPayload> payloads;
            IEnumerable <IAdoNetStreamingResult> results;
            IEnumerable <DbParameter>            dbParameters;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            this.AssertValidConfiguration();

            AdoNetConnectorSpecificConfiguration fsConfig = this.Configuration.StageSpecificConfiguration;

            if ((object)fsConfig.ExecuteCommand == null)
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", nameof(fsConfig.ExecuteCommand)));
            }

            if (SolderFascadeAccessor.DataTypeFascade.IsNullOrWhiteSpace(fsConfig.ExecuteCommand.CommandText))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}.{1}'.", nameof(fsConfig.ExecuteCommand), nameof(fsConfig.ExecuteCommand.CommandText)));
            }

            dbParameters = fsConfig.ExecuteCommand.GetDbDataParameters(this.SourceUnitOfWork);

            results = this.SourceUnitOfWork.ExecuteResults(fsConfig.ExecuteCommand.CommandType ?? CommandType.Text, fsConfig.ExecuteCommand.CommandText, dbParameters);

            if ((object)results == null)
            {
                throw new SyncPremException(nameof(results));
            }

            var channels = this.GetMultiplexedChannels(context, results);
            var records  = channels.SelectMany(x => x.Records);

            channel = context.CreateChannel(records);

            return(channel);
        }
        public void Consume(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
        {
            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            this.ConsumeInternal(context, configuration, channel);
        }
 protected abstract void ConsumeInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel);
        protected override void ConsumeInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
        {
            IEnumerable <ISyncRecord> records;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            this.AssertValidConfiguration();

            records = channel.Records;

            if ((object)records == null)
            {
                throw new SyncPremException(nameof(records));
            }

            var payloads = channel.Records.Select(p => p.Payload);

            this.TextualWriter.WriteRecords(payloads);
        }
Ejemplo n.º 6
0
        protected override void ConsumeInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
        {
            IEnumerable <IRecord> records;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            this.AssertValidConfiguration();

            records = channel.Records;

            if ((object)records == null)
            {
                throw new SyncPremException(nameof(records));
            }

            records.ForceEnumeration();             // force execution
        }
		protected override void ConsumeInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
		{
			IEnumerable<IRecord> records;

			if ((object)context == null)
				throw new ArgumentNullException(nameof(context));

			if ((object)configuration == null)
				throw new ArgumentNullException(nameof(configuration));

			if ((object)channel == null)
				throw new ArgumentNullException(nameof(channel));

			this.AssertValidConfiguration();

			records = channel.Records;

			if ((object)records == null)
				throw new SyncPremException(nameof(records));

			foreach (IRecord record in records)
				TextWriter.WriteLine(record);
		}
Ejemplo n.º 8
0
        protected override void ConsumeInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
        {
            ISchema schema = null;
            IEnumerable <ISyncRecord> records;

            DbDataReader sourceDataReader;
            long         rowsCopied;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            this.AssertValidConfiguration();

            records = channel.Records;

            if ((object)records == null)
            {
                throw new SyncPremException(nameof(records));
            }

            sourceDataReader = null;             //new AdoNetStreamingPayloadDataReader(schema.Fields.Values, records.Select(r => r.Payload));

            try
            {
                this.ConsumeMessageReader(context, configuration, sourceDataReader);
            }
            finally
            {
                // just in case ConsumeMessageReader did not or could not enumerate to completion for disposal...
                do
                {
                    while (sourceDataReader.Read())
                    {
                        ;
                    }
                }while (sourceDataReader.NextResult())
                ;
            }
        }
Ejemplo n.º 9
0
 protected abstract ISyncChannel ProcessInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel, SyncProcessDelegate next);
Ejemplo n.º 10
0
        public ISyncChannel Process(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel, SyncProcessDelegate next)
        {
            ISyncChannel newChannel;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            newChannel = this.ProcessInternal(context, configuration, channel, next);

            return(newChannel);
        }
        protected override void ConsumeInternal(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
        {
            IEnumerable <ISyncRecord> records;

            if ((object)context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if ((object)configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if ((object)channel == null)
            {
                throw new ArgumentNullException(nameof(channel));
            }

            this.AssertValidConfiguration();

            RestfulWebApiConnectorSpecificConfiguration fsConfig = this.Configuration.StageSpecificConfiguration;

            records = channel.Records;

            if ((object)records == null)
            {
                throw new SyncPremException(nameof(records));
            }

            using (HttpClient httpClient = new HttpClient())
            {
                using (HttpContent httpContent = new PushStreamContent((s) => this.SerializeRecordsToStream(s, records)))
                {
                    using (HttpResponseMessage result = httpClient.PostAsync(fsConfig.WebEndpointUri, httpContent).GetAwaiter().GetResult())
                    {
                        result.Content.ReadAsStreamAsync().GetAwaiter().GetResult();
                        result.EnsureSuccessStatusCode();
                    }
                }
            }
        }
 private ISyncChannel Transform(ISyncContext context, RecordConfiguration configuration, ISyncChannel channel)
 {
     Console.WriteLine("voo doo!");
     return(this.SyncProcessToNext(context, configuration, channel, this.SyncNext));
 }