Ejemplo n.º 1
0
        /// <summary>
        /// Sets a custom property to an output column; adds it if the property does not exist.
        /// For internal use within this library. Not for use from outside libraries
        /// </summary>
        /// <param name="output"></param>
        /// <param name="outputColumn"></param>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        /// <param name="containsId"></param>
        /// <returns></returns>
        internal IDTSCustomProperty100 SetCustomPropertyToOutputColumn(IDTSOutput100 output, IDTSOutputColumn100 outputColumn, string propertyName, object propertyValue, bool containsId = false)
        {
            bool propertyExists = false;
            IDTSCustomProperty100 customProperty = null;

            for (int i = 0; i < outputColumn.CustomPropertyCollection.Count; i++)
            {
                if (outputColumn.CustomPropertyCollection[i].Name == propertyName)
                {
                    propertyExists = true;
                    break;
                }
            }
            if (propertyExists)
            {
                customProperty            = DesignTimeComponent.SetOutputColumnProperty(output.ID, outputColumn.ID, propertyName, propertyValue);
                customProperty.ContainsID = containsId;
            }
            else
            {
                customProperty            = outputColumn.CustomPropertyCollection.New();
                customProperty.Name       = propertyName;
                customProperty.Value      = propertyValue;
                customProperty.ContainsID = containsId;
            }

            return(customProperty);
        }
