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)
FileSite Search WorkSpaces
Bob1
Hi,
I am using the IManExt2.WorkspaceSearchCmd which basically is the same function as clicking the following in FileSite in the outlook interface: "FileSite" => "Search Workspaces". Also I am programing within an ICommand interface.
I want to call this search for work spaces and basically return a count of how many workspaces it has found. However I am unable to this without the form popping up. Is there a way to do this without the UI popping up?
Below is what I have at the moment (_context is the ContextItems object in the ICommand object):
ManDMS dms = new ManDMS();
IManFolderSearchParameters searchParameters = dms.CreateWorkspaceSearchParameters();;
searchParameters.Add(imFolderAttributeID.imFolderCustom2, "SearchId");
_context.Add("IManSearchParameters", searchParameters);
WorkspaceSearchCmd searchCommand = new WorkspaceSearchCmd();
searchCommand.Initialize(_context);
searchCommand.Update();
searchCommand.Execute();
IManFolders folders = (IManFolders) _context.Item("SearchedFolders");
int count = folders.Count;
Any help would be much appreciated.
Cheers,
Bob1
Find more posts tagged with
Comments
jny
You should just use the low-level API (imanage.dll) by calling the SearchWorksapces (IManDatabse/IManSession) Method instead of the command object if you don't plan on interfacing with the user to get the search criteria.
//~ Database search
//db is a valid handle to an IManDatabase Object
IManFolders workspaces = db.SearchWorkspaces
(dms.CreateProfileSearchParameters(), searchParameters); //assuming searchParameters is populated.
//~ Cross-database search
//sess is a valid handle to an IManSession Object
ManStrings dblist = new ManStringsClass();
foreach (IManDatabase d in sess.Databases)
{
dblist.Add(d.Name);
}
IManFolders workspaces = sess.SearchWorkspaces(dblist, dms.CreateProfileSearchParameters(), searchParameters); //assuming searchParameters is populated.
Bob1
I am running a workspace search from the ICommand interface with the below section of code. The workspace search seems to work if I use a parameter like imFolderAttributeID.imFolderName however when I switch it to imFolderAttributeID.imFolderCustom2 it does not seem to work. My question is do I have to do anything else to search on custom properties or am I establishing the IManDMS, IManSession & IManDatabases properly inorder to search on custom fields?
// _context is the ContextItems collection from the ICommand.
// "irn" is just a search string being passed in.
// Extract out server name
Array sessions = (Array) _context.Item("SelectedNRTSessions");
NRTSession contextSession = (NRTSession) sessions.GetValue(0);
string serverName = contextSession.ServerName;
// Create context in IMAN library
IManDMS dmsServer = new ManDMS();
IManSession session = dmsServer.Sessions.Add(serverName);
session.Login(contextSession.UserID, contextSession.Password);
IManDatabases databases = session.Databases;
ManStrings databaseList = new ManStringsClass();
foreach (IManDatabase database in databases)
{
databaseList.Add(database.Name);
}
// Create IRN search parameter
IManWorkspaceSearchParameters searchParameters = dmsServer.CreateWorkspaceSearchParameters();
searchParameters.Add(imFolderAttributeID.imFolderCustom2, irn);
// Search the workspaces
IManFolders workspaces =
session.SearchWorkspaces(databaseList, dmsServer.CreateProfileSearchParameters(), searchParameters);
// Return if workspace exists with IRN
if (workspaces != null && workspaces.Count > 0)
{
return true;
}
return false;
Any help much appreciated.
Bob1
Bob1
Found the problem, should have populated the profile prameter instead of the search parameters.
jny
What do you mean by searching by imFolderAttributeID.imFolderCustom2 does not work? Do you mean that it does not return the expected results?
Did you put any values in the IManCustomProperties of the Workspace when you had it created? If not, there's nothing to return when you query for it from the WorkspaceSearchParameters Collection.
It might be worth mentioning that the imFolderCustom2 Property returns the values stored inside the IManCustomProperties which is not where a workspace profile field, matter/CUSTOM2, value is stored. In other words, the CUSTOM2 field value of the workspace profile is represented by the imProfileAttributeID.imProfileCustom2 - not the imFolderAttributeID.imFolderCustom2.
If you want to search for a workspace by its matter (CUSTOM2) value, then add your search value in the IManProfileSearchParameters, like so:
IManProfileSearchParameters profparams = dms.CreateProfileSearchParameters();
profparams .Add(imProfileAttributeID.imProfileCustom2, "1000"); //Arbitrary example of a valid matter alias.
Bob1
That's exactly right jny.
Basically didn't know that there were 2 seperate sorts of properties for workspaces. Profile properties and Folder properties. Once I sorted that out the expected search results were correct.
Cheers
jny.