diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..73261a0 --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,38 @@ +name: Unit tests +run-name: ${{ gitea.actor }} is testing +on: push + +jobs: + test: + runs-on: ubuntu-latest + container: node + + # Service containers to run with `runner-job` + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres + # Provide the password for postgres + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5442:5432 + + steps: + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Check out repository code + uses: actions/checkout@v4 + - name: Run integration tests + run: dotnet test DD.Persistence.IntegrationTests diff --git a/Persistence.API/Controllers/ChangeLogController.cs b/DD.Persistence.API/Controllers/ChangeLogController.cs similarity index 97% rename from Persistence.API/Controllers/ChangeLogController.cs rename to DD.Persistence.API/Controllers/ChangeLogController.cs index 72f0b08..21761e1 100644 --- a/Persistence.API/Controllers/ChangeLogController.cs +++ b/DD.Persistence.API/Controllers/ChangeLogController.cs @@ -1,11 +1,11 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Models.Requests; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; +using DD.Persistence.Repositories; using System.Net; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; [ApiController] [Authorize] diff --git a/Persistence.API/Controllers/DataSaubController.cs b/DD.Persistence.API/Controllers/DataSaubController.cs similarity index 80% rename from Persistence.API/Controllers/DataSaubController.cs rename to DD.Persistence.API/Controllers/DataSaubController.cs index 715b1ef..832faec 100644 --- a/Persistence.API/Controllers/DataSaubController.cs +++ b/DD.Persistence.API/Controllers/DataSaubController.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; /// /// Работа с временными данными diff --git a/Persistence.API/Controllers/DataSourceSystemController.cs b/DD.Persistence.API/Controllers/DataSourceSystemController.cs similarity index 92% rename from Persistence.API/Controllers/DataSourceSystemController.cs rename to DD.Persistence.API/Controllers/DataSourceSystemController.cs index 599c11e..896af1f 100644 --- a/Persistence.API/Controllers/DataSourceSystemController.cs +++ b/DD.Persistence.API/Controllers/DataSourceSystemController.cs @@ -1,10 +1,10 @@ using System.Net; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; /// /// Работа с системами diff --git a/Persistence.API/Controllers/SetpointController.cs b/DD.Persistence.API/Controllers/SetpointController.cs similarity index 97% rename from Persistence.API/Controllers/SetpointController.cs rename to DD.Persistence.API/Controllers/SetpointController.cs index 0ff6878..e3b8b14 100644 --- a/Persistence.API/Controllers/SetpointController.cs +++ b/DD.Persistence.API/Controllers/SetpointController.cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Repositories; using System.Net; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; /// /// Работа с уставками diff --git a/Persistence.API/Controllers/TechMessagesController.cs b/DD.Persistence.API/Controllers/TechMessagesController.cs similarity index 96% rename from Persistence.API/Controllers/TechMessagesController.cs rename to DD.Persistence.API/Controllers/TechMessagesController.cs index 50481a0..81663e0 100644 --- a/Persistence.API/Controllers/TechMessagesController.cs +++ b/DD.Persistence.API/Controllers/TechMessagesController.cs @@ -1,11 +1,11 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Models.Requests; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; +using DD.Persistence.Repositories; using System.Net; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; /// /// Работа с технологическими сообщениями систем автобурения (АБ) diff --git a/Persistence.API/Controllers/TimeSeriesController.cs b/DD.Persistence.API/Controllers/TimeSeriesController.cs similarity index 96% rename from Persistence.API/Controllers/TimeSeriesController.cs rename to DD.Persistence.API/Controllers/TimeSeriesController.cs index f13c641..5fded36 100644 --- a/Persistence.API/Controllers/TimeSeriesController.cs +++ b/DD.Persistence.API/Controllers/TimeSeriesController.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; [ApiController] [Authorize] diff --git a/Persistence.API/Controllers/TimestampedSetController.cs b/DD.Persistence.API/Controllers/TimestampedSetController.cs similarity index 97% rename from Persistence.API/Controllers/TimestampedSetController.cs rename to DD.Persistence.API/Controllers/TimestampedSetController.cs index 4687e72..0c805ab 100644 --- a/Persistence.API/Controllers/TimestampedSetController.cs +++ b/DD.Persistence.API/Controllers/TimestampedSetController.cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Models; +using DD.Persistence.Repositories; using System.Net; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; /// /// Хранение наборов данных с отметкой времени. diff --git a/Persistence.API/Controllers/WitsDataController.cs b/DD.Persistence.API/Controllers/WitsDataController.cs similarity index 96% rename from Persistence.API/Controllers/WitsDataController.cs rename to DD.Persistence.API/Controllers/WitsDataController.cs index 9e855b7..5df6c3f 100644 --- a/Persistence.API/Controllers/WitsDataController.cs +++ b/DD.Persistence.API/Controllers/WitsDataController.cs @@ -1,10 +1,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Services.Interfaces; +using DD.Persistence.Models; +using DD.Persistence.Services.Interfaces; using System.Net; -namespace Persistence.API.Controllers; +namespace DD.Persistence.API.Controllers; /// /// Работа с параметрами Wits diff --git a/Persistence.API/Persistence.API.csproj b/DD.Persistence.API/DD.Persistence.API.csproj similarity index 61% rename from Persistence.API/Persistence.API.csproj rename to DD.Persistence.API/DD.Persistence.API.csproj index fa3b7ad..5f4159b 100644 --- a/Persistence.API/Persistence.API.csproj +++ b/DD.Persistence.API/DD.Persistence.API.csproj @@ -1,17 +1,18 @@ - + net8.0 enable enable Linux - True - $(NoWarn);1591 + true + $(NoWarn);1591 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) + Library @@ -22,9 +23,10 @@ - - - + + + + diff --git a/Persistence.API/DependencyInjection.cs b/DD.Persistence.API/DependencyInjection.cs similarity index 88% rename from Persistence.API/DependencyInjection.cs rename to DD.Persistence.API/DependencyInjection.cs index d2960af..b0a71d5 100644 --- a/Persistence.API/DependencyInjection.cs +++ b/DD.Persistence.API/DependencyInjection.cs @@ -3,25 +3,25 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; -using Persistence.Database.Entity; -using Persistence.Models; -using Persistence.Models.Configurations; -using Persistence.Services; -using Persistence.Services.Interfaces; +using DD.Persistence.Models; +using DD.Persistence.Models.Configurations; +using DD.Persistence.Services; +using DD.Persistence.Services.Interfaces; using Swashbuckle.AspNetCore.SwaggerGen; using System.Reflection; using System.Text.Json.Nodes; +using DD.Persistence.Database.Entity; -namespace Persistence.API; +namespace DD.Persistence.API; public static class DependencyInjection { - public static void MapsterSetup() - { - TypeAdapterConfig.GlobalSettings.Default.Config - .ForType() - .Ignore(dest => dest.System, dest => dest.SystemId); - } + //public static void MapsterSetup() + //{ + // TypeAdapterConfig.GlobalSettings.Default.Config + // .ForType() + // .Ignore(dest => dest.System, dest => dest.SystemId); + //} public static void AddSwagger(this IServiceCollection services, IConfiguration configuration) { services.AddSwaggerGen(c => @@ -74,15 +74,16 @@ public static class DependencyInjection private static void AddKeyCloakAuthentication(this IServiceCollection services, IConfiguration configuration) { + var keyCloakHost = configuration["KeyCloakAuthentication:Host"]; services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) .AddJwtBearer(options => { options.RequireHttpsMetadata = false; - options.Audience = configuration["Authentication:Audience"]; - options.MetadataAddress = configuration["Authentication:MetadataAddress"]!; + options.Audience = configuration["KeyCloakAuthentication:Audience"]; + options.MetadataAddress = $"{keyCloakHost}/.well-known/openid-configuration"; options.TokenValidationParameters = new TokenValidationParameters { - ValidIssuer = configuration["Authentication:ValidIssuer"], + ValidIssuer = keyCloakHost }; }); } @@ -143,6 +144,8 @@ public static class DependencyInjection #region Keycloak private static void AddKeycloakSecurity(this SwaggerGenOptions options, IConfiguration configuration) { + var keyCloakHost = configuration["KeyCloakAuthentication:Host"]; + options.AddSecurityDefinition("Keycloak", new OpenApiSecurityScheme { Description = @"JWT Authorization header using the Bearer scheme. Enter 'Bearer' [space] and then your token in the text input below. Example: 'Bearer 12345token'", @@ -153,7 +156,7 @@ public static class DependencyInjection { Implicit = new OpenApiOAuthFlow { - AuthorizationUrl = new Uri(configuration["Authentication:AuthorizationUrl"]!), + AuthorizationUrl = new Uri($"{keyCloakHost}/protocol/openid-connect/auth"), } } }); diff --git a/Persistence.API/Extensions.cs b/DD.Persistence.API/Extensions.cs similarity index 95% rename from Persistence.API/Extensions.cs rename to DD.Persistence.API/Extensions.cs index 5fa9fd4..a1e070a 100644 --- a/Persistence.API/Extensions.cs +++ b/DD.Persistence.API/Extensions.cs @@ -1,7 +1,7 @@ using System.ComponentModel; using System.Security.Claims; -namespace Persistence.API; +namespace DD.Persistence.API; public static class Extensions { diff --git a/Persistence.API/Properties/launchSettings.json b/DD.Persistence.API/Properties/launchSettings.json similarity index 100% rename from Persistence.API/Properties/launchSettings.json rename to DD.Persistence.API/Properties/launchSettings.json diff --git a/Persistence.API/Startup.cs b/DD.Persistence.API/Startup.cs similarity index 89% rename from Persistence.API/Startup.cs rename to DD.Persistence.API/Startup.cs index 2b522bd..c6c44a4 100644 --- a/Persistence.API/Startup.cs +++ b/DD.Persistence.API/Startup.cs @@ -1,8 +1,8 @@ -using Persistence.Database.Model; -using Persistence.Database.Postgres; -using Persistence.Repository; +using DD.Persistence.Database.Model; +using DD.Persistence.Database.Postgres; +using DD.Persistence.Repository; -namespace Persistence.API; +namespace DD.Persistence.API; public class Startup { @@ -27,7 +27,7 @@ public class Startup services.AddMemoryCache(); services.AddServices(); - DependencyInjection.MapsterSetup(); + //DependencyInjection.MapsterSetup(); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) diff --git a/DD.Persistence.App/.config/dotnet-tools.json b/DD.Persistence.App/.config/dotnet-tools.json new file mode 100644 index 0000000..b0e38ab --- /dev/null +++ b/DD.Persistence.App/.config/dotnet-tools.json @@ -0,0 +1,5 @@ +{ + "version": 1, + "isRoot": true, + "tools": {} +} \ No newline at end of file diff --git a/DD.Persistence.App/DD.Persistence.App.csproj b/DD.Persistence.App/DD.Persistence.App.csproj new file mode 100644 index 0000000..3985241 --- /dev/null +++ b/DD.Persistence.App/DD.Persistence.App.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + 8dcdcfed-c959-4eef-9891-ae60b1b136ea + Linux + + + + <_WebToolingArtifacts Remove="Properties\PublishProfiles\LinuxRelease.pubxml" /> + <_WebToolingArtifacts Remove="Properties\PublishProfiles\WindowsRelease.pubxml" /> + + + + + + + + + + + + + diff --git a/Persistence.API/Dockerfile b/DD.Persistence.App/Dockerfile similarity index 52% rename from Persistence.API/Dockerfile rename to DD.Persistence.App/Dockerfile index bb9a0d6..015ce03 100644 --- a/Persistence.API/Dockerfile +++ b/DD.Persistence.App/Dockerfile @@ -4,21 +4,22 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER app WORKDIR /app EXPOSE 8080 +EXPOSE 8081 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build ARG BUILD_CONFIGURATION=Release WORKDIR /src -COPY ["Persistence.API/Persistence.API.csproj", "Persistence.API/"] -RUN dotnet restore "./Persistence.API/Persistence.API.csproj" +COPY ["DD.Persistence.App/DD.Persistence.App.csproj", "DD.Persistence.App/"] +RUN dotnet restore "./DD.Persistence.App/DD.Persistence.App.csproj" COPY . . -WORKDIR "/src/Persistence.API" -RUN dotnet build "./Persistence.API.csproj" -c $BUILD_CONFIGURATION -o /app/build +WORKDIR "/src/DD.Persistence.App" +RUN dotnet build "./DD.Persistence.App.csproj" -c $BUILD_CONFIGURATION -o /app/build FROM build AS publish ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "./Persistence.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false +RUN dotnet publish "./DD.Persistence.App.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM base AS final WORKDIR /app COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "Persistence.API.dll"] \ No newline at end of file +ENTRYPOINT ["dotnet", "DD.Persistence.App.dll"] \ No newline at end of file diff --git a/Persistence.API/Program.cs b/DD.Persistence.App/Program.cs similarity index 67% rename from Persistence.API/Program.cs rename to DD.Persistence.App/Program.cs index bb6e9a7..4a02472 100644 --- a/Persistence.API/Program.cs +++ b/DD.Persistence.App/Program.cs @@ -1,10 +1,15 @@ -namespace Persistence.API; + +using DD.Persistence.API; +using System.Globalization; + +namespace DD.Persistence.App; public class Program { public static void Main(string[] args) { - + CultureInfo uiCulture = CultureInfo.CurrentUICulture; + CultureInfo.CurrentUICulture = new CultureInfo("en-EN"); var host = CreateHostBuilder(args).Build(); Startup.BeforeRunHandler(host); host.Run(); diff --git a/DD.Persistence.App/Properties/PublishProfiles/LinuxRelease.pubxml b/DD.Persistence.App/Properties/PublishProfiles/LinuxRelease.pubxml new file mode 100644 index 0000000..0b476ba --- /dev/null +++ b/DD.Persistence.App/Properties/PublishProfiles/LinuxRelease.pubxml @@ -0,0 +1,22 @@ + + + + + true + false + true + Release + Any CPU + FileSystem + bin\Release\net8.0\publish\ + FileSystem + <_TargetId>Folder + + net8.0 + linux-x64 + 063238bf-e982-43fa-9ddb-7d7d279086d8 + true + + \ No newline at end of file diff --git a/DD.Persistence.App/Properties/PublishProfiles/WindowsRelease.pubxml b/DD.Persistence.App/Properties/PublishProfiles/WindowsRelease.pubxml new file mode 100644 index 0000000..139caca --- /dev/null +++ b/DD.Persistence.App/Properties/PublishProfiles/WindowsRelease.pubxml @@ -0,0 +1,22 @@ + + + + + true + false + true + Release + Any CPU + FileSystem + bin\Release\net8.0\publish\ + FileSystem + <_TargetId>Folder + + net8.0 + win-x64 + 063238bf-e982-43fa-9ddb-7d7d279086d8 + false + + \ No newline at end of file diff --git a/DD.Persistence.App/Properties/launchSettings.json b/DD.Persistence.App/Properties/launchSettings.json new file mode 100644 index 0000000..bc27d22 --- /dev/null +++ b/DD.Persistence.App/Properties/launchSettings.json @@ -0,0 +1,52 @@ +{ + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "http://localhost:5266" + }, + "https": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true, + "applicationUrl": "https://localhost:7154;http://localhost:5266" + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Container (Dockerfile)": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "environmentVariables": { + "ASPNETCORE_HTTPS_PORTS": "8081", + "ASPNETCORE_HTTP_PORTS": "8080" + }, + "publishAllPorts": true, + "useSSL": true + } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:54958", + "sslPort": 44352 + } + } +} \ No newline at end of file diff --git a/DD.Persistence.App/Readme.md b/DD.Persistence.App/Readme.md new file mode 100644 index 0000000..f0e7d34 --- /dev/null +++ b/DD.Persistence.App/Readme.md @@ -0,0 +1,29 @@ +# DD.Persistence.App Readme +## Краткое описание DD.Persistence.App сервиса +DD.Persistence.App - проект исполняемого файла микросервиса + +## Настройка DD.Persistence.App (файл appsettings.json) +- `appsettings.json` - файл с настройками проекта. + +### Подключение к БД +- Настройки подключения к базе хранятся в свойстве `DefaultConnection` секции `ConnectionStrings` +файла `appsettings.json`, где: + - Host - название или ip хоста; + - Database - название базы данных; + - Username - пользователь базы данных; + - Password - пароль базы данных; +- Больше информации о настройке подключения к postgreSQL можно прочесть по [ссылке](https://www.npgsql.org/doc/connection-string-parameters.html) + +### Авторизация +1. В проекте предусмотрены 2 типа авторизации: +- Авторизация через KeyCloak. Используется в продакшен версии. +- Авторизация через Jwt-токен. Используется для разработки и тестирования. +2. Для включения авторизации через KeyCloak необходимо: +- Установить секцию `NeedUseKeyCloak` файла `appsettings.json` в `true` +- По необходимости настроить свойства секции `Authentication` файла `appsettings.json` + +### defaultsettings.json +Копия файла `appsettings.json` хранится в файле `defaultsettings.json` + + + diff --git a/Persistence.API/appsettings.Development.json b/DD.Persistence.App/appsettings.Development.json similarity index 100% rename from Persistence.API/appsettings.Development.json rename to DD.Persistence.App/appsettings.Development.json diff --git a/DD.Persistence.App/appsettings.Tests.json b/DD.Persistence.App/appsettings.Tests.json new file mode 100644 index 0000000..72c43d3 --- /dev/null +++ b/DD.Persistence.App/appsettings.Tests.json @@ -0,0 +1,17 @@ +{ + "DbConnection": { + "Host": "postgres", + "Port": 5432, + "Database": "persistence", + "Username": "postgres", + "Password": "postgres" + }, + "NeedUseKeyCloak": false, + "AuthUser": { + "username": "myuser", + "password": 12345, + "clientId": "webapi", + "grantType": "password" + }, + "KeycloakGetTokenUrl": "http://192.168.0.10:8321/realms/Persistence/protocol/openid-connect/token" +} diff --git a/DD.Persistence.App/appsettings.json b/DD.Persistence.App/appsettings.json new file mode 100644 index 0000000..4e263b2 --- /dev/null +++ b/DD.Persistence.App/appsettings.json @@ -0,0 +1,24 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "ConnectionStrings": { + "DefaultConnection": "Host=localhost;Port=5432;Database=persistence;Username=postgres;Password=postgres;Persist Security Info=True" + }, + "AllowedHosts": "*", + "NeedUseKeyCloak": false, + "KeyCloakAuthentication": { + "Audience": "account", + "Host": "http://192.168.0.10:8321/realms/Persistence" + }, + "AuthUser": { + "username": "myuser", + "password": 12345, + "clientId": "webapi", + "grantType": "password", + "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "7d9f3574-6574-4ca3-845a-0276eb4aa8f6" + } +} diff --git a/DD.Persistence.App/defaultsettings.Development.json b/DD.Persistence.App/defaultsettings.Development.json new file mode 100644 index 0000000..896c0b7 --- /dev/null +++ b/DD.Persistence.App/defaultsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "NeedUseKeyCloak": false +} diff --git a/Persistence.API/appsettings.Tests.json b/DD.Persistence.App/defaultsettings.Tests.json similarity index 100% rename from Persistence.API/appsettings.Tests.json rename to DD.Persistence.App/defaultsettings.Tests.json diff --git a/Persistence.API/appsettings.json b/DD.Persistence.App/defaultsettings.json similarity index 100% rename from Persistence.API/appsettings.json rename to DD.Persistence.App/defaultsettings.json diff --git a/Persistence.Client/Clients/Base/BaseClient.cs b/DD.Persistence.Client/Clients/Base/BaseClient.cs similarity index 91% rename from Persistence.Client/Clients/Base/BaseClient.cs rename to DD.Persistence.Client/Clients/Base/BaseClient.cs index c29cf14..3b13cdb 100644 --- a/Persistence.Client/Clients/Base/BaseClient.cs +++ b/DD.Persistence.Client/Clients/Base/BaseClient.cs @@ -1,8 +1,8 @@ -using Microsoft.Extensions.Logging; -using Persistence.Client.Helpers; +using DD.Persistence.Client.Helpers; +using Microsoft.Extensions.Logging; using Refit; -namespace Persistence.Client.Clients.Base; +namespace DD.Persistence.Client.Clients.Base; public abstract class BaseClient { private readonly ILogger logger; diff --git a/Persistence.Client/Clients/ChangeLogClient.cs b/DD.Persistence.Client/Clients/ChangeLogClient.cs similarity index 94% rename from Persistence.Client/Clients/ChangeLogClient.cs rename to DD.Persistence.Client/Clients/ChangeLogClient.cs index 78c71a7..e10008e 100644 --- a/Persistence.Client/Clients/ChangeLogClient.cs +++ b/DD.Persistence.Client/Clients/ChangeLogClient.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Client.Clients.Base; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class ChangeLogClient : BaseClient, IChangeLogClient { private readonly Interfaces.Refit.IRefitChangeLogClient refitChangeLogClient; diff --git a/Persistence.Client/Clients/DataSourceSystemClient.cs b/DD.Persistence.Client/Clients/DataSourceSystemClient.cs similarity index 81% rename from Persistence.Client/Clients/DataSourceSystemClient.cs rename to DD.Persistence.Client/Clients/DataSourceSystemClient.cs index 25ec605..45e2d29 100644 --- a/Persistence.Client/Clients/DataSourceSystemClient.cs +++ b/DD.Persistence.Client/Clients/DataSourceSystemClient.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients.Interfaces.Refit; -using Persistence.Models; +using DD.Persistence.Client.Clients.Base; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Models; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class DataSourceSystemClient : BaseClient, IDataSourceSystemClient { private readonly IRefitDataSourceSystemClient dataSourceSystemClient; diff --git a/Persistence.Client/Clients/Interfaces/IChangeLogClient.cs b/DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs similarity index 96% rename from Persistence.Client/Clients/Interfaces/IChangeLogClient.cs rename to DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs index 0d24585..19edeab 100644 --- a/Persistence.Client/Clients/Interfaces/IChangeLogClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/IChangeLogClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с записями ChangeLog diff --git a/Persistence.Client/Clients/Interfaces/IDataSourceSystemClient.cs b/DD.Persistence.Client/Clients/Interfaces/IDataSourceSystemClient.cs similarity index 87% rename from Persistence.Client/Clients/Interfaces/IDataSourceSystemClient.cs rename to DD.Persistence.Client/Clients/Interfaces/IDataSourceSystemClient.cs index fc25412..618cef6 100644 --- a/Persistence.Client/Clients/Interfaces/IDataSourceSystemClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/IDataSourceSystemClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с системами diff --git a/Persistence.Client/Clients/Interfaces/ISetpointClient.cs b/DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs similarity index 96% rename from Persistence.Client/Clients/Interfaces/ISetpointClient.cs rename to DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs index 295ab87..86462ea 100644 --- a/Persistence.Client/Clients/Interfaces/ISetpointClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ISetpointClient.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с уставками diff --git a/Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs b/DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs similarity index 94% rename from Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs rename to DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs index 5545dad..a27e553 100644 --- a/Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ITechMessagesClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с технологическими сообщениями diff --git a/Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs b/DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs similarity index 95% rename from Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs rename to DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs index 316c0c9..26bbfa6 100644 --- a/Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ITimeSeriesClient.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с временными данными diff --git a/Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs b/DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs similarity index 96% rename from Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs rename to DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs index 21fd222..be98a77 100644 --- a/Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/ITimestampedSetClient.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с репозиторием для хранения разных наборов данных рядов. diff --git a/Persistence.Client/Clients/Interfaces/IWitsDataClient.cs b/DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs similarity index 95% rename from Persistence.Client/Clients/Interfaces/IWitsDataClient.cs rename to DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs index e0fee60..e954484 100644 --- a/Persistence.Client/Clients/Interfaces/IWitsDataClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/IWitsDataClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces; +namespace DD.Persistence.Client.Clients.Interfaces; /// /// Клиент для работы с параметрами Wits diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs similarity index 93% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs index c7a7bc1..958e24e 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitChangeLogClient.cs @@ -1,8 +1,8 @@ -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit; +namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitChangeLogClient : IDisposable { diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitDataSourceSystemClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitDataSourceSystemClient.cs similarity index 80% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitDataSourceSystemClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitDataSourceSystemClient.cs index ba20504..a4b47eb 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitDataSourceSystemClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitDataSourceSystemClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit; +namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitDataSourceSystemClient : IDisposable { private const string BaseRoute = "/api/dataSourceSystem"; diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs similarity index 92% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs index 69a2719..b6e021a 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitSetpointClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit; +namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitSetpointClient : IDisposable { diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs similarity index 90% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs index 3e4cd10..2638600 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTechMessagesClient.cs @@ -1,9 +1,9 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit +namespace DD.Persistence.Client.Clients.Interfaces.Refit { public interface IRefitTechMessagesClient : IDisposable { diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs similarity index 89% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs index 79135e1..2edc8fe 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimeSeriesClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit; +namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitTimeSeriesClient : IDisposable where TDto : class, new() { diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs similarity index 91% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs index 8caeb61..14db284 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitTimestampedSetClient.cs @@ -1,7 +1,7 @@ -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit; +namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitTimestampedSetClient : IDisposable { diff --git a/Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs similarity index 91% rename from Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs rename to DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs index c22f919..57bff6f 100644 --- a/Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs +++ b/DD.Persistence.Client/Clients/Interfaces/Refit/IRefitWitsDataClient.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; +using DD.Persistence.Models; using Refit; -namespace Persistence.Client.Clients.Interfaces.Refit; +namespace DD.Persistence.Client.Clients.Interfaces.Refit; public interface IRefitWitsDataClient : IDisposable { private const string BaseRoute = "/api/witsData"; diff --git a/Persistence.Client/Clients/SetpointClient.cs b/DD.Persistence.Client/Clients/SetpointClient.cs similarity index 90% rename from Persistence.Client/Clients/SetpointClient.cs rename to DD.Persistence.Client/Clients/SetpointClient.cs index ea6d767..4a990c5 100644 --- a/Persistence.Client/Clients/SetpointClient.cs +++ b/DD.Persistence.Client/Clients/SetpointClient.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients.Interfaces.Refit; -using Persistence.Models; +using DD.Persistence.Client.Clients.Base; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Models; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class SetpointClient : BaseClient, ISetpointClient { diff --git a/Persistence.Client/Clients/TechMessagesClient.cs b/DD.Persistence.Client/Clients/TechMessagesClient.cs similarity index 89% rename from Persistence.Client/Clients/TechMessagesClient.cs rename to DD.Persistence.Client/Clients/TechMessagesClient.cs index f69c110..c981569 100644 --- a/Persistence.Client/Clients/TechMessagesClient.cs +++ b/DD.Persistence.Client/Clients/TechMessagesClient.cs @@ -1,11 +1,11 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients.Interfaces.Refit; -using Persistence.Models; -using Persistence.Models.Requests; +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.Requests; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class TechMessagesClient : BaseClient, ITechMessagesClient { diff --git a/Persistence.Client/Clients/TimeSeriesClient.cs b/DD.Persistence.Client/Clients/TimeSeriesClient.cs similarity index 87% rename from Persistence.Client/Clients/TimeSeriesClient.cs rename to DD.Persistence.Client/Clients/TimeSeriesClient.cs index 72b8ed8..2c15938 100644 --- a/Persistence.Client/Clients/TimeSeriesClient.cs +++ b/DD.Persistence.Client/Clients/TimeSeriesClient.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients.Interfaces.Refit; -using Persistence.Models; +using DD.Persistence.Client.Clients.Base; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Models; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class TimeSeriesClient : BaseClient, ITimeSeriesClient where TDto : class, new() { private readonly IRefitTimeSeriesClient timeSeriesClient; diff --git a/Persistence.Client/Clients/TimestampedSetClient.cs b/DD.Persistence.Client/Clients/TimestampedSetClient.cs similarity index 90% rename from Persistence.Client/Clients/TimestampedSetClient.cs rename to DD.Persistence.Client/Clients/TimestampedSetClient.cs index 3009488..38828b6 100644 --- a/Persistence.Client/Clients/TimestampedSetClient.cs +++ b/DD.Persistence.Client/Clients/TimestampedSetClient.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients.Interfaces.Refit; -using Persistence.Models; +using DD.Persistence.Client.Clients.Base; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Models; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class TimestampedSetClient : BaseClient, ITimestampedSetClient { private readonly IRefitTimestampedSetClient refitTimestampedSetClient; diff --git a/Persistence.Client/Clients/WitsDataClient.cs b/DD.Persistence.Client/Clients/WitsDataClient.cs similarity index 88% rename from Persistence.Client/Clients/WitsDataClient.cs rename to DD.Persistence.Client/Clients/WitsDataClient.cs index 73e5873..3251194 100644 --- a/Persistence.Client/Clients/WitsDataClient.cs +++ b/DD.Persistence.Client/Clients/WitsDataClient.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.Logging; -using Persistence.Client.Clients.Base; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients.Interfaces.Refit; -using Persistence.Models; +using DD.Persistence.Client.Clients.Base; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Models; -namespace Persistence.Client.Clients; +namespace DD.Persistence.Client.Clients; public class WitsDataClient : BaseClient, IWitsDataClient { private readonly IRefitWitsDataClient refitWitsDataClient; diff --git a/Persistence.Client/CustomExceptions/AcceptableException.cs b/DD.Persistence.Client/CustomExceptions/AcceptableException.cs similarity index 77% rename from Persistence.Client/CustomExceptions/AcceptableException.cs rename to DD.Persistence.Client/CustomExceptions/AcceptableException.cs index 0bdea54..f9c2186 100644 --- a/Persistence.Client/CustomExceptions/AcceptableException.cs +++ b/DD.Persistence.Client/CustomExceptions/AcceptableException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Not Acceptable (406) diff --git a/Persistence.Client/CustomExceptions/BadGatewayException.cs b/DD.Persistence.Client/CustomExceptions/BadGatewayException.cs similarity index 76% rename from Persistence.Client/CustomExceptions/BadGatewayException.cs rename to DD.Persistence.Client/CustomExceptions/BadGatewayException.cs index 2730140..b299d85 100644 --- a/Persistence.Client/CustomExceptions/BadGatewayException.cs +++ b/DD.Persistence.Client/CustomExceptions/BadGatewayException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Bad gateway (502) diff --git a/Persistence.Client/CustomExceptions/ForbiddenException.cs b/DD.Persistence.Client/CustomExceptions/ForbiddenException.cs similarity index 76% rename from Persistence.Client/CustomExceptions/ForbiddenException.cs rename to DD.Persistence.Client/CustomExceptions/ForbiddenException.cs index bfd9e7d..faa6c76 100644 --- a/Persistence.Client/CustomExceptions/ForbiddenException.cs +++ b/DD.Persistence.Client/CustomExceptions/ForbiddenException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Forbidden (403) diff --git a/Persistence.Client/CustomExceptions/InternalServerException.cs b/DD.Persistence.Client/CustomExceptions/InternalServerException.cs similarity index 78% rename from Persistence.Client/CustomExceptions/InternalServerException.cs rename to DD.Persistence.Client/CustomExceptions/InternalServerException.cs index 6e8265b..85d45e8 100644 --- a/Persistence.Client/CustomExceptions/InternalServerException.cs +++ b/DD.Persistence.Client/CustomExceptions/InternalServerException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Internal Server Error (500) diff --git a/Persistence.Client/CustomExceptions/LockedException.cs b/DD.Persistence.Client/CustomExceptions/LockedException.cs similarity index 75% rename from Persistence.Client/CustomExceptions/LockedException.cs rename to DD.Persistence.Client/CustomExceptions/LockedException.cs index c24dca4..b798035 100644 --- a/Persistence.Client/CustomExceptions/LockedException.cs +++ b/DD.Persistence.Client/CustomExceptions/LockedException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Locked (423) diff --git a/Persistence.Client/CustomExceptions/ServiceUnavailableException.cs b/DD.Persistence.Client/CustomExceptions/ServiceUnavailableException.cs similarity index 79% rename from Persistence.Client/CustomExceptions/ServiceUnavailableException.cs rename to DD.Persistence.Client/CustomExceptions/ServiceUnavailableException.cs index 3929d42..79557ee 100644 --- a/Persistence.Client/CustomExceptions/ServiceUnavailableException.cs +++ b/DD.Persistence.Client/CustomExceptions/ServiceUnavailableException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Service Unavailable Error (503) diff --git a/Persistence.Client/CustomExceptions/TooManyRequestsException.cs b/DD.Persistence.Client/CustomExceptions/TooManyRequestsException.cs similarity index 78% rename from Persistence.Client/CustomExceptions/TooManyRequestsException.cs rename to DD.Persistence.Client/CustomExceptions/TooManyRequestsException.cs index d28f642..8ba6567 100644 --- a/Persistence.Client/CustomExceptions/TooManyRequestsException.cs +++ b/DD.Persistence.Client/CustomExceptions/TooManyRequestsException.cs @@ -1,4 +1,4 @@ -namespace Persistence.Client.CustomExceptions; +namespace DD.Persistence.Client.CustomExceptions; /// /// Too Many Requests (429) diff --git a/DD.Persistence.Client/DD.Persistence.Client.csproj b/DD.Persistence.Client/DD.Persistence.Client.csproj new file mode 100644 index 0000000..2943076 --- /dev/null +++ b/DD.Persistence.Client/DD.Persistence.Client.csproj @@ -0,0 +1,63 @@ + + + + net8.0 + enable + enable + true + + + True + + Persistence.Client + + 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) + + 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) + + Persistence.Client + + + Digital Drilling + + Digital Drilling + + Пакет для получения клиентов для работы с Persistence сервисом + + + https://git.ddrilling.ru/on.nemtina/persistence.git + + git + + true + + snupkg + + C:\Projects\Nuget + + + Readme.md + + + + 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) + 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) + + + + + + + + + + + + + + + + + + + diff --git a/Persistence.Client/Helpers/ApiTokenHelper.cs b/DD.Persistence.Client/Helpers/ApiTokenHelper.cs similarity index 97% rename from Persistence.Client/Helpers/ApiTokenHelper.cs rename to DD.Persistence.Client/Helpers/ApiTokenHelper.cs index a2f632e..9e62110 100644 --- a/Persistence.Client/Helpers/ApiTokenHelper.cs +++ b/DD.Persistence.Client/Helpers/ApiTokenHelper.cs @@ -1,13 +1,13 @@ using Microsoft.Extensions.Configuration; using Microsoft.IdentityModel.Tokens; -using Persistence.Models.Configurations; +using DD.Persistence.Models.Configurations; using RestSharp; using System.IdentityModel.Tokens.Jwt; using System.Net.Http.Headers; using System.Security.Claims; using System.Text.Json; -namespace Persistence.Client.Helpers; +namespace DD.Persistence.Client.Helpers; public static class ApiTokenHelper { public static void Authorize(this HttpClient httpClient, IConfiguration configuration) diff --git a/Persistence.Client/Helpers/ExceptionsHelper.cs b/DD.Persistence.Client/Helpers/ExceptionsHelper.cs similarity index 95% rename from Persistence.Client/Helpers/ExceptionsHelper.cs rename to DD.Persistence.Client/Helpers/ExceptionsHelper.cs index 0e3a31a..d4075a0 100644 --- a/Persistence.Client/Helpers/ExceptionsHelper.cs +++ b/DD.Persistence.Client/Helpers/ExceptionsHelper.cs @@ -1,8 +1,8 @@ -using System.ComponentModel.DataAnnotations; -using Persistence.Client.CustomExceptions; +using DD.Persistence.Client.CustomExceptions; using Refit; +using System.ComponentModel.DataAnnotations; -namespace Persistence.Client.Helpers; +namespace DD.Persistence.Client.Helpers; public static class ExceptionsHelper { private static readonly Dictionary ExceptionsDictionary = new Dictionary() @@ -30,6 +30,6 @@ public static class ExceptionsHelper var result = exception ?? new Exception("Неопознанная ошибка"); - return result; + return result; } } diff --git a/Persistence.Client/PersistenceClientFactory.cs b/DD.Persistence.Client/PersistenceClientFactory.cs similarity index 95% rename from Persistence.Client/PersistenceClientFactory.cs rename to DD.Persistence.Client/PersistenceClientFactory.cs index 4807367..ad7c817 100644 --- a/Persistence.Client/PersistenceClientFactory.cs +++ b/DD.Persistence.Client/PersistenceClientFactory.cs @@ -1,15 +1,15 @@ using Microsoft.Extensions.Configuration; -using Persistence.Client.Clients.Interfaces; -using Persistence.Client.Clients; -using Persistence.Client.Helpers; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client.Clients; +using DD.Persistence.Client.Helpers; using Refit; -using Persistence.Factories; -using Persistence.Client.Clients.Interfaces.Refit; +using DD.Persistence.Factories; +using DD.Persistence.Client.Clients.Interfaces.Refit; using Microsoft.Extensions.Logging; using Microsoft.Extensions.DependencyInjection; using System.Text.Json; -namespace Persistence.Client +namespace DD.Persistence.Client { /// /// Фабрика клиентов для доступа к Persistence - сервису diff --git a/Persistence.Client/Readme.md b/DD.Persistence.Client/Readme.md similarity index 94% rename from Persistence.Client/Readme.md rename to DD.Persistence.Client/Readme.md index f7c35f6..1e09e2f 100644 --- a/Persistence.Client/Readme.md +++ b/DD.Persistence.Client/Readme.md @@ -6,7 +6,7 @@ Persistence сервис отвечает за работу с хранимым ## Описание пакета Данный пакет предоставляет возможность взаимодействия с Persistence сервисом посредством обращения к конкретному -клиенту, ответсвенному за работу с одной из областей сервиса. +клиенту, ответственному за работу с одной из областей сервиса. ## Список предоставляемых клиентов - `ISetpointClient` - Клиент для работы с уставками @@ -31,7 +31,7 @@ Persistence сервисом посредством обращения к кон 4. Обратиться к фабрике Persistence - клиентов и получить требуемого клиента. ## xunit тестирование -При написании интеграционных тестов с ипользованием Persistence - клиентов +При написании интеграционных тестов с использованием Persistence - клиентов Http - клиент не обязан быть авторизован через передачу токена в `PersistenceClientFactory`. Для осуществления тестовой авторизации достаточно добавить в `appsettings.Tests.json` : ```json diff --git a/Persistence.Database.Postgres/Persistence.Database.Postgres.csproj b/DD.Persistence.Database.Postgres/DD.Persistence.Database.Postgres.csproj similarity index 87% rename from Persistence.Database.Postgres/Persistence.Database.Postgres.csproj rename to DD.Persistence.Database.Postgres/DD.Persistence.Database.Postgres.csproj index e383e91..e86ac4d 100644 --- a/Persistence.Database.Postgres/Persistence.Database.Postgres.csproj +++ b/DD.Persistence.Database.Postgres/DD.Persistence.Database.Postgres.csproj @@ -14,12 +14,12 @@ - - - - + + + + diff --git a/Persistence.Database.Postgres/DependencyInjection.cs b/DD.Persistence.Database.Postgres/DependencyInjection.cs similarity index 94% rename from Persistence.Database.Postgres/DependencyInjection.cs rename to DD.Persistence.Database.Postgres/DependencyInjection.cs index e775952..f0c8ff1 100644 --- a/Persistence.Database.Postgres/DependencyInjection.cs +++ b/DD.Persistence.Database.Postgres/DependencyInjection.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Persistence.Database.Model; +namespace DD.Persistence.Database.Model; public static class DependencyInjection { diff --git a/Persistence.Database.Postgres/DesignTimeDbContextFactory.cs b/DD.Persistence.Database.Postgres/DesignTimeDbContextFactory.cs similarity index 92% rename from Persistence.Database.Postgres/DesignTimeDbContextFactory.cs rename to DD.Persistence.Database.Postgres/DesignTimeDbContextFactory.cs index b4fbd85..639f0a9 100644 --- a/Persistence.Database.Postgres/DesignTimeDbContextFactory.cs +++ b/DD.Persistence.Database.Postgres/DesignTimeDbContextFactory.cs @@ -1,9 +1,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Npgsql; -using Persistence.Database.Model; +using DD.Persistence.Database.Model; -namespace Persistence.Database.Postgres; +namespace DD.Persistence.Database.Postgres; /// /// Фабрика контекста для dotnet ef миграций diff --git a/Persistence.Database.Postgres/EFExtensionsInitialization.cs b/DD.Persistence.Database.Postgres/EFExtensionsInitialization.cs similarity index 97% rename from Persistence.Database.Postgres/EFExtensionsInitialization.cs rename to DD.Persistence.Database.Postgres/EFExtensionsInitialization.cs index a876f7a..fe24f37 100644 --- a/Persistence.Database.Postgres/EFExtensionsInitialization.cs +++ b/DD.Persistence.Database.Postgres/EFExtensionsInitialization.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using System.Diagnostics; -namespace Persistence.Database.Postgres; +namespace DD.Persistence.Database.Postgres; public static class EFExtensionsInitialization { public static void EnsureCreatedAndMigrated(this DatabaseFacade db) diff --git a/Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs b/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.Designer.cs similarity index 89% rename from Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs rename to DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.Designer.cs index 0124f24..02a25ce 100644 --- a/Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.Designer.cs +++ b/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.Designer.cs @@ -1,54 +1,52 @@ // using System; +using DD.Persistence.Database.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Persistence.Database.Model; #nullable disable -namespace Persistence.Database.Postgres.Migrations.PersistencePostgres +namespace DD.Persistence.Database.Postgres.Migrations { [DbContext(typeof(PersistencePostgresContext))] - [Migration("20241212041758_TechMessageMigration")] - partial class TechMessageMigration + [Migration("20241220062251_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .UseCollation("Russian_Russia.1251") .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63); - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("Persistence.Database.Entity.DrillingSystem", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b => { b.Property("SystemId") .ValueGeneratedOnAdd() .HasColumnType("uuid") - .HasComment("Id системы автобурения"); + .HasComment("Id системы - источника данных"); b.Property("Description") .HasColumnType("text") - .HasComment("Описание системы автобурения"); + .HasComment("Описание системы - источника данных"); b.Property("Name") .IsRequired() .HasColumnType("varchar(256)") - .HasComment("Наименование системы автобурения"); + .HasComment("Наименование системы - источника данных"); b.HasKey("SystemId"); - b.ToTable("DrillingSystem"); + b.ToTable("DataSourceSystem"); }); - modelBuilder.Entity("Persistence.Database.Entity.ParameterData", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => { b.Property("DiscriminatorId") .HasColumnType("uuid") @@ -72,7 +70,7 @@ namespace Persistence.Database.Postgres.Migrations.PersistencePostgres b.ToTable("ParameterData"); }); - modelBuilder.Entity("Persistence.Database.Entity.TechMessage", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { b.Property("EventId") .ValueGeneratedOnAdd() @@ -107,7 +105,7 @@ namespace Persistence.Database.Postgres.Migrations.PersistencePostgres b.ToTable("TechMessage"); }); - modelBuilder.Entity("Persistence.Database.Entity.TimestampedSet", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b => { b.Property("IdDiscriminator") .HasColumnType("uuid") @@ -130,7 +128,7 @@ namespace Persistence.Database.Postgres.Migrations.PersistencePostgres }); }); - modelBuilder.Entity("Persistence.Database.Model.ChangeLog", b => + modelBuilder.Entity("DD.Persistence.Database.Model.ChangeLog", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -183,7 +181,7 @@ namespace Persistence.Database.Postgres.Migrations.PersistencePostgres b.ToTable("ChangeLog"); }); - modelBuilder.Entity("Persistence.Database.Model.DataSaub", b => + modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => { b.Property("Date") .HasColumnType("timestamp with time zone") @@ -266,7 +264,7 @@ namespace Persistence.Database.Postgres.Migrations.PersistencePostgres b.ToTable("DataSaub"); }); - modelBuilder.Entity("Persistence.Database.Model.Setpoint", b => + modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b => { b.Property("Key") .HasColumnType("uuid") @@ -290,9 +288,9 @@ namespace Persistence.Database.Postgres.Migrations.PersistencePostgres b.ToTable("Setpoint"); }); - modelBuilder.Entity("Persistence.Database.Entity.TechMessage", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { - b.HasOne("Persistence.Database.Entity.DrillingSystem", "System") + b.HasOne("DD.Persistence.Database.Entity.DataSourceSystem", "System") .WithMany() .HasForeignKey("SystemId") .OnDelete(DeleteBehavior.Cascade) diff --git a/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.cs b/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.cs new file mode 100644 index 0000000..03a8c43 --- /dev/null +++ b/DD.Persistence.Database.Postgres/Migrations/20241220062251_Init.cs @@ -0,0 +1,172 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace DD.Persistence.Database.Postgres.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ChangeLog", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false, comment: "Ключ записи"), + IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор таблицы"), + IdAuthor = table.Column(type: "uuid", nullable: false, comment: "Автор изменения"), + IdEditor = table.Column(type: "uuid", nullable: true, comment: "Редактор"), + Creation = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата создания записи"), + Obsolete = table.Column(type: "timestamp with time zone", nullable: true, comment: "Дата устаревания (например при удалении)"), + IdNext = table.Column(type: "uuid", nullable: true, comment: "Id заменяющей записи"), + DepthStart = table.Column(type: "double precision", nullable: false, comment: "Глубина забоя на дату начала интервала"), + DepthEnd = table.Column(type: "double precision", nullable: false, comment: "Глубина забоя на дату окончания интервала"), + IdSection = table.Column(type: "uuid", nullable: false, comment: "Ключ секции"), + Value = table.Column(type: "jsonb", nullable: false, comment: "Значение") + }, + constraints: table => + { + table.PrimaryKey("PK_ChangeLog", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "DataSaub", + columns: table => new + { + date = table.Column(type: "timestamp with time zone", nullable: false), + mode = table.Column(type: "integer", nullable: true), + user = table.Column(type: "text", nullable: true), + wellDepth = table.Column(type: "double precision", nullable: true), + bitDepth = table.Column(type: "double precision", nullable: true), + blockPosition = table.Column(type: "double precision", nullable: true), + blockSpeed = table.Column(type: "double precision", nullable: true), + pressure = table.Column(type: "double precision", nullable: true), + axialLoad = table.Column(type: "double precision", nullable: true), + hookWeight = table.Column(type: "double precision", nullable: true), + rotorTorque = table.Column(type: "double precision", nullable: true), + rotorSpeed = table.Column(type: "double precision", nullable: true), + flow = table.Column(type: "double precision", nullable: true), + mseState = table.Column(type: "smallint", nullable: false), + idFeedRegulator = table.Column(type: "integer", nullable: false), + mse = table.Column(type: "double precision", nullable: true), + pump0Flow = table.Column(type: "double precision", nullable: true), + pump1Flow = table.Column(type: "double precision", nullable: true), + pump2Flow = table.Column(type: "double precision", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_DataSaub", x => x.date); + }); + + migrationBuilder.CreateTable( + name: "DataSourceSystem", + columns: table => new + { + SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы - источника данных"), + Name = table.Column(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"), + Description = table.Column(type: "text", nullable: true, comment: "Описание системы - источника данных") + }, + constraints: table => + { + table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId); + }); + + migrationBuilder.CreateTable( + name: "ParameterData", + columns: table => new + { + DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"), + ParameterId = table.Column(type: "integer", nullable: false, comment: "Id параметра"), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"), + Value = table.Column(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки") + }, + constraints: table => + { + table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp }); + }); + + migrationBuilder.CreateTable( + name: "Setpoint", + columns: table => new + { + Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), + Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"), + Value = table.Column(type: "jsonb", nullable: false, comment: "Значение уставки"), + IdUser = table.Column(type: "uuid", nullable: false, comment: "Id автора последнего изменения") + }, + constraints: table => + { + table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); + }); + + migrationBuilder.CreateTable( + name: "TimestampedSets", + columns: table => new + { + IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Отметка времени, строго в UTC"), + Set = table.Column(type: "jsonb", nullable: false, comment: "Набор сохраняемых данных") + }, + constraints: table => + { + table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp }); + }, + comment: "Общая таблица данных временных рядов"); + + migrationBuilder.CreateTable( + name: "TechMessage", + columns: table => new + { + EventId = table.Column(type: "uuid", nullable: false, comment: "Id события"), + CategoryId = table.Column(type: "integer", nullable: false, comment: "Id Категории важности"), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"), + Text = table.Column(type: "varchar(512)", nullable: false, comment: "Текст сообщения"), + SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"), + EventState = table.Column(type: "integer", nullable: false, comment: "Статус события") + }, + constraints: table => + { + table.PrimaryKey("PK_TechMessage", x => x.EventId); + table.ForeignKey( + name: "FK_TechMessage_DataSourceSystem_SystemId", + column: x => x.SystemId, + principalTable: "DataSourceSystem", + principalColumn: "SystemId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_TechMessage_SystemId", + table: "TechMessage", + column: "SystemId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ChangeLog"); + + migrationBuilder.DropTable( + name: "DataSaub"); + + migrationBuilder.DropTable( + name: "ParameterData"); + + migrationBuilder.DropTable( + name: "Setpoint"); + + migrationBuilder.DropTable( + name: "TechMessage"); + + migrationBuilder.DropTable( + name: "TimestampedSets"); + + migrationBuilder.DropTable( + name: "DataSourceSystem"); + } + } +} diff --git a/Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs similarity index 92% rename from Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs rename to DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs index f233af8..4c66e90 100644 --- a/Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs +++ b/DD.Persistence.Database.Postgres/Migrations/PersistencePostgresContextModelSnapshot.cs @@ -1,14 +1,14 @@ // using System; +using DD.Persistence.Database.Model; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Persistence.Database.Model; #nullable disable -namespace Persistence.Database.Postgres.Migrations +namespace DD.Persistence.Database.Postgres.Migrations { [DbContext(typeof(PersistencePostgresContext))] partial class PersistencePostgresContextModelSnapshot : ModelSnapshot @@ -17,14 +17,12 @@ namespace Persistence.Database.Postgres.Migrations { #pragma warning disable 612, 618 modelBuilder - .UseCollation("Russian_Russia.1251") .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 63); - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("Persistence.Database.Entity.DataSourceSystem", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b => { b.Property("SystemId") .ValueGeneratedOnAdd() @@ -45,7 +43,7 @@ namespace Persistence.Database.Postgres.Migrations b.ToTable("DataSourceSystem"); }); - modelBuilder.Entity("Persistence.Database.Entity.ParameterData", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b => { b.Property("DiscriminatorId") .HasColumnType("uuid") @@ -69,7 +67,7 @@ namespace Persistence.Database.Postgres.Migrations b.ToTable("ParameterData"); }); - modelBuilder.Entity("Persistence.Database.Entity.TechMessage", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { b.Property("EventId") .ValueGeneratedOnAdd() @@ -104,7 +102,7 @@ namespace Persistence.Database.Postgres.Migrations b.ToTable("TechMessage"); }); - modelBuilder.Entity("Persistence.Database.Entity.TimestampedSet", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b => { b.Property("IdDiscriminator") .HasColumnType("uuid") @@ -127,7 +125,7 @@ namespace Persistence.Database.Postgres.Migrations }); }); - modelBuilder.Entity("Persistence.Database.Model.ChangeLog", b => + modelBuilder.Entity("DD.Persistence.Database.Model.ChangeLog", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -180,7 +178,7 @@ namespace Persistence.Database.Postgres.Migrations b.ToTable("ChangeLog"); }); - modelBuilder.Entity("Persistence.Database.Model.DataSaub", b => + modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b => { b.Property("Date") .HasColumnType("timestamp with time zone") @@ -263,7 +261,7 @@ namespace Persistence.Database.Postgres.Migrations b.ToTable("DataSaub"); }); - modelBuilder.Entity("Persistence.Database.Model.Setpoint", b => + modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b => { b.Property("Key") .HasColumnType("uuid") @@ -287,9 +285,9 @@ namespace Persistence.Database.Postgres.Migrations b.ToTable("Setpoint"); }); - modelBuilder.Entity("Persistence.Database.Entity.TechMessage", b => + modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b => { - b.HasOne("Persistence.Database.Entity.DataSourceSystem", "System") + b.HasOne("DD.Persistence.Database.Entity.DataSourceSystem", "System") .WithMany() .HasForeignKey("SystemId") .OnDelete(DeleteBehavior.Cascade) diff --git a/Persistence.Database.Postgres/PersistencePostgresContext.cs b/DD.Persistence.Database.Postgres/PersistencePostgresContext.cs similarity index 70% rename from Persistence.Database.Postgres/PersistencePostgresContext.cs rename to DD.Persistence.Database.Postgres/PersistencePostgresContext.cs index 6016a1d..6cd8955 100644 --- a/Persistence.Database.Postgres/PersistencePostgresContext.cs +++ b/DD.Persistence.Database.Postgres/PersistencePostgresContext.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace Persistence.Database.Model; +namespace DD.Persistence.Database.Model; /// /// EF Postgres @@ -13,10 +13,6 @@ public partial class PersistencePostgresContext : PersistenceDbContext protected override void OnModelCreating(ModelBuilder modelBuilder) { - modelBuilder.HasPostgresExtension("adminpack") - .HasAnnotation("Relational:Collation", "Russian_Russia.1251"); - base.OnModelCreating(modelBuilder); - } } diff --git a/Persistence.Database.Postgres/Readme.md b/DD.Persistence.Database.Postgres/Readme.md similarity index 51% rename from Persistence.Database.Postgres/Readme.md rename to DD.Persistence.Database.Postgres/Readme.md index 7172774..176788f 100644 --- a/Persistence.Database.Postgres/Readme.md +++ b/DD.Persistence.Database.Postgres/Readme.md @@ -1,11 +1,11 @@ ## Создать миграцию ``` -dotnet ef migrations add --project Persistence.Database.Postgres +dotnet ef migrations add --project DD.Persistence.Database.Postgres ``` ## Откатить миграцию ``` -dotnet ef migrations remove --project Persistence.Database.Postgres +dotnet ef migrations remove --project DD.Persistence.Database.Postgres ``` Удаляется последняя созданная миграция. \ No newline at end of file diff --git a/Persistence.Database/Persistence.Database.csproj b/DD.Persistence.Database/DD.Persistence.Database.csproj similarity index 88% rename from Persistence.Database/Persistence.Database.csproj rename to DD.Persistence.Database/DD.Persistence.Database.csproj index 3019e82..c1db678 100644 --- a/Persistence.Database/Persistence.Database.csproj +++ b/DD.Persistence.Database/DD.Persistence.Database.csproj @@ -15,7 +15,7 @@ - + diff --git a/Persistence.Database/EFExtensions.cs b/DD.Persistence.Database/EFExtensions.cs similarity index 97% rename from Persistence.Database/EFExtensions.cs rename to DD.Persistence.Database/EFExtensions.cs index decdb39..498d332 100644 --- a/Persistence.Database/EFExtensions.cs +++ b/DD.Persistence.Database/EFExtensions.cs @@ -2,7 +2,7 @@ using System.Text.Json; using System.Text.Json.Serialization; -namespace Persistence.Database; +namespace DD.Persistence.Database; public static class EFExtensions { diff --git a/Persistence.Database/Entity/ChangeLog.cs b/DD.Persistence.Database/Entity/ChangeLog.cs similarity index 95% rename from Persistence.Database/Entity/ChangeLog.cs rename to DD.Persistence.Database/Entity/ChangeLog.cs index edffb52..439e886 100644 --- a/Persistence.Database/Entity/ChangeLog.cs +++ b/DD.Persistence.Database/Entity/ChangeLog.cs @@ -1,10 +1,10 @@  using Microsoft.EntityFrameworkCore; -using Persistence.Models; +using DD.Persistence.Models; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Model; +namespace DD.Persistence.Database.Model; /// /// Часть записи, описывающая изменение diff --git a/Persistence.Database/Entity/DataSaub.cs b/DD.Persistence.Database/Entity/DataSaub.cs similarity index 97% rename from Persistence.Database/Entity/DataSaub.cs rename to DD.Persistence.Database/Entity/DataSaub.cs index ee18d40..d4515b2 100644 --- a/Persistence.Database/Entity/DataSaub.cs +++ b/DD.Persistence.Database/Entity/DataSaub.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Model; +namespace DD.Persistence.Database.Model; public class DataSaub : ITimestampedData { [Key, Column("date")] diff --git a/Persistence.Database/Entity/DataSourceSystem.cs b/DD.Persistence.Database/Entity/DataSourceSystem.cs similarity index 93% rename from Persistence.Database/Entity/DataSourceSystem.cs rename to DD.Persistence.Database/Entity/DataSourceSystem.cs index a2fcaf9..d200731 100644 --- a/Persistence.Database/Entity/DataSourceSystem.cs +++ b/DD.Persistence.Database/Entity/DataSourceSystem.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Entity; +namespace DD.Persistence.Database.Entity; public class DataSourceSystem { [Key, Comment("Id системы - источника данных")] diff --git a/Persistence.Database/Entity/IChangeLog.cs b/DD.Persistence.Database/Entity/IChangeLog.cs similarity index 96% rename from Persistence.Database/Entity/IChangeLog.cs rename to DD.Persistence.Database/Entity/IChangeLog.cs index c4dc962..b91808b 100644 --- a/Persistence.Database/Entity/IChangeLog.cs +++ b/DD.Persistence.Database/Entity/IChangeLog.cs @@ -1,5 +1,5 @@  -namespace Persistence.Database.Model; +namespace DD.Persistence.Database.Model; /// /// Часть записи, описывающая изменение diff --git a/Persistence.Database/Entity/ITimestampedData.cs b/DD.Persistence.Database/Entity/ITimestampedData.cs similarity index 80% rename from Persistence.Database/Entity/ITimestampedData.cs rename to DD.Persistence.Database/Entity/ITimestampedData.cs index ce21da5..ce5468c 100644 --- a/Persistence.Database/Entity/ITimestampedData.cs +++ b/DD.Persistence.Database/Entity/ITimestampedData.cs @@ -1,4 +1,4 @@ -namespace Persistence.Database.Model; +namespace DD.Persistence.Database.Model; public interface ITimestampedData { /// diff --git a/Persistence.Database/Entity/ParameterData.cs b/DD.Persistence.Database/Entity/ParameterData.cs similarity index 94% rename from Persistence.Database/Entity/ParameterData.cs rename to DD.Persistence.Database/Entity/ParameterData.cs index eb4fa4c..c81b029 100644 --- a/Persistence.Database/Entity/ParameterData.cs +++ b/DD.Persistence.Database/Entity/ParameterData.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Entity; +namespace DD.Persistence.Database.Entity; [PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))] public class ParameterData diff --git a/Persistence.Database/Entity/Setpoint.cs b/DD.Persistence.Database/Entity/Setpoint.cs similarity index 93% rename from Persistence.Database/Entity/Setpoint.cs rename to DD.Persistence.Database/Entity/Setpoint.cs index 968bdd7..94eca3f 100644 --- a/Persistence.Database/Entity/Setpoint.cs +++ b/DD.Persistence.Database/Entity/Setpoint.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Model +namespace DD.Persistence.Database.Model { [PrimaryKey(nameof(Key), nameof(Created))] public class Setpoint diff --git a/Persistence.Database/Entity/TechMessage.cs b/DD.Persistence.Database/Entity/TechMessage.cs similarity index 96% rename from Persistence.Database/Entity/TechMessage.cs rename to DD.Persistence.Database/Entity/TechMessage.cs index 52fcecc..e233941 100644 --- a/Persistence.Database/Entity/TechMessage.cs +++ b/DD.Persistence.Database/Entity/TechMessage.cs @@ -2,7 +2,7 @@ using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Entity +namespace DD.Persistence.Database.Entity { public class TechMessage { diff --git a/Persistence.Database/Entity/TimestampedSet.cs b/DD.Persistence.Database/Entity/TimestampedSet.cs similarity index 93% rename from Persistence.Database/Entity/TimestampedSet.cs rename to DD.Persistence.Database/Entity/TimestampedSet.cs index 09a50ee..f0d1815 100644 --- a/Persistence.Database/Entity/TimestampedSet.cs +++ b/DD.Persistence.Database/Entity/TimestampedSet.cs @@ -1,7 +1,7 @@ using Microsoft.EntityFrameworkCore; using System.ComponentModel.DataAnnotations.Schema; -namespace Persistence.Database.Entity; +namespace DD.Persistence.Database.Entity; [Comment("Общая таблица данных временных рядов")] [PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))] diff --git a/Persistence.Database/PersistenceDbContext.cs b/DD.Persistence.Database/PersistenceDbContext.cs similarity index 90% rename from Persistence.Database/PersistenceDbContext.cs rename to DD.Persistence.Database/PersistenceDbContext.cs index e43b1d7..a0587cd 100644 --- a/Persistence.Database/PersistenceDbContext.cs +++ b/DD.Persistence.Database/PersistenceDbContext.cs @@ -1,8 +1,8 @@ using Microsoft.EntityFrameworkCore; -using Persistence.Database.Entity; -using Persistence.Database.Model; +using DD.Persistence.Database.Entity; +using DD.Persistence.Database.Model; -namespace Persistence.Database; +namespace DD.Persistence.Database; /// /// EF контекст для любых БД поддерживаемых в EF diff --git a/Persistence.IntegrationTests/BaseIntegrationTest.cs b/DD.Persistence.IntegrationTests/BaseIntegrationTest.cs similarity index 84% rename from Persistence.IntegrationTests/BaseIntegrationTest.cs rename to DD.Persistence.IntegrationTests/BaseIntegrationTest.cs index 9cc68ab..4a15ecf 100644 --- a/Persistence.IntegrationTests/BaseIntegrationTest.cs +++ b/DD.Persistence.IntegrationTests/BaseIntegrationTest.cs @@ -1,9 +1,9 @@ using Microsoft.Extensions.DependencyInjection; -using Persistence.Database; -using Persistence.Database.Model; +using DD.Persistence.Database; +using DD.Persistence.Database.Model; using Xunit; -namespace Persistence.IntegrationTests; +namespace DD.Persistence.IntegrationTests; public abstract class BaseIntegrationTest : IClassFixture, IDisposable { protected readonly IServiceScope scope; diff --git a/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs similarity index 96% rename from Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs rename to DD.Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs index 51edebd..3f1bb6c 100644 --- a/Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/ChangeLogControllerTest.cs @@ -1,15 +1,14 @@ using Mapster; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients.Interfaces; -using Persistence.Database.Entity; -using Persistence.Database.Model; -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; using Xunit; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client; -namespace Persistence.IntegrationTests.Controllers; +namespace DD.Persistence.IntegrationTests.Controllers; public class ChangeLogControllerTest : BaseIntegrationTest { private readonly IChangeLogClient client; @@ -52,7 +51,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest var result = await client.ClearAndAddRange(idDiscriminator, dtos, new CancellationToken()); // assert - Assert.Equal(insertedCount*2, result); + Assert.Equal(insertedCount * 2, result); } [Fact] @@ -116,11 +115,11 @@ public class ChangeLogControllerTest : BaseIntegrationTest Assert.NotNull(changeLogResult); var obsoleteDto = changeLogResult - .Where(e => e.Obsolete.HasValue) + .Where(e => e.Obsolete.HasValue) .FirstOrDefault(); var activeDto = changeLogResult - .Where(e => !e.Obsolete.HasValue) + .Where(e => !e.Obsolete.HasValue) .FirstOrDefault(); if (obsoleteDto == null || activeDto == null) diff --git a/Persistence.IntegrationTests/Controllers/DataSaubControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/DataSaubControllerTest.cs similarity index 93% rename from Persistence.IntegrationTests/Controllers/DataSaubControllerTest.cs rename to DD.Persistence.IntegrationTests/Controllers/DataSaubControllerTest.cs index 49365a8..7daad50 100644 --- a/Persistence.IntegrationTests/Controllers/DataSaubControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/DataSaubControllerTest.cs @@ -1,8 +1,8 @@ -using Persistence.Database.Model; -using Persistence.Models; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; using Xunit; -namespace Persistence.IntegrationTests.Controllers; +namespace DD.Persistence.IntegrationTests.Controllers; public class DataSaubControllerTest : TimeSeriesBaseControllerTest { private readonly DataSaubDto dto = new() diff --git a/DD.Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs new file mode 100644 index 0000000..03d5b8a --- /dev/null +++ b/DD.Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs @@ -0,0 +1,82 @@ +using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.DependencyInjection; +using DD.Persistence.Client; +using DD.Persistence.Client.Clients; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; +using Xunit; + +namespace DD.Persistence.IntegrationTests.Controllers +{ + public class DataSourceSystemControllerTest : BaseIntegrationTest + { + private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey"; + private readonly IDataSourceSystemClient dataSourceSystemClient; + private readonly IMemoryCache memoryCache; + public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory) + { + var scope = factory.Services.CreateScope(); + var persistenceClientFactory = scope.ServiceProvider + .GetRequiredService(); + + dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient(); + memoryCache = scope.ServiceProvider.GetRequiredService(); + } + + [Fact] + public async Task Get_returns_success() + { + //arrange + memoryCache.Remove(SystemCacheKey); + dbContext.CleanupDbSet(); + + //act + var response = await dataSourceSystemClient.Get(CancellationToken.None); + + //assert + Assert.NotNull(response); + Assert.Empty(response); + } + + [Fact] + public async Task Get_AfterSave_returns_success() + { + //arrange + await Add(); + + //act + var response = await dataSourceSystemClient.Get(CancellationToken.None); + + //assert + Assert.NotNull(response); + + var expectedSystemCount = 1; + var actualSystemCount = response!.Count(); + Assert.Equal(expectedSystemCount, actualSystemCount); + } + + [Fact] + public async Task Add_returns_success() + { + await Add(); + } + + private async Task Add() + { + //arrange + memoryCache.Remove(SystemCacheKey); + dbContext.CleanupDbSet(); + + var dto = new DataSourceSystemDto() + { + SystemId = Guid.NewGuid(), + Name = "Test", + Description = "Test" + }; + + //act + await dataSourceSystemClient.Add(dto, CancellationToken.None); + } + } +} diff --git a/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs new file mode 100644 index 0000000..d79b6c0 --- /dev/null +++ b/DD.Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs @@ -0,0 +1,227 @@ +using Microsoft.Extensions.DependencyInjection; +using DD.Persistence.Client; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Database.Model; +using System.Net; +using Xunit; + +namespace DD.Persistence.IntegrationTests.Controllers +{ + public class SetpointControllerTest : BaseIntegrationTest + { + private readonly ISetpointClient setpointClient; + private class TestObject + { + public string? Value1 { get; set; } + public int? Value2 { get; set; } + } + public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory) + { + var scope = factory.Services.CreateScope(); + var persistenceClientFactory = scope.ServiceProvider + .GetRequiredService(); + + setpointClient = persistenceClientFactory.GetSetpointClient(); + } + + [Fact] + public async Task GetCurrent_returns_success() + { + //arrange + var setpointKeys = new List() + { + Guid.NewGuid(), + Guid.NewGuid() + }; + + //act + var response = await setpointClient.GetCurrent(setpointKeys, new CancellationToken()); + + //assert + Assert.NotNull(response); + Assert.Empty(response); + } + + [Fact] + public async Task GetCurrent_AfterSave_returns_success() + { + //arrange + var setpointKey = await Add(); + + //act + var response = await setpointClient.GetCurrent([setpointKey], new CancellationToken()); + + //assert + Assert.NotNull(response); + Assert.NotEmpty(response); + Assert.Equal(setpointKey, response.FirstOrDefault()?.Key); + } + + [Fact] + public async Task GetHistory_returns_success() + { + //arrange + var setpointKeys = new List() + { + Guid.NewGuid(), + Guid.NewGuid() + }; + var historyMoment = DateTimeOffset.UtcNow; + + //act + var response = await setpointClient.GetHistory(setpointKeys, historyMoment, new CancellationToken()); + + //assert + Assert.NotNull(response); + Assert.Empty(response); + } + + [Fact] + public async Task GetHistory_AfterSave_returns_success() + { + //arrange + var setpointKey = await Add(); + var historyMoment = DateTimeOffset.UtcNow; + historyMoment = historyMoment.AddDays(1); + + //act + var response = await setpointClient.GetHistory([setpointKey], historyMoment, new CancellationToken()); + + //assert + Assert.NotNull(response); + Assert.NotEmpty(response); + Assert.Equal(setpointKey, response.FirstOrDefault()?.Key); + } + + [Fact] + public async Task GetLog_returns_success() + { + //arrange + var setpointKeys = new List() + { + Guid.NewGuid(), + Guid.NewGuid() + }; + + //act + var response = await setpointClient.GetLog(setpointKeys, new CancellationToken()); + + //assert + Assert.NotNull(response); + Assert.Empty(response); + } + + [Fact] + public async Task GetLog_AfterSave_returns_success() + { + //arrange + var setpointKey = await Add(); + + //act + var response = await setpointClient.GetLog([setpointKey], new CancellationToken()); + + //assert + Assert.NotNull(response); + Assert.NotEmpty(response); + Assert.Equal(setpointKey, response.FirstOrDefault().Key); + } + + [Fact] + public async Task GetDatesRange_returns_success() + { + //arrange + dbContext.CleanupDbSet(); + + //act + var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None); + + //assert + Assert.NotNull(response); + Assert.Equal(DateTimeOffset.MinValue, response!.From); + Assert.Equal(DateTimeOffset.MaxValue, response!.To); + } + + [Fact] + public async Task GetDatesRange_AfterSave_returns_success() + { + //arrange + dbContext.CleanupDbSet(); + + await Add(); + + var dateBegin = DateTimeOffset.MinValue; + var take = 1; + var part = await setpointClient.GetPart(dateBegin, take, CancellationToken.None); + + //act + var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None); + + //assert + Assert.NotNull(response); + + var expectedValue = part! + .FirstOrDefault()!.Created + .ToString("dd.MM.yyyy-HH:mm:ss"); + var actualValueFrom = response.From + .ToString("dd.MM.yyyy-HH:mm:ss"); + Assert.Equal(expectedValue, actualValueFrom); + + var actualValueTo = response.To + .ToString("dd.MM.yyyy-HH:mm:ss"); + Assert.Equal(expectedValue, actualValueTo); + } + + [Fact] + public async Task GetPart_returns_success() + { + //arrange + var dateBegin = DateTimeOffset.UtcNow; + var take = 2; + + //act + var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None); + + //assert + Assert.NotNull(response); + Assert.Empty(response); + } + + [Fact] + public async Task GetPart_AfterSave_returns_success() + { + //arrange + var dateBegin = DateTimeOffset.UtcNow; + var take = 1; + await Add(); + + //act + var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None); + + //assert + Assert.NotNull(response); + Assert.NotEmpty(response); + } + + [Fact] + public async Task Save_returns_success() + { + await Add(); + } + + private async Task Add() + { + //arrange + var setpointKey = Guid.NewGuid(); + var setpointValue = new TestObject() + { + Value1 = "1", + Value2 = 2 + }; + + //act + await setpointClient.Add(setpointKey, setpointValue, new CancellationToken()); + + return setpointKey; + } + } +} diff --git a/Persistence.IntegrationTests/Controllers/TechMessagesControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/TechMessagesControllerTest.cs similarity index 90% rename from Persistence.IntegrationTests/Controllers/TechMessagesControllerTest.cs rename to DD.Persistence.IntegrationTests/Controllers/TechMessagesControllerTest.cs index c51804a..bdcddb9 100644 --- a/Persistence.IntegrationTests/Controllers/TechMessagesControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/TechMessagesControllerTest.cs @@ -1,15 +1,15 @@ -using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients.Interfaces; -using Persistence.Database.Entity; -using Persistence.Models; -using Persistence.Models.Enumerations; -using Persistence.Models.Requests; +using DD.Persistence.Client; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; +using DD.Persistence.Models.Enumerations; +using DD.Persistence.Models.Requests; using System.Net; using Xunit; -namespace Persistence.IntegrationTests.Controllers +namespace DD.Persistence.IntegrationTests.Controllers { public class TechMessagesControllerTest : BaseIntegrationTest { @@ -209,20 +209,20 @@ namespace Persistence.IntegrationTests.Controllers Assert.NotNull(response?.To); } - [Fact] - public async Task GetPart_returns_success() - { - //arrange - var dateBegin = DateTimeOffset.UtcNow; - var take = 2; + // [Fact] + // public async Task GetPart_returns_success() + // { + // //arrange + // var dateBegin = DateTimeOffset.UtcNow; + // var take = 2; - //act - var response = await techMessagesClient.GetPart(dateBegin, take, CancellationToken.None); + // //act + // var response = await techMessagesClient.GetPart(dateBegin, take, CancellationToken.None); - //assert - Assert.NotNull(response); - Assert.Empty(response); - } + // //assert + // Assert.NotNull(response); + // Assert.Empty(response); + //} [Fact] public async Task GetPart_AfterSave_returns_success() diff --git a/Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs similarity index 92% rename from Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs rename to DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs index ef43a10..7d75875 100644 --- a/Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/TimeSeriesBaseControllerTest.cs @@ -1,12 +1,12 @@ using Mapster; using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients.Interfaces; -using Persistence.Database.Model; +using DD.Persistence.Client; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Database.Model; using System.Net; using Xunit; -namespace Persistence.IntegrationTests.Controllers; +namespace DD.Persistence.IntegrationTests.Controllers; public abstract class TimeSeriesBaseControllerTest : BaseIntegrationTest where TEntity : class, ITimestampedData, new() @@ -22,7 +22,7 @@ public abstract class TimeSeriesBaseControllerTest : BaseIntegrat var persistenceClientFactory = scope.ServiceProvider .GetRequiredService(); - timeSeriesClient = persistenceClientFactory.GetTimeSeriesClient(); + timeSeriesClient = persistenceClientFactory.GetTimeSeriesClient(); } public async Task InsertRangeSuccess(TDto dto) diff --git a/Persistence.IntegrationTests/Controllers/TimestampedSetControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/TimestampedSetControllerTest.cs similarity index 96% rename from Persistence.IntegrationTests/Controllers/TimestampedSetControllerTest.cs rename to DD.Persistence.IntegrationTests/Controllers/TimestampedSetControllerTest.cs index f3546f5..567b8c8 100644 --- a/Persistence.IntegrationTests/Controllers/TimestampedSetControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/TimestampedSetControllerTest.cs @@ -1,10 +1,10 @@ using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients.Interfaces; -using Persistence.Models; +using DD.Persistence.Client; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Models; using Xunit; -namespace Persistence.IntegrationTests.Controllers; +namespace DD.Persistence.IntegrationTests.Controllers; public class TimestampedSetControllerTest : BaseIntegrationTest { private readonly ITimestampedSetClient client; @@ -72,7 +72,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest } } - [Fact] + [Fact] public async Task Get_geDate() { // arrange @@ -112,11 +112,11 @@ public class TimestampedSetControllerTest : BaseIntegrationTest // assert Assert.NotNull(response); - Assert.Equal(expectedCount, response.Count()); - } + Assert.Equal(expectedCount, response.Count()); + } - [Fact] + [Fact] public async Task Get_with_big_skip_take() { // arrange diff --git a/Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs b/DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs similarity index 64% rename from Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs rename to DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs index 731ec9e..6db5853 100644 --- a/Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs +++ b/DD.Persistence.IntegrationTests/Controllers/WitsDataControllerTest.cs @@ -1,13 +1,12 @@ using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients; -using Persistence.Client.Clients.Interfaces; -using Persistence.Database.Entity; -using Persistence.Models; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; using System.Net; using Xunit; +using DD.Persistence.Client.Clients.Interfaces; +using DD.Persistence.Client; -namespace Persistence.IntegrationTests.Controllers; +namespace DD.Persistence.IntegrationTests.Controllers; public class WitsDataControllerTest : BaseIntegrationTest { private IWitsDataClient witsDataClient; @@ -18,8 +17,8 @@ public class WitsDataControllerTest : BaseIntegrationTest var persistenceClientFactory = scope.ServiceProvider .GetRequiredService(); - witsDataClient = persistenceClientFactory.GetWitsDataClient(); - } + witsDataClient = persistenceClientFactory.GetWitsDataClient(); + } [Fact] public async Task GetDatesRangeAsync_returns_success() @@ -32,9 +31,9 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None); - //assert - Assert.NotNull(response); - } + //assert + Assert.NotNull(response); + } [Fact] public async Task GetPart_returns_success() @@ -49,10 +48,10 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.GetPart(discriminatorId, dateBegin, take, CancellationToken.None); - //assert - Assert.NotNull(response); - Assert.Empty(response); - } + //assert + Assert.NotNull(response); + Assert.Empty(response); + } [Fact] public async Task InsertRange_returns_success() @@ -78,10 +77,10 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointCount, CancellationToken.None); - //assert - Assert.NotNull(response); - Assert.Empty(response); - } + //assert + Assert.NotNull(response); + Assert.Empty(response); + } [Fact] public async Task GetDatesRangeAsync_AfterSave_returns_success() @@ -95,25 +94,25 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None); - //assert - Assert.NotNull(response); + //assert + Assert.NotNull(response); - var expectedDateFrom = dtos - .Select(e => e.Timestamped) - .Min() - .ToString("dd.MM.yyyy-HH:mm:ss"); - var actualDateFrom = response.From.DateTime - .ToString("dd.MM.yyyy-HH:mm:ss"); - Assert.Equal(expectedDateFrom, actualDateFrom); + var expectedDateFrom = dtos + .Select(e => e.Timestamped) + .Min() + .ToString("dd.MM.yyyy-HH:mm:ss"); + var actualDateFrom = response.From.DateTime + .ToString("dd.MM.yyyy-HH:mm:ss"); + Assert.Equal(expectedDateFrom, actualDateFrom); - var expectedDateTo = dtos - .Select(e => e.Timestamped) - .Max() - .ToString("dd.MM.yyyy-HH:mm:ss"); - var actualDateTo = response.To.DateTime - .ToString("dd.MM.yyyy-HH:mm:ss"); - Assert.Equal(expectedDateTo, actualDateTo); - } + var expectedDateTo = dtos + .Select(e => e.Timestamped) + .Max() + .ToString("dd.MM.yyyy-HH:mm:ss"); + var actualDateTo = response.To.DateTime + .ToString("dd.MM.yyyy-HH:mm:ss"); + Assert.Equal(expectedDateTo, actualDateTo); + } [Fact] public async Task GetPart_AfterSave_returns_success() @@ -129,14 +128,14 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.GetPart(discriminatorId, dateBegin, take, CancellationToken.None); - //assert - Assert.NotNull(response); - Assert.NotEmpty(response); - Assert.Equal(take, response.Count()); + //assert + Assert.NotNull(response); + Assert.NotEmpty(response); + Assert.Equal(take, response.Count()); - var expectedDto = dtos.FirstOrDefault(); - var actualDto = response.FirstOrDefault(); - Assert.Equal(expectedDto?.DiscriminatorId, actualDto?.DiscriminatorId); + var expectedDto = dtos.FirstOrDefault(); + var actualDto = response.FirstOrDefault(); + Assert.Equal(expectedDto?.DiscriminatorId, actualDto?.DiscriminatorId); var expectedValueDto = expectedDto?.Values.FirstOrDefault(); var actualValueDto = actualDto?.Values.FirstOrDefault(); @@ -159,27 +158,27 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointCount, CancellationToken.None); - //assert - Assert.NotNull(response); - Assert.Equal(approxPointCount, response.Count()); - } + //assert + Assert.NotNull(response); + Assert.Equal(approxPointCount, response.Count()); + } - [Fact] - public async Task AddRange_returns_BadRequest() - { - //arrange - const string exceptionMessage = "Ошибка валидации, формата или маршрутизации запроса"; - var dtos = new List() - { - new WitsDataDto() - { - DiscriminatorId = Guid.NewGuid(), - Timestamped = DateTimeOffset.UtcNow, - Values = new List() - { - new WitsValueDto() - { - RecordId = -1, // < 0 + [Fact] + public async Task AddRange_returns_BadRequest() + { + //arrange + const string exceptionMessage = "Ошибка валидации, формата или маршрутизации запроса"; + var dtos = new List() + { + new WitsDataDto() + { + DiscriminatorId = Guid.NewGuid(), + Timestamped = DateTimeOffset.UtcNow, + Values = new List() + { + new WitsValueDto() + { + RecordId = -1, // < 0 ItemId = 101, // > 100 Value = string.Empty } @@ -187,17 +186,17 @@ public class WitsDataControllerTest : BaseIntegrationTest } }; - try - { - //act - var response = await witsDataClient.AddRange(dtos, CancellationToken.None); - } - catch (Exception ex) - { - //assert - Assert.Equal(exceptionMessage, ex.Message); - } - } + try + { + //act + var response = await witsDataClient.AddRange(dtos, CancellationToken.None); + } + catch (Exception ex) + { + //assert + Assert.Equal(exceptionMessage, ex.Message); + } + } private async Task> AddRange(int countToCreate = 10) { @@ -226,9 +225,9 @@ public class WitsDataControllerTest : BaseIntegrationTest //act var response = await witsDataClient.AddRange(dtos, CancellationToken.None); - //assert - var count = dtos.SelectMany(e => e.Values).Count(); - Assert.Equal(count, response); + //assert + var count = dtos.SelectMany(e => e.Values).Count(); + Assert.Equal(count, response); return dtos; } diff --git a/Persistence.IntegrationTests/Persistence.IntegrationTests.csproj b/DD.Persistence.IntegrationTests/DD.Persistence.IntegrationTests.csproj similarity index 76% rename from Persistence.IntegrationTests/Persistence.IntegrationTests.csproj rename to DD.Persistence.IntegrationTests/DD.Persistence.IntegrationTests.csproj index a5cf35f..d452985 100644 --- a/Persistence.IntegrationTests/Persistence.IntegrationTests.csproj +++ b/DD.Persistence.IntegrationTests/DD.Persistence.IntegrationTests.csproj @@ -24,9 +24,10 @@ - - - + + + + diff --git a/Persistence.IntegrationTests/DbConnection.cs b/DD.Persistence.IntegrationTests/DbConnection.cs similarity index 89% rename from Persistence.IntegrationTests/DbConnection.cs rename to DD.Persistence.IntegrationTests/DbConnection.cs index ac733fa..55ada6b 100644 --- a/Persistence.IntegrationTests/DbConnection.cs +++ b/DD.Persistence.IntegrationTests/DbConnection.cs @@ -1,4 +1,4 @@ -namespace Persistence.IntegrationTests; +namespace DD.Persistence.IntegrationTests; public class DbConnection { public string Host { get; set; } = null!; diff --git a/Persistence.IntegrationTests/EFCoreExtensions.cs b/DD.Persistence.IntegrationTests/EFCoreExtensions.cs similarity index 87% rename from Persistence.IntegrationTests/EFCoreExtensions.cs rename to DD.Persistence.IntegrationTests/EFCoreExtensions.cs index 4e20423..49afd23 100644 --- a/Persistence.IntegrationTests/EFCoreExtensions.cs +++ b/DD.Persistence.IntegrationTests/EFCoreExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -namespace Persistence.IntegrationTests; +namespace DD.Persistence.IntegrationTests; public static class EFCoreExtensions { public static void CleanupDbSet(this DbContext dbContext) diff --git a/Persistence.IntegrationTests/TestHttpClientFactory.cs b/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs similarity index 91% rename from Persistence.IntegrationTests/TestHttpClientFactory.cs rename to DD.Persistence.IntegrationTests/TestHttpClientFactory.cs index a158b10..b0f86c8 100644 --- a/Persistence.IntegrationTests/TestHttpClientFactory.cs +++ b/DD.Persistence.IntegrationTests/TestHttpClientFactory.cs @@ -1,4 +1,4 @@ -namespace Persistence.IntegrationTests +namespace DD.Persistence.IntegrationTests { /// /// Фабрика HTTP клиентов для интеграционных тестов diff --git a/Persistence.IntegrationTests/WebAppFactoryFixture.cs b/DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs similarity index 85% rename from Persistence.IntegrationTests/WebAppFactoryFixture.cs rename to DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs index 535236f..76cf71b 100644 --- a/Persistence.IntegrationTests/WebAppFactoryFixture.cs +++ b/DD.Persistence.IntegrationTests/WebAppFactoryFixture.cs @@ -5,14 +5,15 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; -using Persistence.API; -using Persistence.Client; -using Persistence.Database.Model; -using Persistence.Database.Postgres; +using DD.Persistence.API; +using DD.Persistence.Client; +using DD.Persistence.Database.Model; +using DD.Persistence.Database.Postgres; using RestSharp; +using DD.Persistence.App; -namespace Persistence.IntegrationTests; -public class WebAppFactoryFixture : WebApplicationFactory +namespace DD.Persistence.IntegrationTests; +public class WebAppFactoryFixture : WebApplicationFactory { private string connectionString = string.Empty; @@ -24,6 +25,7 @@ public class WebAppFactoryFixture : WebApplicationFactory var dbConnection = config.Build().GetSection("DbConnection").Get()!; connectionString = dbConnection.GetConnectionString(); + //connectionString = "Host=postgres;Port=5442;Username=postgres;Password=postgres;Database=persistence"; }); builder.ConfigureServices(services => diff --git a/Persistence.Repository/CyclicArray.cs b/DD.Persistence.Repository/CyclicArray.cs similarity index 99% rename from Persistence.Repository/CyclicArray.cs rename to DD.Persistence.Repository/CyclicArray.cs index 1de7a5b..7a7ea1d 100644 --- a/Persistence.Repository/CyclicArray.cs +++ b/DD.Persistence.Repository/CyclicArray.cs @@ -1,6 +1,6 @@ using System.Collections; -namespace Persistence.Repository; +namespace DD.Persistence.Repository; /// /// Цикличный массив /// diff --git a/Persistence.Repository/Persistence.Repository.csproj b/DD.Persistence.Repository/DD.Persistence.Repository.csproj similarity index 70% rename from Persistence.Repository/Persistence.Repository.csproj rename to DD.Persistence.Repository/DD.Persistence.Repository.csproj index 833fc6f..09ea5a5 100644 --- a/Persistence.Repository/Persistence.Repository.csproj +++ b/DD.Persistence.Repository/DD.Persistence.Repository.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/Persistence.Repository/DependencyInjection.cs b/DD.Persistence.Repository/DependencyInjection.cs similarity index 69% rename from Persistence.Repository/DependencyInjection.cs rename to DD.Persistence.Repository/DependencyInjection.cs index a7db05e..df15095 100644 --- a/Persistence.Repository/DependencyInjection.cs +++ b/DD.Persistence.Repository/DependencyInjection.cs @@ -1,17 +1,22 @@ using Mapster; using Microsoft.Extensions.DependencyInjection; -using Persistence.Database.Model; -using Persistence.Models; -using Persistence.Repositories; -using Persistence.Repository.Repositories; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; +using DD.Persistence.Repositories; +using DD.Persistence.Repository.Repositories; +using DD.Persistence.Database.Entity; +using System.Reflection; -namespace Persistence.Repository; +namespace DD.Persistence.Repository; public static class DependencyInjection { public static void MapsterSetup() { TypeAdapterConfig.GlobalSettings.Default.Config - .ForType() + .ForType() + .Ignore(dest => dest.System, dest => dest.SystemId); + + TypeAdapterConfig.NewConfig() .Map(dest => dest.Value, src => new DataWithWellDepthAndSectionDto() { DepthEnd = src.DepthEnd, @@ -20,11 +25,14 @@ public static class DependencyInjection Value = src.Value, Id = src.Id }); - } public static IServiceCollection AddInfrastructure(this IServiceCollection services) { + var typeAdapterConfig = TypeAdapterConfig.GlobalSettings; + typeAdapterConfig.RuleMap.Clear(); + typeAdapterConfig.Scan(Assembly.GetExecutingAssembly()); + MapsterSetup(); services.AddTransient, TimeSeriesDataRepository>(); diff --git a/Persistence.Repository/Extensions/EFExtensionsSortBy.cs b/DD.Persistence.Repository/Extensions/EFExtensionsSortBy.cs similarity index 99% rename from Persistence.Repository/Extensions/EFExtensionsSortBy.cs rename to DD.Persistence.Repository/Extensions/EFExtensionsSortBy.cs index 97ca992..bdfc8a2 100644 --- a/Persistence.Repository/Extensions/EFExtensionsSortBy.cs +++ b/DD.Persistence.Repository/Extensions/EFExtensionsSortBy.cs @@ -2,7 +2,7 @@ using System.Collections.Concurrent; using System.Linq.Expressions; using System.Reflection; -namespace Persistence.Repository.Extensions; +namespace DD.Persistence.Repository.Extensions; public static class EFExtensionsSortBy { diff --git a/Persistence.Repository/QueryBuilders.cs b/DD.Persistence.Repository/QueryBuilders.cs similarity index 94% rename from Persistence.Repository/QueryBuilders.cs rename to DD.Persistence.Repository/QueryBuilders.cs index a0e17be..6fad2cc 100644 --- a/Persistence.Repository/QueryBuilders.cs +++ b/DD.Persistence.Repository/QueryBuilders.cs @@ -1,9 +1,9 @@ using Microsoft.EntityFrameworkCore; -using Persistence.Database.Model; -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.Repository; +namespace DD.Persistence.Repository; /// /// класс с набором методов, необходимых для фильтрации записей diff --git a/Persistence.Repository/Repositories/ChangeLogRepository.cs b/DD.Persistence.Repository/Repositories/ChangeLogRepository.cs similarity index 97% rename from Persistence.Repository/Repositories/ChangeLogRepository.cs rename to DD.Persistence.Repository/Repositories/ChangeLogRepository.cs index aecb62c..ef57d10 100644 --- a/Persistence.Repository/Repositories/ChangeLogRepository.cs +++ b/DD.Persistence.Repository/Repositories/ChangeLogRepository.cs @@ -1,12 +1,12 @@ using Mapster; using Microsoft.EntityFrameworkCore; -using Persistence.Database.Model; -using Persistence.Models; -using Persistence.Models.Requests; -using Persistence.Repositories; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; +using DD.Persistence.Repositories; using UuidExtensions; -namespace Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.Repositories; public class ChangeLogRepository : IChangeLogRepository { private readonly DbContext db; diff --git a/Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs b/DD.Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs similarity index 94% rename from Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs rename to DD.Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs index 5869992..37009e8 100644 --- a/Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs +++ b/DD.Persistence.Repository/Repositories/DataSourceSystemCachedRepository.cs @@ -1,8 +1,8 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.Repositories; public class DataSourceSystemCachedRepository : DataSourceSystemRepository { private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey"; diff --git a/DD.Persistence.Repository/Repositories/DataSourceSystemRepository.cs b/DD.Persistence.Repository/Repositories/DataSourceSystemRepository.cs new file mode 100644 index 0000000..d8b6c0a --- /dev/null +++ b/DD.Persistence.Repository/Repositories/DataSourceSystemRepository.cs @@ -0,0 +1,33 @@ +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; +using DD.Persistence.Repositories; +using Mapster; +using Microsoft.EntityFrameworkCore; + +namespace DD.Persistence.Repository.Repositories; +public class DataSourceSystemRepository : IDataSourceSystemRepository +{ + protected DbContext db; + public DataSourceSystemRepository(DbContext db) + { + this.db = db; + } + protected virtual IQueryable GetQueryReadOnly() => db.Set(); + + public virtual async Task Add(DataSourceSystemDto dataSourceSystemDto, CancellationToken token) + { + var entity = dataSourceSystemDto.Adapt(); + + await db.Set().AddAsync(entity, token); + await db.SaveChangesAsync(token); + } + + public virtual async Task> Get(CancellationToken token) + { + var query = GetQueryReadOnly(); + var entities = await query.ToArrayAsync(token); + var dtos = entities.Select(e => e.Adapt()); + + return dtos; + } +} diff --git a/Persistence.Repository/Repositories/ParameterRepository.cs b/DD.Persistence.Repository/Repositories/ParameterRepository.cs similarity index 94% rename from Persistence.Repository/Repositories/ParameterRepository.cs rename to DD.Persistence.Repository/Repositories/ParameterRepository.cs index 38f3ef0..434d59f 100644 --- a/Persistence.Repository/Repositories/ParameterRepository.cs +++ b/DD.Persistence.Repository/Repositories/ParameterRepository.cs @@ -1,10 +1,10 @@ using Mapster; using Microsoft.EntityFrameworkCore; -using Persistence.Database.Entity; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.Repositories; public class ParameterRepository : IParameterRepository { private DbContext db; diff --git a/Persistence.Repository/Repositories/SetpointRepository.cs b/DD.Persistence.Repository/Repositories/SetpointRepository.cs similarity index 95% rename from Persistence.Repository/Repositories/SetpointRepository.cs rename to DD.Persistence.Repository/Repositories/SetpointRepository.cs index 800d7fa..f7a719a 100644 --- a/Persistence.Repository/Repositories/SetpointRepository.cs +++ b/DD.Persistence.Repository/Repositories/SetpointRepository.cs @@ -1,10 +1,10 @@ using Mapster; using Microsoft.EntityFrameworkCore; -using Persistence.Database.Model; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.Repository.Repositories +namespace DD.Persistence.Repository.Repositories { public class SetpointRepository : ISetpointRepository { diff --git a/Persistence.Repository/Repositories/TechMessagesRepository.cs b/DD.Persistence.Repository/Repositories/TechMessagesRepository.cs similarity index 96% rename from Persistence.Repository/Repositories/TechMessagesRepository.cs rename to DD.Persistence.Repository/Repositories/TechMessagesRepository.cs index 74aff0a..6bbb382 100644 --- a/Persistence.Repository/Repositories/TechMessagesRepository.cs +++ b/DD.Persistence.Repository/Repositories/TechMessagesRepository.cs @@ -2,13 +2,13 @@ using Mapster; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using Newtonsoft.Json.Linq; -using Persistence.Database.Entity; -using Persistence.Models; -using Persistence.Models.Requests; -using Persistence.Repositories; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; +using DD.Persistence.Repositories; using UuidExtensions; -namespace Persistence.Repository.Repositories +namespace DD.Persistence.Repository.Repositories { public class TechMessagesRepository : ITechMessagesRepository { diff --git a/Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs b/DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs similarity index 96% rename from Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs rename to DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs index 2690c09..768f747 100644 --- a/Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs +++ b/DD.Persistence.Repository/Repositories/TimeSeriesDataCachedRepository.cs @@ -1,8 +1,8 @@ using Microsoft.EntityFrameworkCore; -using Persistence.Database.Model; -using Persistence.Models; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; -namespace Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.Repositories; public class TimeSeriesDataCachedRepository : TimeSeriesDataRepository where TEntity : class, ITimestampedData, new() diff --git a/Persistence.Repository/Repositories/TimeSeriesDataRepository.cs b/DD.Persistence.Repository/Repositories/TimeSeriesDataRepository.cs similarity index 94% rename from Persistence.Repository/Repositories/TimeSeriesDataRepository.cs rename to DD.Persistence.Repository/Repositories/TimeSeriesDataRepository.cs index ba60f27..c4c634b 100644 --- a/Persistence.Repository/Repositories/TimeSeriesDataRepository.cs +++ b/DD.Persistence.Repository/Repositories/TimeSeriesDataRepository.cs @@ -1,10 +1,10 @@ using Mapster; using Microsoft.EntityFrameworkCore; -using Persistence.Database.Model; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Database.Model; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.Repositories; public class TimeSeriesDataRepository : ITimeSeriesDataRepository where TEntity : class, ITimestampedData, new() where TDto : class, ITimeSeriesAbstractDto, new() diff --git a/Persistence.Repository/Repositories/TimestampedSetRepository.cs b/DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs similarity index 96% rename from Persistence.Repository/Repositories/TimestampedSetRepository.cs rename to DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs index 158bfd7..6f54521 100644 --- a/Persistence.Repository/Repositories/TimestampedSetRepository.cs +++ b/DD.Persistence.Repository/Repositories/TimestampedSetRepository.cs @@ -1,9 +1,9 @@ using Microsoft.EntityFrameworkCore; -using Persistence.Database.Entity; -using Persistence.Models; -using Persistence.Repositories; +using DD.Persistence.Database.Entity; +using DD.Persistence.Models; +using DD.Persistence.Repositories; -namespace Persistence.Repository.Repositories; +namespace DD.Persistence.Repository.Repositories; /// /// Репозиторий для хранения разных наборов данных временных рядов. diff --git a/Persistence.sln b/DD.Persistence.sln similarity index 63% rename from Persistence.sln rename to DD.Persistence.sln index a8115a8..22c6b2a 100644 --- a/Persistence.sln +++ b/DD.Persistence.sln @@ -3,19 +3,21 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.9.34714.143 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "Persistence\Persistence.csproj", "{417177AE-A27E-445B-B3B9-D5EFCEC812A0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence", "DD.Persistence\DD.Persistence.csproj", "{417177AE-A27E-445B-B3B9-D5EFCEC812A0}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.API", "Persistence.API\Persistence.API.csproj", "{8650A227-929E-45F0-AEF7-2C91F45FE884}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.API", "DD.Persistence.API\DD.Persistence.API.csproj", "{8650A227-929E-45F0-AEF7-2C91F45FE884}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.Repository", "Persistence.Repository\Persistence.Repository.csproj", "{493D6D92-231B-4CB6-831B-BE13884B0DE4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.Repository", "DD.Persistence.Repository\DD.Persistence.Repository.csproj", "{493D6D92-231B-4CB6-831B-BE13884B0DE4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.Database", "Persistence.Database\Persistence.Database.csproj", "{F77475D1-D074-407A-9D69-2FADDDAE2056}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.Database", "DD.Persistence.Database\DD.Persistence.Database.csproj", "{F77475D1-D074-407A-9D69-2FADDDAE2056}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.IntegrationTests", "Persistence.IntegrationTests\Persistence.IntegrationTests.csproj", "{10752C25-3773-4081-A1F2-215A1D950126}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.IntegrationTests", "DD.Persistence.IntegrationTests\DD.Persistence.IntegrationTests.csproj", "{10752C25-3773-4081-A1F2-215A1D950126}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence.Database.Postgres", "Persistence.Database.Postgres\Persistence.Database.Postgres.csproj", "{CC284D27-162D-490C-B6CF-74D666B7C5F3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.Database.Postgres", "DD.Persistence.Database.Postgres\DD.Persistence.Database.Postgres.csproj", "{CC284D27-162D-490C-B6CF-74D666B7C5F3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Persistence.Client", "Persistence.Client\Persistence.Client.csproj", "{84B68660-48E6-4974-A4E5-517552D9DE23}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.Client", "DD.Persistence.Client\DD.Persistence.Client.csproj", "{84B68660-48E6-4974-A4E5-517552D9DE23}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.App", "DD.Persistence.App\DD.Persistence.App.csproj", "{063238BF-E982-43FA-9DDB-7D7D279086D8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -51,6 +53,10 @@ Global {84B68660-48E6-4974-A4E5-517552D9DE23}.Debug|Any CPU.Build.0 = Debug|Any CPU {84B68660-48E6-4974-A4E5-517552D9DE23}.Release|Any CPU.ActiveCfg = Release|Any CPU {84B68660-48E6-4974-A4E5-517552D9DE23}.Release|Any CPU.Build.0 = Release|Any CPU + {063238BF-E982-43FA-9DDB-7D7D279086D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {063238BF-E982-43FA-9DDB-7D7D279086D8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Persistence/API/IChangeLogApi.cs b/DD.Persistence/API/IChangeLogApi.cs similarity index 97% rename from Persistence/API/IChangeLogApi.cs rename to DD.Persistence/API/IChangeLogApi.cs index 25b5158..e865894 100644 --- a/Persistence/API/IChangeLogApi.cs +++ b/DD.Persistence/API/IChangeLogApi.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Интерфейс для работы с API журнала изменений diff --git a/Persistence/API/ISetpointApi.cs b/DD.Persistence/API/ISetpointApi.cs similarity index 97% rename from Persistence/API/ISetpointApi.cs rename to DD.Persistence/API/ISetpointApi.cs index 9be553e..f600f99 100644 --- a/Persistence/API/ISetpointApi.cs +++ b/DD.Persistence/API/ISetpointApi.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Интерфейс для API, предназначенного для работы с уставками diff --git a/Persistence/API/ISyncApi.cs b/DD.Persistence/API/ISyncApi.cs similarity index 94% rename from Persistence/API/ISyncApi.cs rename to DD.Persistence/API/ISyncApi.cs index e630ee7..5bd8379 100644 --- a/Persistence/API/ISyncApi.cs +++ b/DD.Persistence/API/ISyncApi.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Интерфейс для API, предназначенного для синхронизации данных diff --git a/Persistence/API/ISyncWithDiscriminatorApi.cs b/DD.Persistence/API/ISyncWithDiscriminatorApi.cs similarity index 95% rename from Persistence/API/ISyncWithDiscriminatorApi.cs rename to DD.Persistence/API/ISyncWithDiscriminatorApi.cs index eb74533..05f0a90 100644 --- a/Persistence/API/ISyncWithDiscriminatorApi.cs +++ b/DD.Persistence/API/ISyncWithDiscriminatorApi.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Интерфейс для API, предназначенного для синхронизации данных, у которых есть дискриминатор diff --git a/Persistence/API/ITimeSeriesBaseDataApi.cs b/DD.Persistence/API/ITimeSeriesBaseDataApi.cs similarity index 97% rename from Persistence/API/ITimeSeriesBaseDataApi.cs rename to DD.Persistence/API/ITimeSeriesBaseDataApi.cs index 8f80acb..a16a51d 100644 --- a/Persistence/API/ITimeSeriesBaseDataApi.cs +++ b/DD.Persistence/API/ITimeSeriesBaseDataApi.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Базовый интерфейс для работы с временными рядами diff --git a/Persistence/API/ITimeSeriesDataApi.cs b/DD.Persistence/API/ITimeSeriesDataApi.cs similarity index 93% rename from Persistence/API/ITimeSeriesDataApi.cs rename to DD.Persistence/API/ITimeSeriesDataApi.cs index 9dc39a4..d9b415a 100644 --- a/Persistence/API/ITimeSeriesDataApi.cs +++ b/DD.Persistence/API/ITimeSeriesDataApi.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Интерфейс для работы с API временных данных diff --git a/Persistence/API/IWitsDataApi.cs b/DD.Persistence/API/IWitsDataApi.cs similarity index 94% rename from Persistence/API/IWitsDataApi.cs rename to DD.Persistence/API/IWitsDataApi.cs index 5f41b4b..266c5b0 100644 --- a/Persistence/API/IWitsDataApi.cs +++ b/DD.Persistence/API/IWitsDataApi.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.API; +namespace DD.Persistence.API; /// /// Интерфейс для работы с параметрами Wits diff --git a/Persistence/Persistence.csproj b/DD.Persistence/DD.Persistence.csproj similarity index 91% rename from Persistence/Persistence.csproj rename to DD.Persistence/DD.Persistence.csproj index 3e63047..f43aaa4 100644 --- a/Persistence/Persistence.csproj +++ b/DD.Persistence/DD.Persistence.csproj @@ -4,6 +4,7 @@ net8.0 enable enable + true diff --git a/Persistence/EFExtensions.cs b/DD.Persistence/EFExtensions.cs similarity index 99% rename from Persistence/EFExtensions.cs rename to DD.Persistence/EFExtensions.cs index 425e52a..a308db9 100644 --- a/Persistence/EFExtensions.cs +++ b/DD.Persistence/EFExtensions.cs @@ -2,7 +2,7 @@ using System.Linq.Expressions; using System.Reflection; -namespace Persistence; +namespace DD.Persistence; public static class EFExtensions { struct TypeAccessor diff --git a/Persistence/Factories/IAuthTokenFactory.cs b/DD.Persistence/Factories/IAuthTokenFactory.cs similarity index 86% rename from Persistence/Factories/IAuthTokenFactory.cs rename to DD.Persistence/Factories/IAuthTokenFactory.cs index 2b12095..412565b 100644 --- a/Persistence/Factories/IAuthTokenFactory.cs +++ b/DD.Persistence/Factories/IAuthTokenFactory.cs @@ -1,4 +1,4 @@ -namespace Persistence.Factories; +namespace DD.Persistence.Factories; /// /// Фабрика токенов аутентификации diff --git a/Persistence/Models/ChangeLogDto.cs b/DD.Persistence/Models/ChangeLogDto.cs similarity index 96% rename from Persistence/Models/ChangeLogDto.cs rename to DD.Persistence/Models/ChangeLogDto.cs index d42d659..8f2725b 100644 --- a/Persistence/Models/ChangeLogDto.cs +++ b/DD.Persistence/Models/ChangeLogDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Часть записи описывающая изменение diff --git a/Persistence/Models/Configurations/AuthUser.cs b/DD.Persistence/Models/Configurations/AuthUser.cs similarity index 86% rename from Persistence/Models/Configurations/AuthUser.cs rename to DD.Persistence/Models/Configurations/AuthUser.cs index 94f65b7..6287c7f 100644 --- a/Persistence/Models/Configurations/AuthUser.cs +++ b/DD.Persistence/Models/Configurations/AuthUser.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models.Configurations; +namespace DD.Persistence.Models.Configurations; /// /// Настройки credentials для авторизации diff --git a/Persistence/Models/Configurations/JwtParams.cs b/DD.Persistence/Models/Configurations/JwtParams.cs similarity index 91% rename from Persistence/Models/Configurations/JwtParams.cs rename to DD.Persistence/Models/Configurations/JwtParams.cs index 44436ed..767094f 100644 --- a/Persistence/Models/Configurations/JwtParams.cs +++ b/DD.Persistence/Models/Configurations/JwtParams.cs @@ -1,7 +1,7 @@ using Microsoft.IdentityModel.Tokens; using System.Text; -namespace Persistence.Models.Configurations +namespace DD.Persistence.Models.Configurations { public static class JwtParams { diff --git a/Persistence/Models/Configurations/JwtToken.cs b/DD.Persistence/Models/Configurations/JwtToken.cs similarity index 79% rename from Persistence/Models/Configurations/JwtToken.cs rename to DD.Persistence/Models/Configurations/JwtToken.cs index ff19aa9..0e9b066 100644 --- a/Persistence/Models/Configurations/JwtToken.cs +++ b/DD.Persistence/Models/Configurations/JwtToken.cs @@ -1,6 +1,6 @@ using System.Text.Json.Serialization; -namespace Persistence.Models.Configurations +namespace DD.Persistence.Models.Configurations { public class JwtToken { diff --git a/Persistence/Models/Configurations/WitsInfo.cs b/DD.Persistence/Models/Configurations/WitsInfo.cs similarity index 68% rename from Persistence/Models/Configurations/WitsInfo.cs rename to DD.Persistence/Models/Configurations/WitsInfo.cs index 76b2a51..26e473f 100644 --- a/Persistence/Models/Configurations/WitsInfo.cs +++ b/DD.Persistence/Models/Configurations/WitsInfo.cs @@ -1,6 +1,6 @@ -using Persistence.Models.Enumerations; +using DD.Persistence.Models.Enumerations; -namespace Persistence.Models.Configurations; +namespace DD.Persistence.Models.Configurations; /// /// Протокол Wits diff --git a/Persistence/Models/DataSaubDto.cs b/DD.Persistence/Models/DataSaubDto.cs similarity index 96% rename from Persistence/Models/DataSaubDto.cs rename to DD.Persistence/Models/DataSaubDto.cs index cd547da..34306d9 100644 --- a/Persistence/Models/DataSaubDto.cs +++ b/DD.Persistence/Models/DataSaubDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; public class DataSaubDto : ITimeSeriesAbstractDto { public DateTimeOffset Date { get; set; } = DateTimeOffset.UtcNow; diff --git a/Persistence/Models/DataSourceSystemDto.cs b/DD.Persistence/Models/DataSourceSystemDto.cs similarity index 93% rename from Persistence/Models/DataSourceSystemDto.cs rename to DD.Persistence/Models/DataSourceSystemDto.cs index 56df611..4abe706 100644 --- a/Persistence/Models/DataSourceSystemDto.cs +++ b/DD.Persistence/Models/DataSourceSystemDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Модель системы - источника данных diff --git a/Persistence/Models/DataWithWellDepthAndSectionDto.cs b/DD.Persistence/Models/DataWithWellDepthAndSectionDto.cs similarity index 96% rename from Persistence/Models/DataWithWellDepthAndSectionDto.cs rename to DD.Persistence/Models/DataWithWellDepthAndSectionDto.cs index 033ddb8..7644229 100644 --- a/Persistence/Models/DataWithWellDepthAndSectionDto.cs +++ b/DD.Persistence/Models/DataWithWellDepthAndSectionDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Dto для хранения записей, содержащих начальную и конечную глубину забоя, а также секцию diff --git a/Persistence/Models/DatesRangeDto.cs b/DD.Persistence/Models/DatesRangeDto.cs similarity index 90% rename from Persistence/Models/DatesRangeDto.cs rename to DD.Persistence/Models/DatesRangeDto.cs index 1df7369..0a764ce 100644 --- a/Persistence/Models/DatesRangeDto.cs +++ b/DD.Persistence/Models/DatesRangeDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Диапазон дат diff --git a/Persistence/Models/Enumerations/EventState.cs b/DD.Persistence/Models/Enumerations/EventState.cs similarity index 55% rename from Persistence/Models/Enumerations/EventState.cs rename to DD.Persistence/Models/Enumerations/EventState.cs index 3f4103c..ab7efa8 100644 --- a/Persistence/Models/Enumerations/EventState.cs +++ b/DD.Persistence/Models/Enumerations/EventState.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models.Enumerations; +namespace DD.Persistence.Models.Enumerations; public enum EventState { NotTriggered = 0, diff --git a/Persistence/Models/Enumerations/WitsType.cs b/DD.Persistence/Models/Enumerations/WitsType.cs similarity index 90% rename from Persistence/Models/Enumerations/WitsType.cs rename to DD.Persistence/Models/Enumerations/WitsType.cs index 888e237..59c9117 100644 --- a/Persistence/Models/Enumerations/WitsType.cs +++ b/DD.Persistence/Models/Enumerations/WitsType.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models.Enumerations; +namespace DD.Persistence.Models.Enumerations; /// /// WITS Data Type Codes diff --git a/Persistence/Models/ITimeSeriesAbstractDto.cs b/DD.Persistence/Models/ITimeSeriesAbstractDto.cs similarity index 88% rename from Persistence/Models/ITimeSeriesAbstractDto.cs rename to DD.Persistence/Models/ITimeSeriesAbstractDto.cs index 39a29cf..b01c104 100644 --- a/Persistence/Models/ITimeSeriesAbstractDto.cs +++ b/DD.Persistence/Models/ITimeSeriesAbstractDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Интерфейс, описывающий временные данные diff --git a/Persistence/Models/IWithSectionPart.cs b/DD.Persistence/Models/IWithSectionPart.cs similarity index 82% rename from Persistence/Models/IWithSectionPart.cs rename to DD.Persistence/Models/IWithSectionPart.cs index adb5fdd..8b3fbaf 100644 --- a/Persistence/Models/IWithSectionPart.cs +++ b/DD.Persistence/Models/IWithSectionPart.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; public interface IWithSectionPart { public double DepthStart { get; set; } diff --git a/Persistence/Models/MessagesStatisticDto.cs b/DD.Persistence/Models/MessagesStatisticDto.cs similarity index 93% rename from Persistence/Models/MessagesStatisticDto.cs rename to DD.Persistence/Models/MessagesStatisticDto.cs index 2e1e419..1a8d984 100644 --- a/Persistence/Models/MessagesStatisticDto.cs +++ b/DD.Persistence/Models/MessagesStatisticDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Статистика сообщений по системам бурения diff --git a/Persistence/Models/PaginationContainer.cs b/DD.Persistence/Models/PaginationContainer.cs similarity index 96% rename from Persistence/Models/PaginationContainer.cs rename to DD.Persistence/Models/PaginationContainer.cs index 7054b2c..89306f8 100644 --- a/Persistence/Models/PaginationContainer.cs +++ b/DD.Persistence/Models/PaginationContainer.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Контейнер для поддержки постраничного просмотра таблиц diff --git a/Persistence/Models/ParameterDto.cs b/DD.Persistence/Models/ParameterDto.cs similarity index 96% rename from Persistence/Models/ParameterDto.cs rename to DD.Persistence/Models/ParameterDto.cs index 9413a79..fbc3beb 100644 --- a/Persistence/Models/ParameterDto.cs +++ b/DD.Persistence/Models/ParameterDto.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Модель параметра diff --git a/Persistence/Models/Requests/PaginationRequest.cs b/DD.Persistence/Models/Requests/PaginationRequest.cs similarity index 95% rename from Persistence/Models/Requests/PaginationRequest.cs rename to DD.Persistence/Models/Requests/PaginationRequest.cs index d9974cd..2aca196 100644 --- a/Persistence/Models/Requests/PaginationRequest.cs +++ b/DD.Persistence/Models/Requests/PaginationRequest.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models.Requests; +namespace DD.Persistence.Models.Requests; /// /// Контейнер для поддержки постраничного просмотра таблиц diff --git a/Persistence/Models/Requests/SectionPartRequest.cs b/DD.Persistence/Models/Requests/SectionPartRequest.cs similarity index 92% rename from Persistence/Models/Requests/SectionPartRequest.cs rename to DD.Persistence/Models/Requests/SectionPartRequest.cs index 3eca015..73319c6 100644 --- a/Persistence/Models/Requests/SectionPartRequest.cs +++ b/DD.Persistence/Models/Requests/SectionPartRequest.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models.Requests; +namespace DD.Persistence.Models.Requests; /// /// Запрос для фильтрации данных по секции и глубине diff --git a/Persistence/Models/SetpointLogDto.cs b/DD.Persistence/Models/SetpointLogDto.cs similarity index 92% rename from Persistence/Models/SetpointLogDto.cs rename to DD.Persistence/Models/SetpointLogDto.cs index 663bf30..9a46a99 100644 --- a/Persistence/Models/SetpointLogDto.cs +++ b/DD.Persistence/Models/SetpointLogDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Модель для описания лога уставки diff --git a/Persistence/Models/SetpointValueDto.cs b/DD.Persistence/Models/SetpointValueDto.cs similarity index 92% rename from Persistence/Models/SetpointValueDto.cs rename to DD.Persistence/Models/SetpointValueDto.cs index 4cae4ff..6d24b0d 100644 --- a/Persistence/Models/SetpointValueDto.cs +++ b/DD.Persistence/Models/SetpointValueDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Модель для хранения значения уставки diff --git a/Persistence/Models/TechMessageDto.cs b/DD.Persistence/Models/TechMessageDto.cs similarity index 93% rename from Persistence/Models/TechMessageDto.cs rename to DD.Persistence/Models/TechMessageDto.cs index e076443..254129a 100644 --- a/Persistence/Models/TechMessageDto.cs +++ b/DD.Persistence/Models/TechMessageDto.cs @@ -1,7 +1,7 @@ using System.ComponentModel.DataAnnotations; -using Persistence.Models.Enumerations; +using DD.Persistence.Models.Enumerations; -namespace Persistence.Models +namespace DD.Persistence.Models { /// /// Модель технологического сообщения diff --git a/Persistence/Models/TimestampedSetDto.cs b/DD.Persistence/Models/TimestampedSetDto.cs similarity index 89% rename from Persistence/Models/TimestampedSetDto.cs rename to DD.Persistence/Models/TimestampedSetDto.cs index 3235a4e..cf72032 100644 --- a/Persistence/Models/TimestampedSetDto.cs +++ b/DD.Persistence/Models/TimestampedSetDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// набор данных с отметкой времени diff --git a/Persistence/Models/WitsDataDto.cs b/DD.Persistence/Models/WitsDataDto.cs similarity index 93% rename from Persistence/Models/WitsDataDto.cs rename to DD.Persistence/Models/WitsDataDto.cs index 982df1f..5aa64f3 100644 --- a/Persistence/Models/WitsDataDto.cs +++ b/DD.Persistence/Models/WitsDataDto.cs @@ -1,4 +1,4 @@ -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Группа параметров Wits diff --git a/Persistence/Models/WitsValueDto.cs b/DD.Persistence/Models/WitsValueDto.cs similarity index 95% rename from Persistence/Models/WitsValueDto.cs rename to DD.Persistence/Models/WitsValueDto.cs index dcbd1cb..0cbaed0 100644 --- a/Persistence/Models/WitsValueDto.cs +++ b/DD.Persistence/Models/WitsValueDto.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace Persistence.Models; +namespace DD.Persistence.Models; /// /// Параметр Wits diff --git a/Persistence/Repositories/IChangeLogRepository.cs b/DD.Persistence/Repositories/IChangeLogRepository.cs similarity index 97% rename from Persistence/Repositories/IChangeLogRepository.cs rename to DD.Persistence/Repositories/IChangeLogRepository.cs index e197090..41dd379 100644 --- a/Persistence/Repositories/IChangeLogRepository.cs +++ b/DD.Persistence/Repositories/IChangeLogRepository.cs @@ -1,7 +1,7 @@ -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс для работы с историческими данными diff --git a/Persistence/Repositories/IDataSourceSystemRepository.cs b/DD.Persistence/Repositories/IDataSourceSystemRepository.cs similarity index 89% rename from Persistence/Repositories/IDataSourceSystemRepository.cs rename to DD.Persistence/Repositories/IDataSourceSystemRepository.cs index d6cf29c..ce674d6 100644 --- a/Persistence/Repositories/IDataSourceSystemRepository.cs +++ b/DD.Persistence/Repositories/IDataSourceSystemRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с системами - источниками данных diff --git a/Persistence/Repositories/IParameterRepository.cs b/DD.Persistence/Repositories/IParameterRepository.cs similarity index 95% rename from Persistence/Repositories/IParameterRepository.cs rename to DD.Persistence/Repositories/IParameterRepository.cs index 6345708..53c48c3 100644 --- a/Persistence/Repositories/IParameterRepository.cs +++ b/DD.Persistence/Repositories/IParameterRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; public interface IParameterRepository { /// diff --git a/Persistence/Repositories/ISetpointRepository.cs b/DD.Persistence/Repositories/ISetpointRepository.cs similarity index 97% rename from Persistence/Repositories/ISetpointRepository.cs rename to DD.Persistence/Repositories/ISetpointRepository.cs index 272c9ec..0af805d 100644 --- a/Persistence/Repositories/ISetpointRepository.cs +++ b/DD.Persistence/Repositories/ISetpointRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с уставками diff --git a/Persistence/Repositories/ISyncRepository.cs b/DD.Persistence/Repositories/ISyncRepository.cs similarity index 91% rename from Persistence/Repositories/ISyncRepository.cs rename to DD.Persistence/Repositories/ISyncRepository.cs index 5a5c9be..10c21f2 100644 --- a/Persistence/Repositories/ISyncRepository.cs +++ b/DD.Persistence/Repositories/ISyncRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с данными diff --git a/Persistence/Repositories/ISyncWithDiscriminatorRepository.cs b/DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs similarity index 93% rename from Persistence/Repositories/ISyncWithDiscriminatorRepository.cs rename to DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs index 7e0bd62..e761c8a 100644 --- a/Persistence/Repositories/ISyncWithDiscriminatorRepository.cs +++ b/DD.Persistence/Repositories/ISyncWithDiscriminatorRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с данными, у которых есть дискриминатор diff --git a/Persistence/Repositories/ITechMessagesRepository.cs b/DD.Persistence/Repositories/ITechMessagesRepository.cs similarity index 95% rename from Persistence/Repositories/ITechMessagesRepository.cs rename to DD.Persistence/Repositories/ITechMessagesRepository.cs index ebb7563..9909106 100644 --- a/Persistence/Repositories/ITechMessagesRepository.cs +++ b/DD.Persistence/Repositories/ITechMessagesRepository.cs @@ -1,7 +1,7 @@ -using Persistence.Models; -using Persistence.Models.Requests; +using DD.Persistence.Models; +using DD.Persistence.Models.Requests; -namespace Persistence.Repositories +namespace DD.Persistence.Repositories { /// /// Интерфейс по работе с технологическими сообщениями diff --git a/Persistence/Repositories/ITimeSeriesBaseRepository.cs b/DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs similarity index 93% rename from Persistence/Repositories/ITimeSeriesBaseRepository.cs rename to DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs index abe6b05..0d5e531 100644 --- a/Persistence/Repositories/ITimeSeriesBaseRepository.cs +++ b/DD.Persistence/Repositories/ITimeSeriesBaseRepository.cs @@ -1,4 +1,4 @@ -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с прореженными данными diff --git a/Persistence/Repositories/ITimeSeriesDataRepository.cs b/DD.Persistence/Repositories/ITimeSeriesDataRepository.cs similarity index 88% rename from Persistence/Repositories/ITimeSeriesDataRepository.cs rename to DD.Persistence/Repositories/ITimeSeriesDataRepository.cs index aa2c9ff..ed05980 100644 --- a/Persistence/Repositories/ITimeSeriesDataRepository.cs +++ b/DD.Persistence/Repositories/ITimeSeriesDataRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Интерфейс по работе с временными данными diff --git a/Persistence/Repositories/ITimestampedSetRepository.cs b/DD.Persistence/Repositories/ITimestampedSetRepository.cs similarity index 97% rename from Persistence/Repositories/ITimestampedSetRepository.cs rename to DD.Persistence/Repositories/ITimestampedSetRepository.cs index c350739..cefbb3e 100644 --- a/Persistence/Repositories/ITimestampedSetRepository.cs +++ b/DD.Persistence/Repositories/ITimestampedSetRepository.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Repositories; +namespace DD.Persistence.Repositories; /// /// Репозиторий для хранения разных наборов данных рядов. diff --git a/Persistence/Services/Config/WitsConfig.json b/DD.Persistence/Services/Config/WitsConfig.json similarity index 100% rename from Persistence/Services/Config/WitsConfig.json rename to DD.Persistence/Services/Config/WitsConfig.json diff --git a/Persistence/Services/Interfaces/IArchiveService.cs b/DD.Persistence/Services/Interfaces/IArchiveService.cs similarity index 93% rename from Persistence/Services/Interfaces/IArchiveService.cs rename to DD.Persistence/Services/Interfaces/IArchiveService.cs index 73abf3f..9829e21 100644 --- a/Persistence/Services/Interfaces/IArchiveService.cs +++ b/DD.Persistence/Services/Interfaces/IArchiveService.cs @@ -1,4 +1,4 @@ -namespace Persistence.Services.Interfaces; +namespace DD.Persistence.Services.Interfaces; /// /// Сервис по работе с БД diff --git a/Persistence/Services/Interfaces/IWitsDataService.cs b/DD.Persistence/Services/Interfaces/IWitsDataService.cs similarity index 95% rename from Persistence/Services/Interfaces/IWitsDataService.cs rename to DD.Persistence/Services/Interfaces/IWitsDataService.cs index 68c5851..3a18da9 100644 --- a/Persistence/Services/Interfaces/IWitsDataService.cs +++ b/DD.Persistence/Services/Interfaces/IWitsDataService.cs @@ -1,6 +1,6 @@ -using Persistence.Models; +using DD.Persistence.Models; -namespace Persistence.Services.Interfaces; +namespace DD.Persistence.Services.Interfaces; /// /// Сервис для работы с параметрами Wits diff --git a/Persistence/Services/WitsDataService.cs b/DD.Persistence/Services/WitsDataService.cs similarity index 93% rename from Persistence/Services/WitsDataService.cs rename to DD.Persistence/Services/WitsDataService.cs index 100bf56..bcee812 100644 --- a/Persistence/Services/WitsDataService.cs +++ b/DD.Persistence/Services/WitsDataService.cs @@ -1,13 +1,13 @@ -using Persistence.Models; -using Persistence.Models.Configurations; -using Persistence.Models.Enumerations; -using Persistence.Repositories; -using Persistence.Services.Interfaces; +using DD.Persistence.Models; +using DD.Persistence.Models.Configurations; +using DD.Persistence.Models.Enumerations; +using DD.Persistence.Repositories; +using DD.Persistence.Services.Interfaces; using System.Globalization; using System.Text.Json; using System.Text.Json.Serialization; -namespace Persistence.Services; +namespace DD.Persistence.Services; public class WitsDataService : IWitsDataService { private readonly IParameterRepository witsDataRepository; @@ -15,7 +15,7 @@ public class WitsDataService : IWitsDataService private readonly WitsInfo[] witsInfo; private const int multiplier = 1000; - private const string witsConfigPath = "Persistence.Services.Config.WitsConfig.json"; + private const string witsConfigPath = "DD.Persistence.Services.Config.WitsConfig.json"; public WitsDataService(IParameterRepository witsDataRepository) { diff --git a/Persistence.Client/Persistence.Client.csproj b/Persistence.Client/Persistence.Client.csproj deleted file mode 100644 index 7d81fc3..0000000 --- a/Persistence.Client/Persistence.Client.csproj +++ /dev/null @@ -1,62 +0,0 @@ - - - - net8.0 - enable - enable - - - True - - Persistence.Client - - 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) - - 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) - - Persistence.Client - - - Digital Drilling - - Digital Drilling - - Пакет для получения клиентов для работы с Persistence сервисом - - - https://git.ddrilling.ru/on.nemtina/persistence.git - - git - - true - - snupkg - - C:\Projects\Nuget - - - Readme.md - - - - 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) - 1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)) - - - - - - - - - - - - - - - - - - - diff --git a/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs b/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs deleted file mode 100644 index fac75d8..0000000 --- a/Persistence.Database.Postgres/Migrations/20241118052225_SetpointMigration.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - /// - public partial class SetpointMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Setpoint", - columns: table => new - { - Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), - Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата изменения уставки"), - Value = table.Column(type: "jsonb", nullable: false, comment: "Значение уставки"), - IdUser = table.Column(type: "uuid", nullable: false, comment: "Id автора последнего изменения") - }, - constraints: table => - { - table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Setpoint"); - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs b/Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs deleted file mode 100644 index c17da2b..0000000 --- a/Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.Designer.cs +++ /dev/null @@ -1,169 +0,0 @@ -// -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Persistence.Database.Model; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - [DbContext(typeof(PersistenceDbContext))] - [Migration("20241126071115_Add_ChangeLog")] - partial class Add_ChangeLog - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Russian_Russia.1251") - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Persistence.Database.Model.ChangeLog", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasColumnName("Id"); - - b.Property("Creation") - .HasColumnType("timestamp with time zone") - .HasColumnName("Creation"); - - b.Property("DepthEnd") - .HasColumnType("double precision") - .HasColumnName("DepthEnd"); - - b.Property("DepthStart") - .HasColumnType("double precision") - .HasColumnName("DepthStart"); - - b.Property("IdAuthor") - .HasColumnType("uuid") - .HasColumnName("IdAuthor"); - - b.Property("IdDiscriminator") - .HasColumnType("uuid") - .HasColumnName("IdDiscriminator"); - - b.Property("IdEditor") - .HasColumnType("uuid") - .HasColumnName("IdEditor"); - - b.Property("IdNext") - .HasColumnType("uuid") - .HasColumnName("IdNext"); - - b.Property("IdSection") - .HasColumnType("uuid") - .HasColumnName("IdSection"); - - b.Property("Obsolete") - .HasColumnType("timestamp with time zone") - .HasColumnName("Obsolete"); - - b.Property>("Value") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("Value"); - - b.HasKey("Id"); - - b.ToTable("ChangeLog"); - }); - - modelBuilder.Entity("Persistence.Database.Model.DataSaub", b => - { - b.Property("Date") - .HasColumnType("timestamp with time zone") - .HasColumnName("date"); - - b.Property("AxialLoad") - .HasColumnType("double precision") - .HasColumnName("axialLoad"); - - b.Property("BitDepth") - .HasColumnType("double precision") - .HasColumnName("bitDepth"); - - b.Property("BlockPosition") - .HasColumnType("double precision") - .HasColumnName("blockPosition"); - - b.Property("BlockSpeed") - .HasColumnType("double precision") - .HasColumnName("blockSpeed"); - - b.Property("Flow") - .HasColumnType("double precision") - .HasColumnName("flow"); - - b.Property("HookWeight") - .HasColumnType("double precision") - .HasColumnName("hookWeight"); - - b.Property("IdFeedRegulator") - .HasColumnType("integer") - .HasColumnName("idFeedRegulator"); - - b.Property("Mode") - .HasColumnType("integer") - .HasColumnName("mode"); - - b.Property("Mse") - .HasColumnType("double precision") - .HasColumnName("mse"); - - b.Property("MseState") - .HasColumnType("smallint") - .HasColumnName("mseState"); - - b.Property("Pressure") - .HasColumnType("double precision") - .HasColumnName("pressure"); - - b.Property("Pump0Flow") - .HasColumnType("double precision") - .HasColumnName("pump0Flow"); - - b.Property("Pump1Flow") - .HasColumnType("double precision") - .HasColumnName("pump1Flow"); - - b.Property("Pump2Flow") - .HasColumnType("double precision") - .HasColumnName("pump2Flow"); - - b.Property("RotorSpeed") - .HasColumnType("double precision") - .HasColumnName("rotorSpeed"); - - b.Property("RotorTorque") - .HasColumnType("double precision") - .HasColumnName("rotorTorque"); - - b.Property("User") - .HasColumnType("text") - .HasColumnName("user"); - - b.Property("WellDepth") - .HasColumnType("double precision") - .HasColumnName("wellDepth"); - - b.HasKey("Date"); - - b.ToTable("DataSaub"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs b/Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs deleted file mode 100644 index 4750bc3..0000000 --- a/Persistence.Database.Postgres/Migrations/20241126071115_Add_ChangeLog.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - /// - public partial class Add_ChangeLog : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ChangeLog", - columns: table => new - { - Id = table.Column(type: "uuid", nullable: false), - IdDiscriminator = table.Column(type: "uuid", nullable: false), - IdAuthor = table.Column(type: "uuid", nullable: false), - IdEditor = table.Column(type: "uuid", nullable: true), - Creation = table.Column(type: "timestamp with time zone", nullable: false), - Obsolete = table.Column(type: "timestamp with time zone", nullable: true), - IdNext = table.Column(type: "uuid", nullable: true), - DepthStart = table.Column(type: "double precision", nullable: false), - DepthEnd = table.Column(type: "double precision", nullable: false), - IdSection = table.Column(type: "uuid", nullable: false), - Value = table.Column>(type: "jsonb", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ChangeLog", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ChangeLog"); - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs b/Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs deleted file mode 100644 index e461173..0000000 --- a/Persistence.Database.Postgres/Migrations/20241126100631_Init.Designer.cs +++ /dev/null @@ -1,162 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Persistence.Database.Model; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - [DbContext(typeof(PersistencePostgresContext))] - [Migration("20241126100631_Init")] - partial class Init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Russian_Russia.1251") - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Persistence.Database.Entity.TimestampedSet", b => - { - b.Property("IdDiscriminator") - .HasColumnType("uuid") - .HasComment("Дискриминатор ссылка на тип сохраняемых данных"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Отметка времени, строго в UTC"); - - b.Property("Set") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Набор сохраняемых данных"); - - b.HasKey("IdDiscriminator", "Timestamp"); - - b.ToTable("TimestampedSets", t => - { - t.HasComment("Общая таблица данных временных рядов"); - }); - }); - - modelBuilder.Entity("Persistence.Database.Model.DataSaub", b => - { - b.Property("Date") - .HasColumnType("timestamp with time zone") - .HasColumnName("date"); - - b.Property("AxialLoad") - .HasColumnType("double precision") - .HasColumnName("axialLoad"); - - b.Property("BitDepth") - .HasColumnType("double precision") - .HasColumnName("bitDepth"); - - b.Property("BlockPosition") - .HasColumnType("double precision") - .HasColumnName("blockPosition"); - - b.Property("BlockSpeed") - .HasColumnType("double precision") - .HasColumnName("blockSpeed"); - - b.Property("Flow") - .HasColumnType("double precision") - .HasColumnName("flow"); - - b.Property("HookWeight") - .HasColumnType("double precision") - .HasColumnName("hookWeight"); - - b.Property("IdFeedRegulator") - .HasColumnType("integer") - .HasColumnName("idFeedRegulator"); - - b.Property("Mode") - .HasColumnType("integer") - .HasColumnName("mode"); - - b.Property("Mse") - .HasColumnType("double precision") - .HasColumnName("mse"); - - b.Property("MseState") - .HasColumnType("smallint") - .HasColumnName("mseState"); - - b.Property("Pressure") - .HasColumnType("double precision") - .HasColumnName("pressure"); - - b.Property("Pump0Flow") - .HasColumnType("double precision") - .HasColumnName("pump0Flow"); - - b.Property("Pump1Flow") - .HasColumnType("double precision") - .HasColumnName("pump1Flow"); - - b.Property("Pump2Flow") - .HasColumnType("double precision") - .HasColumnName("pump2Flow"); - - b.Property("RotorSpeed") - .HasColumnType("double precision") - .HasColumnName("rotorSpeed"); - - b.Property("RotorTorque") - .HasColumnType("double precision") - .HasColumnName("rotorTorque"); - - b.Property("User") - .HasColumnType("text") - .HasColumnName("user"); - - b.Property("WellDepth") - .HasColumnType("double precision") - .HasColumnName("wellDepth"); - - b.HasKey("Date"); - - b.ToTable("DataSaub"); - }); - - modelBuilder.Entity("Persistence.Database.Model.Setpoint", b => - { - b.Property("Key") - .HasColumnType("uuid") - .HasComment("Ключ"); - - b.Property("Created") - .HasColumnType("timestamp with time zone") - .HasComment("Дата создания уставки"); - - b.Property("IdUser") - .HasColumnType("integer") - .HasComment("Id автора последнего изменения"); - - b.Property("Value") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Значение уставки"); - - b.HasKey("Key", "Created"); - - b.ToTable("Setpoint"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241126100631_Init.cs b/Persistence.Database.Postgres/Migrations/20241126100631_Init.cs deleted file mode 100644 index 74a549e..0000000 --- a/Persistence.Database.Postgres/Migrations/20241126100631_Init.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - /// - public partial class Init : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterDatabase() - .Annotation("Npgsql:PostgresExtension:adminpack", ",,"); - - migrationBuilder.CreateTable( - name: "DataSaub", - columns: table => new - { - date = table.Column(type: "timestamp with time zone", nullable: false), - mode = table.Column(type: "integer", nullable: true), - user = table.Column(type: "text", nullable: true), - wellDepth = table.Column(type: "double precision", nullable: true), - bitDepth = table.Column(type: "double precision", nullable: true), - blockPosition = table.Column(type: "double precision", nullable: true), - blockSpeed = table.Column(type: "double precision", nullable: true), - pressure = table.Column(type: "double precision", nullable: true), - axialLoad = table.Column(type: "double precision", nullable: true), - hookWeight = table.Column(type: "double precision", nullable: true), - rotorTorque = table.Column(type: "double precision", nullable: true), - rotorSpeed = table.Column(type: "double precision", nullable: true), - flow = table.Column(type: "double precision", nullable: true), - mseState = table.Column(type: "smallint", nullable: false), - idFeedRegulator = table.Column(type: "integer", nullable: false), - mse = table.Column(type: "double precision", nullable: true), - pump0Flow = table.Column(type: "double precision", nullable: true), - pump1Flow = table.Column(type: "double precision", nullable: true), - pump2Flow = table.Column(type: "double precision", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_DataSaub", x => x.date); - }); - - migrationBuilder.CreateTable( - name: "Setpoint", - columns: table => new - { - Key = table.Column(type: "uuid", nullable: false, comment: "Ключ"), - Created = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"), - Value = table.Column(type: "jsonb", nullable: false, comment: "Значение уставки"), - IdUser = table.Column(type: "integer", nullable: false, comment: "Id автора последнего изменения") - }, - constraints: table => - { - table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created }); - }); - - migrationBuilder.CreateTable( - name: "TimestampedSets", - columns: table => new - { - IdDiscriminator = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Отметка времени, строго в UTC"), - Set = table.Column(type: "jsonb", nullable: false, comment: "Набор сохраняемых данных") - }, - constraints: table => - { - table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp }); - }, - comment: "Общая таблица данных временных рядов"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DataSaub"); - - migrationBuilder.DropTable( - name: "Setpoint"); - - migrationBuilder.DropTable( - name: "TimestampedSets"); - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs b/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs deleted file mode 100644 index c0f01fc..0000000 --- a/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.Designer.cs +++ /dev/null @@ -1,257 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Persistence.Database.Model; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - [DbContext(typeof(PersistenceDbContext))] - [Migration("20241203120141_ParameterDataMigration")] - partial class ParameterDataMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .UseCollation("Russian_Russia.1251") - .HasAnnotation("ProductVersion", "8.0.10") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack"); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Persistence.Database.Entity.DrillingSystem", b => - { - b.Property("SystemId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasComment("Id системы автобурения"); - - b.Property("Description") - .HasColumnType("text") - .HasComment("Описание системы автобурения"); - - b.Property("Name") - .IsRequired() - .HasColumnType("varchar(256)") - .HasComment("Наименование системы автобурения"); - - b.HasKey("SystemId"); - - b.ToTable("DrillingSystem"); - }); - - modelBuilder.Entity("Persistence.Database.Entity.ParameterData", b => - { - b.Property("DiscriminatorId") - .HasColumnType("integer") - .HasComment("Дискриминатор системы"); - - b.Property("ParameterId") - .HasColumnType("integer") - .HasComment("Id параметра"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Временная отметка"); - - b.Property("Value") - .IsRequired() - .HasColumnType("varchar(256)") - .HasComment("Значение параметра в виде строки"); - - b.HasKey("DiscriminatorId", "ParameterId", "Timestamp"); - - b.ToTable("ParameterData"); - }); - - modelBuilder.Entity("Persistence.Database.Entity.TechMessage", b => - { - b.Property("EventId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid") - .HasComment("Id события"); - - b.Property("CategoryId") - .HasColumnType("integer") - .HasComment("Id Категории важности"); - - b.Property("Depth") - .HasColumnType("double precision") - .HasComment("Глубина забоя"); - - b.Property("MessageText") - .IsRequired() - .HasColumnType("varchar(512)") - .HasComment("Текст сообщения"); - - b.Property("SystemId") - .HasColumnType("uuid") - .HasComment("Id системы автобурения, к которой относится сообщение"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Дата возникновения"); - - b.Property("UserId") - .HasColumnType("uuid") - .HasComment("Id пользователя за пультом бурильщика"); - - b.HasKey("EventId"); - - b.HasIndex("SystemId"); - - b.ToTable("TechMessage"); - }); - - modelBuilder.Entity("Persistence.Database.Entity.TimestampedSet", b => - { - b.Property("IdDiscriminator") - .HasColumnType("uuid") - .HasComment("Дискриминатор ссылка на тип сохраняемых данных"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone") - .HasComment("Отметка времени, строго в UTC"); - - b.Property("Set") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Набор сохраняемых данных"); - - b.HasKey("IdDiscriminator", "Timestamp"); - - b.ToTable("TimestampedSets", t => - { - t.HasComment("Общая таблица данных временных рядов"); - }); - }); - - modelBuilder.Entity("Persistence.Database.Model.DataSaub", b => - { - b.Property("Date") - .HasColumnType("timestamp with time zone") - .HasColumnName("date"); - - b.Property("AxialLoad") - .HasColumnType("double precision") - .HasColumnName("axialLoad"); - - b.Property("BitDepth") - .HasColumnType("double precision") - .HasColumnName("bitDepth"); - - b.Property("BlockPosition") - .HasColumnType("double precision") - .HasColumnName("blockPosition"); - - b.Property("BlockSpeed") - .HasColumnType("double precision") - .HasColumnName("blockSpeed"); - - b.Property("Flow") - .HasColumnType("double precision") - .HasColumnName("flow"); - - b.Property("HookWeight") - .HasColumnType("double precision") - .HasColumnName("hookWeight"); - - b.Property("IdFeedRegulator") - .HasColumnType("integer") - .HasColumnName("idFeedRegulator"); - - b.Property("Mode") - .HasColumnType("integer") - .HasColumnName("mode"); - - b.Property("Mse") - .HasColumnType("double precision") - .HasColumnName("mse"); - - b.Property("MseState") - .HasColumnType("smallint") - .HasColumnName("mseState"); - - b.Property("Pressure") - .HasColumnType("double precision") - .HasColumnName("pressure"); - - b.Property("Pump0Flow") - .HasColumnType("double precision") - .HasColumnName("pump0Flow"); - - b.Property("Pump1Flow") - .HasColumnType("double precision") - .HasColumnName("pump1Flow"); - - b.Property("Pump2Flow") - .HasColumnType("double precision") - .HasColumnName("pump2Flow"); - - b.Property("RotorSpeed") - .HasColumnType("double precision") - .HasColumnName("rotorSpeed"); - - b.Property("RotorTorque") - .HasColumnType("double precision") - .HasColumnName("rotorTorque"); - - b.Property("User") - .HasColumnType("text") - .HasColumnName("user"); - - b.Property("WellDepth") - .HasColumnType("double precision") - .HasColumnName("wellDepth"); - - b.HasKey("Date"); - - b.ToTable("DataSaub"); - }); - - modelBuilder.Entity("Persistence.Database.Model.Setpoint", b => - { - b.Property("Key") - .HasColumnType("uuid") - .HasComment("Ключ"); - - b.Property("Created") - .HasColumnType("timestamp with time zone") - .HasComment("Дата создания уставки"); - - b.Property("IdUser") - .HasColumnType("uuid") - .HasComment("Id автора последнего изменения"); - - b.Property("Value") - .IsRequired() - .HasColumnType("jsonb") - .HasComment("Значение уставки"); - - b.HasKey("Key", "Created"); - - b.ToTable("Setpoint"); - }); - - modelBuilder.Entity("Persistence.Database.Entity.TechMessage", b => - { - b.HasOne("Persistence.Database.Entity.DrillingSystem", "System") - .WithMany() - .HasForeignKey("SystemId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("System"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs b/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs deleted file mode 100644 index 8d44be9..0000000 --- a/Persistence.Database.Postgres/Migrations/20241203120141_ParameterDataMigration.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations -{ - /// - public partial class ParameterDataMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "ParameterData", - columns: table => new - { - DiscriminatorId = table.Column(type: "uuid", nullable: false, comment: "Дискриминатор системы"), - ParameterId = table.Column(type: "integer", nullable: false, comment: "Id параметра"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"), - Value = table.Column(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки") - }, - constraints: table => - { - table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp }); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ParameterData"); - } - } -} diff --git a/Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs b/Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs deleted file mode 100644 index c0066ae..0000000 --- a/Persistence.Database.Postgres/Migrations/20241212041758_TechMessageMigration.cs +++ /dev/null @@ -1,64 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Persistence.Database.Postgres.Migrations.PersistencePostgres -{ - /// - public partial class TechMessageMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "DataSourceSystem", - columns: table => new - { - SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы - источника данных"), - Name = table.Column(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"), - Description = table.Column(type: "text", nullable: true, comment: "Описание системы - источника данных") - }, - constraints: table => - { - table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId); - }); - - migrationBuilder.CreateTable( - name: "TechMessage", - columns: table => new - { - EventId = table.Column(type: "uuid", nullable: false, comment: "Id события"), - CategoryId = table.Column(type: "integer", nullable: false, comment: "Id Категории важности"), - Timestamp = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"), - Text = table.Column(type: "varchar(512)", nullable: false, comment: "Текст сообщения"), - SystemId = table.Column(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"), - EventState = table.Column(type: "integer", nullable: false, comment: "Статус события") - }, - constraints: table => - { - table.PrimaryKey("PK_TechMessage", x => x.EventId); - table.ForeignKey( - name: "FK_TechMessage_DataSourceSystem_SystemId", - column: x => x.SystemId, - principalTable: "DataSourceSystem", - principalColumn: "SystemId", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_TechMessage_SystemId", - table: "TechMessage", - column: "SystemId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TechMessage"); - - migrationBuilder.DropTable( - name: "DataSourceSystem"); - } - } -} diff --git a/Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs b/Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs deleted file mode 100644 index 8638e90..0000000 --- a/Persistence.IntegrationTests/Controllers/DataSourceSystemControllerTest.cs +++ /dev/null @@ -1,82 +0,0 @@ -using Microsoft.Extensions.Caching.Memory; -using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients; -using Persistence.Client.Clients.Interfaces; -using Persistence.Database.Entity; -using Persistence.Models; -using Xunit; - -namespace Persistence.IntegrationTests.Controllers -{ - public class DataSourceSystemControllerTest : BaseIntegrationTest - { - private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey"; - private readonly IDataSourceSystemClient dataSourceSystemClient; - private readonly IMemoryCache memoryCache; - public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory) - { - var scope = factory.Services.CreateScope(); - var persistenceClientFactory = scope.ServiceProvider - .GetRequiredService(); - - dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient(); - memoryCache = scope.ServiceProvider.GetRequiredService(); - } - - [Fact] - public async Task Get_returns_success() - { - //arrange - memoryCache.Remove(SystemCacheKey); - dbContext.CleanupDbSet(); - - //act - var response = await dataSourceSystemClient.Get(CancellationToken.None); - - //assert - Assert.NotNull(response); - Assert.Empty(response); - } - - [Fact] - public async Task Get_AfterSave_returns_success() - { - //arrange - await Add(); - - //act - var response = await dataSourceSystemClient.Get(CancellationToken.None); - - //assert - Assert.NotNull(response); - - var expectedSystemCount = 1; - var actualSystemCount = response!.Count(); - Assert.Equal(expectedSystemCount, actualSystemCount); - } - - [Fact] - public async Task Add_returns_success() - { - await Add(); - } - - private async Task Add() - { - //arrange - memoryCache.Remove(SystemCacheKey); - dbContext.CleanupDbSet(); - - var dto = new DataSourceSystemDto() - { - SystemId = Guid.NewGuid(), - Name = "Test", - Description = "Test" - }; - - //act - await dataSourceSystemClient.Add(dto, CancellationToken.None); - } - } -} diff --git a/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs b/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs deleted file mode 100644 index 404d8b2..0000000 --- a/Persistence.IntegrationTests/Controllers/SetpointControllerTest.cs +++ /dev/null @@ -1,227 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Persistence.Client; -using Persistence.Client.Clients.Interfaces; -using Persistence.Database.Model; -using System.Net; -using Xunit; - -namespace Persistence.IntegrationTests.Controllers -{ - public class SetpointControllerTest : BaseIntegrationTest - { - private readonly ISetpointClient setpointClient; - private class TestObject - { - public string? Value1 { get; set; } - public int? Value2 { get; set; } - } - public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory) - { - var scope = factory.Services.CreateScope(); - var persistenceClientFactory = scope.ServiceProvider - .GetRequiredService(); - - setpointClient = persistenceClientFactory.GetSetpointClient(); - } - - [Fact] - public async Task GetCurrent_returns_success() - { - //arrange - var setpointKeys = new List() - { - Guid.NewGuid(), - Guid.NewGuid() - }; - - //act - var response = await setpointClient.GetCurrent(setpointKeys, new CancellationToken()); - - //assert - Assert.NotNull(response); - Assert.Empty(response); - } - - [Fact] - public async Task GetCurrent_AfterSave_returns_success() - { - //arrange - var setpointKey = await Add(); - - //act - var response = await setpointClient.GetCurrent([setpointKey], new CancellationToken()); - - //assert - Assert.NotNull(response); - Assert.NotEmpty(response); - Assert.Equal(setpointKey, response.FirstOrDefault()?.Key); - } - - [Fact] - public async Task GetHistory_returns_success() - { - //arrange - var setpointKeys = new List() - { - Guid.NewGuid(), - Guid.NewGuid() - }; - var historyMoment = DateTimeOffset.UtcNow; - - //act - var response = await setpointClient.GetHistory(setpointKeys, historyMoment, new CancellationToken()); - - //assert - Assert.NotNull(response); - Assert.Empty(response); - } - - [Fact] - public async Task GetHistory_AfterSave_returns_success() - { - //arrange - var setpointKey = await Add(); - var historyMoment = DateTimeOffset.UtcNow; - historyMoment = historyMoment.AddDays(1); - - //act - var response = await setpointClient.GetHistory([setpointKey], historyMoment, new CancellationToken()); - - //assert - Assert.NotNull(response); - Assert.NotEmpty(response); - Assert.Equal(setpointKey, response.FirstOrDefault()?.Key); - } - - [Fact] - public async Task GetLog_returns_success() - { - //arrange - var setpointKeys = new List() - { - Guid.NewGuid(), - Guid.NewGuid() - }; - - //act - var response = await setpointClient.GetLog(setpointKeys, new CancellationToken()); - - //assert - Assert.NotNull(response); - Assert.Empty(response); - } - - [Fact] - public async Task GetLog_AfterSave_returns_success() - { - //arrange - var setpointKey = await Add(); - - //act - var response = await setpointClient.GetLog([setpointKey], new CancellationToken()); - - //assert - Assert.NotNull(response); - Assert.NotEmpty(response); - Assert.Equal(setpointKey, response.FirstOrDefault().Key); - } - - [Fact] - public async Task GetDatesRange_returns_success() - { - //arrange - dbContext.CleanupDbSet(); - - //act - var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None); - - //assert - Assert.NotNull(response); - Assert.Equal(DateTimeOffset.MinValue, response!.From); - Assert.Equal(DateTimeOffset.MaxValue, response!.To); - } - - [Fact] - public async Task GetDatesRange_AfterSave_returns_success() - { - //arrange - dbContext.CleanupDbSet(); - - await Add(); - - var dateBegin = DateTimeOffset.MinValue; - var take = 1; - var part = await setpointClient.GetPart(dateBegin, take, CancellationToken.None); - - //act - var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None); - - //assert - Assert.NotNull(response); - - var expectedValue = part! - .FirstOrDefault()!.Created - .ToString("dd.MM.yyyy-HH:mm:ss"); - var actualValueFrom = response.From - .ToString("dd.MM.yyyy-HH:mm:ss"); - Assert.Equal(expectedValue, actualValueFrom); - - var actualValueTo = response.To - .ToString("dd.MM.yyyy-HH:mm:ss"); - Assert.Equal(expectedValue, actualValueTo); - } - - [Fact] - public async Task GetPart_returns_success() - { - //arrange - var dateBegin = DateTimeOffset.UtcNow; - var take = 2; - - //act - var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None); - - //assert - Assert.NotNull(response); - Assert.Empty(response); - } - - [Fact] - public async Task GetPart_AfterSave_returns_success() - { - //arrange - var dateBegin = DateTimeOffset.UtcNow; - var take = 1; - await Add(); - - //act - var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None); - - //assert - Assert.NotNull(response); - Assert.NotEmpty(response); - } - - [Fact] - public async Task Save_returns_success() - { - await Add(); - } - - private async Task Add() - { - //arrange - var setpointKey = Guid.NewGuid(); - var setpointValue = new TestObject() - { - Value1 = "1", - Value2 = 2 - }; - - //act - await setpointClient.Add(setpointKey, setpointValue, new CancellationToken()); - - return setpointKey; - } - } -} diff --git a/Persistence.Repository/Repositories/DataSourceSystemRepository.cs b/Persistence.Repository/Repositories/DataSourceSystemRepository.cs deleted file mode 100644 index 5862ea3..0000000 --- a/Persistence.Repository/Repositories/DataSourceSystemRepository.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Mapster; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Caching.Memory; -using Newtonsoft.Json.Linq; -using Persistence.Database.Entity; -using Persistence.Models; -using Persistence.Repositories; - -namespace Persistence.Repository.Repositories; -public class DataSourceSystemRepository : IDataSourceSystemRepository -{ - protected DbContext db; - public DataSourceSystemRepository(DbContext db) - { - this.db = db; - } - protected virtual IQueryable GetQueryReadOnly() => db.Set(); - - public virtual async Task Add(DataSourceSystemDto dataSourceSystemDto, CancellationToken token) - { - var entity = dataSourceSystemDto.Adapt(); - - await db.Set().AddAsync(entity, token); - await db.SaveChangesAsync(token); - } - - public virtual async Task> Get(CancellationToken token) - { - var query = GetQueryReadOnly(); - var entities = await query.ToArrayAsync(token); - var dtos = entities.Select(e => e.Adapt()); - - return dtos; - } -} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e69de29