Ejemplo n.º 2
0
        public void ManualMapToTargetColumns()
        {
            if (ExternalColumnInputColumnMap.Count > 0)
            {
                string[] viCols = new string[Input.Input.GetVirtualInput().VirtualInputColumnCollection.Count];
                for (int i = 0; i < viCols.Length; i++)
                {
                    viCols.SetValue(Input.Input.GetVirtualInput().VirtualInputColumnCollection[i].Name, i);
                }

                foreach (ExternalColumnInputMap map in ExternalColumnInputColumnMap)
                {
                    if (String.IsNullOrEmpty(map.InputColumnName))
                    {
                    }
                    else
                    {
                        ISExternalMetadataColumn extCol = new ISExternalMetadataColumn(this, DtsInput.Name, map.ExternalColumn.ExternalColumnName, true);
                        for (int vi = 0; vi < viCols.Length; vi++)
                        {
                            if (string.Equals(viCols[vi], map.InputColumnName, StringComparison.CurrentCultureIgnoreCase))
                            {
                                ISInputColumn ic = new ISInputColumn(this, DtsInput.Name, viCols[vi], UsageType.UT_READONLY);
                                DesignTimeComponent.MapInputColumn(DtsInput.ID, ic.ID, extCol.ID);
                                extCol.DataType  = ic.DataType;
                                extCol.CodePage  = ic.CodePage;
                                extCol.Length    = ic.Length;
                                extCol.Precision = ic.Precision;
                                extCol.Scale     = ic.Scale;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets a custom property to an output column; adds it if the property does not exist.
        /// For internal use within this library. Not for use from outside libraries
        /// </summary>
        /// <param name="input"></param>
        /// <param name="inputColumn"></param>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        internal void SetCustomPropertyToInputColumn(IDTSInput100 input, IDTSInputColumn100 inputColumn, string propertyName, object propertyValue, bool containsId = false)
        {
            bool propertyExists        = false;
            IDTSCustomProperty100 prop = null;

            for (int i = 0; i < inputColumn.CustomPropertyCollection.Count; i++)
            {
                if (inputColumn.CustomPropertyCollection[i].Name == propertyName)
                {
                    propertyExists = true;
                    //prop =
                    break;
                }
            }
            if (propertyExists)
            {
                prop            = DesignTimeComponent.SetInputColumnProperty(input.ID, inputColumn.ID, propertyName, propertyValue);
                prop.ContainsID = containsId;
            }
            else
            {
                prop            = inputColumn.CustomPropertyCollection.New();
                prop.Name       = propertyName;
                prop.Value      = propertyValue;
                prop.ContainsID = containsId;
            }
        }
Ejemplo n.º 4
0
        //Dissallow DT_NTEXT, DT_TEXT and DT_IMAGE data types.
        public override bool CheckColumnForInputValidity(IDTSVirtualInput vInput, IDTSInput input, FormInputColumn icol)
        {
            bool validForInput = false;

            var dt = icol.DTSVirtualColumn.DataType;

            if (dt == DataType.DT_NTEXT || dt == DataType.DT_TEXT || dt == DataType.DT_IMAGE)
            {
                validForInput = false;
            }
            else
            {
                if (icol.DTSInputColumn != null)
                {
                    //IDTSCustomProperty nullCol = icol.DTSInputColumn.CustomPropertyCollection[Resources.LookupErrorAggIsNullColumnName];
                    //bool isNullCol = (bool)nullCol.Value;
                    IDTSCustomProperty keyCol = icol.DTSInputColumn.CustomPropertyCollection[Resources.LookupErrorAggIsKeyColumnName];
                    bool isKeyCol             = (bool)keyCol.Value;

                    if (!isKeyCol)
                    {
                        DesignTimeComponent.SetUsageType(input.ID, vInput, icol.LineageID, DTSUsageType.UT_IGNORED);
                        icol.DTSInputColumn = null;
                    }
                }
                validForInput = true;
            }

            return(validForInput);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Add a custom property to an output
        /// For internal use from within this library. Not for use from outside libraries
        /// </summary>
        /// <param name="output"></param>
        /// <param name="propertyName"></param>
        /// <param name="propertyValue"></param>
        internal IDTSCustomProperty100 SetCustomPropertyToOutput(IDTSOutput100 output, string propertyName, object propertyValue)
        {
            bool propertyExists        = false;
            IDTSCustomProperty100 prop = null;

            for (int i = 0; i < output.CustomPropertyCollection.Count; i++)
            {
                if (output.CustomPropertyCollection[i].Name == propertyName)
                {
                    propertyExists = true;
                    break;
                }
            }

            if (propertyExists)
            {
                prop = DesignTimeComponent.SetOutputProperty(output.ID, propertyName, propertyValue);
            }
            else
            {
                prop       = output.CustomPropertyCollection.New();
                prop.Name  = propertyName;
                prop.Value = propertyValue;
            }
            return(prop);
        }
Ejemplo n.º 6
0
        internal ISPipelineComponent(string componentName, string componentMoniker, MainPipe mainPipe)
        {
            bool componentExists = false;

            _readWriteCols = new List <string>();

            /*if (mainPipe == null)
             * {
             *  Console.WriteLine("HMMMMMMMM ...... mainPipe is null");
             * } else
             * {
             *  Console.WriteLine("mainPipe is NOT null");
             * }*/
            foreach (IDTSComponentMetaData100 comp in mainPipe.ComponentMetaDataCollection)
            {
                if (comp.Name == componentName)
                {
                    componentExists   = true;
                    ComponentMetaData = comp;
                    // Assign the CManagedComponentWrapper so that we can change the properties.
                    // But Do not call ProvideComponentProperties() on the IDTSDesignTimeCoomponent100 after the assignment.
                    // Since the CManagedComponentWrapper already exists, the properties were already made available.
                    // Calling ProvideComponentProperties will override the existing properties and set their values to default values; thus losing the existing properties
                    DesignTimeComponent = ComponentMetaData.Instantiate();
                }
            }
            if (!componentExists)
            {
                ComponentMetaData = mainPipe.ComponentMetaDataCollection.New(); // Adds a new "component" to the Data Flow Task's Pipeline
                ComponentMetaData.ComponentClassID = componentMoniker;          //
                DesignTimeComponent = ComponentMetaData.Instantiate();
                DesignTimeComponent.ProvideComponentProperties();
            }
            Name = componentName;
        }
Ejemplo n.º 7
0
        public void SelectLookupInputColumn(System.Windows.Forms.CheckedListBox clbInputColumns, System.Windows.Forms.ListBox lbSelectedItems, int checkedIndex, System.Windows.Forms.CheckState state, int nullColumnLineageId)
        {
            FormInputColumn icol = clbInputColumns.Items[checkedIndex] as FormInputColumn;

            IDTSInput input = ComponentMetadata.InputCollection[0];

            if (icol != null)
            {
                if (state == CheckState.Checked)
                {
                    DesignTimeComponent.SetUsageType(input.ID, VirtualInput, icol.LineageID, DTSUsageType.UT_READONLY);

                    IDTSInputColumn inputCol = input.InputColumnCollection.GetInputColumnByLineageID(icol.LineageID);

                    IDTSCustomProperty keyCol = inputCol.CustomPropertyCollection[Resources.LookupErrorAggIsKeyColumnName];
                    keyCol.Value = true;

                    icol.DTSInputColumn = inputCol;


                    if (lbSelectedItems != null && !lbSelectedItems.Items.Contains(icol))
                    {
                        int sortOrder = 0;
                        if (lbSelectedItems.Items.Count > 0)
                        {
                            FormInputColumn lastCol = lbSelectedItems.Items[lbSelectedItems.Items.Count - 1] as FormInputColumn;
                            sortOrder = lastCol.SortOrder;
                        }
                        icol.SortOrder = sortOrder + 1;

                        lbSelectedItems.Items.Add(icol);
                    }
                }
                else
                {
                    bool isInput = false;
                    if (icol.DTSInputColumn != null)
                    {
                        IDTSCustomProperty prop = icol.DTSInputColumn.CustomPropertyCollection[Resources.LookupErrorAggIsNullColumnName];
                        isInput = (bool)prop.Value;
                        IDTSCustomProperty keyCol = icol.DTSInputColumn.CustomPropertyCollection[Resources.LookupErrorAggIsKeyColumnName];
                        keyCol.Value = false;
                    }

                    if (!isInput)
                    {
                        DesignTimeComponent.SetUsageType(input.ID, VirtualInput, icol.LineageID, DTSUsageType.UT_IGNORED);
                        icol.DTSInputColumn = null;
                    }

                    if (lbSelectedItems != null && lbSelectedItems.Items.Contains(icol))
                    {
                        lbSelectedItems.Items.Remove(icol);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Selexts an InputColumn (to become available in the input buffer)
        /// </summary>
        /// <param name="lineageID">LineageID of the InputColumn</param>
        /// <param name="isSelected">Selection Status of the Column</param>
        public IDTSInputColumn SelectInputColumn(int lineageID, bool selected)
        {
            IDTSInputColumn icol = null;

            if (Input != null)
            {
                DTSUsageType usageType = selected ? DTSUsageType.UT_READONLY : DTSUsageType.UT_IGNORED;

                icol = DesignTimeComponent.SetUsageType(Input.ID, VirtualInput, lineageID, usageType);
            }
            return(icol);
        }
Ejemplo n.º 9
0
        internal IDTSInputColumn100 SetInputColumnDTSUsageType(IDTSInput100 input, string columnName, UsageType dtsUsageType)
        {
            //  keep track of hte columns whose usage type is set to ut_readwrite...for these cols, we want to prevent a change to ut_readonly
            if (dtsUsageType == UsageType.UT_READWRITE)
            {
                _readWriteCols.Add(columnName);
            }

            IDTSVirtualInput100 virtualInput = input.GetVirtualInput();
            IDTSInputColumn100  inputColumn  = DesignTimeComponent.SetUsageType(
                input.ID,
                virtualInput,
                virtualInput.VirtualInputColumnCollection[columnName].LineageID,
                DtsUtility.EnumAToEnumB <UsageType, DTSUsageType>(dtsUsageType)
                );

            return(inputColumn);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Retrieve Metadata for a given source/destination when it is available and connectable.
        /// </summary>
        public bool RetrieveMetaData_Old()
        {
            bool success = false;

            try
            {
                DesignTimeComponent.AcquireConnections(null);
                DesignTimeComponent.ReinitializeMetaData();
                DesignTimeComponent.ReleaseConnections();
                success = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("Could Not Retrieve Metadata; Error:: " + e.Message);
                success = false;
            }
            return(success);
        }
Ejemplo n.º 11
0
        public bool RetrieveMetaData()
        {
            bool success = false;

            try
            {
                DesignTimeComponent.AcquireConnections(null);
                success = true;
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Console.WriteLine("AcquireConn Error:: " + e.Message + " -- " + e.HResult.ToString());
                success = false;
            }

            if (success)
            {
                try
                {
                    DesignTimeComponent.ReinitializeMetaData();
                }
                catch (Exception e)
                {
                    Console.WriteLine("ReinitializeMetaData Error:: " + e.Message);
                    success = false;
                }
            }

            if (success)
            {
                try
                {
                    DesignTimeComponent.ReleaseConnections();
                }
                catch (Exception e)
                {
                    Console.WriteLine("ReleaseConnections Error:: " + e.Message);
                    success = false;
                }
            }


            return(success);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Selects an InputColumn (to become available in the input buffer)
        /// </summary>
        /// <param name="clbInputColumns">CheckedListbox with InputColumns</param>
        /// <param name="lbSelectedItems">ListBox with Selected InputColumns</param>
        /// <param name="checkedIndex">Index of the Item being checked</param>
        /// <param name="state">CheckState of the item being checkd</param>
        public virtual void SelectInputColumn(CheckedListBox clbInputColumns, ListBox lbSelectedItems, int checkedIndex, CheckState state)
        {
            FormInputColumn icol = clbInputColumns.Items[checkedIndex] as FormInputColumn;

            IDTSInput input = ComponentMetadata.InputCollection[0];

            if (icol != null)
            {
                if (state == CheckState.Checked)
                {
                    DesignTimeComponent.SetUsageType(input.ID, VirtualInput, icol.LineageID, DTSUsageType.UT_READONLY);

                    IDTSInputColumn inputCol = input.InputColumnCollection.GetInputColumnByLineageID(icol.LineageID);

                    icol.DTSInputColumn = inputCol;


                    if (lbSelectedItems != null && !lbSelectedItems.Items.Contains(icol))
                    {
                        int sortOrder = 0;
                        if (lbSelectedItems.Items.Count > 0)
                        {
                            FormInputColumn lastCol = lbSelectedItems.Items[lbSelectedItems.Items.Count - 1] as FormInputColumn;
                            sortOrder = lastCol.SortOrder;
                        }
                        icol.SortOrder = sortOrder + 1;

                        lbSelectedItems.Items.Add(icol);
                    }
                }
                else
                {
                    DesignTimeComponent.SetUsageType(input.ID, VirtualInput, icol.LineageID, DTSUsageType.UT_IGNORED);
                    icol.DTSInputColumn = null;

                    if (lbSelectedItems != null && lbSelectedItems.Items.Contains(icol))
                    {
                        lbSelectedItems.Items.Remove(icol);
                    }
                }
            }
        }
Ejemplo n.º 13
0
 /// <summary>
 ///  The Custom Property Collection only contains the "custom" properties of a component.
 ///  Common properties of all components such as Name, Description etc are not available in this colection.
 ///  Therefore calling SetCustomProperty and GetCustomProperty on common properties will result in error.
 /// </summary>
 internal void CustomPropertySetter <T>(string propertyName, T value)
 {
     DesignTimeComponent.SetComponentProperty(propertyName, value);
 }