public CatalogExplorerControl(ISASTaskConsumer3 consumer)
        {
            InitializeComponent();

            Title = "SAS Catalog Explorer";
            consumer3 = consumer;

            // get the list of SAS servers for use in the context menu
            foreach (SasServer s in SasServer.GetSasServers())
            {
                MenuItem mi = new MenuItem();
                mi.Header = s.Name;
                mi.Tag = s;
                mi.Click += new RoutedEventHandler(serverSelected);
                serverContext.Items.Add(mi);
            }

            serverButton.Click += new RoutedEventHandler(serverButton_Click);
            viewButton.Click += new RoutedEventHandler(viewButton_Click);
            deleteButton.Click += new RoutedEventHandler(deleteButton_Click);

            // get notified when the tree view selection changes
            treeView.SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(treeView_SelectedItemChanged);

            SasServer server = new SasServer(consumer3.AssignedServer);
            InitializeWithServer(server);

            deleteButton.IsEnabled = false;
            viewButton.IsChecked = true;
        }
Example #2
0
        public CatalogExplorerControl(ISASTaskConsumer3 consumer)
        {
            InitializeComponent();

            Title     = "SAS Catalog Explorer";
            consumer3 = consumer;

            // get the list of SAS servers for use in the context menu
            foreach (SasServer s in SasServer.GetSasServers())
            {
                MenuItem mi = new MenuItem();
                mi.Header = s.Name;
                mi.Tag    = s;
                mi.Click += new RoutedEventHandler(serverSelected);
                serverContext.Items.Add(mi);
            }

            serverButton.Click += new RoutedEventHandler(serverButton_Click);
            viewButton.Click   += new RoutedEventHandler(viewButton_Click);
            deleteButton.Click += new RoutedEventHandler(deleteButton_Click);

            // get notified when the tree view selection changes
            treeView.SelectedItemChanged += new RoutedPropertyChangedEventHandler <object>(treeView_SelectedItemChanged);

            SasServer server = new SasServer(consumer3.AssignedServer);

            InitializeWithServer(server);

            deleteButton.IsEnabled = false;
            viewButton.IsChecked   = true;
        }
