c# - Create Script Component as Source Programmatically -


I am programming on a package with a data flow function containing a script component as a source. I am able to add packages, data flow tasks, and a script component.

Does anyone know how to make a sauce?

Here's my class on the single method I'm working on:

  using the system; Using System.Collections.Generic; Using System.Linq; Using System.Text; System usage threading. Task; Using DynamicPackageCreator.Models; Using Microsoft.SqlServer.Dts.Runtime; Using System.IO; Using Microsoft.SqlServer.Dts.Pipeline.Wrapper; // Alias ​​DtsColumnDataType = Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType to prevent ambiguity; Namespace DynamicPackage Creeter {Public class DtsClient {Public Zero CreatePackageWithDataFlowAndScriptSource (string file path, string dataflow, string source name, list & output; output definition; output definition) {// package package pkg = new package (); Pkg.Name = Path GetFileName Without Extension (File Path); // Create dataflow executable e = pkg.Executables.Add ("Share: PipelineTask"); Taskhost Thanpip = E Taskhost; ThMainPipeName = dataFlowName; Menpip Dataflow Task = Thanpip. Inner object as a manipip; // Create the source component IDTSComponentMetaData100 sourceComponent = DataFlowTask.ComponentMetaDataCollection.New (); SourceComponent.Name = sourceName; SourceComponent.ComponentClassID = SsisComponentType.ScriptComponent.GetComponentClassId (); // Design time is available for the srcDesignTime component component CManagedComponentWrapper srcDesignTime = sourceComponent.Instantiate (); // Start the component srcDesignTime.ProvideComponentProperties (); Int lastOutputId = 0; // add metadata foreach (var outputDefinition in outputDefinitions) {var output = srcDesignTime.InsertOutput (DTSInsertPlacement.IP_AFTER, lastOutputId); Output.Name = outputDefinition.OutputName; LastOutputId = Output.ID; Var outputcolumncollection = output.OutputColumnCollection; Vorach (var output column definition in output definition. Output code dimension) {var output column = output column collection. OutputColumn.Name = outputColumnDefinition.ColumnName; Output column.Card data typeproperty (DTC columnData type.dT_WSTR, output column definition column column, 0, 0, 0); Metadata srcDesignTime.ReinitializeMetaData (); // Save package application app = new application (); App.SaveToXml (file path, PKG, tap); }}}   

Output Definition Class is a custom class that I created to maintain the definitions used during the output.

So, the solution to this problem is to remove all input from the component. By default the component has "input 0" and one "output 0" that is associated with the transform script component type. There is no input in the source type, and the destination has no output.

To remove the input and output, add:

  sourceComponent.OutputCollection.RemoveAll (); SourceComponent.InputCollection.RemoveAll ();   

here:

  // ... // start the component srcDesignTime.ProvideComponentProperties (); // Remove the default inputs and output to the source. Option Control. Remove (); SourceComponent.InputCollection.RemoveAll (); Int lastOutputId = 0; // ...    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -