Пример #1
0
        public SSISFlatFileDestination(FlatFileDestination fdst, MainPipe pipe, IDTSComponentMetaData100 src, int outputID, ConnectionManager cm)
            : base(pipe, "Flat File Destination", outputID)
        {
            cm.Name = String.Format(CultureInfo.InvariantCulture, "FlatFile Destination Connection Manager {0}", outputID);

            //Create a new FlatFileDestination component

            IDTSComponentMetaData100 comp  = this.MetadataCollection;
            CManagedComponentWrapper dcomp = comp.Instantiate();

            foreach (KeyValuePair <string, object> prop in fdst.CustomProperties.CustomPropertyCollection.InnerArrayList)
            {
                dcomp.SetComponentProperty(prop.Key, prop.Value);
            }

            /*Specify the connection manager for Src.The Connections class is a collection of the connection managers that have been added to that package and are available for use at run time*/
            if (comp.RuntimeConnectionCollection.Count > 0)
            {
                comp.RuntimeConnectionCollection[0].ConnectionManagerID = cm.ID;
                comp.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(cm);
            }

            this.Reinitialize(dcomp);

            //Create datatype converter if needed
            Dictionary <string, int> converted = new Dictionary <string, int>();
            IDTSVirtualInput100      vInput    = src.InputCollection[0].GetVirtualInput();

            if (this.needDataTypeChange(vInput, comp.InputCollection[0]))
            {
                //create the destination column collection
                Dictionary <string, MyColumn> exColumns = new Dictionary <string, MyColumn>();
                foreach (IDTSExternalMetadataColumn100 exColumn in comp.InputCollection[0].ExternalMetadataColumnCollection)
                {
                    MyColumn col = new MyColumn();
                    col.Name      = exColumn.Name;
                    col.DataType  = exColumn.DataType;
                    col.Length    = exColumn.Length;
                    col.Precision = exColumn.Precision;
                    col.Scale     = exColumn.Scale;
                    col.CodePage  = exColumn.CodePage;
                    exColumns.Add(exColumn.Name, col);
                }
                SSISDataConverter ssisdc = new SSISDataConverter(pipe, src, outputID, exColumns);
                src       = ssisdc.MetadataCollection;
                converted = ssisdc.ConvertedColumns;
                outputID  = 0;
            }

            this.ConnectComponents(src, outputID);
            this.MatchInputColumns(converted, false);
        }
        public SSISSharePointDestination(SharePointDestination spdst, MainPipe pipe, IDTSComponentMetaData100 src, int outputID)
            : base(pipe, "SharePoint List Destination", outputID, "Microsoft.Samples.SqlServer.SSIS.SharePointListAdapters.SharePointListDestination, SharePointListAdapters, Version=1.2016.0.0, Culture=neutral, PublicKeyToken=f4b3011e1ece9d47")
        {
            //Create a new SharePointDestination component

            IDTSComponentMetaData100 comp  = this.MetadataCollection;
            CManagedComponentWrapper dcomp = comp.Instantiate();

            foreach (KeyValuePair <string, object> prop in spdst.CustomProperties.CustomPropertyCollection.InnerArrayList)
            {
                dcomp.SetComponentProperty(prop.Key, prop.Value);
            }

            this.Reinitialize(dcomp);

            //Create datatype converter if needed
            Dictionary <string, int> converted = new Dictionary <string, int>();
            IDTSVirtualInput100      vInput    = src.InputCollection[0].GetVirtualInput();

            if (this.needDataTypeChange(vInput, comp.InputCollection[0]))
            {
                //create the destination column collection
                Dictionary <string, MyColumn> exColumns = new Dictionary <string, MyColumn>();
                foreach (IDTSExternalMetadataColumn100 exColumn in comp.InputCollection[0].ExternalMetadataColumnCollection)
                {
                    MyColumn col = new MyColumn();
                    col.Name      = exColumn.Name;
                    col.DataType  = exColumn.DataType;
                    col.Length    = exColumn.Length;
                    col.Precision = exColumn.Precision;
                    col.Scale     = exColumn.Scale;
                    col.CodePage  = exColumn.CodePage;
                    exColumns.Add(exColumn.Name, col);
                }
                SSISDataConverter ssisdc = new SSISDataConverter(pipe, src, outputID, exColumns);
                src       = ssisdc.MetadataCollection;
                converted = ssisdc.ConvertedColumns;
                outputID  = 0;
            }

            this.ConnectComponents(src, outputID);
            this.MatchInputColumns(converted, false);
        }
        public SSISAdoNetDestination(AdoNetDestination dbdst, MainPipe pipe, IDTSComponentMetaData100 src, int outputID, ConnectionManager cm)
            : base(pipe, "ADO NET Destination", outputID)
        {
            //create Ado Net destination component
            //set connection properties
            cm.Name             = String.Format(CultureInfo.InvariantCulture, "AdoNet Destination Connection Manager {0}", outputID);
            cm.ConnectionString = dbdst.ConnectionString;
            cm.Description      = dbdst.Description;
            cm.Qualifier        = dbdst.DBConnection.Qualifier;

            IDTSComponentMetaData100 comp  = this.MetadataCollection;
            CManagedComponentWrapper dcomp = comp.Instantiate();

            // Set AdoNet destination custom properties
            foreach (KeyValuePair <string, object> prop in dbdst.CustomProperties.CustomPropertyCollection.InnerArrayList)
            {
                dcomp.SetComponentProperty(prop.Key, prop.Value);
            }

            //default - OpenRowset; ovveride OpenRowset with stagingtablename if staging is used
            if (!(dbdst.StagingBlock == null) && dbdst.StagingBlock.Staging)
            {
                dcomp.SetComponentProperty("TableOrViewName", dbdst.StagingBlock.StagingTableName);
            }
            else
            {
                dcomp.SetComponentProperty("TableOrViewName", dbdst.CustomProperties.TableOrViewName);
            }

            if (comp.RuntimeConnectionCollection.Count > 0)
            {
                comp.RuntimeConnectionCollection[0].ConnectionManagerID = cm.ID;
                comp.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(cm);
            }

            this.Reinitialize(dcomp);

            //Create datatype converter if needed
            Dictionary <string, int> converted = new Dictionary <string, int>();
            IDTSVirtualInput100      vInput    = src.InputCollection[0].GetVirtualInput();

            if (this.needDataTypeChange(vInput, comp.InputCollection[0]))
            {
                //create the destination column collection
                Dictionary <string, MyColumn> exColumns = new Dictionary <string, MyColumn>();
                foreach (IDTSExternalMetadataColumn100 exColumn in comp.InputCollection[0].ExternalMetadataColumnCollection)
                {
                    MyColumn col = new MyColumn();
                    col.Name      = exColumn.Name;
                    col.DataType  = exColumn.DataType;
                    col.Length    = exColumn.Length;
                    col.Precision = exColumn.Precision;
                    col.Scale     = exColumn.Scale;
                    col.CodePage  = exColumn.CodePage;
                    exColumns.Add(exColumn.Name, col);
                }
                SSISDataConverter ssisdc = new SSISDataConverter(pipe, src, outputID, exColumns);
                src       = ssisdc.MetadataCollection;
                converted = ssisdc.ConvertedColumns;
                outputID  = 0;
            }

            this.ConnectComponents(src, outputID);
            this.MatchInputColumns(converted, true);
        }
        public SSISExcelDestination(ExcelDestination dbdst, MainPipe pipe, IDTSComponentMetaData100 src, int outputID, ConnectionManager cm)
            : base(pipe, "Excel Destination", outputID)
        {
            //create ole db destination component
            //set connection properties
            cm.Name             = String.Format(CultureInfo.InvariantCulture, "Excel Destination Connection Manager {0}", outputID);
            cm.ConnectionString = dbdst.ConnectionString;
            cm.Description      = dbdst.Description;


            //mwrt.IDTSConnectionManagerExcel100 ecm = cm.InnerObject as mwrt.IDTSConnectionManagerExcel100;
            //ecm.ExcelFilePath = dbdst.FilePath;
            //ecm.FirstRowHasColumnName = dbdst.Header;
            //ecm.ExcelVersionNumber = mwrt.DTSExcelVersion.DTSExcelVer_2007;


            IDTSComponentMetaData100 comp  = this.MetadataCollection;
            CManagedComponentWrapper dcomp = comp.Instantiate();

            // Set oledb destination custom properties
            //default to openrowset
            dcomp.SetComponentProperty("AccessMode", 0);
            //foreach (KeyValuePair<string, object> prop in dbdst.CustomProperties.CustomPropertyCollection.InnerArrayList)
            foreach (KeyValuePair <string, object> prop in dbdst.CustomProperties.CustomPropertyCollection.InnerArrayList)
            {
                dcomp.SetComponentProperty(prop.Key, prop.Value);
            }

            if (comp.RuntimeConnectionCollection.Count > 0)
            {
                comp.RuntimeConnectionCollection[0].ConnectionManagerID = cm.ID;
                comp.RuntimeConnectionCollection[0].ConnectionManager   = DtsConvert.GetExtendedInterface(cm);
            }

            this.Reinitialize(dcomp);

            //Create datatype converter if needed
            Dictionary <string, int> converted = new Dictionary <string, int>();
            IDTSVirtualInput100      vInput    = src.InputCollection[0].GetVirtualInput();

            if (this.needDataTypeChange(vInput, comp.InputCollection[0]))
            {
                //create the destination column collection
                Dictionary <string, MyColumn> exColumns = new Dictionary <string, MyColumn>();
                foreach (IDTSExternalMetadataColumn100 exColumn in comp.InputCollection[0].ExternalMetadataColumnCollection)
                {
                    MyColumn col = new MyColumn();
                    col.Name      = exColumn.Name;
                    col.DataType  = exColumn.DataType;
                    col.Length    = exColumn.Length;
                    col.Precision = exColumn.Precision;
                    col.Scale     = exColumn.Scale;
                    col.CodePage  = exColumn.CodePage;
                    exColumns.Add(exColumn.Name, col);
                }
                SSISDataConverter ssisdc = new SSISDataConverter(pipe, src, outputID, exColumns);
                src       = ssisdc.MetadataCollection;
                converted = ssisdc.ConvertedColumns;
                outputID  = 0;
            }

            this.ConnectComponents(src, outputID);
            this.MatchInputColumns(converted, true);
        }