Exemplo n.º 1
0
        public void CheckforNewSystemConfig()
        {
            if (!_portallevel) // only want to edit system level file
            {
                // Add new plugins
                var updated             = false;
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var flist = Directory.GetFiles(pluginfoldermappath);
                    foreach (var f in flist)
                    {
                        if (f.EndsWith("system.config"))
                        {
                            // the system.config file allow us to reset plugins at a system default level.
                            var datain = File.ReadAllText(f);
                            try
                            {
                                var nbi = new NBrightInfo();
                                nbi.XMLData = datain;

                                SystemConfigMerge(nbi);

                                File.Delete(f);
                                updated = true;
                            }
                            catch (Exception)
                            {
                                // data might not be XML complient (ignore)
                            }
                        }
                    }
                    if (updated)
                    {
                        Save(false);          // only update system level
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Load()
        {
            var menuplugin = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, _portallevel, _storeSettings.Settings());

            if (menuplugin != "")
            {
                var info = new NBrightInfo();
                info.PortalId = _portalId;
                info.XMLData  = menuplugin;
                _pluginList   = new List <NBrightInfo>();
                _pluginList   = CalcPluginList(info);
            }
            else
            {
                // no menuplugin.xml exists, so must be new install, get new config
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var xmlDoc = new XmlDocument();
                    xmlDoc.Load(pluginfoldermappath + "\\menu.config");
                    pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Themes/config/default");
                    xmlDoc.Save(pluginfoldermappath + "\\menuplugin.xml");
                    //load new config
                    menuplugin = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, _portallevel, _storeSettings.Settings());
                    if (menuplugin != "")
                    {
                        var info = new NBrightInfo();
                        info.PortalId = _portalId;
                        info.XMLData  = menuplugin;
                        _pluginList   = new List <NBrightInfo>();
                        _pluginList   = CalcPluginList(info);
                    }
                }
            }
            NBrightBuyUtils.SetModCache(0, _cachekey, _pluginList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public void UpdateSystemPlugins()
        {
            if (!_portallevel) // only want to edit system level file
            {
                // Add new plugins
                var updated             = false;
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var ctrlList = new Dictionary <String, int>();
                    var flist    = Directory.GetFiles(pluginfoldermappath);
                    foreach (var f in flist)
                    {
                        if (f.EndsWith(".xml"))
                        {
                            var datain = File.ReadAllText(f);
                            try
                            {
                                var nbi = new NBrightInfo();
                                nbi.XMLData = datain;
                                // check if we are injecting multiple
                                var nodlist = nbi.XMLDoc.SelectNodes("root/genxml");
                                if (nodlist != null && nodlist.Count == 0)
                                {
                                    AddPlugin(nbi);
                                }
                                else
                                {
                                    foreach (XmlNode nod in nodlist)
                                    {
                                        var nbi2 = new NBrightInfo();
                                        nbi2.XMLData = nod.OuterXml;
                                        AddPlugin(nbi2);
                                    }
                                }


                                ctrlList.Add(nbi.GetXmlProperty("genxml/textbox/ctrl"), nbi.GetXmlPropertyInt("genxml/hidden/index"));

                                updated = true;
                                File.Delete(f);
                            }
                            catch (Exception)
                            {
                                // data might not be XML complient (ignore)
                            }
                        }
                    }

                    if (updated)
                    {
                        Save(false); // only update system level
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static void CreateSystemPlugins()
        {
            var cachekey = "pluginlistsystem";
            var pList    = NBrightBuyUtils.GetCache(cachekey);

            if (pList == null)
            {
                var objCtrl = new NBrightBuyController();
                var rtnList = objCtrl.GetList(99999, -1, "PLUGIN", "", "order by nb1.xmldata.value('(genxml/hidden/index)[1]','float')");
                if (rtnList.Count == 0)
                {
                    var pluginList = new List <NBrightInfo>();
                    var info       = new NBrightInfo();
                    // no menuplugin.xml exists, so must be new install, get new config
                    var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                    if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath) && File.Exists(pluginfoldermappath + "\\menu.config"))
                    {
                        var menuconfig = Utils.ReadFile(pluginfoldermappath + "\\menu.config");
                        if (menuconfig != "")
                        {
                            info.XMLData  = menuconfig;
                            info.PortalId = 99999;
                            pluginList    = CalcSystemPluginList(info);
                            CreateDBrecords(pluginList, 99999);
                            CreatePortalPlugins();
                        }
                    }
                }
                NBrightBuyUtils.SetCache(cachekey, "True");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public static void UpdateSystemPlugins()
        {
            // Add new plugins
            var updated             = false;
            var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");

            if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
            {
                var objCtrl = new NBrightBuyController();
                var flist   = Directory.GetFiles(pluginfoldermappath, "*.xml");
                foreach (var f in flist)
                {
                    if (f.EndsWith(".xml"))
                    {
                        var datain = File.ReadAllText(f);
                        try
                        {
                            var nbi = new NBrightInfo();
                            nbi.XMLData = datain;
                            // check if we are injecting multiple
                            var nodlist = nbi.XMLDoc.SelectNodes("genxml");
                            if (nodlist != null && nodlist.Count > 0)
                            {
                                foreach (XmlNode nod in nodlist)
                                {
                                    var nbi2 = new NBrightInfo();
                                    nbi2.XMLData      = nod.OuterXml;
                                    nbi2.ItemID       = -1;
                                    nbi2.GUIDKey      = nbi.GetXmlProperty("genxml/textbox/ctrl");
                                    nbi2.PortalId     = 99999;
                                    nbi2.Lang         = "";
                                    nbi2.ParentItemId = 0;
                                    nbi2.ModuleId     = -1;
                                    nbi2.XrefItemId   = 0;
                                    nbi2.UserId       = 0;
                                    nbi2.TypeCode     = "PLUGIN";

                                    // check if record exists (should NOT) but lets replace if it does.
                                    var existingrecord = objCtrl.GetByGuidKey(-1, -1, "PLUGIN", nbi2.GUIDKey);
                                    if (existingrecord != null)
                                    {
                                        nbi2.ItemID = existingrecord.ItemID;
                                        if (nbi2.GetXmlPropertyBool("genxml/delete"))
                                        {
                                            objCtrl.Delete(existingrecord.ItemID);
                                        }
                                        else
                                        {
                                            objCtrl.Update(nbi2);
                                            updated = true;
                                        }
                                    }
                                    else
                                    {
                                        objCtrl.Update(nbi2);
                                        updated = true;
                                    }
                                }
                            }
                            if (updated)
                            {
                                File.Delete(f);
                            }
                        }
                        catch (Exception)
                        {
                            // data might not be XML complient (ignore)
                        }
                    }
                }
            }

            if (updated)
            {
                CopySystemPluginsToPortal();
                ClearPluginCache(PortalSettings.Current.PortalId);
            }
        }
Exemplo n.º 6
0
        private List <MenuNode> GetCatNodeXml(string currentTabId, int categoryInjectTabId, int parentItemId = 0, bool recursive = true, int depth = 0, MenuNode pnode = null, string defaultListPage = "")
        {
            var nodes = new List <MenuNode>();
            //[TODO: Add images onto DDRMenu]
            //var objS = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SETTINGS", "NBrightBuySettings");
            //var imgFolder = objS.GetXmlProperty("genxml/textbox/txtuploadfolder");
            //var defimgsize = objS.GetXmlProperty("genxml/textbox/txtsmallimgsize");

            //var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATEGORY", strFilter, strOrderBy, 0, 0, 0, 0, "CATEGORYLANG", Utils.GetCurrentCulture());

            var grpCatCtrl = new GrpCatController(Utils.GetCurrentCulture());

            var l = grpCatCtrl.GetCategories(parentItemId);

            foreach (var obj in l)
            {
                if (!obj.ishidden)
                {
                    var n = new MenuNode();

                    n.Parent = pnode;

                    n.TabId = categoryInjectTabId;
                    n.Text  = obj.categoryname;
                    n.Title = obj.categorydesc;

                    var tabid = "";
                    if (Utils.IsNumeric(defaultListPage))
                    {
                        tabid = defaultListPage;
                    }
                    if (tabid == "")
                    {
                        tabid = currentTabId;
                    }
                    if (Utils.IsNumeric(tabid))
                    {
                        n.Url = grpCatCtrl.GetCategoryUrl(obj, Convert.ToInt32((tabid)));
                    }

                    n.Enabled = true;
                    if (obj.disabled)
                    {
                        n.Enabled = false;
                    }
                    n.Selected = false;
                    // redundant with caching
                    //if (_catid == obj.categoryid.ToString("")) n.Selected = true;
                    n.Breadcrumb = false;
                    //if (_catid == obj.categoryid.ToString("")) n.Breadcrumb = true;
                    n.Separator  = false;
                    n.LargeImage = "";
                    n.Icon       = "";
                    var img = obj.imageurl;
                    if (img != "")
                    {
                        n.LargeImage = img;
                        n.Icon       = StoreSettings.NBrightBuyPath() + "/NBrightThumb.ashx?w=50&h=50&src=/" + img.TrimStart('/');
                    }
                    n.Keywords    = obj.metakeywords;
                    n.Description = obj.metadescription;
                    n.CommandName = "";
                    //n.CommandArgument = string.Format("entrycount={0}|moduleid={1}", obj.GetXmlProperty("genxml/hidden/entrycount"), obj.ModuleId.ToString(""));
                    n.CommandArgument = obj.entrycount.ToString(""); // not used, so we use it to store the entry count

                    if (recursive && depth < 5)                      //stop infinate loop, only allow 50 sub levels
                    {
                        depth += 1;
                        var childrenNodes = GetCatNodeXml(tabid, categoryInjectTabId, obj.categoryid, true, depth, n, defaultListPage);
                        if (childrenNodes.Count > 0)
                        {
                            n.Children = childrenNodes;
                        }
                    }

                    nodes.Add(n);
                }
            }

            return(nodes);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public void UpdateSystemPlugins()
        {
            if (!_portallevel) // only want to edit system level file
            {
                // Add new plugins
                var updated             = false;
                var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");
                if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
                {
                    var ctrlList = new Dictionary <String, int>();
                    var flist    = Directory.GetFiles(pluginfoldermappath);
                    foreach (var f in flist)
                    {
                        if (f.EndsWith(".xml"))
                        {
                            var datain = File.ReadAllText(f);
                            try
                            {
                                var nbi = new NBrightInfo();
                                nbi.XMLData = datain;
                                AddPlugin(nbi);
                                ctrlList.Add(nbi.GetXmlProperty("genxml/textbox/ctrl"), nbi.GetXmlPropertyInt("genxml/hidden/index"));

                                updated = true;
                                File.Delete(f);
                            }
                            catch (Exception)
                            {
                                // data might not be XML complient (ignore)
                            }
                        }
                    }

                    if (updated)
                    {
                        Save(false); // only update system level
                        if (ctrlList.Count > 0)
                        {
                            // move new plugin to top.
                            foreach (var p in ctrlList)
                            {
                                var topPlugin = GetPlugin(p.Value);
                                if (topPlugin != null)
                                {
                                    MovePlugin(p.Key, topPlugin.GUIDKey, false);
                                }
                            }
                        }
                    }
                }
            }
        }