Desktop productivity for business analysts and programmers

EG Add-in Development problem -- Colocated workspace

Reply
Contributor
Posts: 47

EG Add-in Development problem -- Colocated workspace

obSAS2 = obSAS.GetNewWorkspace();

sasDbConn2 = new OleDbConnection();

sasDbConn2.ConnectionString = "provider=sas.iomprovider.1; SAS Workspace ID=" + obSAS2.UniqueIdentifier;

sasDbConn2.Open();

I'll create colocated workspaces for parallel processing, but when compiling codes and reaching the line to open an OleDbConnection, visual studio throws an exception showing:

The object 2C2A3465-99AF-4C56-8653-B5D5CCED59BF could not be found; make sure it was previously added to the object keeper.

Does anyone once meet the problem?

Frequent Contributor
Posts: 118

Re: EG Add-in Development problem -- Colocated workspace

you need to register your SAS workspace to the so called "object keeper" first.

You find an example here: http://savian.blogspot.com/2011/04/this-one-is-real-keeper.html

Contributor
Posts: 47

Re: EG Add-in Development problem -- Colocated workspace

Thank you, your post is very helpful. but there is another question.

You kwow, the purpose I create obSAS2 is to perform background processing and the user need not to face frozen UI and wait for a long time before the result coming out.

See the following codes, expecially the line with comments,

sasDbAdap.Fill(srcTable);

I don't why there is a NullReferenceException thrown, do you have experience of using obSAS with BackgroundWorker?

At last, If try to close obSAS2, is my way OK or not?

    obOK.RemoveObject(obSAS2);

    obSAS2.Close();  

/*----------------------------------------------------------------------------------------------------------------------*/

private void bgWorker_DoWork(object sender, DoWorkEventArgs e) {
    bgSuccess = true;

    if (obSAS2 == null || obSAS2.UniqueIdentifier.Length == 0) {
        obSAS2 = obSAS.GetNewWorkspace();
        SasServerCount++;
        obOK.AddObject(SasServerCount, SasServerCount+"Smiley FrustratedASBK", obSAS2);

    /*Stored Process Execution*/

        sasDbConn2 = new OleDbConnection();
        sasDbConn2.ConnectionString = "provider=sas.iomprovider.9.2; SAS Workspace ID=" + obSAS2.UniqueIdentifier;
        sasDbConn2.Open();
    }
}

void obSASLang2_StepError() {
    bgSuccess = false;
}

private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    OleDbDataAdapter sasDbAdap = new OleDbDataAdapter("select * from sashelp.class", sasDbConn);
    try {
        sasDbAdap.Fill(srcTable);  /*Error: NullReferenceException*/
    } catch (Exception ex) {
        bgSuccess = false;
    }
    if (bgSuccess)
      this.grd.DataSource = srcTable;
     
    /*Close obSAS2*/
    obOK.RemoveObject(obSAS2);
    obSAS2.Close();  
}

Frequent Contributor
Posts: 118

Re: EG Add-in Development problem -- Colocated workspace

I don't understand why you need a second SAS session just to prevent your UI from freezing?

If you use a backgroundworker (msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx) with your primary SAS Session to execute your SAS Code and write the results to a dataset in the backgroundworker thread you don't need a second SAS session.

Contributor
Posts: 47

Re: EG Add-in Development problem -- Colocated workspace

First, thank you for your reply.

I use 1 or more background SAS session before I want to run two or more job asychronously, for example, a ETL job and Forecast job at the same time.

I have found the reason: the DoWork method is in the background session, and the RunWorkerCompleted in the foreground session, so if I create obSAS2, get OleDbconnection2, run sas codes only in the same sesion, that's will be OK. I have tested it in my EG Add-in for several days, there is no problem, at last until today.

Although SAS open a door to enhance EG by development of Add-in,  there are still too few materials about the development, so another question.

SAS.Tasks.Toolkit.SasServer obServer;
try {
   obServer = new SAS.Tasks.Toolkit.SasServer( consumer.AssignedServer);

}......

How to get SAS workspace from the obServer, I know I can get SAS workspace from "consumer", but if connection between server and EG is broken, I must re-connect manually by hands, now I try to do it by codes.

I find the method SAS.Tasks.Toolkit.SasServer.GetWorkspaceIdentifier()

Remarks

This method will force a connection to the SAS server, if the connection does not yet exist. The connection might cause a slight delay. It might also force a prompt for user ID and password, depending upon the configuration of the server and its metadata.

Community Manager
Posts: 2,697

EG Add-in Development problem -- Colocated workspace

You're correct.  The API doesn't connect all of the dots in this case.

You can get the WorkspaceIdentifier, which exists only if you are already connected to a session.  That will give you the workspace ID for the session that EG knows about (not any second session you might have spawned using code from your previous post).

But you cannot get the IWorkspace handle from the SasServer class.  Given the workspace ID, you can probably find it using the ObjectKeeper route.

You can get the IWorkspace from the ISASTaskConsumer, given the server name.  But that will throw the logic back into EG to connect to a server as well, if you haven't already got a connection.  Again, it's the one-and-only SAS workspace connection (per logical server) that EG will manage for you.

Chris

Ask a Question
Discussion stats
  • 5 replies
  • 648 views
  • 0 likes
  • 3 in conversation