private static void ReIndexIfNeeded(int moduleid, int tabid, int portalId)
        {
            var currentUserCount     = UserController.GetUserCountByPortal(portalId);
            var userCountAtLastIndex = DnnUtils.GetPortalSetting("UserCountAtLastIndex", 0);

            if (currentUserCount != userCountAtLastIndex)
            {
                // reindex module data
                var module = OpenContentModuleConfig.Create(moduleid, tabid, null);
                LuceneUtils.ReIndexModuleData(module);
                DnnUtils.SetPortalSetting("UserCountAtLastIndex", currentUserCount);
                App.Services.Logger.Info("DnnUsers reindexed");
            }
        }
        public void ImportModule(int moduleId, string content, string version, int userId)
        {
            var     module     = OpenContentModuleConfig.Create(moduleId, Null.NullInteger, PortalSettings.Current);
            var     dataSource = new OpenContentDataSource();
            var     dsContext  = OpenContentUtils.CreateDataContext(module, userId);
            XmlNode xml        = Globals.GetContent(content, "opencontent");
            var     items      = xml.SelectNodes("item");

            if (items != null)
            {
                foreach (XmlNode item in items)
                {
                    XmlNode json       = item.SelectSingleNode("json");
                    XmlNode collection = item.SelectSingleNode("collection");
                    XmlNode key        = item.SelectSingleNode("key");
                    try
                    {
                        JToken data = JToken.Parse(json.InnerText);
                        dsContext.Collection = collection?.InnerText ?? "";
                        dataSource.Add(dsContext, data);
                        App.Services.CacheAdapter.SyncronizeCache(module);
                    }
                    catch (Exception e)
                    {
                        App.Services.Logger.Error($"Failed to parse imported json. Item key: {key}. Collection: {collection}. Error: {e.Message}. Stacktrace: {e.StackTrace}");
                        throw;
                    }
                }
            }
            var settings = xml.SelectNodes("moduleSetting");

            if (settings != null)
            {
                foreach (XmlNode setting in settings)
                {
                    XmlNode settingName  = setting.SelectSingleNode("settingName");
                    XmlNode settingValue = setting.SelectSingleNode("settingValue");

                    if (!string.IsNullOrEmpty(settingName?.InnerText))
                    {
                        ModuleController.Instance.UpdateModuleSetting(moduleId, settingName.InnerText, settingValue?.InnerText ?? "");
                    }
                }
            }
            module = OpenContentModuleConfig.Create(moduleId, Null.NullInteger, PortalSettings.Current);

            LuceneUtils.ReIndexModuleData(module);
        }
Esempio n. 3
0
        private static void ReIndexIfNeeded(int moduleid, int tabid, int portalId)
        {
            if (PortalSettings.Current == null)
            {
                return;                                 // we can not reindex even if we wanted, because we are not in a regular http context (maybe console? scheduler? ashx?)
            }
            var currentUserCount     = UserController.GetUserCountByPortal(portalId);
            var userCountAtLastIndex = DnnUtils.GetPortalSetting("UserCountAtLastIndex", 0);

            if (currentUserCount != userCountAtLastIndex)
            {
                // reindex module data
                var module = OpenContentModuleConfig.Create(moduleid, tabid, null);
                LuceneUtils.ReIndexModuleData(module);
                DnnUtils.SetPortalSetting("UserCountAtLastIndex", currentUserCount);
                App.Services.Logger.Info("DnnUsers reindexed");
            }
        }
Esempio n. 4
0
        protected void bIndex_Click(object sender, EventArgs e)
        {
            var module = OpenContentModuleConfig.Create(ModuleConfiguration, PortalSettings);

            LuceneUtils.ReIndexModuleData(module);
        }