Using IPolicyManager

Discussions related to custom development with Select.
Post Reply
chris.brady
Posts: 105
Joined: Wed Oct 17, 2012 4:20 pm

Using IPolicyManager

Post by chris.brady »

I could use a bit of help with this.

I've tried to use this interface to search through policies by state or lookup code, but I'm getting an "Specified method not supported" error. I even get this error when just trying to enumerate the Policies collection through the debugger.

Are we doing this right?

Code: Select all

IPolicyManager pm = Sps.GetService<IPolicyManager>();
IPolicy p = pm.Policies.FirstOrDefault(x => x.LookupCode == "XYZ";
Supposing we figure out the problem, is there any way to access rate table information? IPolicy doesn't really provide a lot of policy information.
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Using IPolicyManager

Post by John Morris »

Have you tried this:

Code: Select all

IPolicyManager pm = Sps.GetService<IPolicyManager>();
IPolicy p = pm.Policies.Where(x => x.LookupCode == "XYZ").ToList().FirstOrDefault();
John Morris
Sr. Software Architect
SoftPro
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: Using IPolicyManager

Post by tmeisinger »

I just tried the sample code and I'm also getting "Specified method not supported". Was this resolved?
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Using IPolicyManager

Post by John Morris »

Please provide more details. Do you have a callstack and the exact code you're using?
John Morris
Sr. Software Architect
SoftPro
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: Using IPolicyManager

Post by tmeisinger »

Here you go in VB.NET:

Code: Select all

Dim creds As NetworkCredential = New NetworkCredential("api", "*****", "[SERVER]")

Using ss As New SelectServer(New Uri("http:\\softpro-app:8080"), creds)

    Dim reason As String = String.Empty
    If ss.TryAuthenticate(reason) Then
        Dim pm As IPolicyManager = ss.GetService(Of IPolicyManager)()
        Dim p As IPolicy = pm.Policies.Where(Function(x) x.LookupCode = "Loan Policy").ToList().FirstOrDefault()
    End If
End Using
John Morris
Posts: 411
Joined: Thu Sep 11, 2008 11:35 am
Location: Raleigh, NC, USA
Contact:

Re: Using IPolicyManager

Post by John Morris »

Callstack?
John Morris
Sr. Software Architect
SoftPro
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: Using IPolicyManager

Post by tmeisinger »

Is that what you're looking for?

" at SoftPro.OrderTracking.Client.Policies.PolicyManager.GetProfileFilterID(Criteria criteria) at SoftPro.OrderTracking.Client.Policies.PolicyManager.<SoftPro.OrderTracking.Client.Policies.IPolicyManager.get_Policies>b__1(Criteria criteria) at SoftPro.ClientModel.Linq.CriteriaQueryProvider`2.Execute(Expression expression, Boolean enumerable) at SoftPro.ClientModel.Linq.CriteriaQueryProvider`2.Execute[TResult](Expression expression) at SoftPro.ClientModel.Linq.CriteriaQuery`2.GetEnumerator() at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()"
Graham Campbell
Posts: 61
Joined: Fri Jul 01, 2011 10:06 am
Location: Raleigh, North Carolina
Contact:

Re: Using IPolicyManager

Post by Graham Campbell »

The IPolicyManager API requires the consumer to specify what profile to use when querying for results.

Please try something like this:

Code: Select all

IProfileManager profileManager = Sps.GetService<IProfileManager>();
IPolicyManager pm = Sps.GetService<IPolicyManager>();
IPolicy p = pm.Policies.HavingProfile(profileManager.ActiveProfile).Where(x => x.LookupCode == "XYZ").ToList().FirstOrDefault();
Unfortunately, the exception message you have been provided with is not adequately conveying this situation. I will log a bug in our tracker in this regard.
Graham Campbell
SoftPro Software Engineer
Graham Campbell
Posts: 61
Joined: Fri Jul 01, 2011 10:06 am
Location: Raleigh, North Carolina
Contact:

Re: Using IPolicyManager

Post by Graham Campbell »

By the way, when the Order leverages the IPolicyManager, it uses its OwnershipProfile property. If you are trying to replicate the behavior of the application, you will want to use this as well rather than the ActiveProfile.
Graham Campbell
SoftPro Software Engineer
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: Using IPolicyManager

Post by tmeisinger »

Much better, thank you.
Post Reply