Beispiel #1
0
        private void AddOutputColumns(IEnumerable <IOMapEntry> IoMap, IEnumerable <string> copyColNames)
        {
            // Reconfigure outputs:
            _md.OutputCollection[0].Name = "JSON Source Output";
            _md.OutputCollection[0].OutputColumnCollection.RemoveAll();

            var input = _md.InputCollection[ComponentConstants.NAME_INPUT_LANE_PARAMS];

            // Add simple copy columns
            foreach (var colname in copyColNames)
            {
                // Only add them if the inputlan is connected.
                if (!input.IsAttached)
                {
                    _md.FireWarning(0, _md.Name, string.Format("Cannot add outputcolumn for input {0} because input lane is not attached.", colname), null, 0);
                    return;
                }

                // Copy that column
                var incol = input.InputColumnCollection[colname];
                IDTSOutputColumn100 output = _md.OutputCollection[0].OutputColumnCollection.New();
                output.SetDataTypeProperties(incol.DataType, incol.Length, incol.Precision, incol.Scale, incol.CodePage);
                output.MappedColumnID = incol.LineageID;
                output.Name           = incol.Name;
            }

            // For each espected outputcolumn json derived, add the equivalent.
            foreach (IOMapEntry e in IoMap)
            {
                if (e.InputFieldLen < 0)
                {
                    // FIXME TODO: this must be done directly within the UI
                    _md.FireWarning(0, _md.Name, "A row of the IO configuration presents a negative value, which is forbidden.", null, 0);
                }

                IDTSOutputColumn100 col = _md.OutputCollection[0].OutputColumnCollection.New();
                col.Name = e.OutputColName;

                // There might be some possible errors regarding data lenght. We try to correct them here.
                // If length > 4000 and type is string, put TEXT datatype.
                if (e.OutputColumnType == Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_WSTR && (e.InputFieldLen > 4000 || e.InputFieldLen == 0))
                {
                    // FIXME TODO: this must be done directly within the UI
                    // e.OutputColumnType = Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_TEXT;
                    _md.FireWarning(0, _md.Name, string.Format("Column {0} is supposed to be longer than 4000 chars, so DT_WSTR is not a suitable column type. Instead, DT_TEXT has been selected.", e.OutputColName), null, 0);
                    // TODO: parametrize the codepage
                    col.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_TEXT, 0, 0, 0, 1252);
                }
                else
                {
                    col.SetDataTypeProperties(e.OutputColumnType, e.InputFieldLen, 0, 0, 0);
                }
            }
        }
        public override void SetOutputColumnDataTypeProperties(int iOutputID, int iOutputColumnID, DataType eDataType, int iLength, int iPrecision, int iScale, int iCodePage)
        {
            IDTSOutputCollection100 outputColl = ComponentMetaData.OutputCollection;
            IDTSOutput100           output     = outputColl.GetObjectByID(iOutputID);

            if (output != null)
            {
                if (output.IsErrorOut)
                {
                    this.PostErrorAndThrow(MessageStrings.CantChangeErrorOutputProperties);
                }
                else
                {
                    IDTSOutputColumnCollection100 columnColl = output.OutputColumnCollection;
                    IDTSOutputColumn100           column     = columnColl.GetObjectByID(iOutputColumnID);
                    if (column != null)
                    {
                        if (ValidateSupportedDataTypes(eDataType) == DTSValidationStatus.VS_ISVALID)
                        {
                            column.SetDataTypeProperties(eDataType, iLength, iPrecision, iScale, iCodePage);
                        }
                        else
                        {
                            throw new COMException(string.Empty, E_FAIL);
                        }
                    }
                }
            }
        }
        public override IDTSInputColumn100 SetUsageType(int inputID, IDTSVirtualInput100 virtualInput, int lineageID, DTSUsageType usageType)
        {
            IDTSInputColumn100            inputColumn            = null;
            IDTSOutput100                 output                 = this.ComponentMetaData.OutputCollection[0];
            IDTSOutputColumnCollection100 outputColumnCollection = output.OutputColumnCollection;
            IDTSInput100 input = this.ComponentMetaData.InputCollection[0];
            IDTSInputColumnCollection100 inputColumnCollection = input.InputColumnCollection;

            if (usageType == DTSUsageType.UT_IGNORED)
            {
                inputColumn = inputColumnCollection.GetInputColumnByLineageID(lineageID);

                IDTSOutputColumn100 outputColumn = outputColumnCollection.FindObjectByID(inputColumn.MappedColumnID);
                if (outputColumn != null)
                {
                    outputColumnCollection.RemoveObjectByID(outputColumn.ID);
                }

                inputColumn = base.SetUsageType(inputID, virtualInput, lineageID, usageType);
            }
            else
            {
                inputColumn = base.SetUsageType(inputID, virtualInput, lineageID, usageType);

                IDTSOutputColumn100 outputColumn = outputColumnCollection.New();
                outputColumn.Name = inputColumn.Name;
                outputColumn.SetDataTypeProperties(inputColumn.DataType, inputColumn.Length, inputColumn.Precision, inputColumn.Scale, inputColumn.CodePage);
                outputColumn.MappedColumnID = inputColumn.LineageID;
                inputColumn.MappedColumnID  = outputColumn.LineageID;
                AddInputColumnProperty(inputColumn, GeoColumnPropName, "True if the column holds geometry objects to be joined together.", false);
                AddInputColumnProperty(inputColumn, GroupByColumnPropName, "True if the column holds group by values.", false);
            }

            return(inputColumn);
        }
