public DataFlowTask(DataFlow dataFlow, ProjectWrapper projectWrapper, PackageWrapper packageWrapper, ContainerWrapper containerWrapper) { DataFlowTaskWrapper = new DataFlowTaskWrapper(containerWrapper) { Name = dataFlow.Name, DelayValidation = dataFlow.DelayValidation, ForceExecutionResult = dataFlow.ForceExecutionResult.ToString(), AutoAdjustBufferSize = dataFlow.AutoAdjustBufferSize, DefaultBufferMaxRows = int.Parse(dataFlow.DefaultBufferMaxRows, CultureInfo.InvariantCulture), DefaultBufferSize = int.Parse(dataFlow.DefaultBufferSize, CultureInfo.InvariantCulture) }; DataFlowTaskWrapper.PropagateErrors(dataFlow.PropagateErrors); AddComponents(dataFlow.Components, packageWrapper, projectWrapper); }
protected ComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper, string componentClassId) { if (dataFlowTaskWrapper == null) { throw new ArgumentNullException(nameof(dataFlowTaskWrapper)); } Meta = dataFlowTaskWrapper.ComponentMetaDataCollection.New(); Meta.ComponentClassId = componentClassId; Instance = metadataType.GetMethod("Instantiate").Invoke(Meta, null); try { componentWrapperType.GetMethod("ProvideComponentProperties").Invoke(Instance, null); } catch (Exception e) { throw new InvalidOperationException($"Failed to find an implementation of dataflow component {componentClassId}", e); } }
public static RowCountComponentWrapper CreateComponent(RowCount rowCount, DataFlowTaskWrapper dataFlowTaskWrapper) { RowCountComponentWrapper rowCountComponentWrapper = new RowCountComponentWrapper(dataFlowTaskWrapper) { Name = rowCount.Name, VariableName = rowCount.VariableName }; dataFlowTaskWrapper.AddPath(rowCount.DataFlowInputPath.OutputPathName, rowCountComponentWrapper.Meta.InputCollection[0]); try { rowCountComponentWrapper.GetMetadata(); } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {rowCount.Name}!", e); } return(rowCountComponentWrapper); }
public DerivedColumnComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper, List <string> replaceColumns) : base(dataFlowTaskWrapper, "Microsoft.DerivedColumn") { readWriteColumns = replaceColumns; }
public static CustomComponentWrapper CreateComponent(IonStructure.CustomComponent customComponent, DataFlowTaskWrapper dataFlowTaskWrapper, PackageWrapper packageWrapper, ProjectWrapper projectWrapper) { CustomComponentWrapper customComponentWrapper = new CustomComponentWrapper(dataFlowTaskWrapper, customComponent.ComponentTypeName) { Name = customComponent.Name }; if (customComponent.CustomProperties != null) { foreach (CustomProperty customProperty in customComponent.CustomProperties) { customComponentWrapper.SetCustomProperty(customProperty.Name, customProperty.Value); } } SetConnectionManager(projectWrapper, packageWrapper, customComponentWrapper, customComponent.ConnectionName); try { customComponentWrapper.GetMetadata(); } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {customComponent.Name}!", e); } return(customComponentWrapper); }
public static OleDbDestinationComponentWrapper CreateComponent(OleDbDestination oleDbDestination, DataFlowTaskWrapper dataFlowTaskWrapper, PackageWrapper packageWrapper, ProjectWrapper projectWrapper) { OleDbDestinationComponentWrapper oleDbDestinationComponentWrapper = new OleDbDestinationComponentWrapper(dataFlowTaskWrapper) { Name = oleDbDestination.Name, Table = oleDbDestination.ExternalTableOutput.Table, UseFastLoadIfAvailable = oleDbDestination.UseFastLoadIfAvailable }; if (oleDbDestination.OleDbDestinationColumns != null) { foreach (DataFlowColumnMapping dataFlowColumnMapping in oleDbDestination.OleDbDestinationColumns) { oleDbDestinationComponentWrapper.CustomMappingColumns.Add((dataFlowColumnMapping.SourceColumn, dataFlowColumnMapping.TargetColumn)); } } if (oleDbDestination.UseFastLoadIfAvailable) { oleDbDestinationComponentWrapper.CheckConstraints = oleDbDestination.CheckConstraints; oleDbDestinationComponentWrapper.KeepIdentity = oleDbDestination.KeepIdentity; oleDbDestinationComponentWrapper.KeepNulls = oleDbDestination.KeepNulls; oleDbDestinationComponentWrapper.MaximumInsertCommitSize = int.Parse(oleDbDestination.MaximumInsertCommitSize, CultureInfo.InvariantCulture); oleDbDestinationComponentWrapper.TableLock = oleDbDestination.TableLock; } dataFlowTaskWrapper.AddPath(oleDbDestination.DataFlowInputPath.OutputPathName, oleDbDestinationComponentWrapper.Meta.InputCollection[0]); SetConnectionManager(projectWrapper, packageWrapper, oleDbDestinationComponentWrapper, oleDbDestination.ConnectionName); if (oleDbDestination.ErrorHandling != null) { oleDbDestinationComponentWrapper.SetRowDisposition((RowDispositionType)oleDbDestination.ErrorHandling.ErrorRowDisposition, RowFailureType.Error, PathDirectionType.Input); } try { oleDbDestinationComponentWrapper.GetMetadata(); } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {oleDbDestination.Name}!", e); } return(oleDbDestinationComponentWrapper); }
public static FlatFileSourceComponentWrapper CreateComponent(FlatFileSource flatFileSource, DataFlowTaskWrapper dataFlowTaskWrapper, PackageWrapper packageWrapper, ProjectWrapper projectWrapper) { FlatFileSourceComponentWrapper flatFileSourceComponentWrapper = new FlatFileSourceComponentWrapper(dataFlowTaskWrapper) { Name = flatFileSource.Name, RetainNulls = flatFileSource.RetainNulls }; if (flatFileSource.FlatFileSourceColumns != null) { foreach (DataFlowColumnMapping dataFlowColumnMapping in flatFileSource.FlatFileSourceColumns) { flatFileSourceComponentWrapper.CustomMappingColumns.Add((dataFlowColumnMapping.SourceColumn, dataFlowColumnMapping.TargetColumn)); } } SetConnectionManager(projectWrapper, packageWrapper, flatFileSourceComponentWrapper, flatFileSource.ConnectionName); try { flatFileSourceComponentWrapper.GetMetadata(); } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {flatFileSourceComponentWrapper.Name}!", e); } return(flatFileSourceComponentWrapper); }
public OleDbSourceComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper) : base(dataFlowTaskWrapper, "Microsoft.OleDbSource") { }
public FlatFileSourceComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper) : base(dataFlowTaskWrapper, "Microsoft.FlatFileSource") { }
public CustomComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper, string componentTypeName) : base(dataFlowTaskWrapper, componentTypeName) { }
public static FlatFileDestinationComponentWrapper CreateComponent(FlatFileDestination flatFileDestination, DataFlowTaskWrapper dataFlowTaskWrapper, PackageWrapper packageWrapper, ProjectWrapper projectWrapper) { FlatFileDestinationComponentWrapper flatFileDestinationComponentWrapper = new FlatFileDestinationComponentWrapper(dataFlowTaskWrapper) { Name = flatFileDestination.Name, Overwrite = flatFileDestination.Overwrite }; if (flatFileDestination.FlatFileDestinationColumns != null) { foreach (DataFlowColumnMapping dataFlowColumnMapping in flatFileDestination.FlatFileDestinationColumns) { flatFileDestinationComponentWrapper.CustomMappingColumns.Add((dataFlowColumnMapping.SourceColumn, dataFlowColumnMapping.TargetColumn)); } } if (flatFileDestination.Header != null) { flatFileDestinationComponentWrapper.Header = flatFileDestination.Header; } dataFlowTaskWrapper.AddPath(flatFileDestination.DataFlowInputPath.OutputPathName, flatFileDestinationComponentWrapper.Meta.InputCollection[0]); SetConnectionManager(projectWrapper, packageWrapper, flatFileDestinationComponentWrapper, flatFileDestination.ConnectionName); if (flatFileDestination.ErrorHandling != null) { flatFileDestinationComponentWrapper.SetRowDisposition((RowDispositionType)flatFileDestination.ErrorHandling.ErrorRowDisposition, RowFailureType.Error, PathDirectionType.Input); } try { flatFileDestinationComponentWrapper.GetMetadata(); } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {flatFileDestination.Name}!", e); } return(flatFileDestinationComponentWrapper); }
public FlatFileDestinationComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper) : base(dataFlowTaskWrapper, "Microsoft.FlatFileDestination") { }
public RowCountComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper) : base(dataFlowTaskWrapper, "Microsoft.RowCount") { }
public static OleDbSourceComponentWrapper CreateComponent(OleDbSource oleDbSource, DataFlowTaskWrapper dataFlowTaskWrapper, PackageWrapper packageWrapper, ProjectWrapper projectWrapper) { OleDbSourceComponentWrapper oleDbSourceComponentWrapper = new OleDbSourceComponentWrapper(dataFlowTaskWrapper) { Name = oleDbSource.Name }; if (oleDbSource.OleDbSourceColumns != null) { foreach (DataFlowColumnMapping dataFlowColumnMapping in oleDbSource.OleDbSourceColumns) { oleDbSourceComponentWrapper.CustomMappingColumns.Add((dataFlowColumnMapping.SourceColumn, dataFlowColumnMapping.TargetColumn)); } } if (oleDbSource.SqlCommand != null) { oleDbSourceComponentWrapper.SqlCommand = oleDbSource.SqlCommand.Value; } else if (oleDbSource.VariableInput != null) { oleDbSourceComponentWrapper.SqlCommandVariable = oleDbSource.VariableInput.VariableName; } else { throw new InvalidOperationException($"Data flow component {oleDbSourceComponentWrapper.Name} needs to have an input type set!"); } if (oleDbSource.VariableParameterMappings != null) { for (int i = 0; i < oleDbSource.VariableParameterMappings.Count; i++) { oleDbSourceComponentWrapper.AddParameter(i, oleDbSource.VariableParameterMappings[i].ParameterName, oleDbSource.VariableParameterMappings[i].VariableName); } } SetConnectionManager(projectWrapper, packageWrapper, oleDbSourceComponentWrapper, oleDbSource.ConnectionName); try { oleDbSourceComponentWrapper.GetMetadata(); } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {oleDbSourceComponentWrapper.Name}!", e); } return(oleDbSourceComponentWrapper); }
public static DerivedColumnComponentWrapper CreateComponent(DerivedColumn derivedColumn, DataFlowTaskWrapper dataFlowTaskWrapper) { List <string> duplicates = derivedColumn.DerivedColumns.GroupBy(c => c.ColumnName) .Where(c => c.Count() > 1) .Select(c => c.Key) .Distinct() .ToList(); if (duplicates.Count > 0) { string duplicateNames = string.Join(", ", duplicates); throw new InvalidOperationException($"The following columns are duplicated in the derived column list: {duplicateNames}"); } List <string> replaceColumns = derivedColumn.DerivedColumns.Where(c => c.Replace).Select(c => c.ColumnName).ToList(); DerivedColumnComponentWrapper derivedColumnComponentWrapper = new DerivedColumnComponentWrapper(dataFlowTaskWrapper, replaceColumns) { Name = derivedColumn.Name }; dataFlowTaskWrapper.AddPath(derivedColumn.DataFlowInputPath.OutputPathName, derivedColumnComponentWrapper.Meta.InputCollection[0]); try { derivedColumnComponentWrapper.GetMetadata(); // Get virtual input column metadata to the component. } catch (Exception e) { throw new Exception($"Failed to get metadata for data flow component {derivedColumn.Name}!", e); } foreach (DerivedColumnEntry column in derivedColumn.DerivedColumns) { try { if (column.Replace) { derivedColumnComponentWrapper.ReplaceColumn(column.ColumnName, column.Expression); derivedColumnComponentWrapper.SetColumnDisposition(column.ColumnName, (RowDispositionType)column.ErrorRowDisposition, RowFailureType.Error, PathDirectionType.Input); derivedColumnComponentWrapper.SetColumnDisposition(column.ColumnName, (RowDispositionType)column.TruncationRowDisposition, RowFailureType.Truncation, PathDirectionType.Input); } else { derivedColumnComponentWrapper.AddNewColumn(column.ColumnName, column.Expression); derivedColumnComponentWrapper.SetColumnDisposition(column.ColumnName, (RowDispositionType)column.ErrorRowDisposition, RowFailureType.Error, PathDirectionType.Output); derivedColumnComponentWrapper.SetColumnDisposition(column.ColumnName, (RowDispositionType)column.TruncationRowDisposition, RowFailureType.Truncation, PathDirectionType.Output); } } catch (Exception e) { string msg = $"Could not set expression {column.Expression} on derived column {column.ColumnName}! Verify that it is a valid expression."; e.Data.Add(Constants.ExceptionComponentMessageKey, msg); throw; } } return(derivedColumnComponentWrapper); }
public OleDbDestinationComponentWrapper(DataFlowTaskWrapper dataFlowTaskWrapper) : base(dataFlowTaskWrapper, "Microsoft.OleDbDestination") { }