Developer forum

Forum » Development » Custom ConfigurationProvider not hit

Custom ConfigurationProvider not hit

Anders Ebdrup
Anders Ebdrup
Reply

Dear Dynamicweb,

 

We have an issue where our custom ConfigurationProvider is not always hit in the application, but after recycle of the application pool the configuration provider is hit again.

It is an issue as shipping vat is not handled correct for reverse vat.

 

This is our code:

    [Dynamicweb.Extensibility.Notifications.Subscribe(Dynamicweb.Notifications.Standard.Application.BeforeDynamicwebStart)]
    public class BeforeStartObserver : Dynamicweb.Extensibility.Notifications.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.Notifications.NotificationArgs args)
        {
            Dynamicweb.Configuration.SystemConfiguration.Instance.AddProviderPriority(new CustomConfigurationProvider());

        }

    }

 public class CustomConfigurationProvider : IConfigurationProvider
    {
        public bool TryGet(string key, out string value)
        {
            var pageview = Dynamicweb.Frontend.PageView.Current();

            if (key.Equals("/Globalsettings/Ecom/Order/ShippingFee/IncludeVATOnShippingFee", System.StringComparison.InvariantCultureIgnoreCase))
            {

                if (Dynamicweb.Ecommerce.Common.Context.ReverseChargeForVatEnabled)
                {

                    value = bool.FalseString;
                    return true;

                }
                else
                {
                    value = bool.TrueString;
                    return true;
                }

            }

        }
    }

 

I hope that you can solve this?

 

Best regards,

Anders


Replies

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Anders,

I've tried to reproduce your issue, but I've been unable to do so.

Do you have any additional information about when it stops being hit? Also, the provided code is not complete, so it's difficult for me to determine whether one of the implementations of the methods on the interface could cause this. Can you provide the complete provider? If you don't want to post it here, you can send it to me directly.

- Jeppe

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Jeppe,

 

We are now able to reproduce the behaviour, and the notification subscriber is hit every time just as you said, but if we change just a single setting in the management setting, then our custom ConfigurationProvider is not used anymore and that is why we have these issues.

Can you please try to look into this?

 

Best regards, Anders

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Anders,

Would it be possible for you to send me a copy of the solution in a state where the notification subscriber works as well as steps to make it not work? That way I can try and debug it locally.

- Jeppe

 
Anders Ebdrup
Anders Ebdrup
Reply

Dear Jeppe,

 

Has this issue been fixed?

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Hi Anders,

We've investigated the issue. A bugfix (73828) will be released with Dynamicweb 9.7.6.

- Jeppe

 
Anders Ebdrup
Anders Ebdrup
Reply

Nice! Which package should we upgrade to solve the issue? :-)

 
Jeppe Eriksson Agger Dynamicweb Employee
Jeppe Eriksson Agger
Reply

Unfortunately, the issue is in Dynamicweb.Admin so there isn't a package you can upgrade yet.

We'll notify you in this thread when it's available.

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply
This post has been marked as an answer

Hi Anders

The problem regarding #73828 "Editing configuration settings causes Reset of SystemConfiguration:" has now been resolved in Dynamicweb version 9.7.6

To upgrade please choose this version from download:

http://doc.dynamicweb.com/releases-and-downloads/releases

Let me know if you need any more help regarding this

Kind Regards
Dynamicweb Support
Kristian Kirkholt

Votes for this answer: 1

 

You must be logged in to post in the forum