Beispiel #4
0
        /// <summary>
        /// Constructs an output column and adds it to the provided output, using the column metadata from the provided BSON element.
        /// </summary>
        /// <param name="output"></param>
        /// <param name="bsonElement"></param>
        /// <returns></returns>
        private IDTSOutputColumn100 BuildOutputColumn(IDTSOutput100 output, BsonElement bsonElement)
        {
            IDTSOutputColumn100 outColumn = output.OutputColumnCollection.New();

            // Set the properties of the output column.
            outColumn.Name = bsonElement.Name;

            DataType dt       = GetColumnDataType(bsonElement.Value);
            int      length   = 0;
            int      codepage = 0;

            if (dt == DataType.DT_STR)
            {
                length   = 256;
                codepage = 1252;
            }

            outColumn.SetDataTypeProperties(dt, length, 0, 0, codepage);

            // Setting these values enables the end-user to configure the error behavior on a per-column basis
            if (!output.IsErrorOut)
            {
                outColumn.ErrorRowDisposition      = DTSRowDisposition.RD_FailComponent;
                outColumn.TruncationRowDisposition = DTSRowDisposition.RD_FailComponent;
            }

            return(outColumn);
        }
Beispiel #5
0
        public IDTSOutputColumn100 ModifyComp_DerivedCol_AddCol(IDTSComponentMetaData100 Comp,
                                                                string DCName,
                                                                string DCExpression,
                                                                DataType DTDataType,
                                                                int DCDTLength    = 0,
                                                                int DCDTPrecision = 0,
                                                                int DCDTScale     = 0,
                                                                int DCDTCodePage  = 0
                                                                )
        {
            IDTSOutputColumn100 Col = Comp.OutputCollection[0].OutputColumnCollection.New();

            Col.Name = DCName;
            Col.SetDataTypeProperties(DTDataType, DCDTLength, DCDTPrecision, DCDTScale, DCDTCodePage);
            Col.ExternalMetadataColumnID = 0;
            Col.ErrorRowDisposition      = DTSRowDisposition.RD_FailComponent;
            Col.TruncationRowDisposition = DTSRowDisposition.RD_FailComponent;

            IDTSCustomProperty100 propExp = Col.CustomPropertyCollection.New();

            propExp.Name  = "Expression";
            propExp.Value = DCExpression;

            IDTSCustomProperty100 propFrExp = Col.CustomPropertyCollection.New();

            propFrExp.Name  = "FriendlyExpression";
            propFrExp.Value = DCExpression;

            return(Col);
        }
Beispiel #6
0
        /// <summary>
        /// The add xml column.
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        private void AddXmlColumn(IDTSOutput100 output)
        {
            IDTSOutputColumn100 column = output.OutputColumnCollection.New();

            column.Name = "Xml";
            column.SetDataTypeProperties(DataType.DT_NTEXT, 0, 0, 0, 0);
        }
        public void TestOutputColumn_Timecode_Missing()
        {
            Microsoft.SqlServer.Dts.Runtime.Package package = new Microsoft.SqlServer.Dts.Runtime.Package();
            Executable exec = package.Executables.Add("STOCK:PipelineTask");

            Microsoft.SqlServer.Dts.Runtime.TaskHost thMainPipe = exec as Microsoft.SqlServer.Dts.Runtime.TaskHost;
            MainPipe dataFlowTask        = thMainPipe.InnerObject as MainPipe;
            ComponentEventHandler events = new ComponentEventHandler();

            dataFlowTask.Events = DtsConvert.GetExtendedInterface(events as IDTSComponentEvents);

            IDTSComponentMetaData100 speechToText = dataFlowTask.ComponentMetaDataCollection.New();

            speechToText.ComponentClassID = typeof(Martin.SQLServer.Dts.SSISSpeechToText).AssemblyQualifiedName;
            CManagedComponentWrapper speechToTextInstance = speechToText.Instantiate();

            speechToTextInstance.ProvideComponentProperties();
            speechToText.CustomPropertyCollection[Utility.SubscriptionKeyPropName].Value = "NotTheDefault";
            // Before this is default setup for a clean component

            speechToText.OutputCollection[0].OutputColumnCollection.RemoveObjectByID(speechToText.OutputCollection[0].OutputColumnCollection[Utility.OutputTimecodeColumnName].ID);
            IDTSOutputColumn100 tempCol = speechToText.OutputCollection[0].OutputColumnCollection.New();

            tempCol.Name = "TempCol";
            tempCol.SetDataTypeProperties(DataType.DT_STR, 10, 0, 0, 1252);
            DTSValidationStatus actual   = speechToTextInstance.Validate();
            DTSValidationStatus expected = DTSValidationStatus.VS_ISCORRUPT;

            Assert.AreEqual(expected, actual);
            Assert.AreEqual("[Error] SSIS Speech To Text: Required Output Column Timecode is missing.", events.errorMessages[0]);
        }
