Пример #1
0
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            SetContextLangauge(ajaxInfo);     // Ajax breaks context with DNN, so reset the context language to match the client.

            var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var lang   = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (lang == "")
            {
                lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            }
            if (lang == "")
            {
                lang = _lang;
            }

            if (Utils.IsNumeric(itemid))
            {
                // get DB record
                var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                if (nbi != null)
                {
                    var typecode = nbi.TypeCode;

                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);
                    nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
                    objCtrl.Update(nbi);

                    // do langauge record
                    var nbi2 = objCtrl.GetDataLang(Convert.ToInt32(itemid), lang);
                    nbi2.UpdateAjax(strIn);
                    objCtrl.Update(nbi2);

                    DataCache.ClearCache();     // clear ALL cache.

                    // run the promo now.
                    if (typecode == "CATEGORYPROMO")
                    {
                        PromoUtils.CalcGroupPromoItem(nbi);
                    }
                    if (typecode == "MULTIBUYPROMO")
                    {
                        PromoUtils.CalcMultiBuyPromoItem(nbi);
                    }
                }
            }
            return("");
        }
Пример #2
0
        private static void FlagProductMultiBuy(int portalid, int productId, string promoname, int promoid, String promoType, DateTime dteF, DateTime dteU)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == 0 || currentpromoid == promoid)
                {
                    prdData.SetXmlProperty("genxml/hidden/promotype", promoType);
                    prdData.SetXmlProperty("genxml/hidden/promoname", promoname);
                    prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString());
                    prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O"));

                    objCtrl.Update(prdData);
                    if (promoType == "PROMOMULTIBUY")
                    {
                        foreach (var lang in cultureList)
                        {
                            var p           = objCtrl.GetDataLang(promoid, lang);
                            var prdDataLang = objCtrl.GetDataLang(productId, lang);
                            if (prdDataLang != null)
                            {
                                prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description"));
                                objCtrl.Update(prdDataLang);
                            }
                        }
                    }
                }
            }
        }
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
            var lang   = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (lang == "")
            {
                lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
            }
            if (lang == "")
            {
                lang = _lang;
            }

            if (Utils.IsNumeric(itemid))
            {
                // get DB record
                var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                if (nbi != null)
                {
                    var typecode = nbi.TypeCode;

                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);
                    if (nbi.GUIDKey == "")
                    {
                        nbi.GUIDKey = Utils.GetUniqueKey();
                    }
                    objCtrl.Update(nbi);

                    // do langauge record
                    var nbi2 = objCtrl.GetDataLang(Convert.ToInt32(itemid), lang);
                    nbi2.UpdateAjax(strIn);
                    objCtrl.Update(nbi2);

                    DataCache.ClearCache();     // clear ALL cache.
                }
            }
            return("");
        }
        private String SaveData(HttpContext context)
        {
            var objCtrl = new NBrightBuyController();

            //get uploaded params
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);


            var guidkey  = ajaxInfo.GetXmlProperty("genxml/hidden/guidkey");
            var typeCode = ajaxInfo.GetXmlProperty("genxml/hidden/typecode");
            var editlang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");

            if (editlang == "")
            {
                editlang = _lang;
            }


            // get data record with language
            var obj = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -2, typeCode, guidkey);

            if (obj != null)
            {
                // get DB record
                var nbi = objCtrl.Get(obj.ItemID);
                if (nbi != null)
                {
                    // get data passed back by ajax
                    var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                    // update record with ajax data
                    nbi.UpdateAjax(strIn);
                    if (nbi.GUIDKey == "")
                    {
                        nbi.GUIDKey = typeCode;
                    }
                    objCtrl.Update(nbi);

                    // do langauge record
                    var nbi2 = objCtrl.GetDataLang(obj.ItemID, editlang);
                    nbi2.UpdateAjax(strIn);
                    objCtrl.Update(nbi2);

                    DataCache.ClearCache(); // clear ALL cache.
                }
            }
            return("");
        }
