Ejemplo n.º 1
0
        private void PageLoad()
        {
            #region "Data Repeater"

            if (UserId > 0) // only logged in users can see data on this module.
            {
                var levelList = NBrightBuyUtils.GetCategoryGroups(EditLanguage, true);

                // validate language record for list
                foreach (var nbi in levelList)
                {
                    var gp = new GroupData(nbi.ItemID, EditLanguage);
                    gp.Validate();
                }

                rpData.DataSource = levelList;
                rpData.DataBind();
            }

            #endregion

            // display header (Do header after the data return so the productcount works)
            base.DoDetail(rpDataH);

            // display footer
            base.DoDetail(rpDataF);
        }
Ejemplo n.º 2
0
        private void Load(String lang, Boolean debugMode = false)
        {
            lock (lockobjectLoad)
            {
                _objCtrl = new NBrightBuyController();
                _lang    = lang;

                var strCacheKey = "GrpList_" + lang + "_" + _portalId;
                GroupList = (List <NBrightInfo>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (GroupList == null || debugMode)
                {
                    // get groups
                    GroupList = NBrightBuyUtils.GetCategoryGroups(_portalId, _lang, true);
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupList);
                }

                strCacheKey      = "GroupsDictionary_" + lang + "_" + _portalId;
                GroupsDictionary = (Dictionary <string, string>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (GroupsDictionary == null || debugMode)
                {
                    GroupsDictionary = new Dictionary <String, String>();
                    foreach (var g in GroupList)
                    {
                        if (!GroupsDictionary.ContainsKey(g.GetXmlProperty("genxml/textbox/groupref")))
                        {
                            GroupsDictionary.Add(g.GetXmlProperty("genxml/textbox/groupref"), g.GetXmlProperty("genxml/lang/genxml/textbox/groupname"));
                        }
                    }
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupsDictionary);
                }

                // build group category list
                strCacheKey     = "GrpCategoryList_" + lang + "_" + _portalId;
                GrpCategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (GrpCategoryList == null || debugMode)
                {
                    GrpCategoryList = GetGrpCatListFromDatabase(lang);
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, GrpCategoryList);
                }

                // build cateogry list for navigation from group category list
                strCacheKey  = "CategoryList_" + lang + "_" + _portalId;
                CategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
                if (CategoryList == null || debugMode)
                {
                    var lenum = from i in GrpCategoryList where i.grouptyperef == "cat" select i;
                    CategoryList = lenum.ToList();
                    NBrightBuyUtils.SetModCache(-1, strCacheKey, CategoryList);
                }

                // add breadcrumb (needs both GrpCategoryList and CategoryList )
                //[TODO: fix this catch 22 for list dependancy]
                foreach (var grpcat in CategoryList)
                {
                    grpcat.breadcrumb = GetBreadCrumb(grpcat.categoryid, 200, ">", false);
                }
            }
        }
