Exemplo n.º 1
0
        public override void DoWork()
        {
            try
            {

                var portallist = DnnUtils.GetAllPortals();

                foreach (var portal in portallist)
                {

                    // clear down NBStore temp folder
                    var storeSettings = new StoreSettings(portal.PortalID);
                    if (Directory.Exists(storeSettings.FolderTempMapPath))
                    {
                        string[] files = Directory.GetFiles(storeSettings.FolderTempMapPath);

                        foreach (string file in files)
                        {
                            FileInfo fi = new FileInfo(file);
                            if (fi.LastAccessTime < DateTime.Now.AddHours(-3)) fi.Delete();
                        }

                        // DO Scheduler Jobs
                        var pluginData = new PluginData(portal.PortalID);
                        var l = pluginData.GetSchedulerProviders();

                        foreach (var p in l)
                        {
                            var prov = p.Value;
                            ObjectHandle handle = null;
                            handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                            if (handle != null)
                            {
                                var objProvider = (SchedulerInterface)handle.Unwrap();
                                var strMsg = objProvider.DoWork(portal.PortalID);
                                if (strMsg != "")
                                {
                                    this.ScheduleHistoryItem.AddLogNote(strMsg);
                                }
                            }

                        }
                    }
                }

                this.ScheduleHistoryItem.Succeeded = true;

            }
            catch (Exception Ex)
            {
                //--intimate the schedule mechanism to write log note in schedule history
                this.ScheduleHistoryItem.Succeeded = false;
                this.ScheduleHistoryItem.AddLogNote("NBS Service Start. Failed. " + Ex.ToString());
                this.Errored(ref Ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="portalfinfo"></param>
        /// <returns></returns>
        public override string DoWork()
        {
            try
            {
                var objCtrl = new NBrightBuyController();

                // the sceduler runs at host level, we therefore need to loop through ALL portals to process data at a portal level.
                var portalList = NBrightDNN.DnnUtils.GetAllPortals();
                foreach (var portal in portalList)
                {
                    // check if we have NBS in this portal by looking for default settings.
                    var nbssetting = objCtrl.GetByGuidKey(portal.PortalID, -1, "SETTINGS", "NBrightBuySettings");
                    if (nbssetting != null)
                    {
                        var storeSettings = new StoreSettings(portal.PortalID);
                        var pluginData = new PluginData(portal.PortalID); // get plugin data to see if this scheduler is active on this portal
                        var plugin = pluginData.GetPluginByCtrl("dnnsearchindex");
                        if (plugin != null && plugin.GetXmlPropertyBool("genxml/checkbox/active"))
                        {
                            // The NBS scheduler is normally set to run hourly, therefore if we only want a process to run daily we need the logic this function.
                            // To to this we keep a last run flag on the sceduler settings
                            var setting = objCtrl.GetByGuidKey(portal.PortalID, -1, "DNNIDXSCHEDULER", "DNNIDXSCHEDULER");
                            if (setting == null)
                            {
                                setting = new NBrightInfo(true);
                                setting.ItemID = -1;
                                setting.PortalId = portal.PortalID;
                                setting.TypeCode = "DNNIDXSCHEDULER";
                                setting.GUIDKey = "DNNIDXSCHEDULER";
                                setting.ModuleId = -1;
                                setting.XMLData = "<genxml></genxml>";
                            }

                            var lastrun = setting.GetXmlPropertyRaw("genxml/lastrun");
                            var lastrundate = DateTime.Now.AddYears(-99);
                            if (Utils.IsDate(lastrun)) lastrundate = Convert.ToDateTime(lastrun);

                            var rtnmsg = DoProductIdx(portal, lastrundate, storeSettings.DebugMode);
                            setting.SetXmlProperty("genxml/lastrun", DateTime.Now.ToString("s"), TypeCode.DateTime);
                            objCtrl.Update(setting);
                            if (rtnmsg != "") return rtnmsg;

                        }
                    }

                }

                return " - NBS-DNNIDX scheduler OK ";
            }
            catch (Exception ex)
            {
                return " - NBS-DNNIDX scheduler FAIL: " + ex.ToString() + " : ";
            }
        }
Exemplo n.º 3
0
        public StoreSettings GetStoreSettings(int portalId)
        {
            var objSs = (StoreSettings)Utils.GetCache("NBBStoreSettings" + portalId.ToString(""));

            if (objSs == null)
            {
                objSs = new StoreSettings(portalId);
                Utils.SetCache("NBBStoreSettings" + portalId.ToString(""), objSs);
            }
            return(objSs);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get current portal StoreSettings
        /// </summary>
        /// <returns></returns>
        public static StoreSettings GetCurrentPortalData()
        {
            StoreSettings objPortalSettings = null;

            if (HttpContext.Current != null)
            {
                // build StoreSettings and place in httpcontext
                if (HttpContext.Current.Items["NBBStoreSettings" + PortalSettings.Current.PortalId.ToString("")] == null)
                {
                    HttpContext.Current.Items.Add("NBBStoreSettings" + PortalSettings.Current.PortalId.ToString(""), GetStaticStoreSettings(PortalSettings.Current.PortalId));
                }
                objPortalSettings = (StoreSettings)HttpContext.Current.Items["NBBStoreSettings" + PortalSettings.Current.PortalId.ToString("")];
            }
            return(objPortalSettings);
        }
Exemplo n.º 5
0
        public PluginData(int portalId, Boolean systemlevel = false)
        {
            _templCtrl = NBrightBuyUtils.GetTemplateGetter(portalId,"config");

            portallevel = !systemlevel;

            if (StoreSettings.Current == null)
            {
                storeSettings = new StoreSettings(portalId);
            }
            else
            {
                storeSettings = StoreSettings.Current;
            }

            var menuplugin = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, portallevel, storeSettings.Settings());
            if (menuplugin != "")
            {
                Info = new NBrightInfo();
                Info.XMLData = menuplugin;
                _pluginList = new List<NBrightInfo>();
                _pluginList = GetPluginList();
            }
            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 != "")
                    {
                        Info = new NBrightInfo();
                        Info.XMLData = menuplugin;
                        _pluginList = new List<NBrightInfo>();
                        _pluginList = GetPluginList();
                    }
                }
            }
        }