Пример #5
0
        public static void RemoveProductPromoData(int portalid, int productId, int promoid)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");

            if (currentpromoid == promoid)
            {
                prdData.RemoveXmlNode("genxml/hidden/promotype");
                prdData.RemoveXmlNode("genxml/hidden/promoname");
                prdData.RemoveXmlNode("genxml/hidden/promoid");
                prdData.RemoveXmlNode("genxml/hidden/promocalcdate");
                prdData.RemoveXmlNode("genxml/hidden/datefrom");
                prdData.RemoveXmlNode("genxml/hidden/dateuntil");

                // remove any sale price amounts that may have been added by group promotion.
                var l = prdData.XMLDoc.SelectNodes("genxml/models/genxml");
                if (l != null)
                {
                    var lp = 1;
                    foreach (XmlNode nod in l)
                    {
                        prdData.SetXmlProperty("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", "0");
                        lp += 1;
                    }
                }

                objCtrl.Update(prdData);
                foreach (var lang in cultureList)
                {
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.RemoveXmlNode("genxml/hidden/promodesc");
                        objCtrl.Update(prdDataLang);
                    }
                }
            }
        }
Пример #6
0
        public static void RemoveProductPromoData(int portalid, int productId, int promoid)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            // (legacy) remove fields for old promo
            var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");

            if (currentpromoid != 0) //
            {
                prdData.RemoveXmlNode("genxml/hidden/promotype");
                prdData.RemoveXmlNode("genxml/hidden/promoname");
                prdData.RemoveXmlNode("genxml/hidden/promoid");
                prdData.RemoveXmlNode("genxml/hidden/promocalcdate");
                prdData.RemoveXmlNode("genxml/hidden/datefrom");
                prdData.RemoveXmlNode("genxml/hidden/dateuntil");
            }

            // remove any sale price amounts that may have been added by group promotion.
            var l = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (l != null)
            {
                var promoexist = false;
                var lp         = 1;
                foreach (XmlNode nod in l)
                {
                    var promodealersaleid = prdData.GetXmlPropertyInt("genxml/promo/dealersaleid" + lp);
                    var promosalepriceid  = prdData.GetXmlPropertyInt("genxml/promo/salepriceid" + lp);
                    var promodealercostid = prdData.GetXmlPropertyInt("genxml/promo/dealercostid" + lp);

                    if (promosalepriceid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", "0");
                        prdData.RemoveXmlNode("genxml/promo/salepriceid" + lp);
                        promosalepriceid = 0;
                    }
                    if (promodealercostid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", "0");
                        prdData.RemoveXmlNode("genxml/promo/dealercostid" + lp);
                        promodealercostid = 0;
                    }
                    if (promodealersaleid == promoid)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", "0");
                        prdData.RemoveXmlNode("genxml/promo/dealersaleid" + lp);
                        promodealersaleid = 0;
                    }

                    if (promodealersaleid > 0 || promosalepriceid > 0 || promodealercostid > 0)
                    {
                        promoexist = true;
                    }

                    lp += 1;
                }

                if (!promoexist)
                {
                    prdData.RemoveXmlNode("genxml/hidden/promoflag");
                    prdData.RemoveXmlNode("genxml/promo");
                }

                // promo description only at product level, thi sis not correct for multiple price promoiton.
                // but this is a rare use case issue.
                foreach (var lang in cultureList)
                {
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.RemoveXmlNode("genxml/hidden/promodesc");
                        objCtrl.Update(prdDataLang);
                    }
                }
            }

            objCtrl.Update(prdData);
        }
