mirror of
https://github.com/oqtane/oqtane.framework.git
synced 2025-05-30 00:33:05 +00:00
Merge pull request #4381 from sbwalker/dev
use PageModule in ISearchable
This commit is contained in:
commit
64830aae9f
@ -49,17 +49,16 @@ namespace Oqtane.Managers.Search
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var module = pageModule.Module;
|
if (pageModule.Module.ModuleDefinition != null && pageModule.Module.ModuleDefinition.ServerManagerType != "")
|
||||||
if (module.ModuleDefinition != null && module.ModuleDefinition.ServerManagerType != "")
|
|
||||||
{
|
{
|
||||||
_logger.LogDebug($"Search: Begin index module {module.ModuleId}.");
|
_logger.LogDebug($"Search: Begin index module {pageModule.ModuleId}.");
|
||||||
var type = Type.GetType(module.ModuleDefinition.ServerManagerType);
|
var type = Type.GetType(pageModule.Module.ModuleDefinition.ServerManagerType);
|
||||||
if (type?.GetInterface(nameof(ISearchable)) != null)
|
if (type?.GetInterface(nameof(ISearchable)) != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var moduleSearch = (ISearchable)ActivatorUtilities.CreateInstance(_serviceProvider, type);
|
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)
|
if(contentList != null)
|
||||||
{
|
{
|
||||||
foreach(var searchContent in contentList)
|
foreach(var searchContent in contentList)
|
||||||
@ -73,11 +72,11 @@ namespace Oqtane.Managers.Search
|
|||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, $"Search: Index module {module.ModuleId} failed.");
|
_logger.LogError(ex, $"Search: Index module {pageModule.ModuleId} failed.");
|
||||||
handleError($"Search: Index module {module.ModuleId} failed: {ex.Message}");
|
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}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,18 +48,18 @@ namespace Oqtane.Modules.HtmlText.Manager
|
|||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SearchContent> GetSearchContents(Module module, DateTime startDate)
|
public List<SearchContent> GetSearchContents(PageModule pageModule, DateTime startDate)
|
||||||
{
|
{
|
||||||
var searchContentList = new List<SearchContent>();
|
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))
|
if (htmltexts != null && htmltexts.Any(i => i.CreatedOn >= startDate))
|
||||||
{
|
{
|
||||||
var htmltext = htmltexts.OrderByDescending(item => item.CreatedOn).First();
|
var htmltext = htmltexts.OrderByDescending(item => item.CreatedOn).First();
|
||||||
|
|
||||||
searchContentList.Add(new SearchContent
|
searchContentList.Add(new SearchContent
|
||||||
{
|
{
|
||||||
Title = module.Title,
|
Title = pageModule.Module.Title,
|
||||||
Description = string.Empty,
|
Description = string.Empty,
|
||||||
Body = htmltext.Content,
|
Body = htmltext.Content,
|
||||||
ContentModifiedBy = htmltext.ModifiedBy,
|
ContentModifiedBy = htmltext.ModifiedBy,
|
||||||
|
@ -6,6 +6,6 @@ namespace Oqtane.Interfaces
|
|||||||
{
|
{
|
||||||
public interface ISearchable
|
public interface ISearchable
|
||||||
{
|
{
|
||||||
public List<SearchContent> GetSearchContents(Module module, DateTime startTime);
|
public List<SearchContent> GetSearchContents(PageModule pageModule, DateTime startTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user