BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
abbieagocs
Fluorite | Level 6

I am working on a custom task for EG 5.1 -- Linux SAS 9.4.

I would like to either present a tree displaying the user's home directory (folders/subfolders) - to allow the user to select a location -- or

to capture the selection under the SASServer->Files-..  

 

I have seen examples of capturing the selected library -- but cannot find any doc on getting the selected File.

 

Any suggestions on how to accomplish either task would be greatly appreciated.

 

Thanks,

Abbie

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

The task APIs don't offer a way to show the file structure on the SAS session, so you would need to create that part yourself.

 

Rather than use a SAS program to figure out the structure, you can use the IOM FileService->ListFiles API to accomplish this.  You can get this from the SAS workspace, which you can obtain from the Consumer property.

 

You'll need to add some more assembly references to your project: SASInterop, SASIOMCommonInterop, and SASOManInterop.  These are all in the EG application folder as well as in the SAS Integration Technologies client folder.

 

Sample code to get you started:

 

 

string ListedPath;
Array Names;
Array TypeNames;
Array TypeCategories;
Array Sizes;
Array ModTimes;
Array Engines;
Array Mask;

SAS.Workspace ws = Consumer.Workspace(Consumer.AssignedServer) as SAS.Workspace;
SAS.FileService fs = ws.FileService;
Mask = Array.CreateInstance(typeof(bool), 6);
for (int i = 0; i < 5; i++)
    Mask.SetValue(true, i);
Mask.SetValue(false, 5);	// skip engines field
fs.ListFiles("", SAS.FileServiceListFilesMode.FileServiceListFilesModePath, ref Mask,	
	out ListedPath,	out Names,	
	out TypeNames,	out TypeCategories,	
	out Sizes, out ModTimes,		
	out Engines);

Your work: parsing the array output here, then presenting files versus directories (folders).  You can then build a UI that allows the user to drill in and pass the starting path (first argument to ListFiles) to find the contents of subfolders.

 

I'll be the first to admit this is cumbersome -- these array-based APIs were built for use with COM-based standards in mind and aren't very "object oriented".  But they work!

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

View solution in original post

5 REPLIES 5
SASKiwi
PROC Star

Have you checked out the configuarion options in SAS Management Console?

 

In Server Manager - SASApp - SASApp Logical Workspace Server - SASApp Workspace Server - Properties - Options - Advanced Options you should see the following where you can specify a file path. It seems to work for me under Windows. Not sure about Unix.

 

screenshot10.jpg

abbieagocs
Fluorite | Level 6

Thanks SASKiwi,

I don't think I stated my problem well enough.

I have configured the File Navigation option correctly - to point to SAS User root.

The part that I cannot yet solve is:

Once the user has used the File portion of the SAS Server tree for navigation - ie made a selection in that tree,

is it possible to get that selection to my custom task?

 

If not, then I would need to write a sas program returns the directory structure and loads that into a treeview.

(I think)

ChrisHemedinger
Community Manager

The task APIs don't offer a way to show the file structure on the SAS session, so you would need to create that part yourself.

 

Rather than use a SAS program to figure out the structure, you can use the IOM FileService->ListFiles API to accomplish this.  You can get this from the SAS workspace, which you can obtain from the Consumer property.

 

You'll need to add some more assembly references to your project: SASInterop, SASIOMCommonInterop, and SASOManInterop.  These are all in the EG application folder as well as in the SAS Integration Technologies client folder.

 

Sample code to get you started:

 

 

string ListedPath;
Array Names;
Array TypeNames;
Array TypeCategories;
Array Sizes;
Array ModTimes;
Array Engines;
Array Mask;

SAS.Workspace ws = Consumer.Workspace(Consumer.AssignedServer) as SAS.Workspace;
SAS.FileService fs = ws.FileService;
Mask = Array.CreateInstance(typeof(bool), 6);
for (int i = 0; i < 5; i++)
    Mask.SetValue(true, i);
Mask.SetValue(false, 5);	// skip engines field
fs.ListFiles("", SAS.FileServiceListFilesMode.FileServiceListFilesModePath, ref Mask,	
	out ListedPath,	out Names,	
	out TypeNames,	out TypeCategories,	
	out Sizes, out ModTimes,		
	out Engines);

Your work: parsing the array output here, then presenting files versus directories (folders).  You can then build a UI that allows the user to drill in and pass the starting path (first argument to ListFiles) to find the contents of subfolders.

 

I'll be the first to admit this is cumbersome -- these array-based APIs were built for use with COM-based standards in mind and aren't very "object oriented".  But they work!

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
abbieagocs
Fluorite | Level 6

Chris,

Thanks so much - that was exactly what was needed.

I've unwrapped the directory entries - traversed and can now display the tree.

Reeza
Super User

File isn't an option in a prompt?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1681 views
  • 1 like
  • 4 in conversation