/// <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() + " : ";
            }
        }
Beispiel #2
0
        public static Boolean CheckPluginSecurity(int portalId, String ctrl)
        {
            var currentuser = UserController.Instance.GetCurrentUserInfo();

            if (currentuser.IsSuperUser)
            {
                return(true);
            }
            if (currentuser.IsInRole("Administrators"))
            {
                return(true);
            }

            var pluginData = new PluginData(portalId);
            var p          = pluginData.GetPluginByCtrl(ctrl);

            return(CheckSecurity(p));
        }
Beispiel #3
0
        private String GetMenu()
        {
            var strCacheKey = "bomenuhtml*" + Utils.GetCurrentCulture() + "*" + PortalId.ToString("") + "*" + UserId.ToString("");

            var strOut = "";
            var obj = Utils.GetCache(strCacheKey);
            if (obj != null) strOut = (String)obj;

            if (StoreSettings.Current.DebugMode || strOut == "")
            {
                var pluginData = new PluginData(PortalId);

                var bomenuattributes = DnnUtils.GetLocalizedString("bomenuattributes", _resxpath, Utils.GetCurrentCulture());
                var bosubmenuattributes = DnnUtils.GetLocalizedString("bosubmenuattributes", _resxpath, Utils.GetCurrentCulture());

                //get group list (these are the sections/first level of the menu)
                var rootList = new Dictionary<String, String>();
                foreach (var p in pluginData.GetPluginList())
                {
                    var grpname = p.GetXmlProperty("genxml/textbox/group");
                    if (p.GetXmlPropertyBool("genxml/checkbox/hidden") == false)
                    {
                        var rootname = grpname;
                        if (rootname == "") rootname = p.GetXmlProperty("genxml/textbox/ctrl");
                        if (!rootList.ContainsKey(rootname))
                        {
                            var resxname = DnnUtils.GetLocalizedString(rootname.ToLower(), _resxpath, Utils.GetCurrentCulture());
                            if (resxname == "") resxname = rootname;
                            rootList.Add(rootname, resxname);
                        }
                    }
                }

                strOut = "<ul " + bomenuattributes + ">";

                foreach (var rootname in rootList)
                {
                    var rtnlist = pluginData.GetSubList(rootname.Key);
                    var sublist = new List<NBrightInfo>();
                    // check security
                    foreach (var p in rtnlist)
                    {
                        if (CheckSecurity(p)) sublist.Add(p);
                    }

                    var href = "#";
                    var ctrl = "";
                    var name = "unknown";
                    var icon = "";
                    var hrefclass = "";
                    var securityrootcheck = true;
                    if (sublist.Count > 0)
                    {
                        // has sub menus
                        ctrl = rootname.Key;
                        name = rootname.Value;
                        hrefclass = "class='dropdown-toggle'";
                        icon = DnnUtils.GetLocalizedString(ctrl.ToLower() + "_icon", _resxpath, Utils.GetCurrentCulture());
                        strOut += "<li class='dropdown'>";
                    }
                    else
                    {
                        // clickable root menu
                        var rootp = pluginData.GetPluginByCtrl(rootname.Key);
                        if (rootp != null)
                        {
                            ctrl = rootp.GetXmlProperty("genxml/textbox/ctrl");
                            name = rootp.GetXmlProperty("genxml/textbox/name");
                            icon = rootp.GetXmlProperty("genxml/textbox/icon");

                            securityrootcheck = CheckSecurity(rootp);
                            if (securityrootcheck)
                            {
                                strOut += "<li>";
                                var param = new string[1];
                                param[0] = "ctrl=" + ctrl;
                                href = Globals.NavigateURL(TabId, "", param);
                            }
                        }
                        else
                        {
                            securityrootcheck = false;
                        }
                    }
                    if (securityrootcheck) strOut += GetRootLinkNode(name, ctrl, icon, href, hrefclass);

                    if (sublist.Count > 0)
                    {
                        strOut += "<ul " + bosubmenuattributes + ">";
                        foreach (var p in sublist)
                        {
                            if (p.GetXmlPropertyBool("genxml/checkbox/hidden") == false)
                            {

                                ctrl = p.GetXmlProperty("genxml/textbox/ctrl");
                                name = p.GetXmlProperty("genxml/textbox/name");
                                icon = p.GetXmlProperty("genxml/textbox/icon");
                                var param = new string[1];
                                param[0] = "ctrl=" + ctrl;
                                href = Globals.NavigateURL(TabId, "", param);
                                strOut += "<li>" + GetSubLinkNode(name, ctrl, icon, href) + "</li>";
                            }
                        }
                        strOut += "</ul>";
                    }
                    if (securityrootcheck) strOut += "</li>";
                }

                // add exit button
                strOut += "<li>";
                var tabid = StoreSettings.Current.Get("exittab");
                var exithref = "/";
                if (Utils.IsNumeric(tabid)) exithref = Globals.NavigateURL(Convert.ToInt32(tabid));
                strOut += GetRootLinkNode("Exit", "exit", DnnUtils.GetLocalizedString("exit_icon", _resxpath, Utils.GetCurrentCulture()), exithref, "");
                strOut += "</li>";

                strOut += "</ul>";

                NBrightBuyUtils.SetModCache(0, strCacheKey, strOut);

                if (StoreSettings.Current.DebugModeFileOut) Utils.SaveFile(PortalSettings.HomeDirectoryMapPath + "\\debug_menu.html", strOut);
            }

            return strOut;
        }
 private String GetControlPath(String ctrl)
 {
     var pluginData = new PluginData(PortalId);
     var p = pluginData.GetPluginByCtrl(ctrl);
     return p.GetXmlProperty("genxml/textbox/path");
 }