Пример #7
0
        private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, int promoid, int whichprice, bool overwrite)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                prdData.SetXmlProperty("genxml/hidden/promoflag", "True"); // set flag, so we can identify products with promo for product save event removal.
                if (prdData.GetXmlProperty("genxml/promo") == "")
                {
                    prdData.SetXmlProperty("genxml/promo", "");
                }
                var lp = 1;
                foreach (XmlNode nod in nodList)
                {
                    var currentpromoid = GetCurrentPromoId(prdData, whichprice, lp);
                    var nbi            = new NBrightInfo();
                    nbi.XMLData = nod.OuterXml;
                    var    disablesale      = nbi.GetXmlPropertyBool("genxml/checkbox/chkdisablesale");
                    var    disabledealer    = nbi.GetXmlPropertyBool("genxml/checkbox/chkdisabledealer");
                    var    unitcost         = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                    var    dealercost       = nbi.GetXmlPropertyDouble("genxml/textbox/txtdealercost");
                    Double newamt           = 0;
                    Double newdealersaleamt = 0;
                    Double newdealeramt     = 0;
                    if (amounttype == "1")
                    {
                        newamt           = unitcost - amount;
                        newdealersaleamt = dealercost - amount;
                    }
                    else
                    {
                        newamt           = unitcost - ((unitcost / 100) * amount);
                        newdealersaleamt = dealercost - ((dealercost / 100) * amount);
                    }
                    newdealeramt = newamt;
                    if (newamt < 0)
                    {
                        newamt = 0;
                    }
                    if (newdealersaleamt < 0)
                    {
                        newdealersaleamt = 0;
                    }

                    var currentprice = GetCurrentPromoPrice(prdData, whichprice, lp);
                    if (!overwrite)
                    {
                        if (currentprice == 0)
                        {
                            overwrite = true;
                        }
                        if (currentpromoid == promoid)
                        {
                            overwrite = true;
                        }
                    }
                    if (overwrite)
                    {
                        switch (whichprice)
                        {
                        case 1:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;

                        case 2:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", newdealeramt);
                            prdData.SetXmlProperty("genxml/promo/dealercostid" + lp, promoid.ToString());
                            break;

                        case 3:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", newdealersaleamt);
                            prdData.SetXmlProperty("genxml/promo/dealersaleid" + lp, promoid.ToString());
                            break;

                        case 4:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", newdealersaleamt);
                            prdData.SetXmlProperty("genxml/promo/dealersaleid" + lp, promoid.ToString());
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;

                        default:
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                            prdData.SetXmlProperty("genxml/promo/salepriceid" + lp, promoid.ToString());
                            break;
                        }
                    }
                    if (disablesale)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", 0);
                        prdData.RemoveXmlNode("genxml/promo/salepriceid" + lp);
                    }
                    if (disabledealer)
                    {
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealercost", 0);
                        prdData.RemoveXmlNode("genxml/promo/dealercostid" + lp);
                        prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtdealersale", 0);
                        prdData.RemoveXmlNode("genxml/promo/dealersaleid" + lp);
                    }

                    lp += 1;
                }
                objCtrl.Update(prdData);

                foreach (var lang in cultureList)
                {
                    var promodesc = "";
                    var p         = objCtrl.GetDataLang(promoid, lang);
                    if (p != null)
                    {
                        promodesc = p.GetXmlProperty("genxml/textbox/description");
                    }
                    var prdDataLang = objCtrl.GetDataLang(productId, lang);
                    if (prdDataLang != null)
                    {
                        prdDataLang.SetXmlProperty("genxml/hidden/promodesc", promodesc);
                        objCtrl.Update(prdDataLang);
                    }
                }
            }
        }