Beispiel #8
0
        //Methode de récupération d'une ligne de la Table Azure puis de création de colonnes SSIS Typées
        public void InitializeOutput()
        {
            //Suppression des colonnes existantes pour rechargement
            ComponentMetaData.OutputCollection[0].OutputColumnCollection.RemoveAll();
            //Récupération de la chaine de connexion au stockage blob Azure
            string storageConnectionString = (string)this.ComponentMetaData.CustomPropertyCollection["StorageConnectionString"].Value;

            string tableName = (string)this.ComponentMetaData.CustomPropertyCollection["TableName"].Value;

            //Connexion au stockage
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudTableClient    tableClient         = cloudStorageAccount.CreateCloudTableClient();
            CloudTable          table = tableClient.GetTableReference(tableName);
            //Récupération de la première ligne
            TableQuery <DynamicTableEntity> query = new TableQuery <DynamicTableEntity>();

            query.TakeCount = 1;
            var row = table.ExecuteQuery(query).FirstOrDefault();

            if (row != null)
            {
                var properties = row.Properties;

                foreach (var prop in properties)
                {
                    //Création d'une colonne dans le composant source
                    IDTSOutputColumn100 newOutputCol = ComponentMetaData.OutputCollection[0].OutputColumnCollection.New();
                    //Le nom de la colonne est identique à la source
                    newOutputCol.Name = prop.Key;
                    //Le Type de données de la colonne est convertie en type SSIS puis attribué à la colonne du composant SSIS
                    newOutputCol.SetDataTypeProperties(this.GetSsisType(prop.Value).Key, this.GetSsisType(prop.Value).Value, 0, 0, 0);
                }
            }
        }
        /// <summary>
        /// Initalizes a new instance of the RowHashTransformation.
        /// </summary>
        public override void ProvideComponentProperties()
        {
            base.ProvideComponentProperties();

            // Name the input.
            IDTSInput100 input = ComponentMetaData.InputCollection[0];

            input.Name = INPUT_NAME;

            // Create one synchronized output, and marks it as a built-in output, which cannot be removed.
            IDTSCustomProperty100 isInternal;
            IDTSOutput100         output = ComponentMetaData.OutputCollection[0];

            output.Name = OUTPUT_NAME;
            output.SynchronousInputID = ComponentMetaData.InputCollection[INPUT_NAME].ID;
            isInternal               = output.CustomPropertyCollection.New();
            isInternal.Name          = IS_INTERNAL_CUSTOM_PROPERTY_NAME;
            isInternal.State         = DTSPersistState.PS_PERSISTASDEFAULT;
            isInternal.TypeConverter = typeof(Boolean).AssemblyQualifiedName;
            isInternal.Value         = true;

            // Create the output column to hold the hash value, and marks it as a built-in output column, which cannot be removed.
            IDTSOutputColumn100 rowHashColumn = output.OutputColumnCollection.New();

            rowHashColumn.Name = ROW_HASH_COLUMN_NAME;
            // The size of a SHA1 hash value is 20 bytes.
            rowHashColumn.SetDataTypeProperties(DataType.DT_BYTES, 20, 0, 0, 0);
            isInternal               = rowHashColumn.CustomPropertyCollection.New();
            isInternal.Name          = IS_INTERNAL_CUSTOM_PROPERTY_NAME;
            isInternal.State         = DTSPersistState.PS_PERSISTASDEFAULT;
            isInternal.TypeConverter = typeof(Boolean).AssemblyQualifiedName;
            isInternal.Value         = true;
        }
Beispiel #10
0
        /// <summary>
        /// Add the columns required to the Error Output.
        /// </summary>
        /// <param name="errorOutput">The actual error output</param>
        public static void AddErrorOutputColumns(IDTSOutput100 errorOutput)
        {
            IDTSOutputColumnCollection100 outputColumnCollection = errorOutput.OutputColumnCollection;
            IDTSOutputColumn100           outputColumn           = outputColumnCollection.New();

            outputColumn.Name = MessageStrings.ErrorMessageColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0);
            ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection);
            outputColumn      = outputColumnCollection.New();
            outputColumn.Name = MessageStrings.ColumnDataColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0);
            ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection);
            outputColumn      = outputColumnCollection.New();
            outputColumn.Name = MessageStrings.RowDataColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0);
            ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection);
        }
