Reputation: 2744
How to add multiple data flow tasks to a single foreach
container using EzAPI
. Basicly I need to do as following.
I am new to EzAPI. Can anyone give me a code sample for this kind of scenario. Thanks in advance.
Upvotes: 0
Views: 1364
Reputation: 61211
Your question can really be distilled down to two questions: How do I create the various Containers and Tasks? How do I define precedence constraints between them?
As you can see in the code below, I create instances of the EzPackage
, EzForEachLoop
, EzExecSqlTask
and EzDataFlowTask
. EzAPI tasks and containers all accept a parent object in their constructor. This is how you specify what scope an object should exist at. Thus, the For Each Loop takes the base package as its argument but the Data Flow and Execute SQL Task use the For Each Loop so that they are created inside that container.
There are different mechanisms for defining the Precedence Constraint between objects and it's up to you which version you use: 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);
}
Using that code, I generate a package that looks like
Upvotes: 1