Skip to content

Commit ca99b12

Browse files
committed
Merge branch 'release/3.814.0'
2 parents 5811e81 + b73950d commit ca99b12

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<!-- These properties will be shared for all projects -->
44
<PropertyGroup>
5-
<VersionPrefix>3.813.0</VersionPrefix>
5+
<VersionPrefix>3.814.0</VersionPrefix>
66
<VersionSuffix>
77
</VersionSuffix>
88
<VersionSuffix Condition=" '$(VersionSuffix)' != '' AND '$(BuildNumber)' != '' ">$(VersionSuffix)-$(BuildNumber)</VersionSuffix>

src/VirtoCommerce.CoreModule.Core/Common/SequenceNumberGeneratorOptions.cs

+6
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,11 @@ public class SequenceNumberGeneratorOptions
1010
/// Defines the delay between retries in seconds.
1111
/// </summary>
1212
public int RetryDelay { get; set; } = 5;
13+
14+
/// <summary>
15+
/// Defines usage of the static tenant id instead of store id for generating unique number.
16+
/// Can be useful when you want to have golobal counter for all stores/tenants.
17+
/// </summary>
18+
public bool UseGlobalTenantId { get; set; } = false;
1319
}
1420
}

src/VirtoCommerce.CoreModule.Data/Services/SequenceNumberGeneratorService.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ protected virtual RetryPolicy ConfigureRetryPolicy()
141141
/// <returns></returns>
142142
protected virtual int RequestNextCounter(string tenantId, CounterOptions counterOptions)
143143
{
144-
var sequenceKey = string.IsNullOrEmpty(tenantId) ? counterOptions.NumberTemplate : $"{tenantId}/{counterOptions.NumberTemplate}";
144+
var sequenceKey = GetSequenceKey(tenantId, counterOptions);
145145

146146
using var repository = _repositoryFactory();
147147
var sequence = repository.Sequences.SingleOrDefault(s => s.ObjectType == sequenceKey);
@@ -177,6 +177,16 @@ protected virtual int RequestNextCounter(string tenantId, CounterOptions counter
177177
return sequence.Value;
178178
}
179179

180+
protected virtual string GetSequenceKey(string tenantId, CounterOptions counterOptions)
181+
{
182+
if(_options.UseGlobalTenantId || string.IsNullOrEmpty(tenantId))
183+
{
184+
return counterOptions.NumberTemplate;
185+
}
186+
187+
return $"{tenantId}/{counterOptions.NumberTemplate}";
188+
}
189+
180190
/// <summary>
181191
/// Returns true if counter should be reset.
182192
/// </summary>
@@ -193,7 +203,7 @@ protected virtual bool ShouldResetCounter(DateTime lastResetDate, ResetCounterTy
193203
return currentUtcDate.Date > lastResetDate.Date;
194204
case ResetCounterType.Weekly:
195205
// Reset every Monday
196-
int daysUntilTargetDay = ((int)DayOfWeek.Monday - (int)lastResetDate.DayOfWeek + 7) % 7;
206+
var daysUntilTargetDay = ((int)DayOfWeek.Monday - (int)lastResetDate.DayOfWeek + 7) % 7;
197207
var nextMondayDate = lastResetDate.Date.AddDays(daysUntilTargetDay);
198208
return currentUtcDate >= nextMondayDate;
199209
case ResetCounterType.Monthly:

src/VirtoCommerce.CoreModule.Web/module.manifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<module xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<id>VirtoCommerce.Core</id>
4-
<version>3.813.0</version>
4+
<version>3.814.0</version>
55
<version-tag />
66
<platformVersion>3.853.0</platformVersion>
77
<title>Commerce core module</title>

0 commit comments

Comments
 (0)