Пример #8
0
        private static void CalcProductSalePrice(int portalid, int productId, string amounttype, double amount, string promoname, int promoid, bool overwrite, DateTime dteF, DateTime dteU)
        {
            var cultureList = DnnUtils.GetCultureCodeList(portalid);
            var objCtrl     = new NBrightBuyController();
            var prdData     = objCtrl.GetData(productId);

            var nodList = prdData.XMLDoc.SelectNodes("genxml/models/genxml");

            if (nodList != null)
            {
                var currentpromoid = prdData.GetXmlPropertyInt("genxml/hidden/promoid");
                if (currentpromoid == 0 || currentpromoid == promoid || overwrite)
                {
                    prdData.SetXmlProperty("genxml/hidden/promotype", "PROMOGROUP");
                    prdData.SetXmlPropertyDouble("genxml/hidden/promoname", promoname);
                    prdData.SetXmlProperty("genxml/hidden/promoid", promoid.ToString());
                    prdData.SetXmlProperty("genxml/hidden/promocalcdate", DateTime.Now.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/datefrom", dteF.ToString("O"));
                    prdData.SetXmlProperty("genxml/hidden/dateuntil", dteU.ToString("O"));

                    var lp = 1;
                    foreach (XmlNode nod in nodList)
                    {
                        var nbi = new NBrightInfo();
                        nbi.XMLData = nod.OuterXml;
                        var    unitcost = nbi.GetXmlPropertyDouble("genxml/textbox/txtunitcost");
                        Double newamt   = 0;
                        if (amounttype == "1")
                        {
                            newamt = unitcost - amount;
                        }
                        else
                        {
                            newamt = unitcost - ((unitcost / 100) * amount);
                        }

                        if (newamt < 0)
                        {
                            newamt = 0;
                        }

                        var currentprice = prdData.GetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice");

                        if (!overwrite)
                        {
                            if (currentprice == 0)
                            {
                                overwrite = true;
                            }
                            if (currentpromoid == promoid)
                            {
                                overwrite = true;
                            }
                        }
                        if (overwrite)
                        {
                            prdData.SetXmlPropertyDouble("genxml/models/genxml[" + lp + "]/textbox/txtsaleprice", newamt);
                        }
                        lp += 1;
                    }
                    objCtrl.Update(prdData);

                    foreach (var lang in cultureList)
                    {
                        var p           = objCtrl.GetDataLang(promoid, lang);
                        var prdDataLang = objCtrl.GetDataLang(productId, lang);
                        if (prdDataLang != null)
                        {
                            prdDataLang.SetXmlProperty("genxml/hidden/promodesc", p.GetXmlProperty("genxml/textbox/description"));
                            objCtrl.Update(prdDataLang);
                        }
                    }
                }
            }
        }
Пример #9
0
        public static List <UrlRule> GetRules(int portalId)
        {
            object padlock = new object();

            lock (padlock)
            {
                List <UrlRule> rules    = new List <UrlRule>();
                List <UrlRule> catrules = new List <UrlRule>();

                #if DEBUG
                decimal speed;
                string  mess;
                var     stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                #endif

                var purgeResult    = UrlRulesCaching.PurgeExpiredItems(portalId);
                var portalCacheKey = UrlRulesCaching.GeneratePortalCacheKey(portalId, null);
                var portalRules    = UrlRulesCaching.GetCache(portalId, portalCacheKey, purgeResult.ValidCacheItems);
                if (portalRules != null && portalRules.Count > 0)
                {
                    #if DEBUG
                    stopwatch.Stop();
                    speed = stopwatch.Elapsed.Milliseconds;
                    mess  = $"PortalId: {portalId}. Time elapsed: {stopwatch.Elapsed.Milliseconds}ms. All Cached. PurgedItems: {purgeResult.PurgedItemCount}. Speed: {speed}";
                    Logger.Error(mess);
                    #endif
                    return(portalRules);
                }

                Dictionary <string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalId);

                var objCtrl = new NBrightBuyController();

                var storesettings = new StoreSettings(portalId);

                ModuleController mc  = new ModuleController();
                var modules          = mc.GetModulesByDefinition(portalId, "NBS_ProductDisplay").OfType <ModuleInfo>();
                var modulesOldModule = mc.GetModulesByDefinition(portalId, "NBS_ProductView").OfType <ModuleInfo>();
                modules = modules.Concat(modulesOldModule);

                // ------- Category URL ---------------

                #region "Category Url"

                // Not using the module loop!!
                // becuase tabs that are defined in the url are dealt with by open url rewriter, so we only need use the default tab which is defined by the store settings.

                foreach (KeyValuePair <string, Locale> key in dicLocales)
                {
                    try
                    {
                        string cultureCode     = key.Value.Code;
                        string ruleCultureCode = (dicLocales.Count > 1 ? cultureCode : null);

                        var grpCatCtrl = new GrpCatController(cultureCode, portalId);

                        // get all products in portal, with lang data
                        var catitems = objCtrl.GetList(portalId, -1, "CATEGORY");

                        foreach (var catData in catitems)
                        {
                            var catDataLang = objCtrl.GetDataLang(catData.ItemID, cultureCode);

                            if (catDataLang != null && !catData.GetXmlPropertyBool("genxml/checkbox/chkishidden"))
                            {
                                var            catCacheKey   = portalCacheKey + "_" + catDataLang.ItemID + "_" + cultureCode;
                                List <UrlRule> categoryRules = UrlRulesCaching.GetCache(portalId, catCacheKey, purgeResult.ValidCacheItems);
                                if (categoryRules != null && categoryRules.Count > 0)
                                {
                                    rules.AddRange(categoryRules);
                                }
                                else
                                {
                                    catrules = new List <UrlRule>();

                                    var caturlname   = catDataLang.GUIDKey;
                                    var SEOName      = catDataLang.GetXmlProperty("genxml/textbox/txtseoname");
                                    var categoryName = catDataLang.GetXmlProperty("genxml/textbox/txtcategoryname");

                                    var newcatUrl = grpCatCtrl.GetBreadCrumb(catData.ItemID, 0, "/", false);

                                    var url = newcatUrl;
                                    if (!string.IsNullOrEmpty(url))
                                    {
                                        // ------- Category URL ---------------

                                        var rule = new UrlRule
                                        {
                                            CultureCode = ruleCultureCode,
                                            TabId       = storesettings.ProductListTabId,
                                            Parameters  = "catref=" + caturlname,
                                            Url         = url
                                        };
                                        var reducedRules =
                                            rules.Where(r => r.CultureCode == rule.CultureCode && r.TabId == rule.TabId)
                                            .ToList();
                                        bool ruleExist = reducedRules.Any(r => r.Parameters == rule.Parameters);
                                        if (!ruleExist)
                                        {
                                            if (reducedRules.Any(r => r.Url == rule.Url)) // if duplicate url
                                            {
                                                rule.Url = catData.ItemID + "-" + url;
                                            }
                                            rules.Add(rule);
                                            catrules.Add(rule);
                                        }

                                        var proditems = objCtrl.GetList(catData.PortalId, -1, "CATXREF", " and NB1.XRefItemId = " + catData.ItemID.ToString(""));
                                        var l2        = objCtrl.GetList(catData.PortalId, -1, "CATCASCADE", " and NB1.XRefItemId = " + catData.ItemID.ToString(""));
                                        proditems.AddRange(l2);

                                        var pageurl  = "";
                                        var pageurl1 = rule.Url;
                                        // do paging for category (on all product modules.)
                                        foreach (var module in modules)
                                        {
                                            // ------- Paging URL ---------------
                                            var modsetting        = NBrightBuyUtils.GetSettings(portalId, module.ModuleID);
                                            var pagesize          = modsetting.GetXmlPropertyInt("genxml/textbox/pagesize");
                                            var staticlist        = modsetting.GetXmlPropertyBool("genxml/checkbox/staticlist");
                                            var defaultcatid      = modsetting.GetXmlPropertyBool("genxml/dropdownlist/defaultpropertyid");
                                            var defaultpropertyid = modsetting.GetXmlPropertyBool("genxml/dropdownlist/defaultcatid");
                                            if (pagesize > 0)
                                            {
                                                if (module.TabID != storesettings.ProductListTabId || staticlist)
                                                {
                                                    // on the non-default product list tab, add the moduleid, so we dont; get duplicates.
                                                    // NOTE: this only supports defaut paging url for 1 module on the defaut product list page. Other modules will have moduleid added to the url.

                                                    //pageurl = module.ModuleID + "-" + pageurl1;

                                                    //IGNORE NON DEFAULT MODULES.
                                                }
                                                else
                                                {
                                                    pageurl = pageurl1;


                                                    var pagetotal = Convert.ToInt32((proditems.Count / pagesize) + 1);
                                                    for (int i = 1; i <= pagetotal; i++)
                                                    {
                                                        rule = new UrlRule
                                                        {
                                                            CultureCode = ruleCultureCode,
                                                            TabId       = module.TabID,
                                                            Parameters  = "catref=" + caturlname + "&page=" + i + "&pagemid=" + module.ModuleID,
                                                            Url         = pageurl + "-" + i
                                                        };
                                                        ruleExist = reducedRules.Any(r => r.Parameters == rule.Parameters);
                                                        if (!ruleExist)
                                                        {
                                                            if (reducedRules.Any(r => r.Url == rule.Url)) // if duplicate url
                                                            {
                                                                rule.Url = module.ModuleID + "-" + rule.Url;
                                                            }
                                                            rules.Add(rule);
                                                            catrules.Add(rule);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        // ------- Product URL ---------------
                                        foreach (var xrefData in proditems)
                                        {
                                            //var product = new ProductData(xrefData.ParentItemId, cultureCode, false);
                                            var prdData = objCtrl.GetData(xrefData.ParentItemId, cultureCode);

                                            var pref = prdData.GetXmlProperty("genxml/textbox/txtproductref");

                                            string produrl = prdData.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                                            ;
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = prdData.GetXmlProperty("genxml/lang/genxml/textbox/txtproductname");
                                            }
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = pref;
                                            }
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = prdData.ItemID.ToString("");
                                            }
                                            //if (catref != "") produrl = catref + "-" + produrl;
                                            //if (catref != "") produrl = catref + "-" + produrl;
                                            produrl = newcatUrl + "/" + Utils.UrlFriendly(produrl);
                                            var prodrule = new UrlRule
                                            {
                                                CultureCode = ruleCultureCode,
                                                TabId       = storesettings.ProductDetailTabId,
                                                Parameters  = "catref=" + catDataLang.GUIDKey + "&ref=" + prdData.GUIDKey,
                                                Url         = produrl
                                            };
                                            reducedRules =
                                                rules.Where(
                                                    r => r.CultureCode == prodrule.CultureCode && r.TabId == prodrule.TabId)
                                                .ToList();
                                            ruleExist = reducedRules.Any(r => r.Parameters == prodrule.Parameters);
                                            if (!ruleExist)
                                            {
                                                if (reducedRules.Any(r => r.Url == prodrule.Url)) // if duplicate url
                                                {
                                                    prodrule.Url = prdData.ItemID + "-" + produrl;
                                                }
                                                rules.Add(prodrule);
                                                catrules.Add(prodrule);
                                            }
                                        }
                                    }
                                    UrlRulesCaching.SetCache(portalId, catCacheKey, new TimeSpan(1, 0, 0, 0), catrules);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to generate url for module NBS", ex);
                    }
                }

                #endregion


                UrlRulesCaching.SetCache(portalId, portalCacheKey, new TimeSpan(1, 0, 0, 0), rules);


                #if DEBUG
                stopwatch.Stop();
                mess = $"PortalId: {portalId}. Time elapsed: {stopwatch.Elapsed.Milliseconds}ms. Module Count: {modules.Count()}. PurgedItems: {purgeResult.PurgedItemCount}";
                Logger.Error(mess);
                Console.WriteLine(mess);
                #endif


                return(rules);
            }
        }