コード例 #1
0
ファイル: table.cs プロジェクト: chris17453/ssis_baccahnal
            //underlying add column function base
            public bool Add(string name, int ordinal, int order, int type, bool derived)
            {
                //if it already exist, is the same ordinal or order... dont add it.
                foreach (column_definition c in items)
                {
                    if (c.name.ToLower() == name.ToLower())
                    {
                        return(false);
                    }
                    if (c.ordinal == ordinal)
                    {
                        return(false);
                    }
                    if (c.order == order)
                    {
                        return(false);
                    }
                }
                column_definition new_column = new column_definition(name, ordinal, order, type, derived);

                new_column.min_items = 0;
                new_column.max_items = 1;
                items.Add(new_column);
                return(true);
            }
コード例 #2
0
ファイル: table.cs プロジェクト: chris17453/ssis_baccahnal
            public column(string data, table_config config, int index)
            {
                this.index  = index;
                this.config = config;
                //this.items = new items();
                string[] column_elements = data.Split(config.array_delimiter);

                //loop through the elements
                int element_index            = 0;
                column_definition column_def = config.columns.get_column_by_ordinal(index);

                if (column_def == null)
                {
                    // if we have no column. its because it wasnt defined. so add a default name based on index
                    // then set it to derived and arry type, the least restrictive
                    bool new_col_results = config.columns.Add("COLUMN_" + index, index, index, 2, true);
                    if (false == new_col_results)
                    {
                        //error
                    }

                    column_def = config.columns.get_column_by_ordinal(index);
                    if (column_def == null)
                    {
                        //cant add it at all error
                    }
                }
                if (column_def.type == 1 && column_elements.Length > 1)
                {
                    this.error = true;
                }

                foreach (string element in column_elements)
                {
                    //process the data_item
                    data_item new_item = new data_item(element, config, element_index);
                    items.Add(new_item);
                    if (new_item.error == true)
                    {
                        this.error = true;
                    }
                } //end elements loop
            }
コード例 #3
0
ファイル: table.cs プロジェクト: chris17453/ssis_baccahnal
 public void derive_columns()
 {
     //create columns based on key data
     if (this.derive_key_columns)
     {
         foreach (row r in this.items)
         {
             foreach (column c in r.items)
             {
                 column_definition column_def = this.config.columns.get_column_by_ordinal(c.index);
                 foreach (data_item d in c.items)
                 {
                     if (d.is_key_value)
                     {
                         this.config.columns.AddDerived(d.key);
                     }
                 } //end inner
             }     //end minor
         }         //end major loop
     }             //end creating derived key columns
 }
コード例 #4
0
ファイル: table.cs プロジェクト: chris17453/ssis_baccahnal
 public void derive_array()
 {
     //create columns based on array index data of a column
     if (this.derive_array_columns)
     {
         foreach (row r in this.items)
         {
             foreach (column c in r.items)
             {
                 column_definition column_def = this.config.columns.get_column_by_ordinal(c.index);
                 //if there is more than oone of them....
                 if (column_def.max_items > 1)
                 {
                     for (int a = 0; a < column_def.max_items + 1; a++)
                     {
                         this.config.columns.AddDerived(string.Format("{0}.{1}", column_def.name, a));
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: table.cs プロジェクト: chris17453/ssis_baccahnal
            }//end constructor

            public void populate_min_max()
            {
                //pre populate min/max counts
                foreach (row r in this.items)
                {
                    foreach (column c in r.items)
                    {
                        column_definition column_def = this.config.columns.get_column_by_ordinal(c.index);
                        if (column_def == null)
                        {
                            //error
                        }
                        if (column_def.max_items < c.items.Count)
                        {
                            column_def.max_items = c.items.Count;
                        }
                        if (column_def.min_items > c.items.Count)
                        {
                            column_def.min_items = c.items.Count;
                        }
                    } //end minor
                }     //end major loop
            }
コード例 #6
0
ファイル: table.cs プロジェクト: chris17453/ssis_baccahnal
            //populate derived column data after the fact.
            public void derive_column_data()
            {
                if (this.derive_key_columns | this.derive_array_columns)
                {
                    foreach (row r in this.items)
                    {
                        int count = r.items.Count;
                        for (int i = 0; i < count; i++)
                        {
                            column            c          = r.items[i];
                            column_definition column_def = this.config.columns.get_column_by_ordinal(c.index);
                            List <data_item>  new_data   = new List <data_item>();

                            foreach (data_item d in c.items)
                            {
                                if (d.is_key_value)
                                {
                                    column_definition derived_column_def = this.config.columns.get_column_by_name(d.key);
                                    r.AddDerivedData(d, derived_column_def.ordinal);
                                    continue;
                                }

                                if (d.is_value)
                                {
                                    //we only add array data if the max item count is >1
                                    if (column_def.max_items > 1)
                                    {
                                        column_definition derived_column_def = this.config.columns.get_column_by_ordinal(c.index, d.index);
                                        r.AddDerivedData(d, derived_column_def.ordinal);
                                    }
                                }
                            } //end inner
                        }     //end minor
                    }         //end major loop
                }             //end if derived
            }                 //end