Beispiel #11
0
        public override void ProvideComponentProperties()
        {
            base.ProvideComponentProperties();

            // Data Profile File Name
            IDTSCustomProperty100 dataProfileFileName = ComponentMetaData.CustomPropertyCollection.New();

            dataProfileFileName.Name          = DATA_PROFILE_FILE_NAME_PROPERTY_NAME;
            dataProfileFileName.Description   = DATA_PROFILE_FILE_NAME_PROPERTY_DESCRIPTION;
            dataProfileFileName.State         = DTSPersistState.PS_PERSISTASCDATA;
            dataProfileFileName.TypeConverter = typeof(String).AssemblyQualifiedName;
            dataProfileFileName.Value         = String.Empty;

            // Data Profile Column Name
            IDTSCustomProperty100 dataProfileColumnName = ComponentMetaData.CustomPropertyCollection.New();

            dataProfileColumnName.Name          = DATA_PROFILE_COLUMN_NAME_PROPERTY_NAME;
            dataProfileColumnName.Description   = DATA_PROFILE_COLUMN_NAME_PROPERTY_DESCRIPTION;
            dataProfileColumnName.State         = DTSPersistState.PS_DEFAULT;
            dataProfileColumnName.TypeConverter = typeof(String).AssemblyQualifiedName;
            dataProfileColumnName.Value         = String.Empty;

            // Input
            IDTSInput100 input = ComponentMetaData.InputCollection[0];

            input.Name = INPUT_NAME;
            // Input Column Name
            IDTSCustomProperty100 inputColumnName = input.CustomPropertyCollection.New();

            inputColumnName.Name          = INPUT_COLUMN_NAME;
            inputColumnName.Description   = INPUT_COLUMN_DESCRIPTION;
            inputColumnName.State         = DTSPersistState.PS_DEFAULT;
            inputColumnName.TypeConverter = typeof(String).AssemblyQualifiedName;
            inputColumnName.Value         = String.Empty;

            IDTSCustomProperty100 isInternal;
            // Synchronous Output
            IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

            output.Name = OUTPUT_NAME;
            output.SynchronousInputID = ComponentMetaData.InputCollection[0].ID;
            isInternal               = output.CustomPropertyCollection.New();
            isInternal.Name          = IS_INTERNAL_OBJECT_PROPERTY_NAME;
            isInternal.State         = DTSPersistState.PS_DEFAULT;
            isInternal.TypeConverter = typeof(Boolean).AssemblyQualifiedName;
            isInternal.Value         = true;
            // Output column
            IDTSOutputColumn100 isVaildEmailColumn = output.OutputColumnCollection.New();

            isVaildEmailColumn.Name        = IS_VALID_COLUMN_NAME;
            isVaildEmailColumn.Description = IS_VALID_COLUMN_DESCRIPTION;
            isVaildEmailColumn.SetDataTypeProperties(DataType.DT_BOOL, 0, 0, 0, 0);
            isInternal               = isVaildEmailColumn.CustomPropertyCollection.New();
            isInternal.Name          = IS_INTERNAL_OBJECT_PROPERTY_NAME;
            isInternal.State         = DTSPersistState.PS_DEFAULT;
            isInternal.TypeConverter = typeof(Boolean).AssemblyQualifiedName;
            isInternal.Value         = true;
        }
        public override void SetOutputColumnDataTypeProperties(int iOutputID, int iOutputColumnID, DataType eDataType, int iLength, int iPrecision, int iScale, int iCodePage)
        {
            IDTSOutputCollection100       outputColl = ComponentMetaData.OutputCollection;
            IDTSOutput100                 output     = outputColl.GetObjectByID(iOutputID);
            IDTSOutputColumnCollection100 columnColl = output.OutputColumnCollection;
            IDTSOutputColumn100           column     = columnColl.GetObjectByID(iOutputColumnID);

            column.SetDataTypeProperties(eDataType, iLength, iPrecision, iScale, iCodePage);
        }
        public override void ProvideComponentProperties()
        {
            IDTSOutput100 output = ComponentMetaData.OutputCollection.New();

            output.Name = "BLOB File Inserter Output";

            IDTSOutputColumn100 column = output.OutputColumnCollection.New();

            column.Name = "FileName";
            column.SetDataTypeProperties(DataType.DT_WSTR, 256, 0, 0, 0);

            column      = output.OutputColumnCollection.New();
            column.Name = "FileBLOB";
            column.SetDataTypeProperties(DataType.DT_IMAGE, 0, 0, 0, 0);

            IDTSRuntimeConnection100 conn = ComponentMetaData.RuntimeConnectionCollection.New();

            conn.Name = "FileConnection";
        }
