Super Contributor.. AldoH Super Contributor..
Super Contributor..
537 views

TrimMainObjectSearch need Dispose?

Jump to solution

Hello

I am new using SDK with HPRM 8.3 Through this forum I got information that is helping me understand how to implement code through the SDK.I am using VS 2017 to develop the code but I have a question about TrimMainObjectSearch and Dispose. As I have read, TrimMainObjectSearch does not require Dispose, but when compiling the example code I am testing, VS 2017 generates an error when using TrimMainObjectSearch.

Can you help me solve this error?

Thank you,

CODE:

using System;
using HP.HPTRIM.SDK;
namespace MyFirstConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Database database = new Database())
            {
                database.Id = "F1";
                database.Connect();
                using (TrimMainObjectSearch search = new TrimMainObjectSearch(database, BaseObjectTypes.Record))
                {
                    search.SetSearchString("electronic");
                    {
                        foreach (Record record in search)
                        {
                            Console.WriteLine(record.Number);
                        }
                    }
                }
            }
        }
    }
}
 
ERROR MESSAGE

Error CS1674 'TrimMainObjectSearch': the type used in a using statement must be implicitly converted to 'System.IDisposable'
1 Solution

Accepted Solutions
Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Hi  Jan,

Thanks was very useful and now I can connect to the database without problem.

I still have many doubts and things to learn, but now that I can connect to the database and perform searches, I can move forward and achieve what I need. I do not know if there is a step-by-step manual that can help me to move faster in the use of SDK and API in HPRM. If it exists, do you know where I can get one?

This work for me.

            Database objDB = new Database();
            objDB.Id = "TD";
            objDB.WorkgroupServerName = "###.###.###.###"; // WGS ip
            objDB.AlternateWorkgroupServerName = "###.###.###.###";  // WGS ip 
            objDB.AuthenticationMethod = ClientAuthenticationMechanism.ExplicitWindows;
            objDB.SetAuthenticationCredentials("computer server name\\user", "password");
            objDB.Connect();

Thanks Jan and David for all your help

Warm regards,

Aldo

0 Likes
11 Replies
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch need Dispose?

Jump to solution

This is probably old sample code from back when TrimMainObjectSearch was Disposable.  If you are getting the error just stop using the 'using' statement around TrimMainObjectSearch.


Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Thanks David, when I do not use "using", the error is corrected.

Forgive me for an additional consultation. When I run the example, it can not connect to the database. I have used ".ConnectAs" to try to specify the user and password, but I still can not connect to the database. I have even specified the name of the server with ".WorkgroupServerName" using both the name and the IP address, but I can not connect to the database to achieve the search.

Thanks again.

P.S. Forgive me if I ask very basic questions, but it is my first approach to SDK. I need to be able to send documents, records and start workflows from an external application to HPRM and that is why I am starting with SDK. I have looked for some document that explains step by step how to do it, but I have not got it and that is why I ask so much. Really, thank you very much for your help.

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Assuming you ar running as a user who exists in CM you should not need to call ConnectAs(), just Connect() will do.

If you are running the code on the same machine as where the worgroup server (WGS) is running use 'local' for the WorkgroupServerName name, otherwise the machine name.

It is possible that your WGS does not support integrated authentication, maybe you need to use basic, you will need to check with an administrator.  If 'integrated Windows' is not supported you will need to set the auth method using Database.AuthenticationMethod.

 

Usually if you cannot connect there is an error message?

 

Database db = new Database();

db.WorkgroupServerName = "local";
db.Id = "M1";
db.Connect();


Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Hello David

Thanks for your help.

Currently there are 2 WGS primary and one alternate. My user is registered in the WGS.I am trying to execute the code from the computer I use for development.I will validate with the administrator if the WSG supports integrated authentication.

In fact when executing the code I get this error. 

Unhandled exception: System.Security.SecurityException: The source was not found, but some or all of the event logs could not be searched. To create the source, you need permission to read all the event logs in order to verify that the new source name is unique. Inaccessible records: Security, State.

