Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Searching for a Workspace in C#
Maroun
Hi Guys,
I am trying to write an app to create workspaces, i have managed to create the below and it works fine. My only issue is how i would search for an existing workspace by name if it allready exists.
Any help would be greatly apreciated.
{
string strDSN = "data source = ProductionSQL; initial catalog = aps_dsql; user id = admin; pwd =; connect timeout = 50000";
string strSQL = "select f.cltsortname, c.cltsortname, c.cltfamilygroup from cdbclient c left join cdbclient f on c.cltfamilygroup = f.objinstid where c.cltfamilygroup is not NULL and f.cltsortname is not NULL and c.cltfamilygroup = 19";
SqlConnection myConn = new SqlConnection(strDSN);
SqlDataAdapter myCmd = new SqlDataAdapter(strSQL, myConn);
myConn.Open();
DataSet dtSet = new DataSet();
myCmd.Fill(dtSet, "Clients");
DataTable dTable = dtSet.Tables[0];
foreach (DataRow dtRow in dTable.Rows)
{
listBox1.Items.Add(dtRow[1].ToString());
}
foreach (DataRow dtRow in dTable.Rows)
{
strServer = this.txtServer.Text;
IManDMS myDMS = new ManDMSClass();
IManSession mySession = myDMS.Sessions.Add(strServer);
mySession.TrustedLogin();
IManDatabase myDatabase = mySession.Databases.ItemByIndex(1);
ManStrings myDatabaseList = new ManStringsClass();
myDatabaseList.Add(myDatabase.Name);
IManWorkspace myWorkspace = myDatabase.CreateWorkspace();
myWorkspace.Name = dtRow[0].ToString();
myWorkspace.Description = dtRow[0].ToString();
myWorkspace.SubType = "work";
myWorkspace.SetAttributeByID(imProfileAttributeID.imProfileCustom1, "77720");
myWorkspace.SetAttributeByID(imProfileAttributeID.imProfileCustom2, "");
string filePath = Path.GetTempFileName();
IManProfileUpdateResult updateResult = myWorkspace.UpdateAllWithResults(filePath);
if (updateResult.Succeeded == true)
{
MessageBox.Show("Succeeded in creating the new workspace, " + myWorkspace.Name);
}
IManDocumentFolder myDocFolder1 = myWorkspace.DocumentFolders.AddNewDocumentFolderInheriting(dtRow[1].ToString(), "This is a Test");
}
}
Thanks.
Find more posts tagged with
Comments
jny
ManDMS dms = new ManDMS();
IManSession sess = dms.Sessions.Add("MYSERVERNAME");
sess.TrustedLogin();
ManStrings dblist = new ManStrings();
dblist.Add(sess.Databases.ItemByIndex(1).Name); //list of databases by which to search
IManWorkspaceSearchParameters parms = dms.CreateWorkspaceSearchParameters();
parms.Add(imFolderAttributeID.imFolderName, "My Workspace"); //Name of the target workspace
IManFolders wss = sess.SearchWorkspaces(dblist, dms.CreateProfileSearchParameters(), parms);
if (wss.Empty == false)
{
IManWorkspace ws = (IManWorkspace)wss.ItemByIndex(1);
}
RJKnott
My advice would be to keep a record of created workspaces as a list of objectid's as these are unique and unchanging where workspace name is a variable.
Maroun
Thanks for the sample code jny, this works fine. would you have an example in vb.net also ?
jny
Here you go...
[VBNET]
=============================
Dim dms As IManDMS = new ManDMS()
Dim sess As IManSession = dms.Sessions.Add("MYSERVERNAME")
sess.TrustedLogin()
Dim dblist As ManStrings = new ManStrings()
dblist.Add(sess.Databases.ItemByIndex(1).Name) 'List of databases by which to search
Dim parms As IManWorkspaceSearchParameters = dms.CreateWorkspaceSearchParameters()
parms.Add(imFolderAttributeID.imFolderName, "My Workspace") 'Name of the target workspace
Dim wss As IManFolders = sess.SearchWorkspaces(dblist, dms.CreateProfileSearchParameters(), parms)
If False = wss.Empty Then
Dim ws As IManWorkspace = wss.ItemByIndex(1)
End If
=============================