Пример #1
0
        static void Main(string[] args)
        {
            // Creating the package and the Data Flow Task:
            EzPackage  package  = new EzPackage();
            EzDataFlow dataFlow = new EzDataFlow(package);

            // Creating a connection to the database:
            EzSqlOleDbCM  srcConn = Activator.CreateInstance(typeof(EzSqlOleDbCM), new object[] { package }) as EzSqlOleDbCM;
            EzOleDbSource source  = Activator.CreateInstance(typeof(EzOleDbSource), new object[] { dataFlow }) as EzOleDbSource;

            source.Connection = srcConn;
            srcConn.SetConnectionString("localhost", "Northwind");
            source.Table = "FuzzyOrders";

            // Creating six Flat File Destinations to write the output from the Conditional Split:
            uint numberCases = 6;
            List <EzFlatFileDestination> destinations = new List <EzFlatFileDestination>();

            for (int i = 1; i <= numberCases; i++)
            {
                EzFlatFileCM          conn = Activator.CreateInstance(typeof(EzFlatFileCM), new object[] { package }) as EzFlatFileCM;
                EzFlatFileDestination dest = Activator.CreateInstance(typeof(EzFlatFileDestination), new object[] { dataFlow }) as EzFlatFileDestination;
                dest.Connection       = conn;
                conn.ConnectionString = @"C:\CondSplit\output" + i + ".txt";
                dest.Overwrite        = true;

                destinations.Add(dest);
            }

            // Attaching the Conditional Split to the source, and mapping input columns to output columns:
            EzConditionalSplit split = new EzConditionalSplit(dataFlow);

            split.AttachTo(source);
            split.LinkAllInputsToOutputs();

            /*
             * Important step - this is where the new EzConditionalSplit functionality comes in.
             *
             * The Condition property of EzConditionalSplit indexes over outputs using output names.
             * Providing an output name that does not yet exist will create a new output.
             *
             * The Condition property is set to a string that represents the condition that is evaluated to determine which
             * output a particular row is sent to.
             *
             * The set method of the Condition property also assigns a string to the Expression property, which contains the actual string
             * that is evaulated during runtime.  In this string, column names are replaced with column IDs.  The Expression property
             * can be set directly, but the Condition property allows the user to provide a string containing column names without
             * worrying about IDs.  In addition, the Condition set method also assigns the new expression to be the next case to be evaluated,
             * automatically setting the Order property, which must be sequential in order to guarantee execution.
             */
            for (int i = 1; i <= numberCases; i++)
            {
                split.Condition["case" + i] = "EmployeeID == " + i;
            }

            // Attaching each destination to an output of Conditional Split:
            for (int i = 1; i <= numberCases; i++)
            {
                destinations[i - 1].AttachTo(split, i + 1, 0);
                destinations[i - 1].DefineColumnsInCM();
            }

            // Creating a destination for the default output:
            EzFlatFileCM          conn_default = Activator.CreateInstance(typeof(EzFlatFileCM), new object[] { package }) as EzFlatFileCM;
            EzFlatFileDestination dest_default = Activator.CreateInstance(typeof(EzFlatFileDestination), new object[] { dataFlow }) as EzFlatFileDestination;

            dest_default.Connection       = conn_default;
            conn_default.ConnectionString = @"C:\CondSplit\default.txt";
            dest_default.Overwrite        = true;

            // Attaching the default destination to the default output.
            dest_default.AttachTo(split, 0, 0);
            dest_default.DefineColumnsInCM();

            // Execute the package.
            package.Execute();
        }
 public EzConditionalSplit CompareChecksums()
 {
     EzConditionalSplit component = new EzConditionalSplit(this);
     component.Name = "Compare Checksums";
     //TODO actually compare checksums
     return component;
 }
