@@ -141,7 +141,7 @@ protected virtual RetryPolicy ConfigureRetryPolicy()
141
141
/// <returns></returns>
142
142
protected virtual int RequestNextCounter ( string tenantId , CounterOptions counterOptions )
143
143
{
144
- var sequenceKey = string . IsNullOrEmpty ( tenantId ) ? counterOptions . NumberTemplate : $ " { tenantId } / { counterOptions . NumberTemplate } " ;
144
+ var sequenceKey = GetSequenceKey ( tenantId , counterOptions ) ;
145
145
146
146
using var repository = _repositoryFactory ( ) ;
147
147
var sequence = repository . Sequences . SingleOrDefault ( s => s . ObjectType == sequenceKey ) ;
@@ -177,6 +177,16 @@ protected virtual int RequestNextCounter(string tenantId, CounterOptions counter
177
177
return sequence . Value ;
178
178
}
179
179
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
+
180
190
/// <summary>
181
191
/// Returns true if counter should be reset.
182
192
/// </summary>
@@ -193,7 +203,7 @@ protected virtual bool ShouldResetCounter(DateTime lastResetDate, ResetCounterTy
193
203
return currentUtcDate . Date > lastResetDate . Date ;
194
204
case ResetCounterType . Weekly :
195
205
// 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 ;
197
207
var nextMondayDate = lastResetDate . Date . AddDays ( daysUntilTargetDay ) ;
198
208
return currentUtcDate >= nextMondayDate ;
199
209
case ResetCounterType . Monthly :
0 commit comments