Developer forum

Forum » Development » Something Strange on Notification in Global Tags

Something Strange on Notification in Global Tags

George Nelzo Pereira
Reply

Hi people...

I made one code, basicly to get all user custom fields and publish on Global Tags...

Work fine when the customers have just one group. When they have more than one i got some problens.
After my code, I got timeout... I mean, they don't do anything and still running all the time.

Someone can help?

The code:
 

using Dynamicweb.Modules.Common.CustomFields;

namespace www.humanpixels.com.CustomModules.HupxPriceProvider
{
    [Dynamicweb.Extensibility.Subscribe(Dynamicweb.Notifications.Standard.Page.OnGlobalTags)]
    //public class PageviewObserver : Dynamicweb.Extensibility.NotificationSubscriber
    public class HupxProductListTemplateExtender : Dynamicweb.Extensibility.NotificationSubscriber
    {
        public override void OnNotify(string notification, Dynamicweb.Extensibility.NotificationArgs args)
        {
            if (args == null)
                return;

            Dynamicweb.Notifications.Standard.Page.PageviewNotificationArgs pna = (Dynamicweb.Notifications.Standard.Page.PageviewNotificationArgs)args;

            Dynamicweb.Modules.UserManagement.User user = Dynamicweb.Modules.UserManagement.User.GetCurrentUser();

            if (user != null)
            {
                foreach (CustomFieldValue val in user.CustomFieldValues)
                {
                    Dynamicweb.Modules.Common.CustomFields.CustomField field = val.CustomField;
                    object fieldValue = val.Value;

                    if (val != null)
                    {
                        pna.Template.SetTag("Hupx_" + field.Name, val.Value.ToString());
                    }
                }
            }

        }
    }
}

Replies

 
Nicolai Høeg Pedersen
Reply

It could somehow be a circular reference maybe - if you get a timeout.

 

Try to make sure that this piece of code is only executed once on each pageview.

 

Set a value on httpcontext.items on the first call, and skip the code if subsequent calls.

 

BR Nicolai.

 
George Nelzo Pereira
Reply

I tried that and several ways ...

It calls only once. :(


I'm using 8.1.1.7

 
Nicolai Høeg Pedersen
Reply

Could you try debug what goes wrong in that loop? Does the loop continue, or is it something else?

 
George Nelzo Pereira
Reply

I tried to debug that, but thats looks like the same when the user have just one group... that code finish and show the page... when the user have more then one group that code finish and "try" show the page, but just running and running... I mean the problem is after or something like that... But I don't know where :(

I tried with more solutions and thats fine without that code, when I put this DLL I got this problem.

I have just two groups and six custom fields... Just have problem with more than one group...

:(

 
George Nelzo Pereira
Reply

Ah... I got this "error" just when I try go to the basket otherwise don't get error...

 
George Nelzo Pereira
Reply

I took off the dll but still have this problem... now Im looking if have some configurations or another thing...

 
George Nelzo Pereira
Reply

Hi... I changed the version... the is working... Had something in another version.

Thanks

 

You must be logged in to post in the forum