2

我正在使用 EzApi 创建 SSIS 包。但是,我无法创建具有多个来源和单个目的地的包。例如,两个 OLEDB 源和一个 OLEDB 目标。我到底想知道的是如何使用 c# 代码添加合并转换。请帮忙

4

2 回答 2

2

EzApi中有一个名为EzMerge 如果您需要创建自定义数据流的组件 - 您可以使用名为的基类EzDataFlowPackage

class MyPackage: EzDataFlowPackage
{
        public EzOleDbSource src1;
        public EzOleDbSource src2;
        public EzMerge merge;
        public EzOleDbDest dest;
        public EzOleDbConnectionManager srcConnMgr1;
        public EzOleDbConnectionManager srcConnMgr2;
        public EzOleDbConnectionManager destConnMgr;


        public EzMyPackage() : base() 
        {
            srcConnMgr1 = new EzOleDbConnectionManager(this);
            srcConnMgr2 = new EzOleDbConnectionManager(this);
            src1 = new EzOleDbSource(DataFlow);
            src2 = new EzOleDbSource(DataFlow);
            dest mew EzOleDbDest(DataFlow);
            src1.Connection = srcConnMgr1;
            src2.Connection = srcConnMgr2;
            dest.Connection = destConnMgr;
            merge = new EzMerge(DataFlow);
            src1.AttachTo(merge);
            src2.AttachTo(merge);
            merge.AttachTo(dest);
        }

        public EzMyPackage(Package p) : base(p) { }

        public static implicit operator EzMyPackage(Package p) { return new EzMyPackage(p); }
}

我刚刚输入了这段代码 - 所以它可能包含错误。毕竟,你的包布局已经准备好了。您可以简单地设置组件属性。

于 2012-04-27T01:43:35.370 回答
0

我没有使用过 EzApi,但是在 BIDS (Visual Studio) 中,您需要有两个数据源、一个数据目标和一个“合并”组件来连接它:

像这样:

替代文字

编辑

关于板条箱是程序性的。查看以下链接:

http://thinkerkk.blogspot.com/2007/08/programmatically-creating-dataflow-with.html

在注释后查找代码//create the Merge Transformation

//create the Merge Transformation
IDTSComponentMetaData90 merge = dataflow.ComponentMetaDataCollection.New();
merge.ComponentClassID = "DTSTransform.MergeJoin";
CManagedComponentWrapper mergeDesigntime = merge.Instantiate();
mergeDesigntime.ProvideComponentProperties();
merge.Name = "Merge Source1 and source2";
Console.WriteLine("merge created ");
merge.InputCollection[0].ExternalMetadataColumnCollection.IsUsed = false;
merge.InputCollection[0].HasSideEffects = false;
merge.InputCollection[1].ExternalMetadataColumnCollection.IsUsed = false;
merge.InputCollection[1].HasSideEffects = false;

//create path from source1 to merge
/*More code - see article*/

//create path from source2 to merge
/*More code - see article*/

以下链接也可用于以编程方式创建 SSIS 包:

http://msdn.microsoft.com/en-us/library/ms135946.aspx

http://blogs.msdn.com/b/mattm/archive/2008/12/30/samples-for-creating-ssis-packages-programmatically.aspx

于 2011-01-12T13:05:50.827 回答