Ejemplo n.º 3
0
        private void Load(String lang, Boolean debugMode = false)
        {
            _objCtrl = new NBrightBuyController();
            _lang    = lang;

            var strCacheKey = "NBS_GrpList_" + lang + "_" + _portalId;

            GroupList = (List <NBrightInfo>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (GroupList == null || debugMode)
            {
                // get groups
                GroupList = NBrightBuyUtils.GetCategoryGroups(_lang, true);
                NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupList);
            }

            strCacheKey      = "NBS_GroupsDictionary_" + lang + "_" + _portalId;
            GroupsDictionary = (Dictionary <string, string>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (GroupsDictionary == null || debugMode)
            {
                GroupsDictionary = new Dictionary <String, String>();
                foreach (var g in GroupList)
                {
                    if (!GroupsDictionary.ContainsKey(g.GetXmlProperty("genxml/textbox/groupref")))
                    {
                        GroupsDictionary.Add(g.GetXmlProperty("genxml/textbox/groupref"), g.GetXmlProperty("genxml/lang/genxml/textbox/groupname"));
                    }
                }
                NBrightBuyUtils.SetModCache(-1, strCacheKey, GroupsDictionary);
            }

            // build group category list
            strCacheKey     = "NBS_GrpCategoryList_" + lang + "_" + _portalId;
            GrpCategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (GrpCategoryList == null || debugMode)
            {
                GrpCategoryList = GetGrpCatListFromDatabase(lang);
                NBrightBuyUtils.SetModCache(-1, strCacheKey, GrpCategoryList);
            }

            // build cateogry list for navigation from group category list
            strCacheKey  = "NBS_CategoryList_" + lang + "_" + _portalId;
            CategoryList = (List <GroupCategoryData>)NBrightBuyUtils.GetModCache(strCacheKey);
            if (CategoryList == null || debugMode)
            {
                var lenum = from i in GrpCategoryList where i.grouptyperef == "cat" select i;
                CategoryList = lenum.ToList();
                NBrightBuyUtils.SetModCache(-1, strCacheKey, CategoryList);
            }
        }
Ejemplo n.º 4
0
        private void PageLoad()
        {
            #region "Data Repeater"

            if (UserId > 0) // only logged in users can see data on this module.
            {
                rpData.DataSource = NBrightBuyUtils.GetCategoryGroups(EditLanguage, true);
                rpData.DataBind();
            }

            #endregion

            // display header (Do header after the data return so the productcount works)
            base.DoDetail(rpDataH);

            // display footer
            base.DoDetail(rpDataF);
        }
Ejemplo n.º 5
0
        private void FixRecordSortOrder()
        {
            // fix any incorrect sort orders
            Double lp        = 1;
            var    levelList = NBrightBuyUtils.GetCategoryGroups(EditLanguage, true);

            foreach (NBrightInfo catinfo in levelList)
            {
                var recordsortorder = catinfo.GetXmlPropertyDouble("genxml/hidden/recordsortorder");
                if (recordsortorder != lp)
                {
                    var catData = CategoryUtils.GetCategoryData(catinfo.ItemID, StoreSettings.Current.EditLanguage);
                    catData.DataRecord.SetXmlPropertyDouble("genxml/hidden/recordsortorder", lp);
                    ModCtrl.Update(catData.DataRecord);
                }
                lp += 1;
            }
        }
Ejemplo n.º 6
0
        public IEncodedString GroupSelectList(NBrightInfo info, String xpath, String attributes = "", Boolean allowEmpty = true, String groupType = "1")
        {
            var strOut = "";
            var upd    = getUpdateAttr(xpath, attributes);
            var id     = getIdFromXpath(xpath);

            if (attributes.StartsWith("ResourceKey:"))
            {
                attributes = ResourceKey(attributes.Replace("ResourceKey:", "")).ToString();
            }

            strOut = "<select id='" + id + "' " + upd + " " + attributes + ">";
            var s = "";

            if (allowEmpty)
            {
                strOut += "    <option value=''></option>";
            }

            var tList = NBrightBuyUtils.GetCategoryGroups(StoreSettings.Current.EditLanguage, true, groupType);

            foreach (var tItem in tList)
            {
                if (tItem.GetXmlProperty("genxml/textbox/groupref") != "cat")
                {
                    if (info.GetXmlProperty(xpath) == tItem.GetXmlProperty("genxml/textbox/groupref"))
                    {
                        s = "selected";
                    }
                    else
                    {
                        s = "";
                    }
                    strOut += "    <option value='" + tItem.GetXmlProperty("genxml/textbox/groupref") + "' " + s + ">" + tItem.GetXmlProperty("genxml/textbox/groupref") + ": " + tItem.GetXmlProperty("genxml/lang/genxml/textbox/groupname") + "</option>";
                }
            }

            strOut += "</select>";

            return(new RawString(strOut));
        }
Ejemplo n.º 7
0
        private void Update()
        {
            var settings = ModCtrl.GetByGuidKey(PortalSettings.Current.PortalId, 0, "SETTINGS", "NBrightBuySettings");

            if (settings == null)
            {
                settings          = new NBrightInfo(true);
                settings.PortalId = PortalId;
                // use zero as moduleid so it's not picked up by the modules for their settings.
                // The normal GetList will get all moduleid OR moduleid=-1
                settings.ModuleId = 0;
                settings.ItemID   = -1;
                settings.TypeCode = "SETTINGS";
                settings.GUIDKey  = "NBrightBuySettings";
            }

            var sharedflag = settings.GetXmlProperty("genxml/checkbox/sharedproductsflag"); //maintain shared flag

            settings.XMLData = GenXmlFunctions.GetGenXml(rpData, "", StoreSettings.Current.FolderImagesMapPath);

            if (settings.GetXmlProperty("genxml/hidden/hidemaillogo") != "")
            {
                settings.SetXmlProperty("genxml/hidden/emaillogourl", StoreSettings.Current.FolderImages + "/" + settings.GetXmlProperty("genxml/hidden/hidemaillogo"));
                settings.SetXmlProperty("genxml/hidden/emaillogopath", StoreSettings.Current.FolderImagesMapPath + "\\" + settings.GetXmlProperty("genxml/hidden/hidemaillogo"));
            }


            settings.SetXmlProperty("genxml/hidden/backofficetabid", PortalSettings.Current.ActiveTab.TabID.ToString(""));

            settings.SetXmlProperty("genxml/checkbox/sharedproductsflag", sharedflag); //maintain shared flag

            ModCtrl.Update(settings);

            if (StoreSettings.Current.DebugModeFileOut)
            {
                settings.XMLDoc.Save(PortalSettings.HomeDirectoryMapPath + "\\debug_Settings.xml");
            }

            // create upload folders
            var folder = StoreSettings.Current.FolderNBStoreMapPath;

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderImagesMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderDocumentsMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderUploadsMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderClientUploadsMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderTempMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            //Create default category grouptype
            var l = NBrightBuyUtils.GetCategoryGroups(EditLanguage, true);
            var g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "cat" select i;

            if (!g.Any())
            {
                CreateGroup("cat", "Categories", "2");
            }
            if (l.Count == 0)
            {
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "promo" select i;
                if (!g.Any())
                {
                    CreateGroup("promo", "Promotions", "1");
                }
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "man" select i;
                if (!g.Any())
                {
                    CreateGroup("man", "Manufacturer", "1");
                }
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "supp" select i;
                if (!g.Any())
                {
                    CreateGroup("supp", "Supplier", "1");
                }
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "fea" select i;
                if (!g.Any())
                {
                    CreateGroup("fea", "Features", "1");
                }
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "spec" select i;
                if (!g.Any())
                {
                    CreateGroup("spec", "Specifications", "1");
                }
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "temp" select i;
                if (!g.Any())
                {
                    CreateGroup("temp", "Temp", "1");
                }
                g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "searchfilter" select i;
                if (!g.Any())
                {
                    CreateGroup("searchfilter", "Display Search Filter", "3");
                }
            }

            //update resx fields
            var resxDic     = GenXmlFunctions.GetGenXmlResx(rpData);
            var genTempl    = (GenXmlTemplate)rpData.ItemTemplate;
            var resxfolders = genTempl.GetResxFolders();  // ideally we'd create the settings resx at the portal level, but can't easily get that to work.
            var resxUpdate  = NBrightBuyUtils.UpdateResxFields(resxDic, resxfolders, StoreSettings.Current.EditLanguage, true);

            //remove all cahce setting from cache for reload
            //DNN is sticky with some stuff (had some issues with email addresses not updating), so to be sure clear it all.
            DataCache.ClearCache();
        }
Ejemplo n.º 8
0
        private void Update()
        {
            var settings = ModCtrl.GetByGuidKey(PortalSettings.Current.PortalId, 0, "SETTINGS", "NBrightBuySettings");

            if (settings == null)
            {
                settings          = new NBrightInfo(true);
                settings.PortalId = PortalId;
                // use zero as moduleid so it's not picked up by the modules for their settings.
                // The normal GetList will get all moduleid OR moduleid=-1
                settings.ModuleId = 0;
                settings.ItemID   = -1;
                settings.TypeCode = "SETTINGS";
                settings.GUIDKey  = "NBrightBuySettings";
            }

            var sharedflag = settings.GetXmlProperty("genxml/checkbox/sharedproductsflag"); //maintain shared flag

            settings.XMLData = GenXmlFunctions.GetGenXml(rpData, "", StoreSettings.Current.FolderImagesMapPath);

            if (settings.GetXmlProperty("genxml/hidden/hidemaillogo") != "")
            {
                settings.SetXmlProperty("genxml/hidden/emaillogourl", StoreSettings.Current.FolderImages + "/" + settings.GetXmlProperty("genxml/hidden/hidemaillogo"));
                settings.SetXmlProperty("genxml/hidden/emaillogopath", StoreSettings.Current.FolderImagesMapPath + "\\" + settings.GetXmlProperty("genxml/hidden/hidemaillogo"));
            }


            settings.SetXmlProperty("genxml/hidden/backofficetabid", PortalSettings.Current.ActiveTab.TabID.ToString(""));

            settings.SetXmlProperty("genxml/checkbox/sharedproductsflag", sharedflag); //maintain shared flag

            // store root mappath of website, so we can use it in the scheudler.
            settings.SetXmlProperty("genxml/hidden/rootmappath", HttpContext.Current.Server.MapPath("/"));

            ModCtrl.Update(settings);

            if (StoreSettings.Current.DebugModeFileOut)
            {
                settings.XMLDoc.Save(PortalSettings.HomeDirectoryMapPath + "\\debug_Settings.xml");
            }

            // create upload folders
            var folder = StoreSettings.Current.FolderNBStoreMapPath;

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderImagesMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderDocumentsMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderUploadsMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderClientUploadsMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            folder = StoreSettings.Current.FolderTempMapPath;
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            //Create default category grouptype
            var l = NBrightBuyUtils.GetCategoryGroups(EditLanguage, true);
            var g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == "cat" select i;

            if (!g.Any())
            {
                CreateGroup("cat", "Categories", "2");
            }
            if (l.Count == 0)
            {
                // read init xml config file.
                string relPath  = "/DesktopModules/NBright/NBrightBuy/Themes/config/default";
                var    fullpath = HttpContext.Current.Server.MapPath(relPath);
                var    strXml   = Utils.ReadFile(fullpath + "\\setup.config");
                var    nbi      = new NBrightInfo();
                nbi.XMLData = strXml;

                var xmlNodes = nbi.XMLDoc?.SelectNodes("root/group");
                if (xmlNodes != null)
                {
                    foreach (XmlNode xmlNod in xmlNodes)
                    {
                        if (xmlNod.Attributes?["groupref"] != null)
                        {
                            g = from i in l where i.GetXmlProperty("genxml/textbox/groupref") == xmlNod.Attributes["groupref"].Value select i;
                            if (!g.Any())
                            {
                                CreateGroup(xmlNod.Attributes["groupref"].Value, xmlNod.Attributes["groupname"].Value, xmlNod.Attributes["grouptype"].Value);
                            }
                        }
                    }
                }
            }

            //update resx fields
            var resxDic     = GenXmlFunctions.GetGenXmlResx(rpData);
            var genTempl    = (GenXmlTemplate)rpData.ItemTemplate;
            var resxfolders = genTempl.GetResxFolders();  // ideally we'd create the settings resx at the portal level, but can't easily get that to work.
            var resxUpdate  = NBrightBuyUtils.UpdateResxFields(resxDic, resxfolders, StoreSettings.Current.EditLanguage, true);

            //remove all cahce setting from cache for reload
            //DNN is sticky with some stuff (had some issues with email addresses not updating), so to be sure clear it all.
            DataCache.ClearCache();
        }
Ejemplo n.º 9
0
        protected override void OnInit(EventArgs e)
        {
            _pluginData = new PluginData(PortalId);

            base.OnInit(e);
            try
            {
                if (UserId > 0) //do nothing if user not logged on
                {
                    var ctrl = Utils.RequestQueryStringParam(Context, "ctrl");

                    // anyone only in the client role is only allowed in the products control
                    if (UserInfo.IsInRole(StoreSettings.ClientEditorRole) && (!UserInfo.IsInRole(StoreSettings.EditorRole) && !UserInfo.IsInRole(StoreSettings.ManagerRole) && !UserInfo.IsInRole("Administrators")))
                    {
                        //   ctrl = "products";
                    }

                    if (ctrl == "")
                    {
                        ctrl = (String)HttpContext.Current.Session["nbrightbackofficectrl"];
                    }
                    else
                    {
                        HttpContext.Current.Session["nbrightbackofficectrl"] = ctrl;
                    }

                    if (String.IsNullOrEmpty(ctrl))
                    {
                        var plist = PluginUtils.GetPluginList();
                        if (plist.Count() > 0)
                        {
                            // get first plugin in list as default.
                            ctrl = plist.First().GUIDKey;
                        }
                        if (ctrl == "")
                        {
                            ctrl = "dashsummary";
                        }
                        if (StoreSettings.Current.Settings().Count == 0)
                        {
                            ctrl = "settings";
                        }
                        HttpContext.Current.Session["nbrightbackofficectrl"] = ctrl;
                    }

                    var ctlpath = GetControlPath(ctrl);
                    if (ctlpath == "")  // ctrl may not exist in system, so default to products
                    {
                        ctrl    = "products";
                        ctlpath = GetControlPath(ctrl);
                    }

                    // check for group data, this MUST be there otherwise this is the first time into the BO, so redirect to Admin.
                    var l = NBrightBuyUtils.GetCategoryGroups(Utils.GetCurrentCulture(), true, ""); // don't test for grouptype, on upgrade it might not be there!!
                    if (!l.Any())
                    {
                        // redisplay settings
                        ctrl    = "settings";
                        ctlpath = GetControlPath(ctrl);
                        NBrightBuyUtils.SetNotfiyMessage(ModuleId, "settingssetup", NotifyCode.fail);
                    }

                    if (ctlpath != "" && CheckSecurity(ctrl))
                    {
                        // make compatible with running DNN in virtual directory
                        if (HttpContext.Current.Request.ApplicationPath != null && !ctlpath.StartsWith(HttpContext.Current.Request.ApplicationPath))
                        {
                            ctlpath = HttpContext.Current.Request.ApplicationPath + ctlpath;
                        }
                        var c1 = LoadControl(ctlpath);
                        phData.Controls.Add(c1);
                    }
                    else
                    {
                        var c1 = new Literal();
                        c1.Text = "INVALID CONTROL: " + ctrl;
                        phData.Controls.Add(c1);
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                //display the error on the template (don;t want to log it here, prefer to deal with errors directly.)
                var l = new Literal();
                l.Text = exc.ToString();
                phData.Controls.Add(l);
            }
        }