Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »


 
Opens an _EDMserver_ session. This feature has been implemented to provide all EDMInterface functionality through the remote EDMInterface calls. This function is only applicaple for the LOCAL_CONTEXT communication type.
No access to data in a local _EDMdatabase_ is permitted before an _EDMserver_ session is opened by this operation. If the caller is not already connected to an EDMserver by the edmiRemoteConnect operation, this operation will connect the caller to the EDMserver with the default EDMuser account 'sdai-user' and the EDMgroup account 'sdai-group'.
Related function: edmiRemoteCloseSession
Header:
#include "sdai.h"
Prototype:
EdmiError edmiRemoteOpenSession(SdaiServerContext serverContextId,
                                 SdaiInstance      *sessionId,
                                 SdaiInvocationId  *edmiInvocationId);  
 
Arguments:

serverContextId

Context identification, from edmiDefineServerContext

sessionId

A variable that will receive the sessionId. A sessionId is an instance of the entity SDAI_SESSION within the SDAI_SessionModel. This is a handle to all repositories and models in the EDMdatabase.

edmiInvocationId

Currently not used.

Returns:
A completion code of datatype EdmiError is the returned function value. The completion code has the following values:
Completion code = 0 : Operation successfully performed.
Completion code != 0: Error in operation. Completion code is an _EDMinterface_ error code. Use edmiGetErrorText to get the error text corresponding to the error code.
Example:
EdmiError rstat;
SdaiSession sessionId;
SdaiServerContext myLocalContext;
SdaiRepository repId;
SdaiModel modId;
SdaiAggr aggrId;
SdaiInteger nInst;
SdaiString unavailMsg;
 
/* Define Remote Server Context */
rstat = edmiDefineServerContext("MyLocalContext",
NULL, NULL, NULL, "LOCAL_CONTEXT", NULL, NULL, 
NULL, NULL, NULL, NULL, NULL, &myLocalContext); 
 
/* Connect to a local database. This operation will
connect the EDMthick client to the EDMserver. It 
will fail if the server has no more available 
named users. After the connect, the client may 
be identified on the server by edmiRemoteWhoIsOn() */ 
rstat = edmiRemoteConnect(myLocalContext, "Johnny",
"Supervisor", "cf37ftr", &unavailMsg, NULL); 
 
/* Open a session in the local database */
rstat = edmiRemoteOpenSession(myLocalContext, &sessionId, NULL);
 
/* Open the 'MyRepository' repository */
rstat = edmiRemoteOpenRepository(myLocalContext,
"MyRepository", sdaiRW, NULL, 0, 0, &repId, NULL);  
 
/* Open the 'MyModel' model. This loads a
copy of the model to the local file system. */ 
rstat = edmiRemoteOpenModel(myLocalContext, "MyRepository",
"MyModel", sdaiRW, NULL, 0, 0, &modId, NULL); 
 
. . .
 
/* The local copy of 'MyModel' is loaded when
the model is opened. It remains unchanged 
until a transaction is started. Then the local 
copy will be syncronized with the EDMserver to 
include any changes made by other users in the 
meantime */ 
rstat = edmiStartTransaction();
 
/* Count the current number of instances
of type MyEntity in MyModel */ 
rstat = edmiRemoteGetEntityExtentBN(myLocalContext,
"MyRepository", "MyModel", "MyEntity", 0,  
&aggrId, &nInst, NULL, NULL); 
printf("\n%d instances of MyEntity in MyModel.", nInst);
 
/* Terminate the transaction */
rstat = edmiAbortTransaction();
 
/* Close the model. Some operations may not be
performed on the model by other users for  
as long as it is opened by this client. */ 
rstat = edmiRemoteCloseModel(myLocalContext,
"MyRepository", "MyModel", NULL, 0, 0, NULL); 
 
. . .
 
/* Close the repository. This would implicitely have
closed the model as well. Some operations may not be 
performed on the repository by other users for  
as long as it is opened by this client. */ 
rstat = edmiRemoteCloseRepository(myLocalContext,
"MyRepository", NULL, 0, 0, NULL); 
 
. . .
 
/* Close the session. This will implicitely
close all open models and repositories. */ 
rstat = edmiRemoteCloseSession(myLocalContext, NULL);
 
/* Disconnect. The occupied named user on the
EDMserver will be released. */ 
rstat = edmiRemoteDisconnect(myLocalContext, NULL);
. . .

  • No labels