public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc) { App.Services.Logger.Trace($"Indexing content Module {modInfo.ModuleID} - Tab {modInfo.TabID} - Culture {modInfo.CultureCode}- indexing from {beginDateUtc}"); var searchDocuments = new List <SearchDocument>(); //If module is marked as "don't index" then return no results if (modInfo.ModuleSettings.GetValue("AllowIndex", "True") == "False") { App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - MODULE Indexing disabled"); return(searchDocuments); } //If tab of the module is marked as "don't index" then return no results if (modInfo.ParentTab.TabSettings.GetValue("AllowIndex", "True") == "False") { App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - TAB Indexing disabled"); return(searchDocuments); } //If tab is marked as "inactive" then return no results if (modInfo.ParentTab.DisableLink) { App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - TAB is inactive"); return(searchDocuments); } var module = OpenContentModuleConfig.Create(modInfo, PortalSettings.Current); if (module.Settings.Template?.Main == null || !module.Settings.Template.Main.DnnSearch) { return(searchDocuments); } if (module.Settings.IsOtherModule) { return(searchDocuments); } IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); IDataItems contentList = ds.GetAll(dsContext, null); if (!contentList.Items.Any()) { App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - No content found"); } foreach (IDataItem content in contentList.Items) { if (content == null) { App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - Content is Null"); } else if (content.LastModifiedOnDate.ToUniversalTime() > beginDateUtc && content.LastModifiedOnDate.ToUniversalTime() < DateTime.UtcNow) { SearchDocument searchDoc; if (DnnLanguageUtils.IsMultiLingualPortal(modInfo.PortalID)) { // first process the default language module var culture = modInfo.CultureCode; var localizedData = GetLocalizedContent(content.Data, culture); searchDoc = CreateSearchDocument(modInfo, module.Settings, localizedData, content.Id, culture, content.Title, content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{culture} - OK! {searchDoc.Title} ({modInfo.TabID}) of {content.LastModifiedOnDate.ToUniversalTime()}"); // now do the same with any linked localized instances of this module if (modInfo.LocalizedModules != null) { foreach (var localizedModule in modInfo.LocalizedModules) { culture = localizedModule.Value.CultureCode; localizedData = GetLocalizedContent(content.Data, culture); searchDoc = CreateSearchDocument(modInfo, module.Settings, localizedData, content.Id, culture, content.Title, content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{culture} - OK! {searchDoc.Title} ({modInfo.TabID}) of {content.LastModifiedOnDate.ToUniversalTime()}"); } } } else { searchDoc = CreateSearchDocument(modInfo, module.Settings, content.Data, content.Id, "", content.Title, content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - OK! {searchDoc.Title} ({modInfo.TabID}) of {content.LastModifiedOnDate.ToUniversalTime()}"); } } else { App.Services.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - No need to index: lastmod {content.LastModifiedOnDate.ToUniversalTime()} "); } } return(searchDocuments); }
public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc) { Log.Logger.TraceFormat("Indexing content Module {0} - Tab {1} - indexing from {3}", modInfo.ModuleID, modInfo.TabID, modInfo.CultureCode, beginDateUtc); var searchDocuments = new List <SearchDocument>(); //If module is marked as "don't index" then return no results if (modInfo.ModuleSettings.GetValue("AllowIndex", "True") == "False") { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - MODULE Indexing disabled", modInfo.ModuleID, modInfo.CultureCode); return(searchDocuments); } //If tab of the module is marked as "don't index" then return no results if (modInfo.ParentTab.TabSettings.GetValue("AllowIndex", "True") == "False") { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - TAB Indexing disabled", modInfo.ModuleID, modInfo.CultureCode); return(searchDocuments); } //If tab is marked as "inactive" then return no results if (modInfo.ParentTab.DisableLink) { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - TAB is inactive", modInfo.ModuleID, modInfo.CultureCode); return(searchDocuments); } var module = new OpenContentModuleInfo(modInfo); OpenContentSettings settings = modInfo.OpenContentSettings(); //if (settings.Template?.Main == null || !settings.Template.Main.DnnSearch) //{ // Log.Logger.TraceFormat("Indexing content Module {0} - Tab {1} - settings.Template?.Main == null || !settings.Template.Main.DnnSearch", modInfo.ModuleID, modInfo.TabID, modInfo.CultureCode); // return searchDocuments; //} if (settings.IsOtherModule) { return(searchDocuments); } IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); IDataItems contentList = ds.GetAll(dsContext, null); if (!contentList.Items.Any()) { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - No content found", modInfo.ModuleID, modInfo.CultureCode); } foreach (IDataItem content in contentList.Items) { if (content == null) { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - Content is Null", modInfo.ModuleID, modInfo.CultureCode); } else if (content.LastModifiedOnDate.ToUniversalTime() > beginDateUtc && content.LastModifiedOnDate.ToUniversalTime() < DateTime.UtcNow) { SearchDocument searchDoc; if (DnnLanguageUtils.IsMultiLingualPortal(modInfo.PortalID)) { searchDoc = GetLocalizedItem(modInfo, settings, content); searchDocuments.Add(searchDoc); if (modInfo.LocalizedModules != null) { foreach (var localizedModule in modInfo.LocalizedModules) { SearchDocument localizedSearchDoc = GetLocalizedItem(localizedModule.Value, settings, content); searchDocuments.Add(localizedSearchDoc); } } } else { searchDoc = CreateSearchDocument(modInfo, settings, content.Data, content.Id, "", content.Title, JsonToSearchableString(content.Data), content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); Log.Logger.TraceFormat("Indexing content {0}|{5} - OK! {1} ({2}) of {3}", modInfo.ModuleID, searchDoc.Title, modInfo.TabID, content.LastModifiedOnDate.ToUniversalTime(), modInfo.CultureCode); } } else { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - No need to index: lastmod {2} ", modInfo.ModuleID, modInfo.CultureCode, content.LastModifiedOnDate.ToUniversalTime()); } } return(searchDocuments); }