Пример #1
0
        BuildVariableParamsList(SasData data)
        {
            // Allocate the list
            List <SASVariableSelector.AddVariableParams> parmList =
                new List <SASVariableSelector.AddVariableParams>();

            foreach (SasColumn col in data.GetColumns())
            {
                SASVariableSelector.AddVariableParams parms =
                    new SASVariableSelector.AddVariableParams();

                // populate the column properties
                // from the SasColumn entry
                parms.Name     = col.Name;
                parms.Label    = col.Label;
                parms.Format   = col.Format;
                parms.Informat = col.Informat;

                // map the column category
                // to the variable selector
                // version of this enumeration
                // Ensures the correct "type" icon is
                // shown in the variable selector
                switch (col.Category)
                {
                case SasColumn.eCategory.Character:
                    parms.Type = VARTYPE.Character;
                    break;

                case SasColumn.eCategory.Numeric:
                    parms.Type = VARTYPE.Numeric;
                    break;

                case SasColumn.eCategory.Currency:
                    parms.Type = VARTYPE.Currency;
                    break;

                case SasColumn.eCategory.Date:
                    parms.Type = VARTYPE.Date;
                    break;

                case SasColumn.eCategory.DateTime:
                    parms.Type = VARTYPE.Time;
                    break;

                case SasColumn.eCategory.Georef:
                    parms.Type = VARTYPE.GeoRef;
                    break;

                default:
                    parms.Type = VARTYPE.Numeric;
                    break;
                }
                // add the complete object to the list
                // to return
                parmList.Add(parms);
            }
            return(parmList);
        }
Пример #2
0
        // When selected data member changes, get
        // a new list of columns
        private void onSelectedDatasetChanged(object sender, EventArgs e)
        {
            lbItems.Items.Clear();
            SasData d = lbMembers.SelectedItem as SasData;

            // gets a collection of SasColumn objects
            lbItems.Items.AddRange(new List <SasColumn>(d.GetColumns()).ToArray());
        }
Пример #3
0
        /// <summary>
        /// Build a List of AddVariableParams that can be added
        /// to the SAS Variable Selector control
        /// </summary>
        /// <param name="data">A SasData object for the input data used
        /// in the variable selector</param>
        /// <returns>A list of AddVariableParams objects that
        /// can be added to the control</returns>
        public static List<SASVariableSelector.AddVariableParams> BuildVariableParamsList(SasData data)
        {
            // Allocate the list
            List<SASVariableSelector.AddVariableParams> parmList =
                new List<SASVariableSelector.AddVariableParams>();

            foreach (SasColumn col in data.GetColumns())
            {
                SASVariableSelector.AddVariableParams parms =
                    new SASVariableSelector.AddVariableParams();

                // populate the column properties
                // from the SasColumn entry
                parms.Name = col.Name;
                parms.Label = col.Label;
                parms.Format = col.Format;
                parms.Informat = col.Informat;

                // map the column category
                // to the variable selector
                // version of this enumeration
                // Ensures the correct "type" icon is
                // shown in the variable selector
                switch (col.Category)
                {
                    case SasColumn.eCategory.Character:
                        parms.Type = VARTYPE.Character;
                        break;
                    case SasColumn.eCategory.Numeric:
                        parms.Type = VARTYPE.Numeric;
                        break;
                    case SasColumn.eCategory.Currency:
                        parms.Type = VARTYPE.Currency;
                        break;
                    case SasColumn.eCategory.Date:
                        parms.Type = VARTYPE.Date;
                        break;
                    case SasColumn.eCategory.DateTime:
                        parms.Type = VARTYPE.Time;
                        break;
                    case SasColumn.eCategory.Georef:
                        parms.Type = VARTYPE.GeoRef;
                        break;

                    default:
                        parms.Type = VARTYPE.Numeric;
                        break;
                }
                // add the complete object to the list
                // to return
                parmList.Add(parms);
            }
            return parmList;
        }
Пример #4
0
        private void SetupDataForVarSelector()
        {
            if (this.Consumer.InputData.Length > 0)
            {
                SasData data = new SasData(
                    this.Consumer.InputData[0] as ISASTaskData2
                    );

                // this helps to "realize" the data if it
                // is a local data set
                // we need it to be in an assigned library
                // in order to read the columns from the SasData object
                Helpers.AssignLocalLibraryIfNeeded(Consumer);

                // this builds the variable list
                // in the format that the variable selector needs
                List <SASVariableSelector.AddVariableParams> parmList =
                    Helpers.BuildVariableParamsList(data);
                varSelCtl.AddVariables(parmList);

                // assign the selected measure, if any
                if (!string.IsNullOrEmpty(Settings.VariableMeasure))
                {
                    if (data.ContainsColumn(Settings.VariableMeasure))
                    {
                        varSelCtl.AssignVariable(Translate.MeasureValueRole,
                                                 Settings.VariableMeasure);
                    }
                }

                // assign the selected group vars, if any
                foreach (string var in Settings.VariableGroups)
                {
                    if (data.ContainsColumn(var))
                    {
                        varSelCtl.AssignVariable(Translate.GroupingRole, var);
                    }
                }

                // listen on assigned/unassigned events
                varSelCtl.VariableAssigned +=
                    new SASVariableSelector.VariableAssignedEventHandler(varSelCtl_VariableAssigned);
                varSelCtl.VariableDeassigned +=
                    new SASVariableSelector.VariableDeassignedEventHandler(varSelCtl_VariableDeassigned);
            }
        }