Exemplo n.º 6
0
        public static StoreSettings GetPortalData(int portalId)
        {
            StoreSettings objPortalSettings = null;

            if (HttpContext.Current != null)
            {
                // build StoreSettings and place in httpcontext
                if (HttpContext.Current.Items["NBBStoreSettings" + portalId.ToString()] == null)
                {
                    HttpContext.Current.Items.Add("NBBStoreSettings" + portalId.ToString(), GetStaticStoreSettings(portalId));
                }
                objPortalSettings = (StoreSettings)HttpContext.Current.Items["NBBStoreSettings" + portalId.ToString()];
            }
            else
            {
                // capture all to ensure we pass something.
                objPortalSettings = GetStaticStoreSettings(portalId);
            }
            return(objPortalSettings);
        }
Exemplo n.º 7
0
        public PluginData(int portalId, Boolean systemlevel = false)
        {
            _portalId = portalId;

            _templCtrl = NBrightBuyUtils.GetTemplateGetter(portalId, "config");

            _portallevel = !systemlevel;

            if (StoreSettings.Current == null)
            {
                _storeSettings = new StoreSettings(portalId);
            }
            else
            {
                _storeSettings = StoreSettings.Current;
            }

            _cachekey = "pluginlist" + portalId + "*" + systemlevel;
            var pList = NBrightBuyUtils.GetModCache(_cachekey);

            if (pList != null)
            {
                // if we've created an empty cache record, clear cache data
                _pluginList = (List <NBrightInfo>)pList;
                if (_pluginList.Count == 0)
                {
                    DotNetNuke.Common.Utilities.DataCache.ClearCache();
                }
            }

            if (pList != null && !_storeSettings.DebugMode)
            {
                _pluginList = (List <NBrightInfo>)pList;
            }
            else
            {
                Load();
            }
        }
Exemplo n.º 8
0
        public PluginData(int portalId, Boolean systemlevel = false)
        {
            _portalId = portalId;

            _templCtrl = NBrightBuyUtils.GetTemplateGetter(portalId,"config");

            _portallevel = !systemlevel;

            if (StoreSettings.Current == null)
            {
                _storeSettings = new StoreSettings(portalId);
            }
            else
            {
                _storeSettings = StoreSettings.Current;
            }

            _cachekey = "pluginlist" + portalId + "*" + systemlevel;
            var pList = NBrightBuyUtils.GetModCache(_cachekey);

            if (pList != null)
            {
                // if we've created an empty cache record, clear cache data
                _pluginList = (List<NBrightInfo>)pList;
                if (_pluginList.Count == 0) DotNetNuke.Common.Utilities.DataCache.ClearCache();
            }

            if (pList != null && !_storeSettings.DebugMode)
            {
                _pluginList = (List<NBrightInfo>)pList;
            }
            else
            {
                Load();
            }
        }
Exemplo n.º 9
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.º 10
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.º 11
0
 /// <summary>
 /// Cache the current store settings
 /// </summary>
 /// <returns></returns>
 private static StoreSettings GetStaticStoreSettings(int portalId)
 {
     var objSs = (StoreSettings)Utils.GetCache("NBBStoreSettings" + portalId.ToString(""));
     if (objSs == null)
     {
         objSs = new StoreSettings(portalId);
         Utils.SetCache("NBBStoreSettings" + portalId.ToString(""), objSs);
     }
     return objSs;
 }
