From 750788d550704340e1808fed1974b290109a4b4e Mon Sep 17 00:00:00 2001 From: Roman Efremov Date: Mon, 13 Jan 2025 17:45:49 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B0=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ChangeLogController.cs | 1 + .../Controllers/DataSaubController.cs | 2 +- .../Controllers/SetpointController.cs | 1 + ...eriesController.cs => TagBagController.cs} | 8 +- .../Controllers/TechMessagesController.cs | 1 + .../Controllers/TimestampedSetController.cs | 1 + .../Controllers/WitsDataController.cs | 1 + .../Clients/ChangeLogClient.cs | 1 + .../Clients/Interfaces/IChangeLogClient.cs | 1 + .../Clients/Interfaces/ISetpointClient.cs | 1 + .../Clients/Interfaces/ITechMessagesClient.cs | 1 + .../Clients/Interfaces/ITimeSeriesClient.cs | 5 +- .../Interfaces/ITimestampedSetClient.cs | 1 + .../Clients/Interfaces/IWitsDataClient.cs | 1 + .../Interfaces/Refit/IRefitChangeLogClient.cs | 1 + .../Interfaces/Refit/IRefitSetpointClient.cs | 1 + .../Refit/IRefitTechMessagesClient.cs | 1 + .../Refit/IRefitTimeSeriesClient.cs | 5 +- .../Refit/IRefitTimestampedSetClient.cs | 1 + .../Interfaces/Refit/IRefitWitsDataClient.cs | 1 + .../Clients/SetpointClient.cs | 1 + .../Clients/TechMessagesClient.cs | 1 + .../Clients/TimeSeriesClient.cs | 5 +- .../Clients/TimestampedSetClient.cs | 1 + .../Clients/WitsDataClient.cs | 1 + DD.Persistence.Database/Entity/ChangeLog.cs | 3 +- .../Entity/ParameterData.cs | 5 +- DD.Persistence.Database/Entity/Setpoint.cs | 9 +- DD.Persistence.Database/Entity/TechMessage.cs | 3 +- .../Entity/TimestampedSet.cs | 11 -- .../{TagBag.cs => TimestampedValues.cs} | 11 +- .../IChangeLog.cs | 3 +- .../ITimestampedItem.cs} | 4 +- .../TimeSeriesBaseControllerTest.cs | 8 +- .../DependencyInjection.cs | 5 +- DD.Persistence.Repository/QueryBuilders.cs | 5 +- .../Repositories/ChangeLogRepository.cs | 1 + .../Repositories/ParameterRepository.cs | 1 + .../Repositories/SetpointRepository.cs | 13 ++- .../Repositories/TechMessagesRepository.cs | 3 +- .../TimeSeriesDataCachedRepository.cs | 103 ----------------- .../Repositories/TimestampedSetRepository.cs | 1 + ...tory.cs => TimestampedValuesRepository.cs} | 24 ++-- .../DataSourceSystemCachedRepository.cs | 3 +- .../TimestampedValuesCachedRepository.cs | 104 ++++++++++++++++++ DD.Persistence/API/ISyncApi.cs | 2 +- .../API/ISyncWithDiscriminatorApi.cs | 2 +- DD.Persistence/API/ITimeSeriesDataApi.cs | 4 +- DD.Persistence/EFExtensions.cs | 2 +- .../Models/{ => Common}/DatesRangeDto.cs | 2 +- .../{ => Common}/PaginationContainer.cs | 2 +- DD.Persistence/Models/DataSaubDto.cs | 41 ------- DD.Persistence/Models/TimestampedSetDto.cs | 17 ++- .../ITimestampAbstractDto.cs} | 6 +- .../IWithSectionPart.cs | 2 +- .../Repositories/IChangeLogRepository.cs | 1 + .../Repositories/IParameterRepository.cs | 1 + .../Repositories/ISetpointRepository.cs | 1 + .../Repositories/ISyncRepository.cs | 2 +- .../ISyncWithDiscriminatorRepository.cs | 2 +- .../Repositories/ITechMessagesRepository.cs | 1 + .../Repositories/ITimeSeriesBaseRepository.cs | 9 +- .../Repositories/ITimestampedSetRepository.cs | 1 + ...ory.cs => ITimestampedValuesRepository.cs} | 7 +- .../Services/Interfaces/IWitsDataService.cs | 1 + DD.Persistence/Services/WitsDataService.cs | 1 + 66 files changed, 238 insertions(+), 234 deletions(-) rename DD.Persistence.API/Controllers/{TimeSeriesController.cs => TagBagController.cs} (90%) delete mode 100644 DD.Persistence.Database/Entity/TimestampedSet.cs rename DD.Persistence.Database/Entity/{TagBag.cs => TimestampedValues.cs} (51%) rename DD.Persistence.Database/{Entity => EntityAbstractions}/IChangeLog.cs (95%) rename DD.Persistence.Database/{Entity/ITimestampedData.cs => EntityAbstractions/ITimestampedItem.cs} (63%) delete mode 100644 DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs rename DD.Persistence.Repository/Repositories/{TagBagDataRepository.cs => TimestampedValuesRepository.cs} (76%) rename DD.Persistence.Repository/{Repositories => RepositoriesCached}/DataSourceSystemCachedRepository.cs (92%) create mode 100644 DD.Persistence.Repository/RepositoriesCached/TimestampedValuesCachedRepository.cs rename DD.Persistence/Models/{ => Common}/DatesRangeDto.cs (89%) rename DD.Persistence/Models/{ => Common}/PaginationContainer.cs (95%) delete mode 100644 DD.Persistence/Models/DataSaubDto.cs rename DD.Persistence/{Models/ITimeSeriesAbstractDto.cs => ModelsAbstractions/ITimestampAbstractDto.cs} (59%) rename DD.Persistence/{Models => ModelsAbstractions}/IWithSectionPart.cs (77%) rename DD.Persistence/Repositories/{ITimeSeriesDataRepository.cs => ITimestampedValuesRepository.cs} (59%) diff --git a/DD.Persistence.API/Controllers/ChangeLogController.cs b/DD.Persistence.API/Controllers/ChangeLogController.cs index 21761e1..8b788c4 100644 --- a/DD.Persistence.API/Controllers/ChangeLogController.cs +++ b/DD.Persistence.API/Controllers/ChangeLogController.cs @@ -4,6 +4,7 @@ using DD.Persistence.Models; using DD.Persistence.Models.Requests; using DD.Persistence.Repositories; using System.Net; +using DD.Persistence.Models.Common; namespace DD.Persistence.API.Controllers; diff --git a/DD.Persistence.API/Controllers/DataSaubController.cs b/DD.Persistence.API/Controllers/DataSaubController.cs index 832faec..df86844 100644 --- a/DD.Persistence.API/Controllers/DataSaubController.cs +++ b/DD.Persistence.API/Controllers/DataSaubController.cs @@ -13,7 +13,7 @@ namespace DD.Persistence.API.Controllers; [Route("api/[controller]")] public class DataSaubController : TimeSeriesController { - public DataSaubController(ITimeSeriesDataRepository timeSeriesDataRepository) : base(timeSeriesDataRepository) + public DataSaubController(ITimestampedValuesRepository timeSeriesDataRepository) : base(timeSeriesDataRepository) { } diff --git a/DD.Persistence.API/Controllers/SetpointController.cs b/DD.Persistence.API/Controllers/SetpointController.cs index e3b8b14..663a1c4 100644 --- a/DD.Persistence.API/Controllers/SetpointController.cs +++ b/DD.Persistence.API/Controllers/SetpointController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using DD.Persistence.Models; using DD.Persistence.Repositories; using System.Net; +using DD.Persistence.Models.Common; namespace DD.Persistence.API.Controllers; diff --git a/DD.Persistence.API/Controllers/TimeSeriesController.cs b/DD.Persistence.API/Controllers/TagBagController.cs similarity index 90% rename from DD.Persistence.API/Controllers/TimeSeriesController.cs rename to DD.Persistence.API/Controllers/TagBagController.cs index 5fded36..c7b8475 100644 --- a/DD.Persistence.API/Controllers/TimeSeriesController.cs +++ b/DD.Persistence.API/Controllers/TagBagController.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using DD.Persistence.Models; using DD.Persistence.Repositories; +using DD.Persistence.ModelsAbstractions; namespace DD.Persistence.API.Controllers; @@ -9,11 +9,11 @@ namespace DD.Persistence.API.Controllers; [Authorize] [Route("api/[controller]")] public class TimeSeriesController : ControllerBase, ITimeSeriesDataApi - where TDto : class, ITimeSeriesAbstractDto, new() + where TDto : class, ITimestampAbstractDto, new() { - private readonly ITimeSeriesDataRepository timeSeriesDataRepository; + private readonly ITimestampedValuesRepository timeSeriesDataRepository; - public TimeSeriesController(ITimeSeriesDataRepository timeSeriesDataRepository) + public TimeSeriesController(ITimestampedValuesRepository timeSeriesDataRepository) { this.timeSeriesDataRepository = timeSeriesDataRepository; } diff --git a/DD.Persistence.API/Controllers/TechMessagesController.cs b/DD.Persistence.API/Controllers/TechMessagesController.cs index 81663e0..cd98e42 100644 --- a/DD.Persistence.API/Controllers/TechMessagesController.cs +++ b/DD.Persistence.API/Controllers/TechMessagesController.cs @@ -4,6 +4,7 @@ using DD.Persistence.Models; using DD.Persistence.Models.Requests; using DD.Persistence.Repositories; using System.Net; +using DD.Persistence.Models.Common; namespace DD.Persistence.API.Controllers; diff --git a/DD.Persistence.API/Controllers/TimestampedSetController.cs b/DD.Persistence.API/Controllers/TimestampedSetController.cs index 0c805ab..c4514f5 100644 --- a/DD.Persistence.API/Controllers/TimestampedSetController.cs +++ b/DD.Persistence.API/Controllers/TimestampedSetController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using DD.Persistence.Models; using DD.Persistence.Repositories; using System.Net; +using DD.Persistence.Models.Common; namespace DD.Persistence.API.Controllers; diff --git a/DD.Persistence.API/Controllers/WitsDataController.cs b/DD.Persistence.API/Controllers/WitsDataController.cs index 5df6c3f..c87345e 100644 --- a/DD.Persistence.API/Controllers/WitsDataController.cs +++ b/DD.Persistence.API/Controllers/WitsDataController.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using DD.Persistence.Models; using DD.Persistence.Services.Interfaces; using System.Net; +using DD.Persistence.Models.Common; namespace DD.Persistence.API.Controllers; diff --git a/DD.Persistence.Client/Clients/ChangeLogClient.cs b/DD.Persistence.Client/Clients/ChangeLogClient.cs index 38c2ec4..e4f5904 100644 --- a/DD.Persistence.Client/Clients/ChangeLogClient.cs +++ b/DD.Persistence.Client/Clients/ChangeLogClient.cs @@ -4,6 +4,7 @@ using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Models; using DD.Persistence.Models.Requests; using DD.Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients; public class ChangeLogClient : BaseClient, IChangeLogClient diff --git a/DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs b/DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs index 19edeab..f81ac8d 100644 --- a/DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using DD.Persistence.Models.Requests; namespace DD.Persistence.Client.Clients.Interfaces; diff --git a/DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs b/DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs index 86462ea..5745e7e 100644 --- a/DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients.Interfaces; diff --git a/DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs b/DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs index a27e553..2af1af6 100644 --- a/DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using DD.Persistence.Models.Requests; namespace DD.Persistence.Client.Clients.Interfaces; diff --git a/DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs b/DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs index db619e5..c41564c 100644 --- a/DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs @@ -1,4 +1,5 @@ -using DD.Persistence.Models; +using DD.Persistence.Models.Common; +using DD.Persistence.ModelsAbstractions; namespace DD.Persistence.Client.Clients.Interfaces; @@ -6,7 +7,7 @@ namespace DD.Persistence.Client.Clients.Interfaces; /// Клиент для работы с временными данными /// /// -public interface ITimeSeriesClient : IDisposable where TDto : class, ITimeSeriesAbstractDto +public interface ITimeSeriesClient : IDisposable where TDto : class, ITimestampAbstractDto { /// /// Добавление записей diff --git a/DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs b/DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs index be98a77..5efd6e7 100644 --- a/DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients.Interfaces; diff --git a/DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs b/DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs index e954484..0ac015d 100644 --- a/DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using Refit; namespace DD.Persistence.Client.Clients.Interfaces; diff --git a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs index 83c240f..8e35b4e 100644 --- a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using DD.Persistence.Models.Requests; using Refit; diff --git a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs index 1acb398..8f75dfa 100644 --- a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using Refit; namespace DD.Persistence.Client.Clients.Interfaces.Refit; diff --git a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs index 1fe63c1..862d1c7 100644 --- a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs @@ -2,6 +2,7 @@ using DD.Persistence.Models; using DD.Persistence.Models.Requests; using Refit; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients.Interfaces.Refit { diff --git a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs index 832cfde..0dc4994 100644 --- a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs @@ -1,9 +1,10 @@ -using DD.Persistence.Models; +using DD.Persistence.Models.Common; +using DD.Persistence.ModelsAbstractions; using Refit; namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitTimeSeriesClient : IRefitClient, IDisposable - where TDto : class, ITimeSeriesAbstractDto + where TDto : class, ITimestampAbstractDto { private const string BaseRoute = "/api/dataSaub"; diff --git a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs index 6211d2d..921e867 100644 --- a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using Refit; namespace DD.Persistence.Client.Clients.Interfaces.Refit; diff --git a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs index e7e6d9a..9f719c6 100644 --- a/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Mvc; using DD.Persistence.Models; using Refit; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitWitsDataClient : IRefitClient, IDisposable diff --git a/DD.Persistence.Client/Clients/SetpointClient.cs b/DD.Persistence.Client/Clients/SetpointClient.cs index 808f0b9..c43a0b2 100644 --- a/DD.Persistence.Client/Clients/SetpointClient.cs +++ b/DD.Persistence.Client/Clients/SetpointClient.cs @@ -3,6 +3,7 @@ using DD.Persistence.Client.Clients.Base; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients; diff --git a/DD.Persistence.Client/Clients/TechMessagesClient.cs b/DD.Persistence.Client/Clients/TechMessagesClient.cs index e23c961..681e275 100644 --- a/DD.Persistence.Client/Clients/TechMessagesClient.cs +++ b/DD.Persistence.Client/Clients/TechMessagesClient.cs @@ -4,6 +4,7 @@ using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Models; using DD.Persistence.Models.Requests; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients; diff --git a/DD.Persistence.Client/Clients/TimeSeriesClient.cs b/DD.Persistence.Client/Clients/TimeSeriesClient.cs index c75ec81..10ff2e4 100644 --- a/DD.Persistence.Client/Clients/TimeSeriesClient.cs +++ b/DD.Persistence.Client/Clients/TimeSeriesClient.cs @@ -2,10 +2,11 @@ using DD.Persistence.Client.Clients.Base; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; -using DD.Persistence.Models; +using DD.Persistence.Models.Common; +using DD.Persistence.ModelsAbstractions; namespace DD.Persistence.Client.Clients; -public class TimeSeriesClient : BaseClient, ITimeSeriesClient where TDto : class, ITimeSeriesAbstractDto +public class TimeSeriesClient : BaseClient, ITimeSeriesClient where TDto : class, ITimestampAbstractDto { private readonly IRefitTimeSeriesClient timeSeriesClient; diff --git a/DD.Persistence.Client/Clients/TimestampedSetClient.cs b/DD.Persistence.Client/Clients/TimestampedSetClient.cs index 7d1ba56..d9f71dd 100644 --- a/DD.Persistence.Client/Clients/TimestampedSetClient.cs +++ b/DD.Persistence.Client/Clients/TimestampedSetClient.cs @@ -3,6 +3,7 @@ using DD.Persistence.Client.Clients.Base; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients; public class TimestampedSetClient : BaseClient, ITimestampedSetClient diff --git a/DD.Persistence.Client/Clients/WitsDataClient.cs b/DD.Persistence.Client/Clients/WitsDataClient.cs index e2703dc..d47f771 100644 --- a/DD.Persistence.Client/Clients/WitsDataClient.cs +++ b/DD.Persistence.Client/Clients/WitsDataClient.cs @@ -3,6 +3,7 @@ using DD.Persistence.Client.Clients.Base; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Client.Clients; public class WitsDataClient : BaseClient, IWitsDataClient diff --git a/DD.Persistence.Database/Entity/ChangeLog.cs b/DD.Persistence.Database/Entity/ChangeLog.cs index 439e886..d874ea2 100644 --- a/DD.Persistence.Database/Entity/ChangeLog.cs +++ b/DD.Persistence.Database/Entity/ChangeLog.cs @@ -1,8 +1,9 @@  using Microsoft.EntityFrameworkCore; -using DD.Persistence.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using DD.Persistence.ModelsAbstractions; +using DD.Persistence.Database.EntityAbstractions; namespace DD.Persistence.Database.Model; diff --git a/DD.Persistence.Database/Entity/ParameterData.cs b/DD.Persistence.Database/Entity/ParameterData.cs index c81b029..e1e1a5c 100644 --- a/DD.Persistence.Database/Entity/ParameterData.cs +++ b/DD.Persistence.Database/Entity/ParameterData.cs @@ -1,11 +1,12 @@ -using Microsoft.EntityFrameworkCore; +using DD.Persistence.Database.EntityAbstractions; +using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity; [PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))] -public class ParameterData +public class ParameterData : ITimestampedItem { [Required, Comment("Дискриминатор системы")] public Guid DiscriminatorId { get; set; } diff --git a/DD.Persistence.Database/Entity/Setpoint.cs b/DD.Persistence.Database/Entity/Setpoint.cs index 94eca3f..e3c2ef5 100644 --- a/DD.Persistence.Database/Entity/Setpoint.cs +++ b/DD.Persistence.Database/Entity/Setpoint.cs @@ -1,10 +1,11 @@ -using Microsoft.EntityFrameworkCore; +using DD.Persistence.Database.EntityAbstractions; +using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Model { - [PrimaryKey(nameof(Key), nameof(Created))] - public class Setpoint + [PrimaryKey(nameof(Key), nameof(Timestamp))] + public class Setpoint : ITimestampedItem { [Comment("Ключ")] public Guid Key { get; set; } @@ -13,7 +14,7 @@ namespace DD.Persistence.Database.Model public required object Value { get; set; } [Comment("Дата создания уставки")] - public DateTimeOffset Created { get; set; } + public DateTimeOffset Timestamp { get; set; } [Comment("Id автора последнего изменения")] public Guid IdUser { get; set; } diff --git a/DD.Persistence.Database/Entity/TechMessage.cs b/DD.Persistence.Database/Entity/TechMessage.cs index e233941..ef17e60 100644 --- a/DD.Persistence.Database/Entity/TechMessage.cs +++ b/DD.Persistence.Database/Entity/TechMessage.cs @@ -1,10 +1,11 @@ +using DD.Persistence.Database.EntityAbstractions; using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity { - public class TechMessage + public class TechMessage : ITimestampedItem { [Key, Comment("Id события")] public Guid EventId { get; set; } diff --git a/DD.Persistence.Database/Entity/TimestampedSet.cs b/DD.Persistence.Database/Entity/TimestampedSet.cs deleted file mode 100644 index f0d1815..0000000 --- a/DD.Persistence.Database/Entity/TimestampedSet.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations.Schema; - -namespace DD.Persistence.Database.Entity; - -[Comment("Общая таблица данных временных рядов")] -[PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))] -public record TimestampedSet( - [property: Comment("Дискриминатор ссылка на тип сохраняемых данных")] Guid IdDiscriminator, - [property: Comment("Отметка времени, строго в UTC")] DateTimeOffset Timestamp, - [property: Column(TypeName = "jsonb"), Comment("Набор сохраняемых данных")] IDictionary Set); diff --git a/DD.Persistence.Database/Entity/TagBag.cs b/DD.Persistence.Database/Entity/TimestampedValues.cs similarity index 51% rename from DD.Persistence.Database/Entity/TagBag.cs rename to DD.Persistence.Database/Entity/TimestampedValues.cs index 2aa7546..3205203 100644 --- a/DD.Persistence.Database/Entity/TagBag.cs +++ b/DD.Persistence.Database/Entity/TimestampedValues.cs @@ -1,18 +1,19 @@ -using DD.Persistence.Database.Model; +using DD.Persistence.Database.EntityAbstractions; using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace DD.Persistence.Database.Entity; -[PrimaryKey(nameof(BagId), nameof(Timestamp))] -public class TagBag : ITimestampedData +[PrimaryKey(nameof(DiscriminatorId), nameof(Timestamp))] +public class TimestampedValues : ITimestampedItem { [Comment("Временная отметка"), Key] public DateTimeOffset Timestamp { get; set; } - public Guid BagId { get; set; } + [Comment("Дискриминатор системы"),] + public Guid DiscriminatorId { get; set; } - [Column(TypeName = "jsonb")] + [Comment("Данные"), Column(TypeName = "jsonb")] public required object[] Values { get; set; } } diff --git a/DD.Persistence.Database/Entity/IChangeLog.cs b/DD.Persistence.Database/EntityAbstractions/IChangeLog.cs similarity index 95% rename from DD.Persistence.Database/Entity/IChangeLog.cs rename to DD.Persistence.Database/EntityAbstractions/IChangeLog.cs index b91808b..4d082a7 100644 --- a/DD.Persistence.Database/Entity/IChangeLog.cs +++ b/DD.Persistence.Database/EntityAbstractions/IChangeLog.cs @@ -1,5 +1,4 @@ - -namespace DD.Persistence.Database.Model; +namespace DD.Persistence.Database.EntityAbstractions; /// /// Часть записи, описывающая изменение diff --git a/DD.Persistence.Database/Entity/ITimestampedData.cs b/DD.Persistence.Database/EntityAbstractions/ITimestampedItem.cs similarity index 63% rename from DD.Persistence.Database/Entity/ITimestampedData.cs rename to DD.Persistence.Database/EntityAbstractions/ITimestampedItem.cs index 5a1b25c..f505796 100644 --- a/DD.Persistence.Database/Entity/ITimestampedData.cs +++ b/DD.Persistence.Database/EntityAbstractions/ITimestampedItem.cs @@ -1,5 +1,5 @@ -namespace DD.Persistence.Database.Model; -public interface ITimestampedData +namespace DD.Persistence.Database.EntityAbstractions; +public interface ITimestampedItem { /// /// Дата (должна быть обязательно в UTC) diff --git a/DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs index 4b52f79..481bf57 100644 --- a/DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs @@ -2,8 +2,8 @@ using DD.Persistence.Client; using DD.Persistence.Client.Clients; using DD.Persistence.Client.Clients.Interfaces; using DD.Persistence.Client.Clients.Interfaces.Refit; -using DD.Persistence.Database.Model; -using DD.Persistence.Models; +using DD.Persistence.Database.EntityAbstractions; +using DD.Persistence.ModelsAbstractions; using Mapster; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -12,8 +12,8 @@ using Xunit; namespace DD.Persistence.IntegrationTests.Controllers; public abstract class TimeSeriesBaseControllerTest : BaseIntegrationTest - where TEntity : class, ITimestampedData, new() - where TDto : class, ITimeSeriesAbstractDto, new() + where TEntity : class, ITimestampedItem, new() + where TDto : class, ITimestampAbstractDto, new() { private readonly ITimeSeriesClient timeSeriesClient; diff --git a/DD.Persistence.Repository/DependencyInjection.cs b/DD.Persistence.Repository/DependencyInjection.cs index 5114cd0..be9ed55 100644 --- a/DD.Persistence.Repository/DependencyInjection.cs +++ b/DD.Persistence.Repository/DependencyInjection.cs @@ -6,6 +6,7 @@ using DD.Persistence.Repositories; using DD.Persistence.Repository.Repositories; using DD.Persistence.Database.Entity; using System.Reflection; +using DD.Persistence.Repository.RepositoriesCached; namespace DD.Persistence.Repository; public static class DependencyInjection @@ -35,9 +36,9 @@ public static class DependencyInjection MapsterSetup(); - services.AddTransient, TagBagDataRepository>(); + services.AddTransient, TagBagDataRepository>(); services.AddTransient(); - //services.AddTransient, TimeSeriesDataCachedRepository>(); + //services.AddTransient, TimeSeriesDataCachedRepository>(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/DD.Persistence.Repository/QueryBuilders.cs b/DD.Persistence.Repository/QueryBuilders.cs index 6fad2cc..5fb3eb5 100644 --- a/DD.Persistence.Repository/QueryBuilders.cs +++ b/DD.Persistence.Repository/QueryBuilders.cs @@ -1,7 +1,8 @@ using Microsoft.EntityFrameworkCore; -using DD.Persistence.Database.Model; -using DD.Persistence.Models; using DD.Persistence.Models.Requests; +using DD.Persistence.Models.Common; +using DD.Persistence.ModelsAbstractions; +using DD.Persistence.Database.EntityAbstractions; namespace DD.Persistence.Repository; diff --git a/DD.Persistence.Repository/Repositories/ChangeLogRepository.cs b/DD.Persistence.Repository/Repositories/ChangeLogRepository.cs index ef57d10..60fe08e 100644 --- a/DD.Persistence.Repository/Repositories/ChangeLogRepository.cs +++ b/DD.Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -5,6 +5,7 @@ using DD.Persistence.Models; using DD.Persistence.Models.Requests; using DD.Persistence.Repositories; using UuidExtensions; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repository.Repositories; public class ChangeLogRepository : IChangeLogRepository diff --git a/DD.Persistence.Repository/Repositories/ParameterRepository.cs b/DD.Persistence.Repository/Repositories/ParameterRepository.cs index 434d59f..d241de7 100644 --- a/DD.Persistence.Repository/Repositories/ParameterRepository.cs +++ b/DD.Persistence.Repository/Repositories/ParameterRepository.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; using DD.Persistence.Database.Entity; using DD.Persistence.Models; using DD.Persistence.Repositories; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repository.Repositories; public class ParameterRepository : IParameterRepository diff --git a/DD.Persistence.Repository/Repositories/SetpointRepository.cs b/DD.Persistence.Repository/Repositories/SetpointRepository.cs index f7a719a..8068b79 100644 --- a/DD.Persistence.Repository/Repositories/SetpointRepository.cs +++ b/DD.Persistence.Repository/Repositories/SetpointRepository.cs @@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore; using DD.Persistence.Database.Model; using DD.Persistence.Models; using DD.Persistence.Repositories; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repository.Repositories { @@ -35,8 +36,8 @@ namespace DD.Persistence.Repository.Repositories .ToArrayAsync(token); var filteredEntities = entities .GroupBy(e => e.Key) - .Select(e => e.OrderBy(o => o.Created)) - .Select(e => e.Where(e => e.Created <= historyMoment).Last()); + .Select(e => e.OrderBy(o => o.Timestamp)) + .Select(e => e.Where(e => e.Timestamp <= historyMoment).Last()); var dtos = filteredEntities .Select(e => e.Adapt()); @@ -47,7 +48,7 @@ namespace DD.Persistence.Repository.Repositories { var query = GetQueryReadOnly(); var entities = await query - .Where(e => e.Created >= dateBegin) + .Where(e => e.Timestamp >= dateBegin) .Take(take) .ToArrayAsync(token); var dtos = entities @@ -62,8 +63,8 @@ namespace DD.Persistence.Repository.Repositories .GroupBy(e => 1) .Select(group => new { - Min = group.Min(e => e.Created), - Max = group.Max(e => e.Created), + Min = group.Min(e => e.Timestamp), + Max = group.Max(e => e.Timestamp), }); var values = await query.FirstOrDefaultAsync(token); var result = new DatesRangeDto() @@ -95,7 +96,7 @@ namespace DD.Persistence.Repository.Repositories Key = setpointKey, Value = newValue, IdUser = idUser, - Created = DateTimeOffset.UtcNow + Timestamp = DateTimeOffset.UtcNow }; await db.Set().AddAsync(entity, token); diff --git a/DD.Persistence.Repository/Repositories/TechMessagesRepository.cs b/DD.Persistence.Repository/Repositories/TechMessagesRepository.cs index 6bbb382..2917021 100644 --- a/DD.Persistence.Repository/Repositories/TechMessagesRepository.cs +++ b/DD.Persistence.Repository/Repositories/TechMessagesRepository.cs @@ -7,10 +7,11 @@ using DD.Persistence.Models; using DD.Persistence.Models.Requests; using DD.Persistence.Repositories; using UuidExtensions; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repository.Repositories { - public class TechMessagesRepository : ITechMessagesRepository + public class TechMessagesRepository : ITechMessagesRepository { private readonly IDataSourceSystemRepository sourceSystemRepository; private DbContext db; diff --git a/DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs b/DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs deleted file mode 100644 index 768f747..0000000 --- a/DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs +++ /dev/null @@ -1,103 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using DD.Persistence.Database.Model; -using DD.Persistence.Models; - -namespace DD.Persistence.Repository.Repositories; - -public class TimeSeriesDataCachedRepository : TimeSeriesDataRepository - where TEntity : class, ITimestampedData, new() - where TDto : class, ITimeSeriesAbstractDto, new() -{ - public static TDto? FirstByDate { get; private set; } - public static CyclicArray LastData { get; } = new CyclicArray(CacheItemsCount); - - private const int CacheItemsCount = 3600; - - public TimeSeriesDataCachedRepository(DbContext db) : base(db) - { - Task.Run(async () => - { - var firstDateItem = await base.GetFirstAsync(CancellationToken.None); - if (firstDateItem == null) - { - return; - } - - FirstByDate = firstDateItem; - - var dtos = await base.GetLastAsync(CacheItemsCount, CancellationToken.None); - dtos = dtos.OrderBy(d => d.Date); - LastData.AddRange(dtos); - }).Wait(); - } - - public override async Task> GetGtDate(DateTimeOffset dateBegin, CancellationToken token) - { - - if (LastData.Count == 0 || LastData[0].Date > dateBegin) - { - var dtos = await base.GetGtDate(dateBegin, token); - return dtos; - } - - var items = LastData - .Where(i => i.Date >= dateBegin); - - return items; - } - - public override async Task AddRange(IEnumerable dtos, CancellationToken token) - { - var result = await base.AddRange(dtos, token); - if (result > 0) - { - - dtos = dtos.OrderBy(x => x.Date); - - FirstByDate = dtos.First(); - LastData.AddRange(dtos); - } - - return result; - } - - public override async Task GetDatesRange(CancellationToken token) - { - if (FirstByDate == null) - return null; - - return await Task.Run(() => - { - return new DatesRangeDto - { - From = FirstByDate.Date, - To = LastData[^1].Date - }; - }); - } - - public override async Task> GetResampledData( - DateTimeOffset dateBegin, - double intervalSec = 600d, - int approxPointsCount = 1024, - CancellationToken token = default) - { - var dtos = LastData.Where(i => i.Date >= dateBegin); - if (LastData.Count == 0 || LastData[0].Date > dateBegin) - { - dtos = await base.GetGtDate(dateBegin, token); - } - - var dateEnd = dateBegin.AddSeconds(intervalSec); - dtos = dtos - .Where(i => i.Date <= dateEnd); - - var ratio = dtos.Count() / approxPointsCount; - if (ratio > 1) - dtos = dtos - .Where((_, index) => index % ratio == 0); - - return dtos; - } -} - diff --git a/DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs b/DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs index 6f54521..c265d4d 100644 --- a/DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs +++ b/DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs @@ -2,6 +2,7 @@ using DD.Persistence.Database.Entity; using DD.Persistence.Models; using DD.Persistence.Repositories; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repository.Repositories; diff --git a/DD.Persistence.Repository/Repositories/TagBagDataRepository.cs b/DD.Persistence.Repository/Repositories/TimestampedValuesRepository.cs similarity index 76% rename from DD.Persistence.Repository/Repositories/TagBagDataRepository.cs rename to DD.Persistence.Repository/Repositories/TimestampedValuesRepository.cs index 320b99b..d055594 100644 --- a/DD.Persistence.Repository/Repositories/TagBagDataRepository.cs +++ b/DD.Persistence.Repository/Repositories/TimestampedValuesRepository.cs @@ -1,20 +1,22 @@ -using Mapster; -using Microsoft.EntityFrameworkCore; -using DD.Persistence.Database.Model; -using DD.Persistence.Models; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models.Common; +using DD.Persistence.ModelsAbstractions; using DD.Persistence.Repositories; +using Mapster; +using Microsoft.EntityFrameworkCore; namespace DD.Persistence.Repository.Repositories; -public class TagBagRepository : ITimeSeriesDataRepository +public class TimestampedValuesRepository : ITimestampedValuesRepository + where TDto : class, ITimestampAbstractDto, new() { private readonly DbContext db; - public TagBagRepository(DbContext db) + public TimestampedValuesRepository(DbContext db) { this.db = db; } - protected virtual IQueryable GetQueryReadOnly() => this.db.Set(); + protected virtual IQueryable GetQueryReadOnly() => this.db.Set(); public virtual async Task GetDatesRange(CancellationToken token) { @@ -31,7 +33,7 @@ public class TagBagRepository : ITimeSeriesDataRepository public virtual async Task> GetGtDate(DateTimeOffset date, CancellationToken token) { - var query = this.db.Set().Where(e => e.Timestamp > date); + var query = GetQueryReadOnly().Where(e => e.Timestamp > date); var entities = await query.ToArrayAsync(token); var dtos = entities.Select(e => e.Adapt()); @@ -41,9 +43,9 @@ public class TagBagRepository : ITimeSeriesDataRepository public virtual async Task AddRange(IEnumerable dtos, CancellationToken token) { - var entities = dtos.Select(d => d.Adapt()); + var entities = dtos.Select(d => d.Adapt()); - await db.Set().AddRangeAsync(entities, token); + await db.Set().AddRangeAsync(entities, token); var result = await db.SaveChangesAsync(token); return result; @@ -85,7 +87,7 @@ public class TagBagRepository : ITimeSeriesDataRepository var dateEnd = dateBegin.AddSeconds(intervalSec); dtos = dtos - .Where(i => i.Date <= dateEnd); + .Where(i => i.Timestamp <= dateEnd); var ratio = dtos.Count() / approxPointsCount; if (ratio > 1) diff --git a/DD.Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs b/DD.Persistence.Repository/RepositoriesCached/DataSourceSystemCachedRepository.cs similarity index 92% rename from DD.Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs rename to DD.Persistence.Repository/RepositoriesCached/DataSourceSystemCachedRepository.cs index 37009e8..febb65e 100644 --- a/DD.Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs +++ b/DD.Persistence.Repository/RepositoriesCached/DataSourceSystemCachedRepository.cs @@ -1,8 +1,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using DD.Persistence.Models; +using DD.Persistence.Repository.Repositories; -namespace DD.Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.RepositoriesCached; public class DataSourceSystemCachedRepository : DataSourceSystemRepository { private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey"; diff --git a/DD.Persistence.Repository/RepositoriesCached/TimestampedValuesCachedRepository.cs b/DD.Persistence.Repository/RepositoriesCached/TimestampedValuesCachedRepository.cs new file mode 100644 index 0000000..d1eba07 --- /dev/null +++ b/DD.Persistence.Repository/RepositoriesCached/TimestampedValuesCachedRepository.cs @@ -0,0 +1,104 @@ +//using Microsoft.EntityFrameworkCore; +//using DD.Persistence.Models.Common; +//using DD.Persistence.ModelsAbstractions; +//using DD.Persistence.Database.EntityAbstractions; + +//namespace DD.Persistence.Repository.Repositories; + +//public class TimestampedValuesCachedRepository : TimeSeriesDataRepository +// where TEntity : class, ITimestampedItem, new() +// where TDto : class, ITimestampAbstractDto, new() +//{ +// public static TDto? FirstByDate { get; private set; } +// public static CyclicArray LastData { get; } = new CyclicArray(CacheItemsCount); + +// private const int CacheItemsCount = 3600; + +// public TimestampedValuesCachedRepository(DbContext db) : base(db) +// { +// Task.Run(async () => +// { +// var firstDateItem = await base.GetFirstAsync(CancellationToken.None); +// if (firstDateItem == null) +// { +// return; +// } + +// FirstByDate = firstDateItem; + +// var dtos = await base.GetLastAsync(CacheItemsCount, CancellationToken.None); +// dtos = dtos.OrderBy(d => d.Timestamp); +// LastData.AddRange(dtos); +// }).Wait(); +// } + +// public override async Task> GetGtDate(DateTimeOffset dateBegin, CancellationToken token) +// { + +// if (LastData.Count == 0 || LastData[0].Timestamp > dateBegin) +// { +// var dtos = await base.GetGtDate(dateBegin, token); +// return dtos; +// } + +// var items = LastData +// .Where(i => i.Timestamp >= dateBegin); + +// return items; +// } + +// public override async Task AddRange(IEnumerable dtos, CancellationToken token) +// { +// var result = await base.AddRange(dtos, token); +// if (result > 0) +// { + +// dtos = dtos.OrderBy(x => x.Timestamp); + +// FirstByDate = dtos.First(); +// LastData.AddRange(dtos); +// } + +// return result; +// } + +// public override async Task GetDatesRange(CancellationToken token) +// { +// if (FirstByDate == null) +// return null; + +// return await Task.Run(() => +// { +// return new DatesRangeDto +// { +// From = FirstByDate.Timestamp, +// To = LastData[^1].Timestamp +// }; +// }); +// } + +// public override async Task> GetResampledData( +// DateTimeOffset dateBegin, +// double intervalSec = 600d, +// int approxPointsCount = 1024, +// CancellationToken token = default) +// { +// var dtos = LastData.Where(i => i.Timestamp >= dateBegin); +// if (LastData.Count == 0 || LastData[0].Timestamp > dateBegin) +// { +// dtos = await base.GetGtDate(dateBegin, token); +// } + +// var dateEnd = dateBegin.AddSeconds(intervalSec); +// dtos = dtos +// .Where(i => i.Timestamp <= dateEnd); + +// var ratio = dtos.Count() / approxPointsCount; +// if (ratio > 1) +// dtos = dtos +// .Where((_, index) => index % ratio == 0); + +// return dtos; +// } +//} + diff --git a/DD.Persistence/API/ISyncApi.cs b/DD.Persistence/API/ISyncApi.cs index 5bd8379..ec8b9ba 100644 --- a/DD.Persistence/API/ISyncApi.cs +++ b/DD.Persistence/API/ISyncApi.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Mvc; -using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.API; diff --git a/DD.Persistence/API/ISyncWithDiscriminatorApi.cs b/DD.Persistence/API/ISyncWithDiscriminatorApi.cs index 05f0a90..f57504d 100644 --- a/DD.Persistence/API/ISyncWithDiscriminatorApi.cs +++ b/DD.Persistence/API/ISyncWithDiscriminatorApi.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Mvc; -using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.API; diff --git a/DD.Persistence/API/ITimeSeriesDataApi.cs b/DD.Persistence/API/ITimeSeriesDataApi.cs index d9b415a..1182455 100644 --- a/DD.Persistence/API/ITimeSeriesDataApi.cs +++ b/DD.Persistence/API/ITimeSeriesDataApi.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Mvc; -using DD.Persistence.Models; +using DD.Persistence.ModelsAbstractions; namespace DD.Persistence.API; @@ -7,7 +7,7 @@ namespace DD.Persistence.API; /// Интерфейс для работы с API временных данных /// public interface ITimeSeriesDataApi : ITimeSeriesBaseDataApi - where TDto : class, ITimeSeriesAbstractDto, new() + where TDto : class, ITimestampAbstractDto, new() { /// /// Получить список объектов, удовлетворяющий диапазон дат diff --git a/DD.Persistence/EFExtensions.cs b/DD.Persistence/EFExtensions.cs index a308db9..af6cd15 100644 --- a/DD.Persistence/EFExtensions.cs +++ b/DD.Persistence/EFExtensions.cs @@ -66,7 +66,7 @@ public static class EFExtensions /// и опционально указания направления сортировки "asc" или "desc" /// /// - /// var query = query("Date desc"); + /// var query = query("Timestamp desc"); /// /// Запрос с примененной сортировкой public static IOrderedQueryable SortBy( diff --git a/DD.Persistence/Models/DatesRangeDto.cs b/DD.Persistence/Models/Common/DatesRangeDto.cs similarity index 89% rename from DD.Persistence/Models/DatesRangeDto.cs rename to DD.Persistence/Models/Common/DatesRangeDto.cs index 0a764ce..2049ed7 100644 --- a/DD.Persistence/Models/DatesRangeDto.cs +++ b/DD.Persistence/Models/Common/DatesRangeDto.cs @@ -1,4 +1,4 @@ -namespace DD.Persistence.Models; +namespace DD.Persistence.Models.Common; /// /// Диапазон дат diff --git a/DD.Persistence/Models/PaginationContainer.cs b/DD.Persistence/Models/Common/PaginationContainer.cs similarity index 95% rename from DD.Persistence/Models/PaginationContainer.cs rename to DD.Persistence/Models/Common/PaginationContainer.cs index 89306f8..ec3aa67 100644 --- a/DD.Persistence/Models/PaginationContainer.cs +++ b/DD.Persistence/Models/Common/PaginationContainer.cs @@ -1,4 +1,4 @@ -namespace DD.Persistence.Models; +namespace DD.Persistence.Models.Common; /// /// Контейнер для поддержки постраничного просмотра таблиц diff --git a/DD.Persistence/Models/DataSaubDto.cs b/DD.Persistence/Models/DataSaubDto.cs deleted file mode 100644 index 34306d9..0000000 --- a/DD.Persistence/Models/DataSaubDto.cs +++ /dev/null @@ -1,41 +0,0 @@ -namespace DD.Persistence.Models; -public class DataSaubDto : ITimeSeriesAbstractDto -{ - public DateTimeOffset Date { get; set; } = DateTimeOffset.UtcNow; - - public int? Mode { get; set; } - - public string? User { get; set; } - - public double? WellDepth { get; set; } - - public double? BitDepth { get; set; } - - public double? BlockPosition { get; set; } - - public double? BlockSpeed { get; set; } - - public double? Pressure { get; set; } - - public double? AxialLoad { get; set; } - - public double? HookWeight { get; set; } - - public double? RotorTorque { get; set; } - - public double? RotorSpeed { get; set; } - - public double? Flow { get; set; } - - public short MseState { get; set; } - - public int IdFeedRegulator { get; set; } - - public double? Mse { get; set; } - - public double? Pump0Flow { get; set; } - - public double? Pump1Flow { get; set; } - - public double? Pump2Flow { get; set; } -} diff --git a/DD.Persistence/Models/TimestampedSetDto.cs b/DD.Persistence/Models/TimestampedSetDto.cs index cf72032..20c5cbb 100644 --- a/DD.Persistence/Models/TimestampedSetDto.cs +++ b/DD.Persistence/Models/TimestampedSetDto.cs @@ -1,8 +1,17 @@ namespace DD.Persistence.Models; /// -/// набор данных с отметкой времени +/// Набор данных с отметкой времени /// -/// отметка времени -/// набор данных -public record TimestampedSetDto(DateTimeOffset Timestamp, IDictionary Set); +public class TimestampedSetDto +{ + /// + /// Временная отметка + /// + public DateTimeOffset Timestamp { get; set; } + + /// + /// Набор данных + /// + public required object[] Set { get; set; } +} diff --git a/DD.Persistence/Models/ITimeSeriesAbstractDto.cs b/DD.Persistence/ModelsAbstractions/ITimestampAbstractDto.cs similarity index 59% rename from DD.Persistence/Models/ITimeSeriesAbstractDto.cs rename to DD.Persistence/ModelsAbstractions/ITimestampAbstractDto.cs index b01c104..758e7c5 100644 --- a/DD.Persistence/Models/ITimeSeriesAbstractDto.cs +++ b/DD.Persistence/ModelsAbstractions/ITimestampAbstractDto.cs @@ -1,12 +1,12 @@ -namespace DD.Persistence.Models; +namespace DD.Persistence.ModelsAbstractions; /// /// Интерфейс, описывающий временные данные /// -public interface ITimeSeriesAbstractDto +public interface ITimestampAbstractDto { /// /// временная отметка /// - DateTimeOffset Date { get; set; } + DateTimeOffset Timestamp { get; set; } } diff --git a/DD.Persistence/Models/IWithSectionPart.cs b/DD.Persistence/ModelsAbstractions/IWithSectionPart.cs similarity index 77% rename from DD.Persistence/Models/IWithSectionPart.cs rename to DD.Persistence/ModelsAbstractions/IWithSectionPart.cs index 8b3fbaf..0d3ff1f 100644 --- a/DD.Persistence/Models/IWithSectionPart.cs +++ b/DD.Persistence/ModelsAbstractions/IWithSectionPart.cs @@ -1,4 +1,4 @@ -namespace DD.Persistence.Models; +namespace DD.Persistence.ModelsAbstractions; public interface IWithSectionPart { public double DepthStart { get; set; } diff --git a/DD.Persistence/Repositories/IChangeLogRepository.cs b/DD.Persistence/Repositories/IChangeLogRepository.cs index 41dd379..6c39e24 100644 --- a/DD.Persistence/Repositories/IChangeLogRepository.cs +++ b/DD.Persistence/Repositories/IChangeLogRepository.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using DD.Persistence.Models.Requests; namespace DD.Persistence.Repositories; diff --git a/DD.Persistence/Repositories/IParameterRepository.cs b/DD.Persistence/Repositories/IParameterRepository.cs index 53c48c3..7e8bbd2 100644 --- a/DD.Persistence/Repositories/IParameterRepository.cs +++ b/DD.Persistence/Repositories/IParameterRepository.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repositories; public interface IParameterRepository diff --git a/DD.Persistence/Repositories/ISetpointRepository.cs b/DD.Persistence/Repositories/ISetpointRepository.cs index 0af805d..ecce8e0 100644 --- a/DD.Persistence/Repositories/ISetpointRepository.cs +++ b/DD.Persistence/Repositories/ISetpointRepository.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repositories; diff --git a/DD.Persistence/Repositories/ISyncRepository.cs b/DD.Persistence/Repositories/ISyncRepository.cs index 10c21f2..9a43b01 100644 --- a/DD.Persistence/Repositories/ISyncRepository.cs +++ b/DD.Persistence/Repositories/ISyncRepository.cs @@ -1,4 +1,4 @@ -using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repositories; diff --git a/DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs b/DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs index e761c8a..82efb39 100644 --- a/DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs +++ b/DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs @@ -1,4 +1,4 @@ -using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repositories; diff --git a/DD.Persistence/Repositories/ITechMessagesRepository.cs b/DD.Persistence/Repositories/ITechMessagesRepository.cs index 9909106..6244485 100644 --- a/DD.Persistence/Repositories/ITechMessagesRepository.cs +++ b/DD.Persistence/Repositories/ITechMessagesRepository.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using DD.Persistence.Models.Requests; namespace DD.Persistence.Repositories diff --git a/DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs b/DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs index 0d5e531..5f472e0 100644 --- a/DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs +++ b/DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs @@ -1,10 +1,11 @@ -namespace DD.Persistence.Repositories; +using DD.Persistence.Models; + +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с прореженными данными /// -public interface ITimeSeriesBaseRepository - where TDto : class, new() +public interface ITimeSeriesBaseRepository { /// /// Получить список объектов с прореживанием @@ -12,7 +13,7 @@ public interface ITimeSeriesBaseRepository /// дата начала /// /// - Task> GetResampledData( + Task> GetResampledData( DateTimeOffset dateBegin, double intervalSec = 600d, int approxPointsCount = 1024, diff --git a/DD.Persistence/Repositories/ITimestampedSetRepository.cs b/DD.Persistence/Repositories/ITimestampedSetRepository.cs index cefbb3e..c448744 100644 --- a/DD.Persistence/Repositories/ITimestampedSetRepository.cs +++ b/DD.Persistence/Repositories/ITimestampedSetRepository.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Repositories; diff --git a/DD.Persistence/Repositories/ITimeSeriesDataRepository.cs b/DD.Persistence/Repositories/ITimestampedValuesRepository.cs similarity index 59% rename from DD.Persistence/Repositories/ITimeSeriesDataRepository.cs rename to DD.Persistence/Repositories/ITimestampedValuesRepository.cs index ed05980..447d197 100644 --- a/DD.Persistence/Repositories/ITimeSeriesDataRepository.cs +++ b/DD.Persistence/Repositories/ITimestampedValuesRepository.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.ModelsAbstractions; namespace DD.Persistence.Repositories; @@ -6,8 +7,8 @@ namespace DD.Persistence.Repositories; /// Интерфейс по работе с временными данными /// /// -public interface ITimeSeriesDataRepository : ISyncRepository, ITimeSeriesBaseRepository - where TDto : class, ITimeSeriesAbstractDto, new() +public interface ITimestampedValuesRepository : ISyncRepository, ITimeSeriesBaseRepository + where TDto : class, ITimestampAbstractDto, new() { /// /// Добавление записей @@ -15,5 +16,5 @@ public interface ITimeSeriesDataRepository : ISyncRepository, ITimeS /// /// /// - Task AddRange(IEnumerable dtos, CancellationToken token); + Task AddRange(IEnumerable dtos, CancellationToken token); } diff --git a/DD.Persistence/Services/Interfaces/IWitsDataService.cs b/DD.Persistence/Services/Interfaces/IWitsDataService.cs index 3a18da9..bb3e7d5 100644 --- a/DD.Persistence/Services/Interfaces/IWitsDataService.cs +++ b/DD.Persistence/Services/Interfaces/IWitsDataService.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; namespace DD.Persistence.Services.Interfaces; diff --git a/DD.Persistence/Services/WitsDataService.cs b/DD.Persistence/Services/WitsDataService.cs index bcee812..6c6f0ee 100644 --- a/DD.Persistence/Services/WitsDataService.cs +++ b/DD.Persistence/Services/WitsDataService.cs @@ -1,4 +1,5 @@ using DD.Persistence.Models; +using DD.Persistence.Models.Common; using DD.Persistence.Models.Configurations; using DD.Persistence.Models.Enumerations; using DD.Persistence.Repositories;