Beispiel #14
0
        private void AddOutputColumns(IEnumerable <IOMapEntry> IoMap)
        {
            _md.OutputCollection[0].OutputColumnCollection.RemoveAll();

            var input = _md.InputCollection[0];

            // Aggiungi tante colonne di output quante sono le colonne di input
            foreach (IDTSInputColumn100 i in input.InputColumnCollection)
            {
                IDTSOutputColumn100 col = _md.OutputCollection[0].OutputColumnCollection.New();
                col.Name = i.Name;
                col.SetDataTypeProperties(i.DataType, i.Length, i.Precision, i.Scale, i.CodePage);
            }

            // Aggiungi le colonne di output derivanti dall'interpretazione di JSON
            foreach (IOMapEntry e in IoMap)
            {
                if (e.InputFieldLen < 0)
                {
                    // FIXME TODO
                    _md.FireWarning(0, _md.Name, "A row of the IO configuration presents a negative value, which is forbidden.", null, 0);
                }

                // Creo la nuova colonna descritta dalla riga e la configuro in base ai dettagli specificati
                IDTSOutputColumn100 col = _md.OutputCollection[0].OutputColumnCollection.New();
                col.Name = e.OutputColName;

                // There might be some possible errors regarding data lenght. We try to correct them here.
                // If length > 4000 and type is string, put TEXT datatype.
                if (e.OutputColumnType == Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_WSTR && (e.InputFieldLen > 4000 || e.InputFieldLen == 0))
                {
                    // FIXME TODO: this must be done directly within the UI
                    // e.OutputColumnType = Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_TEXT;
                    _md.FireWarning(0, _md.Name, string.Format("Column {0} is supposed to be longer than 4000 chars, so DT_WSTR is not a suitable column type. Instead, DT_TEXT has been selected.", e.OutputColName), null, 0);
                    // TODO: parametrize the codepage
                    col.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_TEXT, 0, 0, 0, 1252);
                }
                else
                {
                    col.SetDataTypeProperties(e.OutputColumnType, e.InputFieldLen, 0, 0, 0);
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// Adds the columns that are required to the Number Of Rows output
        /// </summary>
        /// <param name="numberOfRows">the number of rows output</param>
        public static void AddNumberOfRowsOutputColumns(IDTSOutput100 numberOfRows)
        {
            IDTSOutputColumnCollection100 outputColumnCollection = numberOfRows.OutputColumnCollection;
            IDTSOutputColumn100           outputColumn           = outputColumnCollection.New();

            outputColumn.Name = MessageStrings.KeyValueColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_STR, DefaultStringColumnSize, 0, 0, 1252);
            outputColumn.Description = MessageStrings.KeyValueColumnDescription;
            ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection);
            outputColumn      = outputColumnCollection.New();
            outputColumn.Name = MessageStrings.NumberOfRowsColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_I8, 0, 0, 0, 0);
            outputColumn.Description = MessageStrings.NumberOfRowsColumnDescription;
            ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection);
            outputColumn      = outputColumnCollection.New();
            outputColumn.Name = MessageStrings.KeyValueStatusColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_STR, DefaultStringColumnSize, 0, 0, 1252);
            outputColumn.Description = MessageStrings.KeyValueStatusColumnDescription;
            ManageProperties.AddIgnorableColumnProperties(outputColumn.CustomPropertyCollection);
        }
        private void PropagateInputColumns(Dictionary <string, MyColumn> exColumns)
        {
            IDTSComponentMetaData100 comp  = this.MetadataCollection;
            CManagedComponentWrapper dcomp = comp.Instantiate();

            IDTSInput100        input  = comp.InputCollection[0];
            IDTSVirtualInput100 vInput = input.GetVirtualInput();
            IDTSVirtualInputColumnCollection100 vColumns = vInput.VirtualInputColumnCollection;

            IDTSOutput100 output = comp.OutputCollection[0];

            output.TruncationRowDisposition = DTSRowDisposition.RD_NotUsed;
            output.ErrorRowDisposition      = DTSRowDisposition.RD_NotUsed;

            //create input columns for destination external
            foreach (KeyValuePair <string, MyColumn> exColumn in exColumns)
            {
                int vColumnID = FindVirtualInputColumnId(vColumns, exColumn.Key);
                if (vColumnID != 0)
                {
                    //do type conversion
                    IDTSVirtualInputColumn100 vColumn = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(vColumnID);
                    if (vColumn.DataType != exColumn.Value.DataType)
                    {
                        dcomp.SetUsageType(input.ID, vInput, vColumnID, DTSUsageType.UT_READONLY);

                        IDTSOutputColumn100 oColumn = output.OutputColumnCollection.New();
                        oColumn.Name = exColumn.Key;
                        oColumn.SetDataTypeProperties(exColumn.Value.DataType, exColumn.Value.Length, exColumn.Value.Precision, exColumn.Value.Scale, exColumn.Value.CodePage);
                        oColumn.ExternalMetadataColumnID = 0;
                        oColumn.ErrorRowDisposition      = DTSRowDisposition.RD_FailComponent;
                        oColumn.TruncationRowDisposition = DTSRowDisposition.RD_FailComponent;
                        IDTSCustomProperty100 property = oColumn.CustomPropertyCollection.New();
                        property.Name  = "SourceInputColumnLineageID";
                        property.Value = vColumnID;
                        property       = oColumn.CustomPropertyCollection.New();
                        property.Name  = "FastParse";
                        property.Value = false;
                        //set of derived columns
                        m_converted.Add(oColumn.Name.ToLower(), oColumn.LineageID);
                    }
                    else
                    {
                        m_converted.Add(exColumn.Key.ToLower(), vColumnID);
                    }
                }
                else
                {
                    //the column wasn't found if the Id is 0, so we'll print out a message and skip this row.
                    //PrintOutput.PrintToOutput("Converter: Could not map external column " + exColumn.Key + ". Skipping column.");
                }
            }
        }