Example #3
0
        public LiferegSettings(ISASTaskConsumer3 SASConsumer)
            : base()
        {
            AsmTask  = this.GetType().Assembly;
            RMString = new ResourceManager("MarcinSzymanski.Lifereg.Resources.Strings", AsmTask);

            InitializeGlobals();
        }
        public LiferegControls(ISASTaskConsumer3 sasConsumer)
        {
            TaskControlList = new List <TaskControl>();
            AsmTask         = this.GetType().Assembly;
            RMString        = new ResourceManager("MarcinSzymanski.Lifereg.Resources.Strings", AsmTask);
            SASConsumer     = sasConsumer;

            InitializeControls();
        }
        // download the catalog entry contents and view in an editor

        override public void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            SAS.FileService  fs = null;
            SAS.IFileref     fr = null;
            SAS.Workspace    ws = null;
            SAS.BinaryStream bs = null;
            string           fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                bs = fr.OpenBinaryStream(StreamOpenMode.StreamOpenModeForReading);

                using (MemoryStream ms = new MemoryStream())
                {
                    // downloading catalog entry contents
                    int   bytes = 1;
                    Array buffer;
                    // iterate through until all lines are read in
                    while (bytes > 0)
                    {
                        bs.Read(32767, out buffer);
                        bytes = buffer.GetLength(0);
                        for (int i = 0; i < bytes; i++)
                        {
                            ms.WriteByte((byte)buffer.GetValue(0));
                        }
                    }

                    ms.Close();
                    BitmapImage b = new BitmapImage();
                    b.BeginInit();
                    b.StreamSource = ms;
                    b.EndInit();

                    imgContent.Source = b;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
        // download the catalog entry contents and view in an editor

        override public void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            Consumer = consumer;

            SAS.FileService fs = null;
            SAS.IFileref    fr = null;
            SAS.Workspace   ws = null;
            SAS.TextStream  ts = null;
            string          fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr           = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                ts           = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500);
                ts.Separator = Environment.NewLine;

                StringBuilder sb = new StringBuilder();

                // downloading catalog entry contents
                int   lines = 1;
                Array truncLines, readLines;
                // iterate through until all lines are read in
                while (lines > 0)
                {
                    ts.ReadLines(100, out truncLines, out readLines);
                    lines = readLines.GetLength(0);
                    for (int i = 0; i < lines; i++)
                    {
                        sb.AppendLine(readLines.GetValue(i).ToString());
                    }
                }

                txtEntry.Text = sb.ToString();

                // cleanup
                ts.Close();
                fs.DeassignFileref(fr.FilerefName);
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
        public OptionViewerDlg(ISASTaskConsumer3 consumer, string taskID) : base(consumer, taskID)
        {
            InitializeComponent();

            // for sorting in the list view
            lvOptions.ColumnClick += new ColumnClickEventHandler(OnOptionsColumnClick);
            chGroup.Width          = lvOptions.ShowGroups ? 0 : widthChGroup;

            LoadServers();
            RefreshValues();

            SendMessage(txtFilter.Handle, EM_SETCUEBANNER, 0, "Filter results");

            UpdateSelectedOptionInfo();
        }
        // download the catalog entry contents and view in an editor
        public override void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            Consumer = consumer;

            SAS.FileService fs = null;
            SAS.IFileref fr = null;
            SAS.Workspace ws = null;
            SAS.TextStream ts = null;
            string fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                ts = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500);
                ts.Separator = Environment.NewLine;

                StringBuilder sb = new StringBuilder();

                // downloading catalog entry contents
                int lines = 1;
                Array truncLines, readLines;
                // iterate through until all lines are read in
                while (lines > 0)
                {
                    ts.ReadLines(100, out truncLines, out readLines);
                    lines = readLines.GetLength(0);
                    for (int i = 0; i < lines; i++)
                        sb.AppendLine(readLines.GetValue(i).ToString());
                }

                txtEntry.Text = sb.ToString();

                // cleanup
                ts.Close();
                fs.DeassignFileref(fr.FilerefName);
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
        // download the catalog entry contents and view in an editor
        public override void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
        {
            SAS.FileService fs = null;
            SAS.IFileref fr = null;
            SAS.Workspace ws = null;
            SAS.BinaryStream bs = null;
            string fileref;

            try
            {
                // use SAS workspace and fileservice to download the file

                ws = consumer.Workspace(serverName) as SAS.Workspace;
                fs = ws.FileService;

                // using the FILENAME CATALOG access method
                fr = fs.AssignFileref("", "CATALOG", catEntry, "", out fileref);
                bs = fr.OpenBinaryStream(StreamOpenMode.StreamOpenModeForReading);

                using (MemoryStream ms = new MemoryStream())
                {
                    // downloading catalog entry contents
                    int bytes = 1;
                    Array buffer;
                    // iterate through until all lines are read in
                    while (bytes > 0)
                    {
                        bs.Read(32767, out buffer);
                        bytes = buffer.GetLength(0);
                        for (int i = 0; i < bytes; i++)
                            ms.WriteByte((byte)buffer.GetValue(0));
                    }

                    ms.Close();
                    BitmapImage b = new BitmapImage();
                    b.BeginInit();
                    b.StreamSource = ms;
                    b.EndInit();

                    imgContent.Source = b;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Cannot open the catalog entry {0}.  Reason: {1}", catEntry, ex.Message));
            }
        }
Example #10
0
        public MacroViewerDlg(ISASTaskConsumer3 consumer, string taskID)
            : base(consumer, taskID)
        {
            InitializeComponent();

            this.ShowInTaskbar = false;

            // for sorting in the list view
            lvMacros.ColumnClick += new ColumnClickEventHandler(lvMacros_ColumnClick);
            chScope.Width = lvMacros.ShowGroups ? 0 : widthChScope;

            LoadServers();
            RefreshValues();

            SendMessage(txtFilter.Handle, EM_SETCUEBANNER, 0, "Filter results");
        }
Example #11
0
        public MacroViewerDlg(ISASTaskConsumer3 consumer, string taskID)
            : base(consumer, taskID)
        {
            InitializeComponent();

            this.ShowInTaskbar = false;

            // for sorting in the list view
            lvMacros.ColumnClick += new ColumnClickEventHandler(lvMacros_ColumnClick);
            chScope.Width         = lvMacros.ShowGroups ? 0 : widthChScope;

            LoadServers();
            RefreshValues();

            SendMessage(txtFilter.Handle, EM_SETCUEBANNER, 0, "Filter results");
        }
        public OptionViewerDlg(ISASTaskConsumer3 consumer, string taskID)
            : base(consumer,taskID)
        {
            InitializeComponent();

            // for sorting in the list view
            lvOptions.ColumnClick += new ColumnClickEventHandler(OnOptionsColumnClick);
            chGroup.Width = lvOptions.ShowGroups ? 0 : widthChGroup;

            LoadServers();
            RefreshValues();

            SendMessage(txtFilter.Handle, EM_SETCUEBANNER, 0, "Filter results");

            UpdateSelectedOptionInfo();
        }
 /// <summary>
 /// In the special case where we have a local SAS data set file (sas7bdat),
 /// and a local SAS server, we have to make sure that there is a library
 /// assigned.  The DatasetConverter class can read data only from a
 /// data source that is accessed via a SAS library (LIBNAME.MEMBER).
 /// </summary>
 /// <param name="sd"></param>
 internal static void AssignLocalLibraryIfNeeded(ISASTaskConsumer3 consumer, SasTask taskModel)
 {
     SAS.Tasks.Toolkit.Data.SasData sd = new SAS.Tasks.Toolkit.Data.SasData(consumer.ActiveData as ISASTaskData2);
     // get a SasServer object so we can see if it's the "Local" server
     SAS.Tasks.Toolkit.SasServer server = new SAS.Tasks.Toolkit.SasServer(sd.Server);
     // local server with local file, so we have to assign library
     if (server.IsLocal)
     {
         // see if the data reference is a file path ("c:\data\myfile.sas7bdat")
         if (!string.IsNullOrEmpty(consumer.ActiveData.File) &&
             consumer.ActiveData.Source == SourceType.SasDataset &&
             consumer.ActiveData.File.Contains("\\"))
         {
             string path = System.IO.Path.GetDirectoryName(consumer.ActiveData.File);
             taskModel.SubmitSASProgramAndWait(string.Format("libname {0} \"{1}\";\r\n", sd.Libref, path));
         }
     }
 }
        private void btnOUT_Click(object sender, EventArgs e)
        {
            MSzTaskForm mszTaskForm = (this.ParentForm as MSzTaskForm);

            string            cookie   = "";
            ISASTaskConsumer3 Consumer = mszTaskForm.Consumer;
            ISASTaskDataName  name     = Consumer.ShowOutputDataSelector(this,
                                                                         ServerAccessMode.OneServer,
                                                                         Consumer.AssignedServer,
                                                                         "", "", ref cookie);

            // if the user closes the dialog without making a selection,
            // the name will be null.
            if (name != null)
            {
                txtOUT.Text =
                    string.Format("{0}.{1}", name.Library, name.Member);
            }
        }
Example #15
0
 /// <summary>
 /// In the special case where we have a local SAS data set file (sas7bdat),
 /// and a local SAS server, we have to make sure that there is a library
 /// assigned.  
 /// </summary>
 /// <param name="sd"></param>
 internal static void AssignLocalLibraryIfNeeded(ISASTaskConsumer3 consumer)
 {
     SAS.Tasks.Toolkit.Data.SasData sd = new SAS.Tasks.Toolkit.Data.SasData(consumer.ActiveData as ISASTaskData2);
     // get a SasServer object so we can see if it's the "Local" server
     SAS.Tasks.Toolkit.SasServer server = new SAS.Tasks.Toolkit.SasServer(sd.Server);
     // local server with local file, so we have to assign library
     if (server.IsLocal)
     {
         // see if the data reference is a file path ("c:\data\myfile.sas7bdat")
         if (!string.IsNullOrEmpty(consumer.ActiveData.File) &&
             consumer.ActiveData.Source == SourceType.SasDataset &&
             consumer.ActiveData.File.Contains("\\"))
         {
             string path = System.IO.Path.GetDirectoryName(consumer.ActiveData.File);
             SasSubmitter submitter = new SasSubmitter(sd.Server);
             string log;
             submitter.SubmitSasProgramAndWait(string.Format("libname {0} \"{1}\";\r\n", sd.Libref, path), out log);
         }
     }
 }
 virtual public void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
 {
 }
 public SPColumnProperties(SPColumn col, ISASTaskConsumer3 cons)
 {
     _column  = col;
     consumer = cons;
     InitializeComponent();
 }
 public SPColumnProperties(SPColumn col,ISASTaskConsumer3 cons)
 {
     _column = col;
     consumer = cons;
     InitializeComponent();
 }
Example #19
0
 /// <summary>
 /// Constructor to get a handle to the app (Consumer)
 /// and the current task class ID
 /// </summary>
 /// <param name="consumer">Handle to application</param>
 /// <param name="taskID">unique class ID for this type of task</param>
 public BaseToolsForm(ISASTaskConsumer3 consumer, string taskID)
 {
     Consumer = consumer;
     TaskClassID = taskID;
 }
Example #20
0
        public string GetSasProgram(ISASTaskConsumer3 consumer)
        {
            StringBuilder program = new StringBuilder();

            string filter = "";

            if (!string.IsNullOrEmpty(FilterSettings.FilterValue))
            {
                filter = string.Format("(where=({0}))", FilterSettings.FilterValue);
            }

            // this handy function creates an
            // easy-to-read comment block
            // in the generated SAS program
            program.Append(
                SAS.Tasks.Toolkit.Helpers.UtilityFunctions.BuildSasTaskCodeHeader(
                    "Calculate Running Totals",
                    string.Format("{0}.{1}", consumer.ActiveData.Library,
                                  consumer.ActiveData.Member),
                    consumer.AssignedServer));

            // if no groups, then easy 1-line calculation
            if (VariableGroups.Count == 0)
            {
                program.AppendFormat("data {0};\n", DataOut);
                program.AppendFormat("  set {0}.{1}{2};\n",
                                     consumer.ActiveData.Library, consumer.ActiveData.Member, filter);
                program.AppendFormat("  {0} + {1}; \n",
                                     UtilityFunctions.SASValidLiteral(VariableTotal),
                                     UtilityFunctions.SASValidLiteral(VariableMeasure));
                program.AppendLine("run;");
            }
            // if there are groups, then create a program
            // with a BY statement and IF FIRST construct
            else
            {
                program.AppendFormat("data {0};\n", DataOut);
                program.AppendFormat("  set {0}.{1}{2};\n",
                                     consumer.ActiveData.Library, consumer.ActiveData.Member, filter);

                // add BY variables
                // and build IF FIRST logic
                program.AppendLine("  by ");
                StringBuilder first = new StringBuilder();
                for (int i = 0; i < VariableGroups.Count; i++)
                {
                    program.AppendLine(string.Format("   {0}",
                                                     SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableGroups[i])));

                    // build 1 or more FIRST checks
                    if (i == 0)
                    {
                        first.AppendFormat("FIRST.{0} ",
                                           SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableGroups[i]));
                    }
                    else
                    {
                        first.AppendFormat("or FIRST.{0} ",
                                           SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableGroups[i]));
                    }
                }
                program.AppendLine("  ;");

                // add FIRST logic line
                program.AppendFormat("  if {0} then \n   {1}={2};\n", first,
                                     SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableTotal),
                                     SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableMeasure));
                program.AppendFormat("  else {0} + {1}; \n",
                                     SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableTotal),
                                     SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableMeasure));
                program.AppendLine("run;");
            }

            // return the built program
            return(program.ToString());
        }
