Search code examples
c#.nethp-trim

Getting contents of HP TRIM Container in C#


I have the following block of code, connecting to our HP TRIM DB, and am trying to pull all the contents of a specific container.

using HP.HPTRIM.SDK;

Database db = new Database();
db.WorkgroupServerName = ConfigurationManager.AppSettings["TrimWorkgroup"];
db.Id = ConfigurationManager.AppSettings["TrimDBID"];
db.WorkgroupServerPort = Int32.Parse(ConfigurationManager.AppSettings["TrimPort"]);

TrimMainObjectSearch Contents = new TrimMainObjectSearch(db, baseObjectTypes.Record);
Contents.SetSearchString("container:" + ContainerNum);

Looking at whatever doco I could find, there only seems to be references to use the string based search, however there's a problem:

String based search of this kind is taking an age. About 25 seconds per container, which is far too long. Using the "string-based search editor" inside HP TRIM [7.3.4.5739] takes a similarly large amount of time, however using the "boolean search editor" method, and selecting "Contained Within" and entering the same container number, results are returned within a second.

So, my question after all of that, is there a way I can do a boolean search of "Contained within" in C#?


Solution

  • As it always goes, I was stumped until I stumbled upon this document: http://community.hpe.com/hpeb/attachments/hpeb/itrc-1015/11992/1/TRIM7.31_.NETSDK.pdf, which noted the method:

    Contents.SelectThoseWithin(CHR);
    

    This works, as I already have all the containers I need. This returns in a few milliseconds.