private String GetProductListData(Dictionary<String, String> settings,bool paging = true)
        {
            var strOut = "";

            if (!settings.ContainsKey("header")) settings.Add("header", "");
            if (!settings.ContainsKey("body")) settings.Add("body", "");
            if (!settings.ContainsKey("footer")) settings.Add("footer", "");
            if (!settings.ContainsKey("filter")) settings.Add("filter", "");
            if (!settings.ContainsKey("orderby")) settings.Add("orderby", "");
            if (!settings.ContainsKey("returnlimit")) settings.Add("returnlimit", "0");
            if (!settings.ContainsKey("pagenumber")) settings.Add("pagenumber", "0");
            if (!settings.ContainsKey("pagesize")) settings.Add("pagesize", "0");
            if (!settings.ContainsKey("searchtext")) settings.Add("searchtext", "");
            if (!settings.ContainsKey("searchcategory")) settings.Add("searchcategory", "");
            if (!settings.ContainsKey("cascade")) settings.Add("cascade", "False");

            var header = settings["header"];
            var body = settings["body"];
            var footer = settings["footer"];
            var filter = settings["filter"];
            var orderby = settings["orderby"];
            var returnLimit = Convert.ToInt32(settings["returnlimit"]);
            var pageNumber = Convert.ToInt32(settings["pagenumber"]);
            var pageSize = Convert.ToInt32(settings["pagesize"]);
            var cascade = Convert.ToBoolean(settings["cascade"]);

            var searchText = settings["searchtext"];
            var searchCategory = settings["searchcategory"];

            if (searchText != "") filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) ";

            if (Utils.IsNumeric(searchCategory))
            {
                if (orderby == "{bycategoryproduct}") orderby += searchCategory;
                var objQual = DataProvider.Instance().ObjectQualifier;
                var dbOwner = DataProvider.Instance().DatabaseOwner;
                if (!cascade)
                    filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") ";
                else
                    filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) ";
            }
            else
            {
                if (orderby == "{bycategoryproduct}") orderby = " order by NB3.productname ";
            }

            var recordCount = 0;

            var themeFolder = StoreSettings.Current.ThemeFolder;
            if (settings.ContainsKey("themefolder")) themeFolder = settings["themefolder"];
            var templCtrl = NBrightBuyUtils.GetTemplateGetter(themeFolder);

            if (!settings.ContainsKey("portalid")) settings.Add("portalid", PortalSettings.Current.PortalId.ToString("")); // aways make sure we have portalid in settings

            var objCtrl = new NBrightBuyController();

            var headerTempl = templCtrl.GetTemplateData(header, _lang, true, true, true, StoreSettings.Current.Settings());
            var bodyTempl = templCtrl.GetTemplateData(body, _lang, true, true, true, StoreSettings.Current.Settings());
            var footerTempl = templCtrl.GetTemplateData(footer, _lang, true, true, true, StoreSettings.Current.Settings());

            // replace any settings tokens (This is used to place the form data into the SQL)
            headerTempl = Utils.ReplaceSettingTokens(headerTempl, settings);
            headerTempl = Utils.ReplaceUrlTokens(headerTempl);
            bodyTempl = Utils.ReplaceSettingTokens(bodyTempl, settings);
            bodyTempl = Utils.ReplaceUrlTokens(bodyTempl);
            footerTempl = Utils.ReplaceSettingTokens(footerTempl, settings);
            footerTempl = Utils.ReplaceUrlTokens(footerTempl);

            var obj = new NBrightInfo(true);
            strOut = GenXmlFunctions.RenderRepeater(obj, headerTempl);

            if (paging) // get record count for paging
            {
                if (pageNumber == 0) pageNumber = 1;
                if (pageSize == 0) pageSize = StoreSettings.Current.GetInt("pagesize");
                recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, "PRD", filter,"PRDLANG",_lang);
            }

            var objList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", _lang, filter, orderby, StoreSettings.Current.DebugMode,"",returnLimit,pageNumber,pageSize,recordCount);
            strOut += GenXmlFunctions.RenderRepeater(objList, bodyTempl);

            strOut += GenXmlFunctions.RenderRepeater(obj, footerTempl);

            // add paging if needed
            if (paging)
            {
                var pg = new NBrightCore.controls.PagingCtrl();
                strOut += pg.RenderPager(recordCount, pageSize, pageNumber);
            }

            return strOut;
        }
