0

如何foreach使用EzAPI. 基本上我需要做以下事情。

在此处输入图像描述

我是 EzAPI 的新手。谁能给我这种情况的代码示例。提前致谢。

4

1 回答 1

1

您的问题实际上可以归结为两个问题:如何创建各种容器和任务?如何定义它们之间的优先约束?

正如您在下面的代码中看到的,我创建了EzPackage、和. EzAPI 任务和容器都在其构造函数中接受父对象。这是您指定对象应存在的范围的方式。因此,For Each 循环将基本包作为其参数,但数据流和执行 SQL 任务使用 For Each 循环,以便在该容器内创建它们。EzForEachLoopEzExecSqlTaskEzDataFlowTask

定义对象之间的优先约束有不同的机制,这取决于您使用哪个版本:object.AttachTo vs package.PrecedenceConstraints.Add

    public static void GimmieDaCodez()
    {
        EzPackage ezPackage = null;
        EzForEachLoop ezLoop = null;
        string packageName = @"so_22533130";
        string outputFile = string.Format("{0}.dtsx",System.IO.Path.Combine(@"C:\Dropbox\Sandbox\UtumnoSandbox\EzAPIDemo\EzAPIDemo", packageName));

        EzDataFlow df1 = null;
        EzDataFlow df2 = null;
        EzDataFlow df3 = null;
        EzExecSqlTask t4 = null;


        // Instantiate and configure our package
        ezPackage = new EzPackage();
        ezPackage.Name = packageName;
        ezPackage.Description = "A package with a foreach enumerator and muliple data flows";

        // Lazy initialization of FELC
        ezLoop = new EzForEachLoop(ezPackage);
        ezLoop.Name = "FELC Enumerate stuff";
        ezLoop.Description = "EzAPI still does not allow configuration of FELC beyond file enumerator";

        // Instantiate our tasks. Details left to the implementer
        df1 = new EzDataFlow(ezLoop);
        df1.Name = "DFT 1";
        df2 = new EzDataFlow(ezLoop);
        df2.Name = "DFT 2";
        df3 = new EzDataFlow(ezLoop);
        df3.Name = "DFT 3";
        t4 = new EzExecSqlTask(ezLoop);
        t4.Name = "SQL Do all the things";

        df2.AttachTo(df1);
        df3.AttachTo(df1);
        t4.AttachTo(df2);
        t4.AttachTo(df3);

        ezPackage.SaveToFile(outputFile);
    }

使用该代码,我生成了一个看起来像

在此处输入图像描述

参考

于 2014-03-21T18:02:10.010 回答