2

I am using Worksite API to query documents in iManage (version 8.5). I've listed my code below. If I only use one search parameter then the code works without any problem. However, if I add more than one parameter then it returns either null or no result (result.Count = 0)

Then I changed my code to use the ManOrQuery class (provided by my Worksite API, please see the commented lines) and that still doesn't work.

// Search for documents matching the specified date range.
iManageSearch rds = new iManageSearch(isession);

// Populate searchparameters
IManProfileSearchParameters searchparams = Utility.CreateUnpopulatedProfileParams(idms);

//searchparams.Add(imProfileAttributeID.imProfileCreateDate, dateRange.Value);
//searchparams.Add(imProfileAttributeID.imProfileAuthor, srchKey);
//searchparams.Add(imProfileAttributeID.imProfileFullText, srchKey);
searchparams.Add(imProfileAttributeID.imProfileDocNum, srchKey);
//searchparams.Add(imProfileAttributeID.imProfileDescription, srchKey);

// Search documents
IManDocuments results = rds.GetDocuments(Utility.BuildDatabaseList(isession.Databases), searchparams);

// tried the other way to search document


//QueryBuilder qb = new QueryBuilder();
//ManOrQuery orquery = qb.CreateORQuery;
//qb.AddORSearchFieldValue(orquery, imProfileAttributeID.imProfileDocNum, srchKey);
//qb.AddORSearchFieldValue(orquery, imProfileAttributeID.imProfileAuthor, srchKey);
//qb.AddORSearchFieldValue(orquery, imProfileAttributeID.imProfileFullText, srchKey);
//IManContents results = qb.GetContents(iworkarea, Utility.BuildDatabaseList(isession.Databases), (IManQuery)orquery);
int c = results.Count;

on my UI, I've a textbox for users to enter their search credential. And I would like to compare the search value with Author, DocNumber, DocTitle and also the content of documents. My goal is to build a query like (docAuthor=srchKey OR docNum=srchKey OR docDescription = srchKey ...). I've been banging my head, hope anyone can help me. Thank you.

PS: I also referred to a post here How to get information out of iManage / Desksite, but that doesn't work for me....

Ashraf.Shk786
  • 618
  • 1
  • 11
  • 23
George Huang
  • 2,504
  • 5
  • 25
  • 47

1 Answers1

3

I know its been a little while since this question was posted, and I have done some searching around stackoverflow and not been able to find much to help me on this problem, however I have managed to write some code that works (for me at least) and I hope if its too late to help you, it might help someone else.

I cant see how you set up the database in the code above, so there may be a problem there - as the syntax for adding your search parameters appears to be correct.

Update: I have spoken to our administrators, and it appears that to do searching, it depends on the indexer settings of the server. This is potentially why your code was not working. For me I had to disable the indexer from the database properties in the WorkSite Service manger, so that it would use SQL

            IManDMS dms = (IManDMS)Activator.CreateInstance(Type.GetTypeFromProgID("iManage.ManDMS"));

            IManSession session = dms.Sessions.Add(serverName);
            session.TrustedLogin2(userToken);

            IManDatabase database = session.Databases.ItemByName(libraryName);
            IManProfileSearchParameters searchparameters = dms.CreateProfileSearchParameters();

            // add search parameters            
            // this works (just to prove that we can search for a document)                
            searchparameters.Add(imProfileAttributeID.imProfileDocNum, "4882408");
            searchparameters.Add(imProfileAttributeID.imProfileCreateDate, new DateTime(2015, 04, 8).ToShortDateString());           

            // run the search
            IManContents searchResults = database.SearchDocuments(searchparameters, true);

            // process the results
            foreach (IManDocument item in ((IEnumerable)searchResults).OfType<IManDocument>())
            {   
                // do something with the document

            }

            session.Logout();
            dms.Sessions.RemoveByObject(session);
KerSplosh
  • 466
  • 8
  • 26