Only retrieving 512 workspaces from the database object...

(I feel a bit guilty in asking for help without having helped somebody first, but I've only recently started to work with the SDK - sorry).

I'm trying to write a small C# application that builds a tree view that we could use to browse workspaces almost in the same manner that they used to before we switched to worksite.

The problem I'm having is that the number of workspaces returned from
oWorkspaces = oDB.Workspaces;
seems to be limited to 512. Is there a way around this? (Our databases contain several thousand workspaces.)

The code below loops through each database, then through each workspace within that database and then through the top level folders of that workspace.
The workspaces are grouped by creating a fee earner node which are stored in a hashtable to save searching for it (I've probably overcooked that a little),
and the workspace nodes are added to the appropriate fee earner node. Workspaces and folder nodes have a string in their tag property and there's a 'open' button that opens outlook to that location.

Is there a way of marking the next bit as code?

private ManDMS m_oDMS;
private IManSession m_oSession;
private IManWorkArea m_oWorkArea;

private Hashtable htFeeEarners = new Hashtable();

private bool LoadTreeView()
//Date Started:22/05/2014 08:44:57
bool blnResult = false;

IManDatabases oDBs = m_oSession.Databases;


Debug.WriteLine("Databases - " + oDBs.Count);

for (int intDBCount = 1; intDBCount <= oDBs.Count; intDBCount++)

IManDatabase oDB = oDBs.ItemByIndex(intDBCount);
string strDBName=oDB.Name;

//loop through the workspaces
IManWorkspaces oWorkspaces = null;
oWorkspaces = oDB.Workspaces; //<----------Problem is here - only getting 512

Debug.WriteLine("Workspaces - " + oWorkspaces.Count);

for (int intWSCount = 1; intWSCount <= oWorkspaces.Count; intWSCount++)

//get fee earner from workspace
IManWorkspace oWS = (IManage.IManWorkspace)oWorkspaces.ItemByIndex(intWSCount);

string strFeeEarner = oWS.GetAttributeValueByID(imProfileAttributeID.imProfileOperator);
strFeeEarner = strFeeEarner.ToUpper();

//create or retrieve the fee earner tree node
TreeNode ndeFeeEarner;
ndeFeeEarner = null;
if (htFeeEarners.ContainsKey(strFeeEarner))
ndeFeeEarner = (TreeNode)htFeeEarners[strFeeEarner];
//first time we've seen the fee earner
ndeFeeEarner = treeView1.Nodes.Add(strFeeEarner);

TreeNode ndeDB;
ndeDB = null;
//now the database node
if (ndeFeeEarner.Nodes.ContainsKey(strDBName))
ndeDB = ndeFeeEarner.Nodes[strDBName];

//now add the workspace to the db node
TreeNode ndeWorkspace = new TreeNode(oWS.Name);
ndeWorkspace.Tag = "THESEUS\r\n" + "!nrtdms:0:!session:TSERVER:!database:" + strDBName +":!folderSmiley Surprisedrdinary," + oWS.ObjectID;

//top level folders only - todo - make this part optional
IManFolders oFolders = oWS.DocumentFolders;
for (int intFolderCount = 1; intFolderCount <= oFolders.Count; intFolderCount++)

IManFolder oFolder=(IManFolder)oFolders.ItemByIndex(intFolderCount);
TreeNode ndeFolder=ndeWorkspace.Nodes.Add(oFolder.Name);
ndeFolder.Tag = "THESEUS\r\n" + "!nrtdms:0:!session:TSERVER:!database:" + strDBName + ":!folderSmiley Surprisedrdinary," + oFolder.ObjectID;




catch (Exception ex)
Debug.WriteLine(ex.Message + " " + "LoadTreeView");
blnResult = false;
return blnResult;

//and the code to open outlook at that location

private void btnOpen_Click(object sender, EventArgs e)
//create a short cut to the selected object and run it.

string strTag = (string)treeView1.SelectedNode.Tag;

if (strTag != "")
string strFileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".nrl";

//save the file
FileUtils.WriteFile(strFilename: strFileName, strText: strTag);

//run the file


Sign In or Register to comment.