public void getSourceColumns(ISASTaskData2 taskData) { ISASTaskDataAccessor accessor = taskData.Accessor; SASVariableSelector.AddVariableParams var_params; ISASTaskDataColumn2 data_column; accessor.Open(); for (int i = 0; i < accessor.ColumnCount; i++) { data_column = accessor.ColumnInfoByIndex(i) as ISASTaskDataColumn2; var_params = var_params = getVarParms(data_column); sasVarSelector.AddVariable(var_params); } accessor.Close(); }
private void LoadColumns() { cmbReport.Items.Add(selectReportPrompt); cmbMeasure.Items.Add(selectMeasurePrompt); try { // to populate the comboboxes with the available columns, // we have to examine the active data source. ISASTaskData data = Model.Consumer.ActiveData; ISASTaskDataAccessor da = data.Accessor; // to do that, we need to "open" the data to get a peek at the column // information if (da.Open()) { for (int i = 0; i < da.ColumnCount; i++) { // first add the most likely categories -- character and date columns ISASTaskDataColumn ci = da.ColumnInfoByIndex(i); if (ci.Group == VariableGroup.Character || ci.Group == VariableGroup.Date) { cmbReport.Items.Add(ci.Name); cmbCategory.Items.Add(ci.Name); } else { cmbMeasure.Items.Add(ci.Name); hashFormats.Add(ci.Name, ci.Format); } } // now add the rest of the numerics for Report and Category. // These are less likely to make sense, but we don't want to // shut the door on "creative" reports. for (int i = 0; i < da.ColumnCount; i++) { ISASTaskDataColumn ci = da.ColumnInfoByIndex(i); if (ci.Group == VariableGroup.Numeric) { cmbReport.Items.Add(ci.Name); cmbCategory.Items.Add(ci.Name); } } cmbCategory.Items.Add(noCategory); da.Close(); } else { // something went wrong in trying to read the data, so // report an error message and end the form. string dataname = "UNKNOWN"; if (Model.Consumer.ActiveData != null) { dataname = string.Format("{0}.{1}", Model.Consumer.ActiveData.Library, Model.Consumer.ActiveData.Member); } MessageBox.Show(string.Format("ERROR: Could not read column information from data {0}.", dataname)); this.Close(); } } catch { // log exception } }