It looks like there's a bug in the wiring up of .NET event handlers in TeaCommerce. The ITeaCommerceExtension.Initialize() method is only called when orders are manipulated from the shop frontend - not when accessing the backend administration interface.
Steps to reproduce:
1. Create a simple ITeaCommerceExtension and hook up to the events.
publicclassEventWireUpTestHandler : ITeaCommerceExtension {
publicvoid Initialize() {
// set a breakpoint herevar debug = true;
WebshopEvents.OrderLineChanged += WebshopEvents_OrderLineChanged;
WebshopEvents.OrderStatusChanged += WebshopEvents_OrderStatusChanged;
}
void WebshopEvents_OrderLineChanged(Order order, OrderLine orderLine) {
// set a breakpoint herevar debug = true;
}
void WebshopEvents_OrderStatusChanged(Order order, OrderStatus status) {
// set a breakpoint herevar debug = true;
}
}
2. Set breakpoints in the Initialize() method and in the two event handlers and attach a debugger to the web application.
3. Go to the admin interface and change the status of an existing order (e.g. from "New" to "Completed"). The breakpoint in WebshopEvents_OrderStatusChanged() is not triggered, nor is the one in Initialize().
4. Go to the frontend and add an item to the basket. The breakpoints in Initialize() and in WebshopEvents_OrderLineChanged() are both triggered.
5. Go back to the admin interface and change the status of an existing order. This time the breakpoint in WebshopEvents_OrderStatusChanged() is triggered correctly.
This issue is kind of critical, since the web application is not necessarily wound up by visitors adding items to the basket - especially not on a low traffic site. In case an administrator ends up winding the application up and starts managing orders, the event handling (in my case: pushing completed orders to an external system) is not performed for these orders.
Note: I'm using the 1.4.1.0 beta version of TeaCommerce.
Thanks for the great error report. You are quite right, the Initialize method is only called when the TeaCommerce.dll is loaded by the webserver. If you're using the TeaCommerce.Data only, that would not happen.
I will try and fix it at once. Hope you will be ready to test it for me.
Seems like it was an easy fix. Whenever the TeaCommerce.Data.dll is now loaded, the eventhandlers will also be loaded. I have debugged it and I can see that they are now being loaded. I have not tested it on real events yet. I will let you do that.
.NET event handler wire up bug
Hi!
It looks like there's a bug in the wiring up of .NET event handlers in TeaCommerce. The ITeaCommerceExtension.Initialize() method is only called when orders are manipulated from the shop frontend - not when accessing the backend administration interface.
Steps to reproduce:
1. Create a simple ITeaCommerceExtension and hook up to the events.
2. Set breakpoints in the Initialize() method and in the two event handlers and attach a debugger to the web application.
3. Go to the admin interface and change the status of an existing order (e.g. from "New" to "Completed"). The breakpoint in WebshopEvents_OrderStatusChanged() is not triggered, nor is the one in Initialize().
4. Go to the frontend and add an item to the basket. The breakpoints in Initialize() and in WebshopEvents_OrderLineChanged() are both triggered.
5. Go back to the admin interface and change the status of an existing order. This time the breakpoint in WebshopEvents_OrderStatusChanged() is triggered correctly.
This issue is kind of critical, since the web application is not necessarily wound up by visitors adding items to the basket - especially not on a low traffic site. In case an administrator ends up winding the application up and starts managing orders, the event handling (in my case: pushing completed orders to an external system) is not performed for these orders.
Note: I'm using the 1.4.1.0 beta version of TeaCommerce.
Hi Kenn,
Thanks for the great error report. You are quite right, the Initialize method is only called when the TeaCommerce.dll is loaded by the webserver. If you're using the TeaCommerce.Data only, that would not happen.
I will try and fix it at once. Hope you will be ready to test it for me.
/Rune
Hi Kenn,
Seems like it was an easy fix. Whenever the TeaCommerce.Data.dll is now loaded, the eventhandlers will also be loaded. I have debugged it and I can see that they are now being loaded. I have not tested it on real events yet. I will let you do that.
A new beta package has been uploaded to the site on our: http://our.umbraco.org/projects/website-utilities/tea-commerce
/Rune
Hi Rune,
Thanks... I'll fetch it and test it tomorrow morning and let you know, how it went :-)
~Kenn
Ok, we will have to fix it before tomorrow at noon as I will be off on vacation and the office is closed all next week. Just for you information :)
But it should work.
/Rune
Hi Rune,
Looks like the 1.4.1.1 beta has fixed this issue. Thank you for the quick fix and have a nice holiday.
~Kenn
That's fantastic. Together we will shape the future of Tea Commerce :D
And thanks, will be sure to enjoy my holidays.
/Rune
is working on a reply...