Desktop productivity for business analysts and programmers

SAS Enterprise Guide Custom Tasks

Reply
Frequent Contributor
Posts: 91

SAS Enterprise Guide Custom Tasks

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
Community Manager
Posts: 2,887

Re: SAS Enterprise Guide Custom Tasks

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
Frequent Contributor
Posts: 91

Re: SAS Enterprise Guide Custom Tasks

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
Community Manager
Posts: 2,887

Re: SAS Enterprise Guide Custom Tasks

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
Frequent Contributor
Posts: 91

Re: SAS Enterprise Guide Custom Tasks

Thanks Chris, just what I needed.

Nick
Frequent Contributor
Posts: 91

Re: SAS Enterprise Guide Custom Tasks

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
Community Manager
Posts: 2,887

Re: SAS Enterprise Guide Custom Tasks

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
N/A
Posts: 0

Re: SAS Enterprise Guide Custom Tasks

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.
Community Manager
Posts: 2,887

Re: SAS Enterprise Guide Custom Tasks

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
N/A
Posts: 0

Re: SAS Enterprise Guide Custom Tasks

Hi Chris,

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

Rudolf.
Frequent Contributor
Posts: 91

Re: SAS Enterprise Guide Custom Tasks

Hi,

Any other goodies for development of custom task?

Nick
Community Manager
Posts: 2,887

Re: SAS Enterprise Guide Custom Tasks

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
Ask a Question
Discussion stats
  • 11 replies
  • 216 views
  • 0 likes
  • 3 in conversation