Пример #5
0
        // for the selected LIBNAME.MEMBER and COLUMN
        // get the Distinct values from the data set
        // This will optionally apply a format as well
        // if one is specified
        private void btnGetValues_Click(object sender, EventArgs e)
        {
            lbValues.Items.Clear();
            SasColumn  c   = lbItems.SelectedItem as SasColumn;
            SasLibrary lib = lbLibraries.SelectedItem as SasLibrary;
            SasData    d   = lbMembers.SelectedItem as SasData;

            if (c != null && lib != null)
            {
                // Fetch distinct values using SAS format
                string format = "";

                // get a handle to the selected data
                ISASTaskData2 td =
                    Consumer.LibrefData(Consumer.AssignedServer, lib.Libref, d.Member) as ISASTaskData2;

                // set the format if not blank
                if (!string.IsNullOrEmpty(txtformat.Text))
                {
                    format = txtformat.Text;
                }

                // this can throw an exception if the
                // selected format does not match
                // the data type.
                try
                {
                    lbValues.Items.AddRange(
                        new List <string>(
                            SAS.Tasks.Toolkit.Helpers.TaskDataHelpers.GetDistinctValues(Consumer, td, c.Name, format)).ToArray()
                        );
                }
                catch (SasDataException)
                {
                    lbValues.Items.Add("<ERROR: could not fetch values>");
                }
            }
        }
Пример #6
0
        private void PopulateDataView()
        {
            SasData d = new SasData(Consumer.AssignedServer, Consumer.ActiveData.Library, Consumer.ActiveData.Member.ToUpper());

            foreach (SasColumn c in d.GetColumns())
            {
                ListViewItem li = new ListViewItem(c.Name);

                li.SubItems.Add(c.Type.ToString());
                li.SubItems.Add(c.Length.ToString());
                li.SubItems.Add(c.Format);
                li.SubItems.Add(Translate.Unknown);
                li.SubItems.Add(Translate.Unknown);
                li.ImageIndex = (int)c.Category;
                li.Tag        = new ColTag()
                {
                    SasColumn = c, Cardinality = new Cardinality()
                };

                lvColumns.Items.Add(li);
            }

            SortAvailableList();
        }
        private void PopulateDataView()
        {
            SasData d = new SasData(Consumer.AssignedServer, Consumer.ActiveData.Library, Consumer.ActiveData.Member.ToUpper());
            foreach (SasColumn c in d.GetColumns())
            {
                ListViewItem li = new ListViewItem(c.Name);
                
                li.SubItems.Add(c.Type.ToString());
                li.SubItems.Add(c.Length.ToString());
                li.SubItems.Add(c.Format);
                li.SubItems.Add(Translate.Unknown);
                li.SubItems.Add(Translate.Unknown);
                li.ImageIndex = (int)c.Category;
                li.Tag = new ColTag() { SasColumn = c, Cardinality=new Cardinality() };

                lvColumns.Items.Add(li);
            }

            SortAvailableList();
        }
        private void SetupDataForVarSelector()
        {
            if (this.Consumer.InputData.Length > 0)
            {
                SasData data = new SasData(
                    this.Consumer.InputData[0] as ISASTaskData2
                    );

                // this helps to "realize" the data if it
                // is a local data set
                // we need it to be in an assigned library
                // in order to read the columns from the SasData object
                Helpers.AssignLocalLibraryIfNeeded(Consumer);

                // this builds the variable list
                // in the format that the variable selector needs
                List<SASVariableSelector.AddVariableParams> parmList =
                    Helpers.BuildVariableParamsList(data);
                varSelCtl.AddVariables(parmList);

                // assign the selected measure, if any
                if (!string.IsNullOrEmpty(Settings.VariableMeasure))
                {
                    if (data.ContainsColumn(Settings.VariableMeasure))
                        varSelCtl.AssignVariable(Translate.MeasureValueRole,
                            Settings.VariableMeasure);
                }

                // assign the selected group vars, if any
                foreach (string var in Settings.VariableGroups)
                {
                    if (data.ContainsColumn(var))
                        varSelCtl.AssignVariable(Translate.GroupingRole, var);
                }

                // listen on assigned/unassigned events
                varSelCtl.VariableAssigned +=
                    new SASVariableSelector.VariableAssignedEventHandler(varSelCtl_VariableAssigned);
                varSelCtl.VariableDeassigned +=
                    new SASVariableSelector.VariableDeassignedEventHandler(varSelCtl_VariableDeassigned);
            }
        }