Skip to content
3 changes: 2 additions & 1 deletion VirtoCommerce.OrdersModule.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=15b5b1f1_002D457c_002D4ca6_002Db278_002D5615aedc07d3/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static readonly fields (private)"&gt;&lt;ElementKinds&gt;&lt;Kind Name="READONLY_FIELD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="_" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:Boolean x:Key="/Default/UserDictionary/Words/=auditable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=hangfire/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=npgsql/@EntryIndexedValue">True</s:Boolean>
Expand Down
7 changes: 6 additions & 1 deletion src/VirtoCommerce.OrdersModule.Core/Model/Address.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
using System.Collections.Generic;
using System.Reflection;
using VirtoCommerce.Platform.Core.Swagger;

namespace VirtoCommerce.OrdersModule.Core.Model
{
[SwaggerSchemaId("OrderAddress")]
public class Address : CoreModule.Core.Common.Address
{
public virtual IEnumerable<PropertyInfo> GetAllProperties()
{
return GetProperties();
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand Down Expand Up @@ -35,20 +34,46 @@ public IndexCustomerOrderChangedEventHandler(
_indexingConfigurations = indexingConfigurations;
}

public async Task Handle(OrderChangedEvent message)
public virtual async Task Handle(OrderChangedEvent message)
{
if (!_configuration.IsOrderFullTextSearchEnabled() ||
!await _settingsManager.GetValueAsync<bool>(ModuleConstants.Settings.General.EventBasedIndexation))
if (await ShouldIndexAsync())
{
return;
await IndexOrdersAsync(message);
}
}

protected virtual async Task<bool> ShouldIndexAsync()
{
return _configuration.IsOrderFullTextSearchEnabled() &&
await _settingsManager.GetValueAsync<bool>(ModuleConstants.Settings.General.EventBasedIndexation);
}

protected virtual Task IndexOrdersAsync(OrderChangedEvent message)
{
var indexEntries = GetOrderIndexEntries(message);

var indexEntries = message?.ChangedEntries
.Select(x => new IndexEntry { Id = x.OldEntry.Id, EntryState = x.EntryState, Type = ModuleConstants.OrderIndexDocumentType })
.ToArray() ?? Array.Empty<IndexEntry>();
if (indexEntries.Count > 0)
{
var documentBuilders = _indexingConfigurations
.GetDocumentBuilders(ModuleConstants.OrderIndexDocumentType, typeof(CustomerOrderChangesProvider))
.ToList();

_indexingJobService.EnqueueIndexAndDeleteDocuments(indexEntries, JobPriority.Normal, documentBuilders);
}

_indexingJobService.EnqueueIndexAndDeleteDocuments(indexEntries,
JobPriority.Normal, _indexingConfigurations.GetDocumentBuilders(ModuleConstants.OrderIndexDocumentType, typeof(CustomerOrderChangesProvider)).ToList());
return Task.CompletedTask;
}

protected virtual IList<IndexEntry> GetOrderIndexEntries(OrderChangedEvent message)
{
return message?.ChangedEntries
.Select(x => new IndexEntry
{
Id = x.OldEntry.Id,
EntryState = x.EntryState,
Type = ModuleConstants.OrderIndexDocumentType,
})
.ToList() ?? [];
}
}
}
Loading
Loading