protected override Task <IAsyncChannel> ProduceAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, CancellationToken cancellationToken) { IAsyncChannel asyncChannel; ISchema schema; IAsyncEnumerable <IPayload> payloads; IAsyncEnumerable <IAsyncRecord> records; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } if ((object)configuration == null) { throw new ArgumentNullException(nameof(configuration)); } this.AssertValidConfiguration(); TTextualConnectorSpecificConfiguration fsConfig = this.Configuration.StageSpecificConfiguration; if (!asyncContext.LocalState.TryGetValue(this, out IDictionary <string, object> localState)) { localState = new Dictionary <string, object>(StringComparer.OrdinalIgnoreCase); asyncContext.LocalState.Add(this, localState); } schema = localState[Constants.ContextComponentScopedSchema] as ISchema; if ((object)schema == null) { throw new SyncPremException(nameof(schema)); } schema = localState[Constants.ContextComponentScopedSchema] as ISchema; if ((object)schema == null) { throw new SyncPremException(nameof(schema)); } payloads = this.TextualReader.ReadRecordsAsync(cancellationToken); if ((object)payloads == null) { throw new SyncPremException(nameof(payloads)); } records = payloads.Select(rec => new DefaultAsyncRecord(schema, rec, string.Empty, Partition.None, Offset.None)); if ((object)records == null) { throw new SyncPremException(nameof(records)); } asyncChannel = asyncContext.CreateChannelAsync(records); return(Task.FromResult(asyncChannel)); }
protected override Task <IAsyncChannel> ProduceAsyncInternal(IAsyncContext asyncContext, RecordConfiguration configuration, CancellationToken cancellationToken) { IAsyncChannel asyncChannel; IAsyncEnumerable <IAdoNetStreamingResult> results; IEnumerable <DbParameter> dbParameters; if ((object)asyncContext == null) { throw new ArgumentNullException(nameof(asyncContext)); } 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.ExecuteResultsAsync(fsConfig.ExecuteCommand.CommandType ?? CommandType.Text, fsConfig.ExecuteCommand.CommandText, dbParameters, cancellationToken); if ((object)results == null) { throw new SyncPremException(nameof(results)); } var records = this.GetMultiplexedRecords(asyncContext, results, cancellationToken); asyncChannel = asyncContext.CreateChannelAsync(records); return(Task.FromResult(asyncChannel)); }