Beispiel #17
0
        private void AddHashColumn()
        {
            IDTSOutputColumn100 column = base.ComponentMetaData.OutputCollection[0].OutputColumnCollection.New();

            column.Name = "Hash";
            column.SetDataTypeProperties(DataType.DT_STR, 40, 0, 0, 1252);
            IDTSCustomProperty100 property = column.CustomPropertyCollection.New();

            property.Name        = "Hash";
            property.Description = "Hash SHA1 transformation result column indicator.";
            property.Value       = "Hash";
        }
        public override void SetOutputColumnDataTypeProperties(int outputID, int outputColumnID, Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType dataType, int length, int precision, int scale, int codePage)

        {
            IDTSOutputCollection100 outputColl = this.ComponentMetaData.OutputCollection;

            IDTSOutput100 output = outputColl.GetObjectByID(outputID);

            IDTSOutputColumnCollection100 columnColl = output.OutputColumnCollection;

            IDTSOutputColumn100 column = columnColl.GetObjectByID(outputColumnID);

            column.SetDataTypeProperties(dataType, length, precision, scale, codePage);
        }
        /// <summary>
        /// Sets up all the base properties for the component to utilise
        /// </summary>
        public override void ProvideComponentProperties()
        {
            // Support resettability.
            this.RemoveAllInputsOutputsAndCustomProperties();
            // Let the base component add the input and output.
            base.ProvideComponentProperties();
            // Add Contact information etc.
            ComponentMetaData.ContactInfo = "https://github.com/keif888/SSISSpeechToText/";

            // Add all the required properties.
            SSISSpeechToText.AddSubscriptionKeyProperty(this.ComponentMetaData);
            SSISSpeechToText.AddOperationModeProperty(this.ComponentMetaData);
            SSISSpeechToText.AddLanguageProperty(this.ComponentMetaData);
            SSISSpeechToText.AddChannelSeparationProperty(this.ComponentMetaData);
            SSISSpeechToText.AddShortPhraseUrlProperty(this.ComponentMetaData);
            SSISSpeechToText.AddLongPhraseUrlProperty(this.ComponentMetaData);

            // Name the input and output, and make the output asynchronous.
            ComponentMetaData.InputCollection[0].Name = "Input";

            IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

            output.Name               = "SpeechOutput";
            output.Description        = "Speech analysis rows are directed to this output.";
            output.SynchronousInputID = 0;


            // Add the output channel column
            IDTSOutputColumn100 outputChannelColumn = output.OutputColumnCollection.New();

            outputChannelColumn.Name        = Utility.OutputChannelColumnName;
            outputChannelColumn.Description = "Contains which channel this speech came from";
            outputChannelColumn.SetDataTypeProperties(DataType.DT_STR, 30, 0, 0, 1252);
            AddOutputTypeProperty(outputChannelColumn, OutputTypeEnum.Channel);

            // Add the output speech column
            IDTSOutputColumn100 outputSpeechColumn = output.OutputColumnCollection.New();

            outputSpeechColumn.Name        = Utility.OutputSpeechColumnName;
            outputSpeechColumn.Description = "Contains which channel this speech came from";
            outputSpeechColumn.SetDataTypeProperties(DataType.DT_TEXT, 0, 0, 0, 1252);
            AddOutputTypeProperty(outputSpeechColumn, OutputTypeEnum.Speech);

            //Add the output timecodes column
            IDTSOutputColumn100 outputTimecodesColumn = output.OutputColumnCollection.New();

            outputTimecodesColumn.Name        = Utility.OutputTimecodeColumnName;
            outputTimecodesColumn.Description = "Contains the time that this fragment of speech started at";
            outputTimecodesColumn.SetDataTypeProperties(DataType.DT_DBTIME2, 0, 0, 7, 0);
            AddOutputTypeProperty(outputTimecodesColumn, OutputTypeEnum.Timecode);
        }
Beispiel #20
0
        protected override void ProcessBindingMappings(SsisEmitterContext context, MappedBinding mappedBinding, IDTSPath100 path)
        {
            if (mappedBinding != null && path != null)
            {
                foreach (AstDataflowColumnMappingNode map in mappedBinding.Mappings)
                {
                    int lineageId;
                    var matchedOutput = TransformationUtility.FindOutputColumnByName(map.SourceName, path.StartPoint, true);

                    if (matchedOutput == null)
                    {
                        var matchedInput = TransformationUtility.FindVirtualInputColumnByName(map.SourceName, path.EndPoint, true);
                        if (matchedInput == null)
                        {
                            MessageEngine.Trace(_astUnionAllNode, Severity.Error, "V0145", "Could not find input column {0} for transformation {1}", map.SourceName, _astUnionAllNode.Name);
                        }

                        lineageId = matchedInput.LineageID;
                    }
                    else
                    {
                        lineageId = matchedOutput.LineageID;
                    }

                    IDTSInputColumn100 ic = TransformationUtility.FindInputColumnByName(map.SourceName, path.EndPoint, true);
                    if (ic == null)
                    {
                        ic           = path.EndPoint.InputColumnCollection.New();
                        ic.Name      = map.SourceName;
                        ic.LineageID = lineageId;
                    }

                    IDTSOutputColumn100 oc = TransformationUtility.FindOutputColumnByName(map.TargetName, OutputPath, true);
                    if (oc == null)
                    {
                        oc      = OutputPath.OutputColumnCollection.New();
                        oc.Name = map.TargetName;
                        oc.SetDataTypeProperties(ic.DataType, ic.Length, ic.Precision, ic.Scale, ic.CodePage);
                    }

                    IDTSCustomProperty100 cp = TransformationUtility.FindCustomPropertyByName("OutputColumnLineageID", ic.CustomPropertyCollection, true);
                    if (cp == null)
                    {
                        cp      = ic.CustomPropertyCollection.New();
                        cp.Name = "OutputColumnLineageID";
                    }

                    cp.Value = oc.LineageID;
                }
            }
        }
