September 14 connecting to Documentum using. neti've spoke in an earlier post about working with Documentum in. net. in this post, I'll show you how to connect to a docbase, and get the list of cabinets. the following code will connect to a docbase. it assumes that you have a username, password and docbase variables declared that contain valid information: // get a client objectdfclientx _ clientx = new dfclientx ();
Idfclient _ client = _ clientx. getlocalclient ();
If (_ client = NULL)
Throw new exception ("failed creating Documentum client ");
// Retrieve the client's version
Console. writeline ("using DFC version '{0}'", _ clientx. getdfcversion ());
// Create an object with the credentials of the user
Idflogininfo _ logininfoobj = _ clientx. getlogininfo ();
_ Logininfoobj. setuser (username );
_ Logininfoobj. setpassword (password );
// Create a new session to the requested docbase
Idfsession _ session = _ client. newsession (docbase, _ logininfoobj );
If (_ session = NULL |! _ Session. isconnected ())
{
Console. writeline ("failed conecting to Documentum ");
If (_ session! = NULL)
{
Console. writeline ("DFC messages: \ r \ n {0}", _ session. getmessage (1 ));
}
Return;
}
Console. writeline ("using server version' {0} '", _ session. getserverversion ());
Now, once we're new to the Documentum docbase, We'll list all the cabinets:
Idfquery query = _ clientx. getquery ();
// Quering the "dm_cabinet" Table returns only items of dm_cabinet type
Query. setdql (
"Select r_object_id, object_name, title from dm_cabinet ");
// Query the session for the cabinets
Idfcollection Col = query.exe cute (_ session, (INT) dfclib. tagdfquerytypes. idfquery_df_read_query );
// Loop through all the items in the collection
While (Col. Next ())
{
// Get the current item from the collection
Idftypedobject typedobj = col. gettypedobject ();
// Print the item's name
Console. writeline ("Cabinet name: {0}", typedobj. getstring ("object_name "))
}
Col. Close ();
One of the most important thing to remember, is that you have to close the idfcollection. each session has a very limited number of Collections It can have open at the same time. if you need more collections, I wocould suggest just caching the items inside. net collection for later use.