Desktop productivity for business analysts and programmers

EG: custom task

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

EG: custom task

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


Accepted Solutions
Solution
‎03-04-2016 11:25 AM
Community Manager
Posts: 2,882

Re: EG: custom task

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!

 

View solution in original post


All Replies
Super User
Posts: 3,233

Re: EG: custom task

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

Occasional Contributor
Posts: 6

Re: EG: custom task

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)

Solution
‎03-04-2016 11:25 AM
Community Manager
Posts: 2,882

Re: EG: custom task

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!

 

Occasional Contributor
Posts: 6

Re: EG: custom task

Chris,

Thanks so much - that was exactly what was needed.

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

Super User
Posts: 18,997

Re: EG: custom task

File isn't an option in a prompt?

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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