Desktop productivity for business analysts and programmers

Custom Task : ISASTaskDataSink

Reply
Contributor
Posts: 36

Custom Task : ISASTaskDataSink

Hello

I need to know how to implement and to use ISASTaskDataSink class. With a sample code, it will be perfect.

The custom task that i develop does not use any SAS code, but generates, however, some SAS tables in existant libraries. I need to insert these tables in the project.

Thank's
Community Manager
Posts: 2,697

Re: Custom Task : ISASTaskDataSink

Victor,

I can supply some sample code, but first: are you developing this for EG 4.1 or 4.2?

Chris
Contributor
Posts: 36

Re: Custom Task : ISASTaskDataSink

For EG 4.1.

Is there a difference? Soon, we will migrate for 4.2.


Thnak's
Community Manager
Posts: 2,697

Re: Custom Task : ISASTaskDataSink

Victor,

If all you need to do is add data to the project, your task can do this by using the ISASTask.OutputDataCount and ISASTask.OutputDataInfo methods. Here is an example to add SASHELP.CLASS from the current server:

[pre]
public int OutputDataCount
{
get { return 1; }
}

public SAS.Shared.AddIns.OutputData OutputDataInfo(int Index, out string Source, out string Label)
{
string server = _consumer.AssignedServer; // ISASTaskConsumer reference
string libref="SASHELP";
string member="CLASS";
Source = string.Format(@"SAS:\Dataset\{0}\{1}\{2}", server, libref, member);
Label = "SASHELP.CLASS";
return SAS.Shared.AddIns.OutputData.SdsName;
}
[/pre]

ISASTaskDataSink is used as a notification from the application that your input data has changed, or that your task should consider generating new names for output data (in the scenario where a task is being re-run, and the user has selected "No" for the "Replace existing results?" question).

Chris
Contributor
Posts: 36

Re: Custom Task : ISASTaskDataSink

Thanks for your rapid answer


Ok. I tried before to use this method under VB with no succes. (I use VB for Custom Task)

Your code gaves me an idea. I tried it under VB and C#. Under VB, no way, it still not working. Under C#, it works fine. Curious

Note:
I changed under both languages the property "RunLog" to return some text and the property "GeneratesSasCode" to return False.


Some explenations ???
Contributor
Posts: 36

Re: Custom Task : ISASTaskDataSink

Sorry

I was not exactly the same method. I tried to use

OutputDataInfo=OutputData.Libref.

It does not works, probably because i don't know the exact syntax.

Can you give me the exact syntax for this also?


Thank's a lot for every thing
Contributor
Posts: 36

Re: Custom Task : ISASTaskDataSink

One more question.

If there is more than one table, what is the exact syntax ?



Thank's
Contributor
Posts: 36

Re: Custom Task : ISASTaskDataSink

It's Ok now. For more then one table, i found it. I use the Index to return different tables.

Thanks
Community Manager
Posts: 2,697

Re: Custom Task : ISASTaskDataSink

Some explanation:

You use the SAS.Shared.AddIns.OutputData.Libref in the "normal" case, when your task generates a SAS program that, when EG runs it on the assigned SAS server, creates/modifies data that you can refer to using the LIBREF.MEMBER syntax.

But in your case, the task isn't running a SAS program to create the data. It's doing something else behind the scenes (I don't know what; that's your secret sauce). But you want to make sure that EG adds the new data to the project after the task is run, so you can supply the full reference with the SAS.Shared.AddIns.OutputData.SdsName reference. We don't document the SdsName schema (that's part of our secret sauce), but this example of building a data set reference should cover the majority of the use cases that folks come up with.

Chris
Contributor
Posts: 36

Custom Task : ISASTaskDataSink

Hello

I'm back because i need help. I'm writing some Custom Tasks for Enterprise Guide 4.3.

I'm using for that, Visual Studio 2008 with the template SAS.Tasks.VBTemplate42 delivered by SAS.

But i notice that the property "OutputDataCount" is ReadOnly and the function "OutputDataInfo" is impossible to override because it is not declared Overridable.

How can i write what was written for Guide 4.1 listed in this discussion ?

Will I have to write everything without using the template ?

In this case, what's the point of the template ?

Where can i find detailed documentations ?

Thank's

Community Manager
Posts: 2,697

Custom Task : ISASTaskDataSink

Victor,

In the template, the SasTask class now implements many of the mundane parts of the task API contract.  You override just the parts that your task needs.  As a result, you'll have many fewer lines of code that deal with the ISASTask* implementation.

To control your output data count, you override the OutputDataCount property in your task class, and return the number that is correct for your task. 

And you override the OutputDataDescriptorList property to return more details:

        public override int OutputDataCount
        {
            get { return 1; }
        }

        // build the output description for the data set
        public override System.Collections.Generic.List OutputDataDescriptorList
        {
            get
            {
                System.Collections.Generic.List outList = 
                    new System.Collections.Generic.List();

                string[] parts = settings.OutputData.Split(new char[] { '.' });
                if (parts.Length == 2)
                {
                    outList.Add(
                        // use this helper method to build the output descriptor
                        SAS.Shared.AddIns.SASTaskDataDescriptor.CreateLibrefDataDescriptor(
                            Consumer.AssignedServer, parts[0], parts[1], "")
                        );
                }
                return outList;
            }
        }

Let me know if you need a VB.NET example of this.

Chris

Contributor
Posts: 36

Custom Task : ISASTaskDataSink

Hello

Indeed, it has changed from the 4.1. Without your help, I would never have found.

That's why i'm very interested in any document or sample on Custmer Tasks, because I do a lot of them.  It is very difficult to find something on them.

Thank's

Ask a Question
Discussion stats
  • 11 replies
  • 247 views
  • 0 likes
  • 2 in conversation