// read list of catalogs for the given library (in the tree node) private void PopulateCatalogs(TreeNode tn) { Cursor c = Cursor.Current; Cursor.Current = Cursors.WaitCursor; tvLibsCats.BeginUpdate(); if (tn != null) { SAS.Workspace ws = null; try { ws = consumer.Workspace(currentServer) as SAS.Workspace; } catch (Exception ex) { throw new System.Exception("ISASTaskConsumer.Workspace is not usable!", ex); } if (currentServer.Length > 0 && ws != null) { // use the SAS IOM OLEDB provider to read data from the SAS workspace ADODB.Recordset adorecordset = new ADODB.RecordsetClass(); ADODB.Connection adoconnect = new ADODB.ConnectionClass(); try { adoconnect.Open("Provider=sas.iomprovider.1; SAS Workspace ID=" + ws.UniqueIdentifier, "", "", 0); // use the SASHELP.VMEMBER view to get names of all of the catalogs in the specified library string selectclause = "select memname from sashelp.vmember where libname='" + tn.Text + "' and memtype in ('CATALOG')"; adorecordset.Open(selectclause, adoconnect, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText); while (!adorecordset.EOF) { TreeNode cat = tn.Nodes.Add(adorecordset.Fields["memname"].Value.ToString()); cat.ImageIndex = (int)CatImages.Catalog; cat.SelectedImageIndex = (int)CatImages.Catalog; cat.Tag = "CATALOG"; adorecordset.MoveNext(); } } catch {} finally { adoconnect.Close(); } } } tvLibsCats.EndUpdate(); Cursor.Current = c; UpdateToolbar(); }
private string GetTextFromFileref(string fileref) { SAS.FileService fs = null; SAS.IFileref fr = null; SAS.Workspace ws = null; SAS.TextStream ts = null; StringBuilder sb = new StringBuilder(); try { // use SAS workspace and fileservice to download the file ws = consumer.Workspace(currentServer) as SAS.Workspace; fs = ws.FileService; fr = fs.UseFileref(fileref); ts = fr.OpenTextStream(SAS.StreamOpenMode.StreamOpenModeForReading, 16500); ts.Separator = Environment.NewLine; // downloading catalog entry contents to local temp file 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()); } } ts.Close(); fs.DeassignFileref(fileref); } catch (Exception) { } finally { ts = null; fr = null; fs = null; ws = null; } return(sb.ToString()); }