diff --git a/Persistence/Repositories/AbstractChangeLogRepository.cs b/Persistence/Repositories/AbstractChangeLogRepository.cs index 92966fa..1e1db12 100644 --- a/Persistence/Repositories/AbstractChangeLogRepository.cs +++ b/Persistence/Repositories/AbstractChangeLogRepository.cs @@ -17,34 +17,36 @@ public abstract class AbstractChangeLogRepository } public abstract TEntity Convert(TDto entity); - public async Task Clear(int idUser, TRequest request, CancellationToken token) + public async Task Clear(int idUser,CancellationToken token) { - var updateTime = DateTimeOffset.UtcNow; + throw new NotImplementedException(); - //todo - var query = BuildQuery(request); - query = query.Where(e => e.Obsolete == null); + //var updateTime = DateTimeOffset.UtcNow; - var entitiesToDelete = await query.ToArrayAsync(token); + ////todo + //var query = BuildQuery(request); + //query = query.Where(e => e.Obsolete == null); - foreach (var entity in entitiesToDelete) - { - entity.IdState = IChangeLogAbstract.IdCleared; - entity.Obsolete = updateTime; - entity.IdEditor = idUser; - } + //var entitiesToDelete = await query.ToArrayAsync(token); - var result = await SaveChangesWithExceptionHandling(token); - return result; + //foreach (var entity in entitiesToDelete) + //{ + // entity.IdState = IChangeLogAbstract.IdCleared; + // entity.Obsolete = updateTime; + // entity.IdEditor = idUser; + //} + + //var result = await SaveChangesWithExceptionHandling(token); + //return result; } - public async Task ClearAndInsertRange(int idUser, TRequest request, IEnumerable dtos, CancellationToken token) + public async Task ClearAndInsertRange(int idUser, IEnumerable dtos, CancellationToken token) { var result = 0; using var transaction = await dbContext.Database.BeginTransactionAsync(token); try { - result += await Clear(idUser, request, token); + result += await Clear(idUser, token); result += await InsertRangeWithoutTransaction(idUser, dtos, token); await transaction.CommitAsync(token); @@ -57,12 +59,12 @@ public abstract class AbstractChangeLogRepository } } - public Task> GetCurrent(TRequest request, CancellationToken token) + public Task> GetCurrent(DateTimeOffset moment, CancellationToken token) { throw new NotImplementedException(); } - public Task> GetDatesChange(TRequest request, CancellationToken token) + public Task> GetDatesChange(CancellationToken token) { throw new NotImplementedException(); } @@ -74,9 +76,7 @@ public abstract class AbstractChangeLogRepository public async Task InsertRange(int idUser, IEnumerable dtos, CancellationToken token) { - this.dbContext.Set(); - var db = GetDataBase(); - using var transaction = db.BeginTransaction(); + using var transaction = dbContext.Database.BeginTransaction(); try { var result = await InsertRangeWithoutTransaction(idUser, dtos, token); @@ -107,7 +107,7 @@ public abstract class AbstractChangeLogRepository throw new NotImplementedException(); } - public Task> GetChangeLogForDate(TRequest request, DateOnly? date, CancellationToken token) + public Task> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token) { throw new NotImplementedException(); } diff --git a/Persistence/Repositories/IChangeLogRepository.cs b/Persistence/Repositories/IChangeLogRepository.cs index 628f59f..d85beb6 100644 --- a/Persistence/Repositories/IChangeLogRepository.cs +++ b/Persistence/Repositories/IChangeLogRepository.cs @@ -3,11 +3,12 @@ namespace Persistence.Repositories; /// -/// +/// Интерфейс для работы с историческими данными /// /// public interface IChangeLogRepository : ISyncRepository where TDto : class + where TChangeLogDto : ChangeLogDto { /// /// Добавление записей @@ -40,20 +41,18 @@ public interface IChangeLogRepository : ISyncRepository /// пользователь, который чистит - /// Фильтр по свойствам конкретной сущности /// /// - Task Clear(int idUser, TRequest request, CancellationToken token); + Task Clear(int idUser, CancellationToken token); /// /// Очистить и добавить новые /// /// - /// /// /// /// - Task ClearAndInsertRange(int idUser, TRequest request, IEnumerable dtos, CancellationToken token); + Task ClearAndInsertRange(int idUser, IEnumerable dtos, CancellationToken token); /// /// Пометить записи как удаленные @@ -70,16 +69,15 @@ public interface IChangeLogRepository : ISyncRepository /// /// - Task> GetDatesChange(TRequest request, CancellationToken token); + Task> GetDatesChange(CancellationToken token); /// /// Получение измененных записей за определенную дату /// - /// - /// Фильтр по дате. Если null - вернет все записи, без привязки к дате + /// /// /// - Task> GetChangeLogForDate(TRequest request, DateOnly? date, CancellationToken token); + Task> GetChangeLogForDate(DateTimeOffset? updateFrom, CancellationToken token); /// /// Получение текущих сейчас записей по параметрам @@ -87,5 +85,5 @@ public interface IChangeLogRepository : ISyncRepository /// /// - Task> GetCurrent(TRequest request, CancellationToken token); + Task> GetCurrent(DateTimeOffset moment, CancellationToken token); } diff --git a/Persistence/Repositories/ISyncRepository.cs b/Persistence/Repositories/ISyncRepository.cs index caf5119..d1a6026 100644 --- a/Persistence/Repositories/ISyncRepository.cs +++ b/Persistence/Repositories/ISyncRepository.cs @@ -1,7 +1,7 @@ namespace Persistence.Repositories; /// -/// +/// Интерфейс по работе с данными /// /// public interface ISyncRepository diff --git a/Persistence/Repositories/ITimeSeriesDataRepository.cs b/Persistence/Repositories/ITimeSeriesDataRepository.cs index 9c28e37..036b4c4 100644 --- a/Persistence/Repositories/ITimeSeriesDataRepository.cs +++ b/Persistence/Repositories/ITimeSeriesDataRepository.cs @@ -1,7 +1,7 @@ namespace Persistence.Repositories; /// -/// +/// Интерфейс по работе с временными данными /// /// public interface ITimeSeriesDataRepository : ISyncRepository