Discussions
Sample Code from IMIS SDK - Is there a replacement for this code or can anyone make it work?
This is code from developer.imis.com - I am trying to load an Invoice into the Shopping Cart. Billing Cycle has already run, but I need the Invoice. The Invoice has this strange notation ####:###### - specifically the second set of numbers which I need to feed to the ItemDetails page/content record.
It appears to be in this format :
"CASH:{partyId}:{billingRunResults.LegacyBillingDataUsedByService.BillingLogKey}"
Does anyone know how to get this code to work, or how to replace this code, or know whether this code is necessary if I want to load Renewal Membership Dues to the cart?
Or can someone steer me toward the more modern approach?
// // Run membership fees billing cycle
string billingCycle = "Regular Membership Fees";
ILegacyBillingService billingService = Resolve<ILegacyBillingService>();
LegacyBillingData runData = new LegacyBillingData
{
BillingCycleId = billingCycle,
BillingRunName = "{billingCycle} Test",
IsRenewal = true,
IndividualBillingPartyId = partyId,
RunDate = tomorrow,
EffectiveDate = effectiveDate
};
LegacyBillingResultsData billingRunResults = billingService.Run(runData);
// Instantiate invoice ID, cart manager for renewal invoice, and find invoice by the ID
string invoiceId = "CASH:{partyId}:{billingRunResults.LegacyBillingDataUsedByService.BillingLogKey}";
Hi Jack,
What version of iMIS are you on?
Hi Cindy,
We are on IMIS GA 2017 w/Service Pack I (the latest version of iMIS)
Hi Jack,
Apologies for the delay, I consulted with one of the developers who worked on this feature, and he noted that the notation can be used without the aforementioned "BillingLogKey" located in the example. In your test, try replacing the line
string invoiceId = "CASH:{partyId}:{billingRunResults.LegacyBillingDataUsedByService.BillingLogKey}";
with
string invoiceId = $"CASH:{partyId}:{AppTime.Now.Date:yyyyMMdd}-1";
and see if that gives you better results. Let me know if this approach works for you so I can update the associated example accordingly.
Thanks,
- Jeremy
In addition you should also remove BillingRunName = "{billingCycle} Test",
as this property was not yet available in your version
Hey thanks for the response. This line doesn't work either and I'm wondering what Resolve method we are using (from what library/namespace etc)
ILegacyBillingService billingService = Resolve();
The Resolve<>() is unknown and not qualified enough for me to use. Any help on that front??
My end goal is to load Dues Products to the Cart - if the road I'm on is a dead-end I'm not married to the solution.... I'd take an alternate solution any day of the week...
thanks for any help...
Jack D
Here's additional information
Issue is: "The Name Resolve does not exist in the Current context..."
ILegacyBillingService billingService = Resolve();
Are we using Unity here?
Honestly I don't know how I am able to figure this stuff out. We need to always have some idea of what technology is being employed. Perhaps if a SUMMARY section at the top says "Uses Unity Version XXX" and "IMIS version...blah blah" maybe we'd have a better chance... It's very hard explain to management when they see an example and say "Uh hey - why don't you just....use this here example and you're done!"
ANYWAY!!! I do believe this helps:
install-package Unity -version 3.5.1404
This Resolve throws the following Error.
Here's what I did
- this Solution uses Unity. Add Unity 3.5 -- install-package Unity -version 3.5.1404
- Add a using statement using Microsoft.Practices.Unity;
I ADDED THIS CODE
IUnityContainer myContainer = new UnityContainer();
// myContainer.RegisterType<ILegacyBillingService, billingService>();
// // Run membership fees billing cycle
string billingCycle = "Regular Membership Fees";
ILegacyBillingService billingService = myContainer.Resolve<ILegacyBillingService>();
LegacyBillingData runData = new LegacyBillingData
{
BillingCycleId = billingCycle,
IsRenewal = true,
IndividualBillingPartyId = partyId,
RunDate = tomorrow,
EffectiveDate = effectiveDate
};
LegacyBillingResultsData billingRunResults = billingService.Run(runData);
// Instantiate invoice ID, cart manager for renewal invoice, and find invoice by the ID
// string invoiceId = "CASH:{partyId}:{billingRunResults.LegacyBillingDataUsedByService.BillingLogKey}";
string invoiceId = "CASH:{partyId}:{AppTime.Now.Date:yyyyMMdd}-1";
I get this error:
An unhandled exception of type 'Microsoft.Practices.Unity.ResolutionFailedException' occurred in Microsoft.Practices.Unity.dll
Additional information: Resolution of the dependency failed, type = "Asi.Soa.Commerce.ServiceContracts.ILegacyBillingService", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, Asi.Soa.Commerce.ServiceContracts.ILegacyBillingService, is an interface and cannot be constructed. Are you missing a type mapping?
At the time of the exception, the container was:
Resolving Asi.Soa.Commerce.ServiceContracts.ILegacyBillingService,(none)
Apologies, Jack, that 'Resolve' method was actually an abstracted call that handled some dependency injection concerns. In the interest of time, I have yet to try this code on your particular Service Pack-versioned iMIS instance, but could you instead try the following code-block that performs those concerns a bit more manually?
using (var scope = IocSupport.Legacy.RequestLifetimeScope.BeginLifetimeScope())
{
var billingService = scope.Resolve<ILegacyBillingService>();
LegacyBillingData runData = new LegacyBillingData
{
BillingCycleId = billingCycle,
BillingRunName = $"{billingCycle} Test",
IsRenewal = true,
IndividualBillingPartyId = partyId,
RunDate = tomorrow,
EffectiveDate = effectiveDate
};
billingService.Run(runData);
}
This is after adding references to 'Asi.Core.Ioc' and 'Autofac':
using Asi.Core.Ioc;
using Autofac;
I'll try this out on a version closer to yours as soon as I get the chance, but do let me know if you beat me to the punch and if that approach works better for you.
ο»Ώ