Exemplo n.º 1
0
 /// <summary>
 /// Reindex all OpenContent modules of all portals.
 /// </summary>
 internal void IndexAll()
 {
     Log.Logger.Info("Reindexing all OpenContent data, from all portals");
     LuceneController.ClearInstance();
     try
     {
         using (var lc = LuceneController.Instance)
         {
             ModuleController mc = new ModuleController();
             foreach (PortalInfo portal in PortalController.Instance.GetPortals())
             {
                 var modules = DnnUtils.GetDnnOpenContentModules(portal.PortalID);
                 foreach (var module in modules)
                 {
                     IndexModule(lc, module);
                 }
             }
             lc.Store.Commit();
             lc.Store.OptimizeSearchIndex(true);
         }
     }
     catch (Exception ex)
     {
         Log.Logger.Error("Error while Reindexing all OpenContent data, from all portals", ex);
     }
     finally
     {
         LuceneController.ClearInstance();
     }
     Log.Logger.Info("Finished Reindexing all OpenContent data, from all portals");
 }
Exemplo n.º 2
0
        private void IndexModuleData(LuceneController lc, int moduleId, OpenContentSettings settings)
        {
            bool index = false;

            if (settings.TemplateAvailable)
            {
                index = settings.Manifest.Index;
            }
            FieldConfig indexConfig = null;

            if (index)
            {
                indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir);
            }

            if (settings.IsOtherModule)
            {
                moduleId = settings.ModuleId;
            }

            lc.Store.Delete(new TermQuery(new Term("$type", moduleId.ToString())));
            OpenContentController occ = new OpenContentController();

            foreach (var item in occ.GetContents(moduleId))
            {
                lc.Add(item, indexConfig);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Reindex all OpenContent modules of all portals.
 /// </summary>
 internal void IndexAll()
 {
     Log.Logger.Info("Reindexing all OpenContent data, from all portals");
     LuceneController.ClearInstance();
     try
     {
         using (var lc = LuceneController.Instance)
         {
             ModuleController mc = new ModuleController();
             foreach (PortalInfo portal in PortalController.Instance.GetPortals())
             {
                 ArrayList modules = mc.GetModulesByDefinition(portal.PortalID, AppConfig.OPENCONTENT);
                 foreach (ModuleInfo module in modules.OfType <ModuleInfo>())
                 {
                     IndexModule(lc, module);
                 }
             }
             lc.Store.Commit();
             lc.Store.OptimizeSearchIndex(true);
         }
     }
     catch (Exception ex)
     {
         Log.Logger.Error("Error while Reindexing all OpenContent data, from all portals", ex);
     }
     finally
     {
         LuceneController.ClearInstance();
     }
     Log.Logger.Info("Finished Reindexing all OpenContent data, from all portals");
 }
Exemplo n.º 4
0
        private void IndexModuleData(LuceneController lc, int moduleId, OpenContentSettings settings)
        {
            bool index = false;

            if (settings.TemplateAvailable)
            {
                index = settings.Manifest.Index;
            }
            FieldConfig indexConfig = null;

            if (index)
            {
                indexConfig = OpenContentUtils.GetIndexConfig(settings.Template);
            }

            if (settings.IsOtherModule)
            {
                moduleId = settings.ModuleId;
            }
            lc.Store.Delete(new TermQuery(new Term("$type", OpenContentInfo.GetScope(moduleId, settings.Template.Collection))));
            OpenContentController occ = new OpenContentController(PortalSettings.Current.PortalId);

            foreach (var item in occ.GetContents(moduleId, settings.Template.Collection))
            {
                lc.Add(item, indexConfig);
            }
        }
Exemplo n.º 5
0
 public static void ClearInstance()
 {
     if (_instance != null)
     {
         _instance.Dispose();
         _instance = null;
     }
     _instance = new LuceneController();
 }
Exemplo n.º 6
0
        private void IndexModule(LuceneController lc, OpenContentModuleInfo module)
        {
            OpenContentUtils.CheckOpenContentSettings(module);

            if (module.IsListMode() && !module.Settings.IsOtherModule)
            {
                IndexModuleData(lc, module.ViewModule.ModuleID, module.Settings);
            }
        }
Exemplo n.º 7
0
        private void IndexModule(LuceneController lc, ModuleInfo module)
        {
            OpenContentSettings settings = new OpenContentSettings(module.ModuleSettings);

            OpenContentUtils.CheckOpenContentSettings(module, settings);

            if (settings.IsListTemplate() && !settings.IsOtherModule)
            {
                IndexModuleData(lc, module.ModuleID, settings);
            }
        }
Exemplo n.º 8
0
 public void ReIndexModuleData(int moduleId, OpenContentSettings settings)
 {
     try
     {
         using (LuceneController lc = LuceneController.Instance)
         {
             IndexModuleData(lc, moduleId, settings);
             lc.Store.Commit();
             lc.Store.OptimizeSearchIndex(true);
         }
     }
     finally
     {
         LuceneController.ClearInstance();
     }
 }
Exemplo n.º 9
0
        private static void RegisterModuleDataForIndexing(LuceneController lc, OpenContentModuleConfig module)
        {
            var indexableData = GetModuleIndexableData(module);
            var dataExample   = indexableData?.ToList().FirstOrDefault();

            if (dataExample == null)
            {
                return;
            }

            var indexConfig = OpenContentUtils.GetIndexConfig(module.Settings.Template); //todo index is being build from schema & options. But they should be provided by the provider, not directly from the files

            string scope = dataExample.GetScope();

            lc.AddList(indexableData, indexConfig, scope);
        }
Exemplo n.º 10
0
 /// <summary>
 /// A method to Register all indexable data. This is used by IndexAll()
 /// </summary>
 private static void RegisterAllIndexableData(LuceneController lc)
 {
     App.Services.Logger.Info("Start Reindexing all OpenContent Data");
     foreach (PortalInfo portal in PortalController.Instance.GetPortals())
     {
         var modules = DnnUtils.GetDnnOpenContentModules(portal.PortalID);
         foreach (var module in modules)
         {
             if (!OpenContentUtils.CheckOpenContentTemplateFiles(module))
             {
                 continue;
             }
             if (module.IsListMode() && module.Settings.Manifest.Index)
             {
                 RegisterModuleDataForIndexing(lc, module);
             }
         }
     }
     App.Services.Logger.Info("Finished Reindexing all OpenContent Data");
 }
Exemplo n.º 11
0
 /// <summary>
 /// Use this to
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="indexConfig">The index configuration.</param>
 /// <param name="scope">The scope.</param>
 public void ReIndexData(IEnumerable <IIndexableItem> list, FieldConfig indexConfig, string scope)
 {
     try
     {
         using (var lc = LuceneController.Instance)
         {
             DeleteAllOfType(lc, scope);
             foreach (IIndexableItem item in list)
             {
                 lc.Add(item, indexConfig);
             }
             lc.Store.Commit();
             lc.Store.OptimizeSearchIndex(true);
         }
     }
     finally
     {
         LuceneController.ClearInstance();
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Use this to
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="indexConfig">The index configuration.</param>
 /// <param name="scope">The scope.</param>
 public void ReIndexModuleData(IEnumerable <IIndexableItem> list, FieldConfig indexConfig, string scope)
 {
     try
     {
         using (LuceneController lc = LuceneController.Instance)
         {
             lc.Store.Delete(new TermQuery(new Term("$type", scope)));
             foreach (var item in list)
             {
                 lc.Add(item, indexConfig);
             }
             lc.Store.Commit();
             lc.Store.OptimizeSearchIndex(true);
         }
     }
     finally
     {
         LuceneController.ClearInstance();
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Reindex all content.
 /// </summary>
 public void IndexAll(Action <LuceneController> funcRegisterAllIndexableData)
 {
     App.Services.Logger.Info("Reindexing all OpenContent data, from all portals");
     LuceneController.ClearInstance();
     try
     {
         using (var lc = LuceneController.Instance)
         {
             lc.Store.DeleteAll();
             funcRegisterAllIndexableData(lc);
             lc.Store.Commit();
             lc.Store.OptimizeSearchIndex(true);
         }
     }
     catch (Exception ex)
     {
         App.Services.Logger.Error("Error while Reindexing all OpenContent data, from all portals", ex);
     }
     finally
     {
         LuceneController.ClearInstance();
     }
     App.Services.Logger.Info("Finished Reindexing all OpenContent data, from all portals");
 }
Exemplo n.º 14
0
        private static void DeleteAllOfType(LuceneController lc, string scope)
        {
            var selection = JsonMappingUtils.CreateTypeQuery(scope);

            lc.Store.Delete(selection);
        }