Beispiel #21
0
        public override void OnInputPathAttached(int inputID)
        {
            IDTSOutput100       defaultOutput = ComponentMetaData.OutputCollection[0];
            IDTSInput100        input         = ComponentMetaData.InputCollection.GetObjectByID(inputID);
            IDTSVirtualInput100 vInput        = input.GetVirtualInput();

            foreach (IDTSVirtualInputColumn100 vCol in vInput.VirtualInputColumnCollection)
            {
                IDTSOutputColumn100 outCol = defaultOutput.OutputColumnCollection.New();
                outCol.Name = input.Name + "." + vCol.Name;
                outCol.SetDataTypeProperties(vCol.DataType, vCol.Length, vCol.Precision, vCol.Scale, vCol.CodePage);
                SetUsageType(inputID, vInput, vCol.LineageID, DTSUsageType.UT_READONLY);
            }
        }
Beispiel #22
0
        public static IDTSOutputColumn100 AddKeyOutputColumns(IDTSOutput100 keyRecords)
        {
            IDTSOutputColumnCollection100 outputColumnCollection = keyRecords.OutputColumnCollection;
            IDTSOutputColumn100           outputColumn           = outputColumnCollection.NewAt(0);

            outputColumn.Name = MessageStrings.KeyRecordKeyColumnName;
            outputColumn.SetDataTypeProperties(DataType.DT_GUID, 0, 0, 0, 0);
            outputColumn.Description = MessageStrings.KeyRecordKeyColumnDescription;
            ManageProperties.AddOutputColumnProperties(outputColumn.CustomPropertyCollection);
            ManageProperties.SetPropertyValue(outputColumn.CustomPropertyCollection, ManageProperties.usageOfColumn, Utilities.usageOfColumnEnum.Key);
            ManageProperties.SetPropertyValue(outputColumn.CustomPropertyCollection, ManageProperties.keyOutputColumnID, -2);

            return(outputColumn);
        }
Beispiel #23
0
        public static IDTSOutputColumn100 AddKeyOutputColumns(IDTSOutput100 keyRecords, IDTSOutput100 errorOutput)
        {
            IDTSOutputColumn100 outputColumn = AddKeyOutputColumns(keyRecords);

            IDTSOutputColumn100 errorOutputColumn = errorOutput.OutputColumnCollection.New();

            errorOutputColumn.Name = MessageStrings.KeyRecordKeyColumnName;
            errorOutputColumn.SetDataTypeProperties(DataType.DT_GUID, 0, 0, 0, 0);
            errorOutputColumn.Description = MessageStrings.KeyRecordKeyColumnDescription;
            ManageProperties.AddOutputColumnProperties(errorOutputColumn.CustomPropertyCollection);
            ManageProperties.SetPropertyValue(errorOutputColumn.CustomPropertyCollection, ManageProperties.usageOfColumn, Utilities.usageOfColumnEnum.Key);
            ManageProperties.SetPropertyValue(errorOutputColumn.CustomPropertyCollection, ManageProperties.keyOutputColumnID, outputColumn.ID);

            return(outputColumn);
        }
Beispiel #24
0
        private void CreateOutputColumns(ref IDTSOutput100 output)
        {
            // Check sum column (internal, and cannot be removed).
            IDTSOutputColumn100 _hashValueColumn = output.OutputColumnCollection.New();

            _hashValueColumn.SetDataTypeProperties(DataType.DT_STR, 128, 0, 0, 1252);
            _hashValueColumn.Name        = _checkSumColumnName;
            _hashValueColumn.Description = _checkSumColumnDescription;
            IDTSCustomProperty100 isInternal = _hashValueColumn.CustomPropertyCollection.New();

            isInternal.Name          = _isInternalPropertyName;
            isInternal.Description   = _isInternalPropertyDescription;
            isInternal.Value         = true;
            isInternal.TypeConverter = typeof(Boolean).AssemblyQualifiedName;
        }
        protected void SetColumnDataType(IDTSOutputColumn100 column, string dataType, decimal length)
        {
            switch (dataType)
            {
            case "Char":
                column.SetDataTypeProperties(DataType.DT_WSTR, (int)length, 0, 0, 0);
                break;

            case "Integer":
                column.SetDataTypeProperties(DataType.DT_I4, 0, 0, 0, 0);
                break;

            case "Decimal":
                column.SetDataTypeProperties(DataType.DT_DECIMAL, 0, 0, 0, 0);
                break;

            case "Date":
                column.SetDataTypeProperties(DataType.DT_DATE, 0, 0, 0, 0);
                break;

            default:
                throw new NotImplementedException();
            }
        }
        private void CreateIdColumn()
        {
            // TODO: Add an option to make this a DT_GUID instead of a string
            IDTSOutputColumn100   outColumn            = ComponentMetaData.OutputCollection[0].OutputColumnCollection.New();
            IDTSCustomProperty100 dataSourceColumnName = outColumn.CustomPropertyCollection.New();

            dataSourceColumnName.Name        = @"EntityPropertyName";
            dataSourceColumnName.Value       = DefaultIdColumnName;
            dataSourceColumnName.Description = @"The name of the property.";

            outColumn.Name = DefaultIdColumnName;
            outColumn.SetDataTypeProperties(DataType.DT_WSTR, 256, 0, 0, 0);

            CreateExternalMetaDataColumn(ComponentMetaData.OutputCollection[0].ExternalMetadataColumnCollection, outColumn);
        }
