Merge pull request #4381 from sbwalker/dev

use PageModule in ISearchable
This commit is contained in:
Shaun Walker 2024-07-02 14:50:42 -04:00 committed by GitHub
commit 64830aae9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 12 deletions

View File

@ -49,17 +49,16 @@ namespace Oqtane.Managers.Search
continue;
}
var module = pageModule.Module;
if (module.ModuleDefinition != null && module.ModuleDefinition.ServerManagerType != "")
if (pageModule.Module.ModuleDefinition != null && pageModule.Module.ModuleDefinition.ServerManagerType != "")
{
_logger.LogDebug($"Search: Begin index module {module.ModuleId}.");
var type = Type.GetType(module.ModuleDefinition.ServerManagerType);
_logger.LogDebug($"Search: Begin index module {pageModule.ModuleId}.");
var type = Type.GetType(pageModule.Module.ModuleDefinition.ServerManagerType);
if (type?.GetInterface(nameof(ISearchable)) != null)
{
try
{
var moduleSearch = (ISearchable)ActivatorUtilities.CreateInstance(_serviceProvider, type);
var contentList = moduleSearch.GetSearchContents(module, startTime.GetValueOrDefault(DateTime.MinValue));
var contentList = moduleSearch.GetSearchContents(pageModule, startTime.GetValueOrDefault(DateTime.MinValue));
if(contentList != null)
{
foreach(var searchContent in contentList)
@ -73,11 +72,11 @@ namespace Oqtane.Managers.Search
}
catch(Exception ex)
{
_logger.LogError(ex, $"Search: Index module {module.ModuleId} failed.");
handleError($"Search: Index module {module.ModuleId} failed: {ex.Message}");
_logger.LogError(ex, $"Search: Index module {pageModule.ModuleId} failed.");
handleError($"Search: Index module {pageModule.ModuleId} failed: {ex.Message}");
}
}
_logger.LogDebug($"Search: End index module {module.ModuleId}.");
_logger.LogDebug($"Search: End index module {pageModule.ModuleId}.");
}
}

View File

@ -48,18 +48,18 @@ namespace Oqtane.Modules.HtmlText.Manager
return content;
}
public List<SearchContent> GetSearchContents(Module module, DateTime startDate)
public List<SearchContent> GetSearchContents(PageModule pageModule, DateTime startDate)
{
var searchContentList = new List<SearchContent>();
var htmltexts = _htmlText.GetHtmlTexts(module.ModuleId);
var htmltexts = _htmlText.GetHtmlTexts(pageModule.ModuleId);
if (htmltexts != null && htmltexts.Any(i => i.CreatedOn >= startDate))
{
var htmltext = htmltexts.OrderByDescending(item => item.CreatedOn).First();
searchContentList.Add(new SearchContent
{
Title = module.Title,
Title = pageModule.Module.Title,
Description = string.Empty,
Body = htmltext.Content,
ContentModifiedBy = htmltext.ModifiedBy,

View File

@ -6,6 +6,6 @@ namespace Oqtane.Interfaces
{
public interface ISearchable
{
public List<SearchContent> GetSearchContents(Module module, DateTime startTime);
public List<SearchContent> GetSearchContents(PageModule pageModule, DateTime startTime);
}
}