Get Current User within Lookups API

Discussions related to order tracking development with the ProForm module.

Moderator: Phil Barton

czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Get Current User within Lookups API

Post by czentman »

How do I get the current user logged in while working with the looups API?
Mark McKenna

Re: Get Current User within Lookups API

Post by Mark McKenna »

Generally, you can obtain the current user via the SoftPro.OrderTracking.Client.IOrder.CurrentUser property. The SDK Help file includes additional details about that property.
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: Get Current User within Lookups API

Post by czentman »

Are you telling me that the only way I can get the userid of who's logged in is via an open order with IOrder. There's no way to retrieve this info with another object if I have no other need to open an order?
Mark McKenna

Re: Get Current User within Lookups API

Post by Mark McKenna »

No. That was one way to do it using the current API's IOrder interface.

Alternatively, if all you need is the name, it is preferable to use the AuthenticatedUserName property of the SoftPro.Select.Client.SelectServer object. Like this:

Code: Select all

// note that from inside the application, if you have a runtime service provider, you can just get the SelectServer service instead of creating a new one each time
SoftPro.Select.Client.SelectServer sps = GetService<SoftPro.Select.Client.SelectServer>( );
SoftPro.OrderTracking.Client.Lookups lookups = sps.GetService<SoftPro.OrderTracking.Client.Lookups>( );
String username = sps.AuthenticatedUserName;
The SDK Help provides additional details about the SelectServer class and the AuthenticatedUserName property.
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: Get Current User within Lookups API

Post by czentman »

This authenticated user give me back "admin" which is how I manually logged in via code to the select server. It's no who is logged into the proform system. Do I need to open an order to see who the user is that is logged in to the system, not the login of the select server that I programmatically connected to. In fact, even how I connect to the select server via "admin" is not ideal, I would really first like to have the userid of who's logged in to the system, and use that login id to get into the select server. Is the only way to get who is logged in to the system, via the IOrder, meaning to have an open order already?
Mark McKenna

Re: Get Current User within Lookups API

Post by Mark McKenna »

How/where are you accessing the SelectServer from your code? In that latest code snippet (01/30) I described how to obtain the SelectServer service directly without creating a new one each time. In that case, the authenticated user is going to be the person that originally logged into Select. If you're creating a new SelectServer service instance each time, then certainly the authenticated user will reflect the credentials that were supplied upon creation (in your case, "Admin").
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: Get Current User within Lookups API

Post by czentman »

Your right, I have the code creating a new every time. Well that's because I copied the code that people recommended when working with the Lookups API. Anyway, I tried replacing the new sps with your code and I got an error on the first line - SoftPro.Select.Client.SelectServer sps = GetService<SoftPro.Select.Client.SelectServer>( );. I'm not sure what's wrong, I have that object SoftPro.Select.Client.SelectServer as one of the the imports at the top. Your comment says, "if you have a runtime service provider". Do I have that? How do I know if I do? The error description 'Protected Overridable Function GetService(service As System.Type) As Object' has no type parameters and so cannot have type arguments." Can you help with this?
Mark McKenna

Re: Get Current User within Lookups API

Post by Mark McKenna »

How and if you access our runtime service provider is dependent on what part of the system you are extending. Often, but not always, our base classes will expose both a non-generic GetService(Type) signature that returns Object and a generic GetService<T>() signature that returns T. In your case, it sounds like we're only exposing the former. So try this instead:

Code: Select all

SoftPro.Select.Client.SelectServer sps = GetService( typeof( SoftPro.Select.Client.SelectServer ) ) as SoftPro.Select.Client.SelectServer;
czentman
Posts: 157
Joined: Tue Dec 02, 2008 12:02 pm

Re: Get Current User within Lookups API

Post by czentman »

Now, I'm not giving the network credentials so I get the security error at runtime.
Mark McKenna

Re: Get Current User within Lookups API

Post by Mark McKenna »

Would you please provide the specific security error (there are several) and a code snippet that describes what you're trying to do? I'd also want to know what feature of Select you are trying to extend (e.g. creating snapsections, print job handlers, etc.).
Post Reply