/// <summary> /// PreExecute phase: Gather all needed informations /// </summary> public override void PreExecute() { base.PreExecute(); InitializeProperties(); bool hasKey = (_isagCustomProperties.UseMatchParameter); /* Hashtable / Get Lookup Table */ DataTable dt = new DataTable(); SqlConnection con = _mainConn; SqlCommand cmd = con.CreateCommand(); cmd.CommandText = _isagCustomProperties.GetSqlLookupQuery(ComponentMetaDataTools.GetTableExpressionFromTemplate(_isagCustomProperties.LU_Table, VariableDispenser, ComponentMetaData)); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); _hashLookupTable = new Hashtable(); List <object> newLine = new List <object>(); object key = null; //match parameter value if (!hasKey) { key = 0; //if no match parameter is used -> the dictionaries has a single key with value 0 } foreach (DataRow row in dt.Rows) { if (hasKey) //match parameter is used, so multiple keys will be used for the hashtable { //key/match column value: null (first row of dataTable) or has changed if (key == null || !key.Equals(row[Constants.ALIAS_ID])) { //add new entry (old match column value + gathered row data) to hashtable if (key != null) { _hashLookupTable.Add(key, newLine.ToArray()); } // clear stored rows newLine.Clear(); //get new key / match column value if (hasKey) { key = row[Constants.ALIAS_ID]; } //store row data newLine.Add(row.ItemArray); } else { //store row data newLine.Add(row.ItemArray); } } else //match parameter is not used, so a single key will be used for the hashtable { newLine.Add(row.ItemArray); } } //add hashtable entry at the end of the row list if (newLine.Count > 0) { _hashLookupTable.Add(key, newLine.ToArray()); } /* Input Mapping */ IDTSInput100 input = this.ComponentMetaData.InputCollection[Constants.INPUT_NAME]; _colInfo = new ColumnInfo(); _colInfo.UseMatchColumn = _isagCustomProperties.UseMatchParameter; _colInfo.IsInclusiveUpperBound = _isagCustomProperties.LU2_IsInclusiveUpperBound; _colInfo.BufferIndexValidFromToColumn = this.BufferManager.FindColumnByLineageID(input.Buffer, input.InputColumnCollection[_isagCustomProperties.LU2_Validparameter].LineageID); if (hasKey) { _colInfo.BufferIndexMatchColumn = this.BufferManager.FindColumnByLineageID(input.Buffer, input.InputColumnCollection[_isagCustomProperties.LU_Matchparameter].LineageID); } else { _colInfo.BufferIndexMatchColumn = -1; } /* Output Mapping*/ _colInfo.BufferIndexOoutputColumns = new int[_isagCustomProperties.OutputConfigList.Count]; for (int i = 0; i < _isagCustomProperties.OutputConfigList.Count; i++) { _colInfo.BufferIndexOoutputColumns[i] = this.BufferManager.FindColumnByLineageID(input.Buffer, input.InputColumnCollection[_isagCustomProperties.OutputConfigList[i].DftColumn].LineageID); } }
/// <summary> /// event for Update button clicked /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event arguments</param> private void btnUpdate_Click(object sender, EventArgs e) { tbSql.Text = _isagCustomProperties.GetSqlLookupQuery(GetTableExpressionFromTemplate(_isagCustomProperties.LU_Table)); }