Save Event in SnapSections
Moderator: Phil Barton
Save Event in SnapSections
Is there anyway to capture whenever the Save Event gets fired from within a SnapSection?
Thanks,
Thanks,
Robert
-
- Posts: 411
- Joined: Thu Sep 11, 2008 11:35 am
- Location: Raleigh, NC, USA
- Contact:
Re: Save Event in SnapSections
You can hook up an order saved handler using basic package capabilities (not snapsection). From your package OnInitialize() routine, you place this code:
Your save handler will be called on every save of an order.
Don't place this code into a snapsection, as the current version of the OrderHelper does not allow un-registering a handler. If you hook up a handler from a snapsection, it will cause memory leaks.
Code: Select all
using SoftPro.OrderTracking.Client
using SoftPro.OrderTracking.Package
protected void OnInitialize()
{
OrderHelper oh = GetService<OrderHelper>();
oh.RegisterOrderSavedHandler(this.MySaveHandler);
}
private void MySaveHandler(object sender, EventArgs e)
{
IOrder o = (IOrder)sender;
//...place your code here...
}
Don't place this code into a snapsection, as the current version of the OrderHelper does not allow un-registering a handler. If you hook up a handler from a snapsection, it will cause memory leaks.
John Morris
Sr. Software Architect
SoftPro
Sr. Software Architect
SoftPro
Re: Save Event in SnapSections
Is this still applicable in version 2.6?John Morris wrote:Don't place this code into a snapsection, as the current version of the OrderHelper does not allow un-registering a handler. If you hook up a handler from a snapsection, it will cause memory leaks.
Re: Save Event in SnapSections
Thanks for the information.
I assume that OrderTracking.OrderSaved replaced OrderHelper.RegisterOrderSavedHandler. Is that correct? If not, would it be safe in a snapsection?
Also, could you explain why adding the save event in a package is safe versus adding it to a snapsection isn't? Doesn't a package live as long as the application is open?
I assume that OrderTracking.OrderSaved replaced OrderHelper.RegisterOrderSavedHandler. Is that correct? If not, would it be safe in a snapsection?
Also, could you explain why adding the save event in a package is safe versus adding it to a snapsection isn't? Doesn't a package live as long as the application is open?
Re: Save Event in SnapSections
No. OrderTracking.OrderSaved is the event and OrderHelper.RegisterOrderSavedHandler is how you can register your handler for that event. They work in conjunction with each other, the former is not a replacement for the latter.
The reason you can safely register your handler in a package is because the package lives for the lifetime of the application and its resources are reclaimed when the application ends. Snap sections have a shorter lifetime and are potentially created and destroyed multiple times within a single instance of the application. Since your snap section would not be able to unregister the handler when it is destroyed, there will be a memory leak.
The reason you can safely register your handler in a package is because the package lives for the lifetime of the application and its resources are reclaimed when the application ends. Snap sections have a shorter lifetime and are potentially created and destroyed multiple times within a single instance of the application. Since your snap section would not be able to unregister the handler when it is destroyed, there will be a memory leak.
Re: Save Event in SnapSections
Got it. Thanks.
-
- Posts: 105
- Joined: Wed Oct 17, 2012 4:20 pm
Re: Save Event in SnapSections
This question has become relevant for me as well, however, I'm unable to find SoftPro.OrderTracking.Package in the Select install folder.
Can you direct me to which DLL I should be using?
Can you direct me to which DLL I should be using?