mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Update TermsPartHandler.cs
Queue a single task to process all terms updated within this work context.
This commit is contained in:
@@ -18,6 +18,8 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
private readonly HashSet<int> _processedTermParts = new HashSet<int>();
|
||||
|
||||
public TermsPartHandler(
|
||||
IContentDefinitionManager contentDefinitionManager,
|
||||
IRepository<TermsPartRecord> repository,
|
||||
@@ -88,12 +90,16 @@ namespace Orchard.Taxonomies.Handlers {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Fires off a processing engine task to run the count processing after the request so it's non-blocking.
|
||||
private void RecalculateCount(IProcessingEngine processingEngine, ShellSettings shellSettings, IShellDescriptorManager shellDescriptorManager, TermsPart part) {
|
||||
var termPartRecordIds = part.Terms.Select(t => t.TermRecord.Id).ToArray();
|
||||
if (termPartRecordIds.Length > 0) {
|
||||
processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary<string, object> { { "termPartRecordIds", termPartRecordIds } });
|
||||
if (termPartRecordIds.Any()) {
|
||||
if (!_processedTermParts.Any()) {
|
||||
processingEngine.AddTask(shellSettings, shellDescriptorManager.GetShellDescriptor(), "ITermCountProcessor.Process", new Dictionary<string, object> { { "termPartRecordIds", _processedTermParts } });
|
||||
}
|
||||
foreach (var termPartRecordId in termPartRecordIds) {
|
||||
_processedTermParts.Add(termPartRecordId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user