Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kenn Jacobsen 132 posts 763 karma points MVP c-trib
    Jul 21, 2011 @ 11:35
    Kenn Jacobsen
    0

    .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.

        public class EventWireUpTestHandler : ITeaCommerceExtension {
            public void Initialize() {
                // set a breakpoint here
                var debug = true;
    
                WebshopEvents.OrderLineChanged += WebshopEvents_OrderLineChanged;
                WebshopEvents.OrderStatusChanged += WebshopEvents_OrderStatusChanged;
            }
    
            void WebshopEvents_OrderLineChanged(Order order, OrderLine orderLine) {
                // set a breakpoint here
                var debug = true;
            }
    
            void WebshopEvents_OrderStatusChanged(Order order, OrderStatus status) {
                // set a breakpoint here
                var 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.

  • Rune Grønkjær 1296 posts 2863 karma points
    Jul 21, 2011 @ 11:53
    Rune Grønkjær
    0

    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

  • Rune Grønkjær 1296 posts 2863 karma points
    Jul 21, 2011 @ 12:10
    Rune Grønkjær
    0

    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

  • Kenn Jacobsen 132 posts 763 karma points MVP c-trib
    Jul 21, 2011 @ 12:14
    Kenn Jacobsen
    0

    Hi Rune,

    Thanks... I'll fetch it and test it tomorrow morning and let you know, how it went :-)

    ~Kenn

  • Rune Grønkjær 1296 posts 2863 karma points
    Jul 21, 2011 @ 12:19
    Rune Grønkjær
    0

    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

  • Kenn Jacobsen 132 posts 763 karma points MVP c-trib
    Jul 21, 2011 @ 14:24
    Kenn Jacobsen
    0

    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

  • Rune Grønkjær 1296 posts 2863 karma points
    Jul 21, 2011 @ 14:26
    Rune Grønkjær
    0

    That's fantastic. Together we will shape the future of Tea Commerce :D

    And thanks, will be sure to enjoy my holidays.

    /Rune

Please Sign in or register to post replies

Write your reply to:

Draft