Exemplo n.º 12
0
        public override void DoWork()
        {
            try
            {
                var portallist = DnnUtils.GetAllPortals();

                foreach (var portal in portallist)
                {
                    var storeSettings = new StoreSettings(portal.PortalID);
                    if (Directory.Exists(storeSettings.FolderTempMapPath))
                    {
                        // clear old carts
                        var objCtrl = new NBrightBuyController();
                        var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                        var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
                        var days    = 60;
                        var d       = DateTime.Now.AddDays(days * -1);
                        var strDate = d.ToString("s");
                        var stmt    = "";
                        stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where PortalId = " + portal.PortalID.ToString("") + " and typecode = 'CART' and ModifiedDate < '" + strDate + "' ";
                        objCtrl.ExecSql(stmt);


                        // clear down NBStore temp folder
                        string[] files = Directory.GetFiles(storeSettings.FolderTempMapPath);

                        foreach (string file in files)
                        {
                            FileInfo fi = new FileInfo(file);
                            if (fi.LastAccessTime < DateTime.Now.AddHours(-1))
                            {
                                fi.Delete();
                            }
                        }

                        // DO Scheduler Jobs
                        var pluginData = new PluginData(portal.PortalID);
                        var l          = pluginData.GetSchedulerProviders();

                        foreach (var p in l)
                        {
                            var          prov   = p.Value;
                            ObjectHandle handle = null;
                            handle = Activator.CreateInstance(prov.GetXmlProperty("genxml/textbox/assembly"), prov.GetXmlProperty("genxml/textbox/namespaceclass"));
                            if (handle != null)
                            {
                                var objProvider = (SchedulerInterface)handle.Unwrap();
                                var strMsg      = objProvider.DoWork(portal.PortalID);
                                if (strMsg != "")
                                {
                                    this.ScheduleHistoryItem.AddLogNote(strMsg);
                                }
                            }
                        }
                    }
                }

                this.ScheduleHistoryItem.Succeeded = true;
            }
            catch (Exception Ex)
            {
                //--intimate the schedule mechanism to write log note in schedule history
                this.ScheduleHistoryItem.Succeeded = false;
                this.ScheduleHistoryItem.AddLogNote("NBS Service Start. Failed. " + Ex.ToString());
                this.Errored(ref Ex);
            }
        }
Exemplo n.º 13
0
        public PluginData(int portalId, Boolean systemlevel = false)
        {
            _templCtrl = NBrightBuyUtils.GetTemplateGetter(portalId,"config");

            portallevel = !systemlevel;

            if (StoreSettings.Current == null)
            {
                storeSettings = new StoreSettings(portalId);
            }
            else
            {
                storeSettings = StoreSettings.Current;
            }

            var cachekey = "pluginlist" + portalId + "*" + systemlevel;
            var pList = NBrightBuyUtils.GetModCache(cachekey);

            if (pList != null)
            {
                // if we've created an empty cache record, clear cache data
                _pluginList = (List<NBrightInfo>)pList;
                if (_pluginList.Count == 0) DotNetNuke.Common.Utilities.DataCache.ClearCache();
            }

            if (pList != null)
            {
                // if we've created an empty cache record, clear cache data
                _pluginList = (List<NBrightInfo>)pList;
                if (_pluginList.Count == 0) DotNetNuke.Common.Utilities.DataCache.ClearCache();
            }

            if (pList != null && !storeSettings.DebugMode)
            {
                _pluginList = (List<NBrightInfo>)pList;
            }
            else
            {
                var menuplugin = _templCtrl.GetTemplateData("menuplugin.xml", Utils.GetCurrentCulture(), true, true, portallevel, storeSettings.Settings());
                if (menuplugin != "")
                {
                    var info = new NBrightInfo();
                    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.XMLData = menuplugin;
                            _pluginList = new List<NBrightInfo>();
                            _pluginList = GetPluginList();
                        }
                    }
                }
                NBrightBuyUtils.SetModCache(0,cachekey,_pluginList);
            }
        }