Example #21
0
 /// <summary>
 /// Constructor to get a handle to the app (Consumer)
 /// and the current task class ID
 /// </summary>
 /// <param name="consumer">Handle to application</param>
 /// <param name="taskID">unique class ID for this type of task</param>
 public BaseToolsForm(ISASTaskConsumer3 consumer, string taskID)
 {
     Consumer    = consumer;
     TaskClassID = taskID;
 }
        public string GetSasProgram(ISASTaskConsumer3 consumer)
        {
            StringBuilder program = new StringBuilder();

            string filter = "";
            if (!string.IsNullOrEmpty(FilterSettings.FilterValue))
                filter = string.Format("(where=({0}))", FilterSettings.FilterValue);

            // this handy function creates an
            // easy-to-read comment block
            // in the generated SAS program
            program.Append(
                SAS.Tasks.Toolkit.Helpers.UtilityFunctions.BuildSasTaskCodeHeader(
                "Calculate Running Totals",
                string.Format("{0}.{1}",consumer.ActiveData.Library,
                    consumer.ActiveData.Member),
                consumer.AssignedServer));

            // if no groups, then easy 1-line calculation
            if (VariableGroups.Count == 0)
            {
                program.AppendFormat("data {0};\n", DataOut);
                program.AppendFormat("  set {0}.{1}{2};\n",
                       consumer.ActiveData.Library, consumer.ActiveData.Member,filter);
                program.AppendFormat("  {0} + {1}; \n",
                    UtilityFunctions.SASValidLiteral(VariableTotal),
                    UtilityFunctions.SASValidLiteral(VariableMeasure));
                program.AppendLine("run;");
            }
            // if there are groups, then create a program
            // with a BY statement and IF FIRST construct
            else
            {
                program.AppendFormat("data {0};\n", DataOut);
                program.AppendFormat("  set {0}.{1}{2};\n",
                       consumer.ActiveData.Library, consumer.ActiveData.Member, filter);

                // add BY variables
                // and build IF FIRST logic
                program.AppendLine("  by ");
                StringBuilder first = new StringBuilder();
                for (int i = 0; i < VariableGroups.Count; i++)
                {
                    program.AppendLine(string.Format("   {0}",
                        SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableGroups[i])));

                    // build 1 or more FIRST checks
                    if (i == 0)
                        first.AppendFormat("FIRST.{0} ",
                            SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableGroups[i]));
                    else first.AppendFormat("or FIRST.{0} ",
                        SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableGroups[i]));
                }
                program.AppendLine("  ;");

                // add FIRST logic line
                program.AppendFormat("  if {0} then \n   {1}={2};\n", first,
                    SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableTotal),
                    SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableMeasure));
                program.AppendFormat("  else {0} + {1}; \n",
                    SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableTotal),
                    SAS.Tasks.Toolkit.Helpers.UtilityFunctions.SASValidLiteral(VariableMeasure));
                program.AppendLine("run;");
            }

            // return the built program
            return program.ToString();
        }
 public virtual void ReadEntry(ISASTaskConsumer3 consumer, string serverName, string catEntry)
 {
 }
        public ImportFromSharePointListTaskForm(ISASTaskConsumer3 consumer)
        {
            InitializeComponent();

            this.Consumer = consumer;
        }
 public ImportFromSharePointListTaskForm(ISASTaskConsumer3 consumer)
 {
     InitializeComponent();
     
     this.Consumer = consumer;                        
 }