public static XmlColumn CreateNewInstance(IDTSOutput output)
            {
                IDTSOutputColumn col = output.OutputColumnCollection.New();

                col.Name        = Resources.XmlColumnDefaultName + col.ID;
                col.Description = Resources.XmlColumnDefaultDesccription;
                ColumnsToXmlTransformation.SetXmlColumnProperties(col);

                XmlColumn c = new XmlColumn(col);

                return(c);
            }
        private void ProcessInputColumns()
        {
            List <int> inputLineages = new List <int>();
            //Get lineages of input columns for all output HASH Columns
            TreeNode node = trvOutputColumns.SelectedNode;

            if (node != null)
            {
                if (node.Tag is FormOutputColumn)
                {
                    node = node.Parent;
                }

                //Iterate through Hash Output Columns
                foreach (TreeNode nd in node.Nodes)
                {
                    XmlColumn ocol = nd.Tag as XmlColumn;
                    if (ocol != null)
                    {
                        var colInputLineages = ocol.XmlInputColumns.GetInputLineages();
                        //Iterate through each input column lineages and store unique lineages in the inputLineages List
                        foreach (int lineageID in colInputLineages)
                        {
                            if (!inputLineages.Contains(lineageID))
                            {
                                inputLineages.Add(lineageID);
                            }
                        }
                    }
                }
            }

            var iCols = UIHelper.GetFormInputColumns();

            foreach (FormInputColumn icol in iCols)
            {
                bool isSelected = inputLineages.Contains(icol.LineageID);
                if (isSelected != icol.IsSelected)
                {
                    UIHelper.SelectInputColumn(icol.LineageID, isSelected);
                }
            }
        }
        /// <summary>
        /// Processes rows in the inpuyt buffer
        /// </summary>
        /// <param name="inputID">ID of the input to process the input rows</param>
        /// <param name="buffer">Pipeline bufere with rows to process</param>
        public override void ProcessInput(int inputID, PipelineBuffer buffer)
        {
            if (!buffer.EndOfRowset)
            {
                while (buffer.NextRow())
                {
                    rowsProcessed++;

                    if (outputColumns.Count == 0)
                    {
                        continue;
                    }

                    XmlColumn lastCol    = null;
                    XElement  rowElement = null;

                    foreach (XmlColumn outCol in outputColumns)
                    {
                        if (rowElement == null || lastCol == null || lastCol.SerializeLineage != outCol.SerializeLineage || lastCol.SerializeDataType != outCol.SerializeDataType)
                        {
                            rowElement = new XElement("row");

                            //Add sourceID and sourceNme attributes to the row node if those are specified in the component properties
                            if (!string.IsNullOrEmpty(outCol.SourceID))
                            {
                                rowElement.Add(new XAttribute("sourceID", outCol.SourceID));
                            }
                            if (!string.IsNullOrEmpty(outCol.SourceName))
                            {
                                rowElement.Add(new XAttribute("sourceName", outCol.SourceName));
                            }

                            XElement columnElement = null;
                            //Process XML for selected input columns
                            for (int i = 0; i < outCol.XmlInputColumns.Count; i++)
                            {
                                int colIdx = outCol.XmlInputColumns[i];

                                InputBufferColumnInfo bci = inputBufferColumns[colIdx];
                                BufferColumn          col = buffer.GetColumnInfo(bci.Index);

                                byte[] bdata;

                                columnElement = new XElement("Column");

                                //add name, id and lineageId atributes to the column node
                                columnElement.Add(new XAttribute("name", bci.Name));

                                if (outCol.SerializeLineage)    //Serialize ID and LineageId
                                {
                                    columnElement.Add(new XAttribute("id", bci.ID), new XAttribute("lineageId", bci.LineageID));
                                }

                                if (outCol.SerializeDataType) //Serialize Data Type Information
                                {
                                    columnElement.Add(
                                        new XAttribute("dataType", bci.DataType.ToString())
                                        , new XAttribute("length", bci.Length)
                                        , new XAttribute("precision", bci.Precision)
                                        , new XAttribute("scale", bci.Scale)
                                        );
                                }

                                //if column value is null add isNull attribute to the column node
                                if (buffer.IsNull(bci.Index))
                                {
                                    columnElement.Add(new XAttribute("isNull", true));
                                }
                                else //get data for the column and store them as data of the column node
                                {
                                    string colData = string.Empty;
                                    switch (col.DataType)
                                    {
                                    case DataType.DT_BYTES:
                                        bdata   = buffer.GetBytes(bci.Index);
                                        colData = BytesToHexString(bdata);      //convert binary data to a hexadecimal string
                                        break;

                                    case DataType.DT_IMAGE:
                                        bdata   = buffer.GetBlobData(bci.Index, 0, (int)buffer.GetBlobLength(bci.Index));
                                        colData = BytesToHexString(bdata);     //convert binary data to a hexadecimal string
                                        break;

                                    case DataType.DT_NTEXT:
                                        bdata   = buffer.GetBlobData(bci.Index, 0, (int)buffer.GetBlobLength(bci.Index));
                                        colData = Encoding.Unicode.GetString(bdata);
                                        break;

                                    case DataType.DT_TEXT:
                                        bdata   = buffer.GetBlobData(bci.Index, 0, (int)buffer.GetBlobLength(bci.Index));
                                        colData = Encoding.GetEncoding(col.CodePage).GetString(bdata);
                                        break;

                                    default:
                                        colData = Convert.ToString(buffer[bci.Index], CultureInfo.InvariantCulture);
                                        break;
                                    }

                                    columnElement.SetValue(colData);
                                    rowElement.Add(columnElement);
                                }
                            }
                        }

                        if (outCol.DataType == DataType.DT_WSTR)
                        {
                            string str = rowElement.ToString(outCol.SaveOptions);
                            if (str.Length > outCol.DataLen)
                            {
                                bool   cancel = false;
                                string msg    = string.Format("Data Truncation has occured when processing row {0}. Could not write {1} characters into column [{2}] of length {3}", rowsProcessed, str.Length, outCol.Name, outCol.DataLen);
                                this.ComponentMetaData.FireError(0, this.ComponentMetaData.Name, msg, string.Empty, 0, out cancel);
                                if (cancel)
                                {
                                    throw new System.Exception(msg);
                                }
                                break;
                            }
                            buffer.SetString(outCol.Index, str);
                        }
                        else
                        {
                            buffer.AddBlobData(outCol.Index, Encoding.Unicode.GetBytes(rowElement.ToString(outCol.SaveOptions)));
                        }
                        lastCol = outCol;
                    }
                }
            }
        }