improve performance of alias handling and allow aliases to be an unlimited number of subfolders in depth
This commit is contained in:
@ -6,7 +6,7 @@ namespace Oqtane.Infrastructure
|
||||
{
|
||||
public interface ISyncManager
|
||||
{
|
||||
List<SyncEvent> GetSyncEvents(DateTime lastSyncDate);
|
||||
void AddSyncEvent(string entityName, int entityId);
|
||||
List<SyncEvent> GetSyncEvents(int tenantId, DateTime lastSyncDate);
|
||||
void AddSyncEvent(int tenantId, string entityName, int entityId);
|
||||
}
|
||||
}
|
||||
|
@ -1,43 +1,28 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oqtane.Models;
|
||||
using Oqtane.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Oqtane.Infrastructure;
|
||||
using Oqtane.Repository;
|
||||
|
||||
namespace Oqtane.Infrastructure
|
||||
{
|
||||
public class SyncManager : ISyncManager
|
||||
{
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private List<SyncEvent> SyncEvents { get; set; }
|
||||
|
||||
public SyncManager(IServiceScopeFactory serviceScopeFactory)
|
||||
public SyncManager()
|
||||
{
|
||||
this._serviceScopeFactory = serviceScopeFactory;
|
||||
SyncEvents = new List<SyncEvent>();
|
||||
}
|
||||
|
||||
private int TenantId
|
||||
public List<SyncEvent> GetSyncEvents(int tenantId, DateTime lastSyncDate)
|
||||
{
|
||||
get
|
||||
{
|
||||
using (var scope = _serviceScopeFactory.CreateScope())
|
||||
{
|
||||
return scope.ServiceProvider.GetRequiredService<ITenantResolver>().GetTenant().TenantId;
|
||||
}
|
||||
}
|
||||
return SyncEvents.Where(item => item.TenantId == tenantId && item.ModifiedOn >= lastSyncDate).ToList();
|
||||
}
|
||||
|
||||
public List<SyncEvent> GetSyncEvents(DateTime lastSyncDate)
|
||||
public void AddSyncEvent(int tenantId, string entityName, int entityId)
|
||||
{
|
||||
return SyncEvents.Where(item => item.TenantId == TenantId && item.ModifiedOn >= lastSyncDate).ToList();
|
||||
}
|
||||
|
||||
public void AddSyncEvent(string entityName, int entityId)
|
||||
{
|
||||
SyncEvents.Add(new SyncEvent { TenantId = TenantId, EntityName = entityName, EntityId = entityId, ModifiedOn = DateTime.UtcNow });
|
||||
SyncEvents.Add(new SyncEvent { TenantId = tenantId, EntityName = entityName, EntityId = entityId, ModifiedOn = DateTime.UtcNow });
|
||||
// trim sync events
|
||||
SyncEvents.RemoveAll(item => item.ModifiedOn < DateTime.UtcNow.AddHours(-1));
|
||||
}
|
||||
|
Reference in New Issue
Block a user