BookmarkSubscribeRSS Feed
nrose
Quartz | Level 8
I have just started developing custom tasks for SAS EG using VB.NET. I have designed a login tool for a remote server using a windows display and capturing username and password. The only way I know to implement the login is to resolve the username and password into a SAS program and have this submitted to SAS. For instance, the output string in the following function is a SAS program which is used by the Property SasCode() implementing the SAS.Shared.AddIns.ISASTask.SasCode interface:
Public Function ToSasProgram() As String
Dim sb As New StringBuilder()
sb.AppendLine()
sb.AppendFormat("%let sever={0};", Server)
sb.AppendLine()
sb.AppendFormat("%let username={0};", Username)
sb.AppendLine()
sb.AppendFormat("%let password={0};", Password)
sb.AppendLine()
Return sb.ToString()
End Function
Unfortunately, when I run this as a custom task, the SAS code is displayed for the user, revealing the password which is not ideal.
The log contents can easily be diverted to an external file and deleted, but I am not sure how to implement suppression of the SAS code in the custom task. This suppression has to be specific for the custom task and not allowed to be overidden.

Can anyone help?

Thanks.
Nick
11 REPLIES 11
ChrisHemedinger
Community Manager
Nick,

I think you want to use the SAS.Shared.AddIns.ISASTaskExecution API. By implementing that in your custom task, you have control over what code is submitted to SAS and what code, if any, is surfaced back into the SAS EG project.

Is this for EG 4.1 or 4.2? I'll see if I can dig up an example.

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
nrose
Quartz | Level 8
Hi,

That would be fantastic. I am using SAS Enterprise Guide 4.2, and using visual studio express.

Just one more thing. I am dissapointed at the lack of documentation for custom tasks in SAS EG 4.2. The 'Creating Custom Add-In Tasks for SAS Enterprise Guide' website still only gives examples for EG 4.1 and the link
http://support.sas.com/documentation/onlinedoc/guide/customtasks/samples/zqj_EG42CustomTasks.zip
whilst good, still looks like a work in progress. It would be great to see when the other chapters are finished.

Are there any other resources, books etc which gives a better representation of how SAS EG and custom tasks interact, other than the help files? Would be much appreciated as the implementation of Custom Tasks has so much potential for our organisation. The ability to create tasks using the microsoft express development tools opens up custom tasks to everyone and it is a shame there is not much info out there - at least that I can find.

Thanks.

Nick
ChrisHemedinger
Community Manager
Nick, I've worked up a simple example using Visual C# Express.

http://support.sas.com/documentation/onlinedoc/guide/customtasks/samples/SignonExample.zip

As you can see, the magic is in the implementation of ISASTaskExecution. That tells EG, "Hey, I'll handle how this task is run. And I'll supply the log text and the results, if any."

This lets you submit secret stuff to SAS without your end user seeing it, and then you can write your own log, even combining it with log out from SAS, if you want.

I tried to include enough comments inline with the code to explain what's going on. Let me know if you have questions.

Chris
It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
nrose
Quartz | Level 8
Thanks Chris, just what I needed.

Nick
nrose
Quartz | Level 8
Hi again,

I am having fun with developing custom tasks, and would like to utilise as much functionality as possible.

I was wondering whether it was possible for SAS to communicate with your custom task whilst the custom task is running. Say I have a login custom task, and the user name and/or password is incorrect. Is it possible for the custom task to supply code to SAS, for SAS to run a program, return a result to the task whilst it is still active, and then act upon this result? This would allow SAS to check the validity of a username/password, return the result and the custom task could then decide to ask the user to try again rather than ending and displaying a result via the output window.

All the custom task examples that i can see, work by building up a SAS program, then submitting it at which point the custom task ends.

Also Chris, any idea when your book on custom tasks will be published? - I am eagerly awaiting.

Thanks
ChrisHemedinger
Community Manager
Nick,

Yes, you can certainly work a task like that, where the window stays up while you submit SAS code and handle the results.

Here is a simple example:

http://support.sas.com/documentation/onlinedoc/guide/customtasks/samples/SASProgramRunnerExample.zip

The main trickiness in the .NET code is making sure that when you want to update the task UI with results from your SAS program, you need to make sure that your code is running on the correct thread. The example shows how to do that, with some comments explaining it.

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

I am having some problems with letting the Custom task know there is no input data required. According to the examples above you need to set this.RequiresData=false in InitializeComponent and use a class attribute [InputRequired(InputResourceType.None)] which I both implemented. Still, the task keeps asking for input data before my form is displayed. When I debug my project I can see the input data dialog appears before InitializeComponent is called.

Anybody has some idea what is going on? I'm using Enterprise Guide 4.2.0.

Thanks in advance,
Rudolf.
ChrisHemedinger
Community Manager
Rudolf,

If you registered your task using the Add-In Manager, you need to do it again so that this metadata (about what data is needed) is refreshed.

If you continue to have a problem with it, open a SAS Technical Support track and include enough of your Visual Studio project so that we can see what's going on. Most likely, tech support would route it to me to look at, but you might mention this thread to expedite that.

Also, if you want to play with some new Visual Studio templates for creating custom tasks, try this link:

http://support.sas.com/documentation/onlinedoc/guide/customtasks/VS2008Templates.zip

There is a PDF file in the zip archive that explains how to use them.

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

Re-registering the custom task in the Add-in manager did the trick. Thanks a lot for the tip!

Rudolf.
nrose
Quartz | Level 8
Hi,

Any other goodies for development of custom task?

Nick
ChrisHemedinger
Community Manager
Nick,

Check out this:
http://blogs.sas.com/sasdummy/index.php?/archives/173-Viewing-SAS-catalogs-from-SAS-Enterprise-Guide...

It's an example task that includes a C# source project so you can see how it works.

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

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
  • 11 replies
  • 985 views
  • 0 likes
  • 3 in conversation