Exemplo n.º 14
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);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 15
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.º 16
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.º 17
0
        private String DoProductIdx(DotNetNuke.Entities.Portals.PortalInfo portal, DateTime lastrun, Boolean debug)
        {
            if (debug)
            {
                InternalSearchController.Instance.DeleteAllDocuments(portal.PortalID, SearchHelper.Instance.GetSearchTypeByName("tab").SearchTypeId);
            }
            var searchDocs = new List<SearchDocument>();
            var culturecodeList = DnnUtils.GetCultureCodeList(portal.PortalID);
            var storeSettings = new StoreSettings(portal.PortalID);
            foreach (var lang in culturecodeList)
            {
                var strContent = "";
                // select all products
                var objCtrl = new NBrightBuyController();
                var strFilter = " and NB1.ModifiedDate > convert(datetime,'" + lastrun.ToString("s") + "') ";
                if (debug) strFilter = "";
                var l = objCtrl.GetList(portal.PortalID, -1, "PRD", strFilter);

                foreach (var p in l)
                {
                    var prodData = new ProductData(p.ItemID, lang);

                    strContent = prodData.Info.GetXmlProperty("genxml/textbox/txtproductref") + " : " + prodData.SEODescription + " " + prodData.SEOName + " " + prodData.SEOTagwords + " " + prodData.SEOTitle;

                    if (strContent != "")
                    {
                        var tags = new List<String>();
                        tags.Add("nbsproduct");

                        //Get the description string
                        string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strContent, false), 100, "...");
                        var searchDoc = new SearchDocument();
                        // Assigns as a Search key the SearchItems'
                        searchDoc.UniqueKey = prodData.Info.ItemID.ToString("");
                        searchDoc.QueryString = "ref=" + prodData.Info.GetXmlProperty("genxml/textbox/txtproductref");
                        searchDoc.Title = prodData.ProductName;
                        searchDoc.Body = strContent;
                        searchDoc.Description = strDescription;
                        if (debug)
                            searchDoc.ModifiedTimeUtc = DateTime.Now.Date;
                        else
                            searchDoc.ModifiedTimeUtc = prodData.Info.ModifiedDate;
                        searchDoc.AuthorUserId = 1;
                        searchDoc.TabId = storeSettings.ProductDetailTabId;
                        searchDoc.PortalId = portal.PortalID;
                        searchDoc.SearchTypeId = SearchHelper.Instance.GetSearchTypeByName("tab").SearchTypeId;
                        searchDoc.CultureCode = lang;
                        searchDoc.Tags = tags;
                        //Add Module MetaData
                        searchDoc.ModuleDefId = 0;
                        searchDoc.ModuleId = 0;

                        searchDocs.Add(searchDoc);
                    }
                }
            }

            //Index
            InternalSearchController.Instance.AddSearchDocuments(searchDocs);
            InternalSearchController.Instance.Commit();

            return " - NBS-DNNIDX scheduler ACTIVATED ";
        }
Exemplo n.º 18
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.º 19
0
 /// <summary>
 /// Used to get the template system getter control.
 /// </summary>
 /// <returns></returns>
 public static TemplateGetter GetTemplateGetter(int portalId, string themeFolder)
 {
     var controlMapPath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath());
     themeFolder = "Themes\\" + themeFolder;
     var map = "";
     var storeThemeFolder = "";
     if (PortalSettings.Current == null) // might be ran from scheduler
     {
         var portalsettings = NBrightDNN.DnnUtils.GetPortalSettings(portalId);
         map = portalsettings.HomeDirectoryMapPath;
         var storeset = new StoreSettings(portalId);
         storeThemeFolder = storeset.ThemeFolder;
     }
     else
     {
         map = PortalSettings.Current.HomeDirectoryMapPath;
         storeThemeFolder = StoreSettings.Current.ThemeFolder;
     }
     var templCtrl = new NBrightCore.TemplateEngine.TemplateGetter(map, controlMapPath, "Themes\\config", themeFolder, "Themes\\" + storeThemeFolder);
     return templCtrl;
 }
Exemplo n.º 20
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.º 21
0
        private void LoadData(int productId, Boolean hydrateLists = true)
        {
            Exists = false;
            var objCtrl = new NBrightBuyController();
            if (productId == -1) productId = AddNew(); // add new record if -1 is used as id.
            Info = objCtrl.Get(productId, "PRDLANG", _lang);
            if (Info != null)
            {
                _portalId = Info.PortalId;
                _storeSettings = new StoreSettings(_portalId);
                Exists = true;
                if (hydrateLists)
                {
                    //build model list
                    Models = GetEntityList("models");
                    Options = GetEntityList("options");
                    Imgs = GetEntityList("imgs");
                    Docs = GetEntityList("docs");

                    OptionValues = new List<NBrightInfo>();
                    foreach (var o in Options)
                    {
                        var l = GetOptionValuesById(o.GetXmlProperty("genxml/hidden/optionid"));
                        OptionValues.AddRange(l);
                    }
                }
                Exists = true;
                DataRecord = objCtrl.GetData(productId);
                DataLangRecord = objCtrl.GetDataLang(productId, _lang);
                if (DataLangRecord == null) // rebuild langauge is we have a missing lang record
                {
                    Validate();
                    DataLangRecord = objCtrl.GetDataLang(productId, _lang);
                }

                IsOnSale = CheckIsOnSale();
                IsInStock = CheckIsInStock();

            }
            else
            {
                Exists = false;
            }
        }