Пример #3
0
        static void Main(string[] args)
        {
            // Creating the package and the Data Flow Task:
            EzPackage package = new EzPackage();
            EzDataFlow dataFlow = new EzDataFlow(package);

            // Creating a connection to the database:
            EzSqlOleDbCM srcConn = Activator.CreateInstance(typeof(EzSqlOleDbCM), new object[] { package }) as EzSqlOleDbCM;
            EzOleDbSource source = Activator.CreateInstance(typeof(EzOleDbSource), new object[] { dataFlow }) as EzOleDbSource;
            source.Connection = srcConn;
            srcConn.SetConnectionString("localhost", "Northwind");
            source.Table = "FuzzyOrders";

            // Creating six Flat File Destinations to write the output from the Conditional Split:
            uint numberCases = 6;
            List<EzFlatFileDestination> destinations = new List<EzFlatFileDestination>();
            for (int i = 1; i <= numberCases; i++)
            {
                EzFlatFileCM conn = Activator.CreateInstance(typeof(EzFlatFileCM), new object[] { package }) as EzFlatFileCM;
                EzFlatFileDestination dest = Activator.CreateInstance(typeof(EzFlatFileDestination), new object[] { dataFlow }) as EzFlatFileDestination;
                dest.Connection = conn;
                conn.ConnectionString = @"C:\CondSplit\output" + i + ".txt";
                dest.Overwrite = true;

                destinations.Add(dest);
            }

            // Attaching the Conditional Split to the source, and mapping input columns to output columns:
            EzConditionalSplit split = new EzConditionalSplit(dataFlow);
            split.AttachTo(source);
            split.LinkAllInputsToOutputs();

            /*
             * Important step - this is where the new EzConditionalSplit functionality comes in.
             * 
             * The Condition property of EzConditionalSplit indexes over outputs using output names.
             * Providing an output name that does not yet exist will create a new output.
             * 
             * The Condition property is set to a string that represents the condition that is evaluated to determine which
             * output a particular row is sent to.
             * 
             * The set method of the Condition property also assigns a string to the Expression property, which contains the actual string
             * that is evaulated during runtime.  In this string, column names are replaced with column IDs.  The Expression property
             * can be set directly, but the Condition property allows the user to provide a string containing column names without
             * worrying about IDs.  In addition, the Condition set method also assigns the new expression to be the next case to be evaluated,
             * automatically setting the Order property, which must be sequential in order to guarantee execution.
             */
            for (int i = 1; i <= numberCases; i++)
            {
                split.Condition["case" + i] = "EmployeeID == " + i;
            }

            // Attaching each destination to an output of Conditional Split:
            for (int i = 1; i <= numberCases; i++)
            {
                destinations[i - 1].AttachTo(split, i + 1, 0);
                destinations[i - 1].DefineColumnsInCM();
            }

            // Creating a destination for the default output:
            EzFlatFileCM conn_default = Activator.CreateInstance(typeof(EzFlatFileCM), new object[] { package }) as EzFlatFileCM;
            EzFlatFileDestination dest_default = Activator.CreateInstance(typeof(EzFlatFileDestination), new object[] { dataFlow }) as EzFlatFileDestination;
            dest_default.Connection = conn_default;
            conn_default.ConnectionString = @"C:\CondSplit\default.txt";
            dest_default.Overwrite = true;

            // Attaching the default destination to the default output.
            dest_default.AttachTo(split, 0, 0);
            dest_default.DefineColumnsInCM();

            // Execute the package.
            package.Execute();
        }
        public DimDataFlow(EzContainer parent, PACKAGE_DIM p, SOURCEOBJECT so)
            : base(parent)
        {
            this.p = p;
            this.so = so;

            EzOleDbSource Source = new EzOleDbSource(this);
            Source.Connection = p.Conns["Source"];
             Source.SqlCommand = String.Format("select * from {0} where ActiveFlag = 'Y' and CreatedDate > '01-01-1900'", so.DATAOBJECT.tableName("PSA"));
            Source.Name = so.DATAOBJECT.tableName("PSA");

            EzDerivedColumn DeriveAttributes = new EzDerivedColumn(this);
            DeriveAttributes.AttachTo(Source);
            DeriveAttributes.Name = "Derive Attributes";
            //TODO for each mapping column add attribute expression
            foreach (MAPPINGCOLUMN mappingColumn in so.MAPPINGCOLUMNS) {
                if (mappingColumn.ATTRIBUTE == null) {
                    mappingColumn.ATTRIBUTE = mappingColumn.DATACOLUMN;
                }
                //TODO based on attribute type determine what sort of SSIS-ifying the data column needs
               DeriveAttributes.Expression[mappingColumn.ATTRIBUTE] = "(DT_STR,150,1252)\"" + mappingColumn.DATACOLUMN + "\"";
            }

            EzConditionalSplit ActionCode = new EzConditionalSplit(this);
            ActionCode.AttachTo(DeriveAttributes);
            ActionCode.Condition["case1"] = "ActionCode == 'UPDATE'";
            ActionCode.Condition["case2"] = "ActionCode == 'INSERT'";

            EzRowCount RowsMatched = new EzRowCount(this);
            RowsMatched.Name = "Rows Matched";
            RowsMatched.VariableName = "Audit::RowsMatched";
            RowsMatched.AttachTo(ActionCode, 0, 0);

            //TODO correct ole db command query, parameter mapping
            EzOleDbCommand UpdateDimension = new EzOleDbCommand(this);
            UpdateDimension.AttachTo(RowsMatched);

            EzRowCount RowsInserted = new EzRowCount(this);
            RowsInserted.Name = "Rows Inserted";
            RowsInserted.VariableName = "Audit::RowsInserted";
            RowsInserted.AttachTo(ActionCode, 1, 0);

            EzOleDbDestination InsertedDestination = new EzOleDbDestination(this);
            InsertedDestination.Name =String.Format("{0} - New Records",  this.p.tableName());
            InsertedDestination.AttachTo(RowsInserted);
            InsertedDestination.Connection = p.Conns["DIM"];
            InsertedDestination.Table = p.tableName();
            InsertedDestination.LinkAllInputsToOutputs();
            InsertedDestination.ReinitializeMetaData();
        }