Thank you,

0 Likes
Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Hi 

I'm getting this error when trying to connect to de database. Can you help me?...

+ $ exception {"Error connecting to HPE Records Manager data set 'TD' in HPE Records Manager Workgroup Server '172.17.114.121'. Unable to connect to HPE Records Manager Workgroup Server at '172.17.114.121'. [RCF : Server-side SSPI authorization failed OS: -2146893044 - Unable to log in] "} HP.HPTRIM.SDK.TrimException

Thank you,

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch need Dispose?

Jump to solution

This is just telling you that the Windows user you are logged in as does not have access to login to Records Manager.


Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Thanks, David,

Forgive my ignorance, I'm a novice in this, but I can not get my code to connect to the database. In effect, my windows user is not a domain userI do not know if I am correctly understanding the function of ConnectAs (), but as I understood it, I could connect to the database if I use a user and password registered as a user in the Records Manager server. Is it like that?. I've done the test in my code, but I still can not connect.I can connect to records manager from my computer and when I run HPRM, it shows me a login window. I guess this is equivalent to using ConnectAss (), is that so?

These are my code lines where I try to connect.

           Database objDB = new  Database();
            objDB.Id = "TD";
            objDB.WorkgroupServerName = "###.###.###.###"; // ip address
            //objDB.AlternateWorkgroupServerName = "###.###.###.###"; // ip address
            objDB.ConnectAs("TRIMServices", "xxxxxx");

When I execute the code I get this message.

Unhandled exception: HP.HPTRIM.SDK.TrimException: Error in connection to the database ... The username or password are not correct. (0x0000052e).    in HP.HPTRIM.SDK.Database.ConnectAs (String userName, String password)

And if I use Connect (), the message is this.

Unhandled exception: HP.HPTRIM.SDK.TrimException: The authentication method 'Windows Authentication' requires a user interface to obtain credentials. in HP.HPTRIM.SDK.Database.Connect ()

 

Forgive me for importunarte to you with so many questions.

 

 

0 Likes
Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

By the way this is the login window that shows when I run HPRM from my computer.login.png

0 Likes
JanMartin Outstanding Contributor.
Outstanding Contributor.

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Hey Aldoh, try this:

Database objDB = new  Database();
objDB.Id = "TD";
objDB.WorkgroupServerName = "###.###.###.###"; // ip address
 //objDB.AlternateWorkgroupServerName = "###.###.###.###"; // ip address
objDB.AuthenticationMethod = ClientAuthenticationMechanism.ExplicitWindows;
objDB.ConnectAs("TRIMServices", "xxxxxx");

In 9.3 there is also a SetAuthenticationCredentials function which I haven't seen before, maybe you need to set that too?

Super Contributor.. AldoH Super Contributor..
Super Contributor..

Re: TrimMainObjectSearch need Dispose?

Jump to solution

Hi  Jan,

Thanks was very useful and now I can connect to the database without problem.

I still have many doubts and things to learn, but now that I can connect to the database and perform searches, I can move forward and achieve what I need. I do not know if there is a step-by-step manual that can help me to move faster in the use of SDK and API in HPRM. If it exists, do you know where I can get one?

This work for me.

            Database objDB = new Database();
            objDB.Id = "TD";
            objDB.WorkgroupServerName = "###.###.###.###"; // WGS ip
            objDB.AlternateWorkgroupServerName = "###.###.###.###";  // WGS ip 
            objDB.AuthenticationMethod = ClientAuthenticationMechanism.ExplicitWindows;
            objDB.SetAuthenticationCredentials("computer server name\\user", "password");
            objDB.Connect();

Thanks Jan and David for all your help

Warm regards,

Aldo

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: TrimMainObjectSearch need Dispose?

Jump to solution

There are the online docs.


Blog | Samples | HPE CM 9.3 SDK Docs
**Any opinions expressed in this forum are my own personal opinion and should not be interpreted as an official statement on behalf of MicroFocus**
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.