Beispiel #27
0
            public void AddOutputColumns(List <CustomDataColumn> columnsList)
            {
                foreach (CustomDataColumn column in columnsList)
                {
                    Debug.WriteLine(column.Name + " - " + column.Type + " - " + column.Length);

                    IDTSOutputColumn100 outputCol = ComponentMetaData.OutputCollection[0].OutputColumnCollection.New();

                    bool     isLong    = false;
                    int      length    = 0;
                    int      precision = 0;
                    int      scale     = 0;
                    DataType dType;
                    int      codePage = 1250;

                    switch (column.Type)
                    {
                    case "I4":
                        dType     = DataType.DT_I4;
                        length    = 0;
                        precision = 0;
                        scale     = 0;
                        codePage  = 0;
                        break;

                    case "WSTR":
                        dType     = DataType.DT_WSTR;
                        length    = int.Parse(column.Length);
                        precision = 0;
                        scale     = 0;
                        codePage  = 0;
                        break;

                    case "DBTIMESTAMP":
                        dType     = DataType.DT_DBTIMESTAMP;
                        length    = 0;
                        precision = 0;
                        codePage  = 0;
                        break;

                    default:
                        throw new NotImplementedException("Error, " + column.Type + " is not implemented");
                    }

                    outputCol.Name = column.Name;
                    outputCol.SetDataTypeProperties(dType, length, precision, scale, codePage);
                }
            }
        //=================================================================================================

        public override void ReinitializeMetaData()
        {
            // baseclass may have some work to do here
            base.ReinitializeMetaData();

            IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

            output.OutputColumnCollection.RemoveAll();
            output.ExternalMetadataColumnCollection.RemoveAll();

            // Execute the WQL query and retrieve metadata
            foreach (PropertyData wmiColumn in GetWmiColumns())
            {
                DataType dtsType;
                int      length;
                int      scale;
                int      precision;
                int      codePage;

                GetWmiColumnProperties(wmiColumn, out dtsType, out length, out scale, out precision, out codePage);

                string Description = (string)GetQualifiers(wmiColumn, "Description", "");

                // create a new column
                IDTSOutputColumn100 outputcolNew = output.OutputColumnCollection.New();

                if (string.IsNullOrEmpty(wmiColumn.Name))
                {
                    bool bCancel;
                    ErrorSupport.FireError(HResults.DTS_E_DATASOURCECOLUMNWITHNONAMEFOUND, out bCancel);
                    throw new PipelineComponentHResultException(HResults.DTS_E_DATASOURCECOLUMNWITHNONAMEFOUND);
                }

                outputcolNew.Name = wmiColumn.Name;
                outputcolNew.SetDataTypeProperties(dtsType, length, precision, scale, codePage);
                outputcolNew.Description = Description;

                CreateExternalMetaDataColumn(output.ExternalMetadataColumnCollection, outputcolNew);
            }

            // Exclusion Group
            output.ExclusionGroup = 0;
            // Synchronous Input
            output.SynchronousInputID = 0;
        }
        private void CreateColumns()
        {
            IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

            output.OutputColumnCollection.RemoveAll();
            output.ExternalMetadataColumnCollection.RemoveAll();

            IDTSOutputColumn100           column1   = output.OutputColumnCollection.New();
            IDTSExternalMetadataColumn100 exColumn1 = output.ExternalMetadataColumnCollection.New();

            IDTSOutputColumn100           column2   = output.OutputColumnCollection.New();
            IDTSExternalMetadataColumn100 exColumn2 = output.ExternalMetadataColumnCollection.New();

            column1.Name = "MessageContents";
            column1.SetDataTypeProperties(DataType.DT_WSTR, 4000, 0, 0, 0);

            column2.Name = "RoutingKey";
            column2.SetDataTypeProperties(DataType.DT_WSTR, 100, 0, 0, 0);
        }
Beispiel #30
0
        private static void GenerateOutputColumn(IDTSOutput100 output, IDTSInputColumn100 inputcolumn, OutputColumn outputColumn)
        {
            bool IsExist = false;

            foreach (IDTSOutputColumn100 OutputColumn in output.OutputColumnCollection)
            {
                if (OutputColumn.Name == outputColumn.ColumnName)
                {
                    IsExist = true;
                }
            }

            if (!IsExist)
            {
                IDTSOutputColumn100 outputcol = output.OutputColumnCollection.New();
                outputcol.Name        = outputColumn.ColumnName;
                outputcol.Description = $"PhoneLib call to {outputColumn.Name}";
                outputcol.SetDataTypeProperties(outputColumn.DataType, outputColumn.DataTypeLength, 0, 0, 0);
            }
        }
        protected void SetColumnDataType(IDTSOutputColumn100 column, string dataType, decimal length)
        {
            switch (dataType)
            {
                case "Char":
                    column.SetDataTypeProperties(DataType.DT_WSTR, (int)length, 0, 0, 0);
                    break;
                case "Integer":
                    column.SetDataTypeProperties(DataType.DT_I4, 0, 0, 0, 0);
                    break;
                case "Decimal":
                    column.SetDataTypeProperties(DataType.DT_DECIMAL, 0, 0, 0, 0);
                    break;
                case "Date":
                    column.SetDataTypeProperties(DataType.DT_DATE, 0, 0, 0, 0);
                    break;

                default:
                    throw new NotImplementedException();
            }
        }