代码之家  ›  专栏  ›  技术社区  ›  Jayanga Kaushalya

如何将多个DataFlow任务添加到Foreach容器

  •  0
  • Jayanga Kaushalya  · 技术社区  · 10 年前

    如何将多个数据流任务添加到单个 foreach 集装箱使用 EzAPI .基本上我需要做以下事情。

    enter image description here

    我是EzAPI的新手。有人能给我一个这种场景的代码示例吗。提前感谢。

    1 回复  |  直到 10 年前
        1
  •  1
  •   billinkc    10 年前

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

    正如您在下面的代码中看到的,我创建了 EzPackage , EzForEachLoop , EzExecSqlTask EzDataFlowTask .EzAPI任务和容器都在其构造函数中接受父对象。这就是如何指定对象应该存在的范围。因此,For Each Loop将基包作为其参数,但Data Flow和Execute SQL Task使用For Each循环,以便在该容器中创建它们。

    定义对象之间的优先级约束有不同的机制,您可以选择使用哪个版本:object.AttachTo vs package.PretenceConstraints.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);
        }
    

    使用该代码,我生成了一个如下的包

    enter image description here

    工具书类