Example #2
0
        private void ResetLanguage()
        {
            var pass = GenXmlFunctions.GetField(rpData, "txtclearpass");
            if (pass == StoreSettings.Current.Get("adminpin") && pass != "")
            {
            var languagetoreset = GenXmlFunctions.GetField(rpData, "languagetoreset");
            var languageresetto = GenXmlFunctions.GetField(rpData, "languageresetto");
                if (languagetoreset != "" && languageresetto != languagetoreset)
                {
                    var objCtrl = new NBrightBuyController();

                    var l = objCtrl.GetDataList(PortalId, -1, "PRD", "", Utils.GetCurrentCulture(), "", "");
                    foreach (var i in l)
                    {
                        var prdData = ProductUtils.GetProductData(i.ItemID, languagetoreset);
                        prdData.ResetLanguage(languageresetto);
                    }

                    l = objCtrl.GetDataList(PortalId, -1, "CATEGORY", "", Utils.GetCurrentCulture(), "", "");
                    foreach (var i in l)
                    {
                        var catData = CategoryUtils.GetCategoryData(i.ItemID, languagetoreset);
                        catData.ResetLanguage(languageresetto);
                    }

                    DataCache.ClearCache();

                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, "completed", NotifyCode.ok);

                }
            }
            else
            {
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "nopin", NotifyCode.fail);
            }
        }
Example #3
0
        private void ProductlistDataBind(object sender, EventArgs e)
        {
            var lc = (Literal)sender;
            var container = (IDataItemContainer)lc.NamingContainer;
            try
            {
                var strOut = "";
                lc.Visible = visibleStatus.DefaultIfEmpty(true).First();
                if (lc.Visible)
                {

                    var param = lc.Text.Split(':');
                    if (param.Count() == 4)
                    {
                        try
                        {

                            var strFilter = "";
                            var templName = param[0];
                            var cascade = param[1];
                            var strOrder = param[2];
                            var filter = param[3];

                            if ((templName != ""))
                            {

                                var nbi = (GroupCategoryData)container.DataItem;
                                var lang = Utils.GetCurrentCulture();

                                var strCacheKey = lang + "*" + nbi.categoryid + "*" + lc.Text;
                                if (!StoreSettings.Current.DebugMode) strOut = (String)Utils.GetCache(strCacheKey);

                                if (String.IsNullOrEmpty(strOut))
                                {
                                    var buyCtrl = new NBrightBuyController();
                                    var rpTempl = buyCtrl.GetTemplateData(-1, templName, lang, _settings, StoreSettings.Current.DebugMode);

                                    //remove templName from template, so we don't get a loop.
                                    if (rpTempl.Contains(templName)) rpTempl = rpTempl.Replace(templName, "");
                                    //build models list

                                    var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                                    var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
                                    if (cascade.ToLower() == "true")
                                    {
                                        strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATCASCADE' or typecode = 'CATXREF') and XrefItemId = " + nbi.categoryid.ToString("") + ") ";
                                    }
                                    else
                                        strFilter = strFilter + " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + nbi.categoryid.ToString("") + ") ";

                                    if (strOrder == "{bycategoryproduct}") strOrder += nbi.categoryid.ToString(""); // do special custom sort in each cateogry

                                    if (filter != "") strFilter += " AND " + filter;

                                    var objL = buyCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "PRD", "PRDLANG", Utils.GetCurrentCulture(), strFilter, strOrder);

                                    // inject the categoryid into the data, so the entryurl can have the correct catid
                                    foreach (var i in objL)
                                    {
                                        i.SetXmlProperty("genxml/categoryid", nbi.categoryid.ToString(""));
                                    }

                                    var itemTemplate = NBrightBuyUtils.GetGenXmlTemplate(rpTempl, _settings, PortalSettings.Current.HomeDirectory,visibleStatus);
                                    strOut = GenXmlFunctions.RenderRepeater(objL, itemTemplate);
                                    if (!StoreSettings.Current.DebugMode) NBrightBuyUtils.SetModCache(-1, strCacheKey, strOut);
                                }

                            }
                        }
                        catch (Exception exc)
                        {
                            strOut = "ERROR: <br/>" + exc;
                        }

                    }

                }
                lc.Text = strOut;

            }
            catch (Exception)
            {
                lc.Text = "";
            }
        }
Example #4
0
 public List<NBrightInfo> GetRelatedProducts()
 {
     var objCtrl = new NBrightBuyController();
     var strSelectedIds = "";
     var arylist = objCtrl.GetList(_portalId, -1, "PRDXREF", " and NB1.parentitemid = " + Info.ItemID.ToString(""));
     foreach (var obj in arylist)
     {
         strSelectedIds += obj.XrefItemId.ToString("") + ",";
     }
     var relList = new List<NBrightInfo>();
     if (strSelectedIds.TrimEnd(',') != "")
     {
         var strFilter = " and NB1.[ItemId] in (" + strSelectedIds.TrimEnd(',') + ") ";
         relList = objCtrl.GetDataList(_portalId, -1, "PRD", "PRDLANG", _lang, strFilter, "");
     }
     return relList;
 }
Example #5
0
        public static List<NBrightInfo> GetCatList(int parentid = 0, string groupref = "", String lang = "")
        {
            if (lang == "") lang = Utils.GetCurrentCulture();

            var strFilter = "";
            if (groupref == "" || groupref == "0") // Because we've introduced Properties (for non-category groups) we will only display these if cat is not selected.
                strFilter += " and [XMLData].value('(genxml/dropdownlist/ddlgrouptype)[1]','nvarchar(max)') != 'cat' ";
            else
            {
                if (groupref == "cat") strFilter = " and NB1.ParentItemId = " + parentid + " "; // only category have multipel levels.
                strFilter += " and [XMLData].value('(genxml/dropdownlist/ddlgrouptype)[1]','nvarchar(max)') = '" + groupref + "' ";
            }

            var objCtrl = new NBrightBuyController();
            var levelList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "CATEGORY", "CATEGORYLANG", lang, strFilter, " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ", true);

            var grpCtrl = new GrpCatController(lang);

            foreach (var c in levelList)
            {
                var g = grpCtrl.GetCategory(c.ItemID);
                if (g != null) c.SetXmlProperty("genxml/entrycount", g.entrycount.ToString(""));
            }

            return levelList;
        }
Example #6
0
 public static List<NBrightInfo> GetCategoryGroups(String lang, Boolean debugMode = false)
 {
     var objCtrl = new NBrightBuyController();
     var levelList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "GROUP", "GROUPLANG", lang, "", " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ", debugMode);
     return levelList;
 }
Example #7
0
        public static int ValidateStore()
        {
            // clear all cache to start.
            DataCache.ClearCache();

            var objCtrl = new NBrightBuyController();
            var errcount = 0;

            // Validate Products
            var prodList = objCtrl.GetList(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, -1, "PRD");
            foreach (var p in prodList)
            {
                var prodData = ProductUtils.GetProductData(p.ItemID, StoreSettings.Current.EditLanguage);
                errcount += prodData.Validate();
            }

            // Validate Categories
            var catList = objCtrl.GetList(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, -1, "CATEGORY");
            foreach (var c in catList)
            {
                var catData = CategoryUtils.GetCategoryData(c.ItemID, StoreSettings.Current.EditLanguage);
                errcount += catData.Validate();
            }

            // Validate Groups
            var grpList = objCtrl.GetList(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, -1, "GROUP");
            foreach (var c in grpList)
            {
                var grpData = new GroupData(c.ItemID, StoreSettings.Current.EditLanguage);
                errcount += grpData.Validate();
            }

            // reset catid from catref
            var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "SETTINGS", "", Utils.GetCurrentCulture(), " and [XMLdata].value('(genxml/catref)[1]','nvarchar(max)') != ''","");
            foreach (var s in l)
            {
                var info = ModuleSettingsResetCatIdFromRef(s);
                objCtrl.Update(info);
            }

            return errcount;
        }
Example #8
0
 public static List<NBrightInfo> GetCategoryGroups(string lang, Boolean debugMode = false, string groupType = "")
 {
     var filter = "";
     if (groupType != "") filter = " and [XMLData].value('(genxml/dropdownlist/grouptype)[1]','nvarchar(max)') = '" + groupType + "' ";
     var objCtrl = new NBrightBuyController();
     var levelList = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "GROUP", "GROUPLANG", lang, filter, " order by [XMLData].value('(genxml/hidden/recordsortorder)[1]','decimal(10,2)') ", debugMode);
     return levelList;
 }