Compare commits
10 Commits
master
...
Partitioni
Author | SHA1 | Date | |
---|---|---|---|
f06eda826b | |||
ff95cad258 | |||
50c535de5e | |||
df7148688d | |||
45fbfaf657 | |||
cdbbcce3bf | |||
7fe7357712 | |||
86ea991934 | |||
84731fbf3c | |||
74959284f3 |
@ -16,6 +16,12 @@ namespace DD.Persistence.API;
|
|||||||
|
|
||||||
public static class DependencyInjection
|
public static class DependencyInjection
|
||||||
{
|
{
|
||||||
|
//public static void MapsterSetup()
|
||||||
|
//{
|
||||||
|
// TypeAdapterConfig.GlobalSettings.Default.Config
|
||||||
|
// .ForType<TechMessageDto, TechMessage>()
|
||||||
|
// .Ignore(dest => dest.System, dest => dest.SystemId);
|
||||||
|
//}
|
||||||
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
|
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.AddSwaggerGen(c =>
|
services.AddSwaggerGen(c =>
|
||||||
|
@ -26,6 +26,8 @@ public class Startup
|
|||||||
services.AddJWTAuthentication(Configuration);
|
services.AddJWTAuthentication(Configuration);
|
||||||
services.AddMemoryCache();
|
services.AddMemoryCache();
|
||||||
services.AddServices();
|
services.AddServices();
|
||||||
|
|
||||||
|
//DependencyInjection.MapsterSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"DbConnection": {
|
"DbConnection": {
|
||||||
"Host": "postgres",
|
"Host": "localhost",
|
||||||
"Port": 5432,
|
"Port": 5432,
|
||||||
"Database": "persistence",
|
"Database": "persistence",
|
||||||
"Username": "postgres",
|
"Username": "postgres",
|
||||||
"Password": "postgres"
|
"Password": "q"
|
||||||
},
|
},
|
||||||
"NeedUseKeyCloak": false,
|
"NeedUseKeyCloak": false,
|
||||||
"AuthUser": {
|
"AuthUser": {
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning",
|
||||||
|
"Microsoft.EntityFrameworkCore.Database.Command": "Error"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
@ -20,6 +21,5 @@
|
|||||||
"clientId": "webapi",
|
"clientId": "webapi",
|
||||||
"grantType": "password",
|
"grantType": "password",
|
||||||
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "7d9f3574-6574-4ca3-845a-0276eb4aa8f6"
|
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier": "7d9f3574-6574-4ca3-845a-0276eb4aa8f6"
|
||||||
},
|
}
|
||||||
"ClientUrl": "http://localhost:5000/"
|
|
||||||
}
|
}
|
||||||
|
24
DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj
Normal file
24
DD.Persistence.Benchmark/DD.Persistence.Benchmark.csproj
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
|
||||||
|
<PackageReference Include="xunit.extensibility.core" Version="2.9.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\DD.Persistence.API\DD.Persistence.API.csproj" />
|
||||||
|
<ProjectReference Include="..\DD.Persistence.App\DD.Persistence.App.csproj" />
|
||||||
|
<ProjectReference Include="..\DD.Persistence.Client\DD.Persistence.Client.csproj" />
|
||||||
|
<ProjectReference Include="..\DD.Persistence.Database.Postgres\DD.Persistence.Database.Postgres.csproj" />
|
||||||
|
<ProjectReference Include="..\DD.Persistence.Database\DD.Persistence.Database.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
14
DD.Persistence.Benchmark/Database/DbConnection.cs
Normal file
14
DD.Persistence.Benchmark/Database/DbConnection.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
namespace Persistence.Benchmark.Database;
|
||||||
|
public class DbConnection
|
||||||
|
{
|
||||||
|
public string Host { get; set; } = null!;
|
||||||
|
|
||||||
|
public int Port { get; set; }
|
||||||
|
|
||||||
|
public string Username { get; set; } = null!;
|
||||||
|
|
||||||
|
public string Password { get; set; } = null!;
|
||||||
|
|
||||||
|
public string GetConnectionString() =>
|
||||||
|
$"Host={Host};Database=persistence;Port={Port};Username={Username};Password={Password};Persist Security Info=True;Include Error Detail=True";
|
||||||
|
}
|
10
DD.Persistence.Benchmark/Program.cs
Normal file
10
DD.Persistence.Benchmark/Program.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using Persistence.Benchmark.Tests;
|
||||||
|
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
private static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var count = Convert.ToInt32(Console.ReadLine());
|
||||||
|
WitsDataBenchmark.ExecuteTest(count).Wait();
|
||||||
|
}
|
||||||
|
}
|
28
DD.Persistence.Benchmark/Results.md
Normal file
28
DD.Persistence.Benchmark/Results.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Тестирование скорости работы с данными Wits
|
||||||
|
|
||||||
|
Данный проект предназначен для замеров времени сохранения / получения данных с параметром и отметкой времени. Осуществляется сравнение скорости работы стандартных таблиц и гипертаблиц (timescale), а также сохранения параметра в формате string и jsonb, составного ключа и int ключа.
|
||||||
|
|
||||||
|
## Партиционирование (timescale) | Формат параметра - Jsonb | Составной ПК
|
||||||
|
|Кол-во|Сохранение|Вычитка|
|
||||||
|
|-|--------|---|
|
||||||
|
|1.000.000|55 сек.|6.83 сек.|
|
||||||
|
|2.000.000|1 мин. 57 сек.|11 сек.|
|
||||||
|
|5.000.000|4 мин. 11 сек.|35 сек.|
|
||||||
|
|10.000.000|8 мин. 20 сек.|58 сек.|
|
||||||
|
|80.000.000|>100 мин.|20 мин. 3 сек.|
|
||||||
|
|
||||||
|
## Без партиционирования | Формат параметра - String | Составной ПК
|
||||||
|
|Кол-во|Сохранение|Вычитка|
|
||||||
|
|-|--------|---|
|
||||||
|
|1.000.000|40 сек.|26 сек.|
|
||||||
|
|2.000.000|1 мин. 26 сек.|48 сек.|
|
||||||
|
|5.000.000|3 мин. 5 сек.|2 мин. 28 сек.|
|
||||||
|
|10.000.000|8 мин. 42 сек.|4 мин. 49 сек.|
|
||||||
|
|
||||||
|
## Без партиционирования | Формат параметра - String | Int ПК
|
||||||
|
|Кол-во|Сохранение|Вычитка|
|
||||||
|
|-|--------|---|
|
||||||
|
|1.000.000|42 сек.|21 сек.|
|
||||||
|
|2.000.000|1 мин. 22 сек.|51 сек.|
|
||||||
|
|5.000.000|3 мин. 19 сек.|2 мин. 23 сек.|
|
||||||
|
|10.000.000|8 мин. 31 сек.|4 мин. 55 сек.|
|
18
DD.Persistence.Benchmark/TestHttpClientFactory.cs
Normal file
18
DD.Persistence.Benchmark/TestHttpClientFactory.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace Persistence.Benchmark;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Фабрика HTTP клиентов для интеграционных тестов
|
||||||
|
/// </summary>
|
||||||
|
public class TestHttpClientFactory : IHttpClientFactory
|
||||||
|
{
|
||||||
|
private readonly WebAppFactoryFixture factory;
|
||||||
|
|
||||||
|
public TestHttpClientFactory(WebAppFactoryFixture factory)
|
||||||
|
{
|
||||||
|
this.factory = factory;
|
||||||
|
}
|
||||||
|
public HttpClient CreateClient(string name)
|
||||||
|
{
|
||||||
|
return factory.CreateClient();
|
||||||
|
}
|
||||||
|
}
|
100
DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs
Normal file
100
DD.Persistence.Benchmark/Tests/WitsDataBenchmark.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using DD.Persistence.Client;
|
||||||
|
using DD.Persistence.Models;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace Persistence.Benchmark.Tests;
|
||||||
|
|
||||||
|
public static class WitsDataBenchmark
|
||||||
|
{
|
||||||
|
private const string discriminatorId = "fef21bfd-e924-473d-b6c8-e4377e38245d";
|
||||||
|
private const int chunkSize = 25_000;
|
||||||
|
|
||||||
|
public static async Task ExecuteTest(int count)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var factory = new WebAppFactoryFixture();
|
||||||
|
|
||||||
|
var scope = factory.Services.CreateScope();
|
||||||
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
var client = persistenceClientFactory.GetWitsDataClient();
|
||||||
|
|
||||||
|
var source = new CancellationTokenSource(TimeSpan.FromSeconds(6000));
|
||||||
|
var data = GenerateData(count);
|
||||||
|
|
||||||
|
var sw = new Stopwatch();
|
||||||
|
var saved = 0;
|
||||||
|
foreach (var item in data)
|
||||||
|
{
|
||||||
|
var time = sw.Elapsed;
|
||||||
|
|
||||||
|
sw.Start();
|
||||||
|
var response = await client.AddRange(item, source.Token);
|
||||||
|
sw.Stop();
|
||||||
|
saved = saved + response;
|
||||||
|
Console.WriteLine($"Сохранено: {saved.ToString()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine($"Затрачено времени на сохранение: {sw.Elapsed}");
|
||||||
|
|
||||||
|
var discriminator = Guid.Parse(discriminatorId);
|
||||||
|
var date = DateTime.Now.AddDays(-365);
|
||||||
|
|
||||||
|
Console.WriteLine($"\nВычитка...");
|
||||||
|
|
||||||
|
sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
var get = await client.GetPart(discriminator, date, count, source.Token);
|
||||||
|
sw.Stop();
|
||||||
|
|
||||||
|
Console.WriteLine($"Затрачено времени на вычитку {get.SelectMany(e => e.Values).Count()} записей: {sw.Elapsed}");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IEnumerable<IEnumerable<WitsDataDto>> GenerateData(int countToCreate)
|
||||||
|
{
|
||||||
|
var result = new List<List<WitsDataDto>>();
|
||||||
|
|
||||||
|
var time = DateTimeOffset.UtcNow;
|
||||||
|
var seconds = -1;
|
||||||
|
int enumerableCount = countToCreate / chunkSize + (countToCreate % chunkSize == 0 ? 0 : 1);
|
||||||
|
for (var k = 0; k < enumerableCount; k++)
|
||||||
|
{
|
||||||
|
var dtos = new List<WitsDataDto>();
|
||||||
|
for (var j = 0; j < 1000; j++)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < chunkSize / 1000; i++)
|
||||||
|
{
|
||||||
|
var random = new Random();
|
||||||
|
|
||||||
|
var timestamped = time.AddSeconds(seconds);
|
||||||
|
seconds = seconds - 1;
|
||||||
|
|
||||||
|
dtos.Add(new WitsDataDto()
|
||||||
|
{
|
||||||
|
DiscriminatorId = Guid.Parse(discriminatorId),
|
||||||
|
Timestamped = timestamped.AddSeconds(i),
|
||||||
|
Values = new List<WitsValueDto>()
|
||||||
|
{
|
||||||
|
new WitsValueDto()
|
||||||
|
{
|
||||||
|
RecordId = i + 1,
|
||||||
|
ItemId = i + 1,
|
||||||
|
Value = random.Next(1, 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.Add(dtos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
69
DD.Persistence.Benchmark/WebAppFactoryFixture.cs
Normal file
69
DD.Persistence.Benchmark/WebAppFactoryFixture.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using DD.Persistence.Client;
|
||||||
|
using DD.Persistence.Database.Model;
|
||||||
|
using DD.Persistence.Database.Postgres;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Testing;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Persistence.Benchmark.Database;
|
||||||
|
|
||||||
|
namespace Persistence.Benchmark;
|
||||||
|
public class WebAppFactoryFixture : WebApplicationFactory<DD.Persistence.App.Program>
|
||||||
|
{
|
||||||
|
private string connectionString = string.Empty;
|
||||||
|
|
||||||
|
protected override void ConfigureWebHost(IWebHostBuilder builder)
|
||||||
|
{
|
||||||
|
builder.ConfigureAppConfiguration((hostingContext, config) =>
|
||||||
|
{
|
||||||
|
config.AddJsonFile("appsettings.Tests.json");
|
||||||
|
|
||||||
|
var dbConnection = config.Build().GetSection("DbConnection").Get<DbConnection>()!;
|
||||||
|
connectionString = dbConnection.GetConnectionString();
|
||||||
|
});
|
||||||
|
|
||||||
|
builder.ConfigureServices(services =>
|
||||||
|
{
|
||||||
|
var descriptor = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions<PersistencePostgresContext>));
|
||||||
|
if (descriptor != null)
|
||||||
|
services.Remove(descriptor);
|
||||||
|
|
||||||
|
services.AddDbContext<PersistencePostgresContext>(options =>
|
||||||
|
options.UseNpgsql(connectionString));
|
||||||
|
|
||||||
|
services.AddLogging(builder => builder.AddConsole());
|
||||||
|
|
||||||
|
services.RemoveAll<IHttpClientFactory>();
|
||||||
|
services.AddSingleton<IHttpClientFactory>(provider =>
|
||||||
|
{
|
||||||
|
return new TestHttpClientFactory(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddSingleton<PersistenceClientFactory>();
|
||||||
|
|
||||||
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
|
using var scope = serviceProvider.CreateScope();
|
||||||
|
var scopedServices = scope.ServiceProvider;
|
||||||
|
|
||||||
|
var dbContext = scopedServices.GetRequiredService<PersistencePostgresContext>();
|
||||||
|
//dbContext.Database.EnsureCreatedAndMigrated();
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async ValueTask DisposeAsync()
|
||||||
|
{
|
||||||
|
var dbContext = new PersistencePostgresContext(
|
||||||
|
new DbContextOptionsBuilder<PersistencePostgresContext>()
|
||||||
|
.UseNpgsql(connectionString)
|
||||||
|
.Options);
|
||||||
|
|
||||||
|
await dbContext.Database.EnsureDeletedAsync();
|
||||||
|
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
}
|
@ -3,16 +3,15 @@ using DD.Persistence.Client.Clients.Base;
|
|||||||
using DD.Persistence.Client.Clients.Interfaces;
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
using DD.Persistence.Models.Requests;
|
using DD.Persistence.Models.Requests;
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients;
|
namespace DD.Persistence.Client.Clients;
|
||||||
public class ChangeLogClient : BaseClient, IChangeLogClient
|
public class ChangeLogClient : BaseClient, IChangeLogClient
|
||||||
{
|
{
|
||||||
private readonly IRefitChangeLogClient refitChangeLogClient;
|
private readonly Interfaces.Refit.IRefitChangeLogClient refitChangeLogClient;
|
||||||
|
|
||||||
public ChangeLogClient(IRefitClientFactory<IRefitChangeLogClient> refitClientFactory, ILogger<ChangeLogClient> logger) : base(logger)
|
public ChangeLogClient(Interfaces.Refit.IRefitChangeLogClient refitChangeLogClient, ILogger<ChangeLogClient> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.refitChangeLogClient = refitClientFactory.Create();
|
this.refitChangeLogClient = refitChangeLogClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> ClearAndAddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
public async Task<int> ClearAndAddRange(Guid idDiscriminator, IEnumerable<DataWithWellDepthAndSectionDto> dtos, CancellationToken token)
|
||||||
|
@ -9,9 +9,9 @@ public class DataSourceSystemClient : BaseClient, IDataSourceSystemClient
|
|||||||
{
|
{
|
||||||
private readonly IRefitDataSourceSystemClient dataSourceSystemClient;
|
private readonly IRefitDataSourceSystemClient dataSourceSystemClient;
|
||||||
|
|
||||||
public DataSourceSystemClient(IRefitClientFactory<IRefitDataSourceSystemClient> dataSourceSystemClientFactory, ILogger<DataSourceSystemClient> logger) : base(logger)
|
public DataSourceSystemClient(IRefitDataSourceSystemClient dataSourceSystemClient, ILogger<DataSourceSystemClient> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.dataSourceSystemClient = dataSourceSystemClientFactory.Create();
|
this.dataSourceSystemClient = dataSourceSystemClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Add(DataSourceSystemDto dataSourceSystemDto, CancellationToken token)
|
public async Task Add(DataSourceSystemDto dataSourceSystemDto, CancellationToken token)
|
||||||
|
@ -6,7 +6,7 @@ namespace DD.Persistence.Client.Clients.Interfaces;
|
|||||||
/// Клиент для работы с временными данными
|
/// Клиент для работы с временными данными
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TDto"></typeparam>
|
/// <typeparam name="TDto"></typeparam>
|
||||||
public interface ITimeSeriesClient<TDto> : IDisposable where TDto : class, ITimeSeriesAbstractDto
|
public interface ITimeSeriesClient<TDto> : IDisposable where TDto : class, new()
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление записей
|
/// Добавление записей
|
||||||
|
@ -4,7 +4,7 @@ using Refit;
|
|||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
|
|
||||||
public interface IRefitChangeLogClient : IRefitClient, IDisposable
|
public interface IRefitChangeLogClient : IDisposable
|
||||||
{
|
{
|
||||||
private const string BaseRoute = "/api/ChangeLog";
|
private const string BaseRoute = "/api/ChangeLog";
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
using Refit;
|
using Refit;
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
public interface IRefitDataSourceSystemClient : IRefitClient, IDisposable
|
public interface IRefitDataSourceSystemClient : IDisposable
|
||||||
{
|
{
|
||||||
private const string BaseRoute = "/api/dataSourceSystem";
|
private const string BaseRoute = "/api/dataSourceSystem";
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using Refit;
|
|||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
|
|
||||||
public interface IRefitSetpointClient : IRefitClient, IDisposable
|
public interface IRefitSetpointClient : IDisposable
|
||||||
{
|
{
|
||||||
private const string BaseRoute = "/api/setpoint";
|
private const string BaseRoute = "/api/setpoint";
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
using DD.Persistence.Models;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using DD.Persistence.Models;
|
||||||
using DD.Persistence.Models.Requests;
|
using DD.Persistence.Models.Requests;
|
||||||
using Refit;
|
using Refit;
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit
|
||||||
{
|
{
|
||||||
public interface IRefitTechMessagesClient : IRefitClient, IDisposable
|
public interface IRefitTechMessagesClient : IDisposable
|
||||||
{
|
{
|
||||||
private const string BaseRoute = "/api/techMessages";
|
private const string BaseRoute = "/api/techMessages";
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@ using DD.Persistence.Models;
|
|||||||
using Refit;
|
using Refit;
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
public interface IRefitTimeSeriesClient<TDto> : IRefitClient, IDisposable
|
public interface IRefitTimeSeriesClient<TDto> : IDisposable
|
||||||
where TDto : class, ITimeSeriesAbstractDto
|
where TDto : class, new()
|
||||||
{
|
{
|
||||||
private const string BaseRoute = "/api/dataSaub";
|
private const string BaseRoute = "/api/dataSaub";
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ using Refit;
|
|||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
|
|
||||||
public interface IRefitTimestampedSetClient : IRefitClient, IDisposable
|
public interface IRefitTimestampedSetClient : IDisposable
|
||||||
{
|
{
|
||||||
private const string baseUrl = "/api/TimestampedSet/{idDiscriminator}";
|
private const string baseUrl = "/api/TimestampedSet/{idDiscriminator}";
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using DD.Persistence.Models;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using DD.Persistence.Models;
|
||||||
using Refit;
|
using Refit;
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
||||||
public interface IRefitWitsDataClient : IRefitClient, IDisposable
|
public interface IRefitWitsDataClient : IDisposable
|
||||||
{
|
{
|
||||||
private const string BaseRoute = "/api/witsData";
|
private const string BaseRoute = "/api/witsData";
|
||||||
|
|
||||||
|
@ -10,9 +10,9 @@ public class SetpointClient : BaseClient, ISetpointClient
|
|||||||
{
|
{
|
||||||
private readonly IRefitSetpointClient refitSetpointClient;
|
private readonly IRefitSetpointClient refitSetpointClient;
|
||||||
|
|
||||||
public SetpointClient(IRefitClientFactory<IRefitSetpointClient> refitSetpointClientFactory, ILogger<SetpointClient> logger) : base(logger)
|
public SetpointClient(IRefitSetpointClient refitSetpointClient, ILogger<SetpointClient> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.refitSetpointClient = refitSetpointClientFactory.Create();
|
this.refitSetpointClient = refitSetpointClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<SetpointValueDto>> GetCurrent(IEnumerable<Guid> setpointKeys, CancellationToken token)
|
public async Task<IEnumerable<SetpointValueDto>> GetCurrent(IEnumerable<Guid> setpointKeys, CancellationToken token)
|
||||||
|
@ -11,9 +11,9 @@ public class TechMessagesClient : BaseClient, ITechMessagesClient
|
|||||||
{
|
{
|
||||||
private readonly IRefitTechMessagesClient refitTechMessagesClient;
|
private readonly IRefitTechMessagesClient refitTechMessagesClient;
|
||||||
|
|
||||||
public TechMessagesClient(IRefitClientFactory<IRefitTechMessagesClient> refitTechMessagesClientFactory, ILogger<TechMessagesClient> logger) : base(logger)
|
public TechMessagesClient(IRefitTechMessagesClient refitTechMessagesClient, ILogger<TechMessagesClient> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.refitTechMessagesClient = refitTechMessagesClientFactory.Create();
|
this.refitTechMessagesClient = refitTechMessagesClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<PaginationContainer<TechMessageDto>> GetPage(PaginationRequest request, CancellationToken token)
|
public async Task<PaginationContainer<TechMessageDto>> GetPage(PaginationRequest request, CancellationToken token)
|
||||||
|
@ -5,13 +5,13 @@ using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients;
|
namespace DD.Persistence.Client.Clients;
|
||||||
public class TimeSeriesClient<TDto> : BaseClient, ITimeSeriesClient<TDto> where TDto : class, ITimeSeriesAbstractDto
|
public class TimeSeriesClient<TDto> : BaseClient, ITimeSeriesClient<TDto> where TDto : class, new()
|
||||||
{
|
{
|
||||||
private readonly IRefitTimeSeriesClient<TDto> timeSeriesClient;
|
private readonly IRefitTimeSeriesClient<TDto> timeSeriesClient;
|
||||||
|
|
||||||
public TimeSeriesClient(IRefitClientFactory<IRefitTimeSeriesClient<TDto>> refitTechMessagesClientFactory, ILogger<TimeSeriesClient<TDto>> logger) : base(logger)
|
public TimeSeriesClient(IRefitTimeSeriesClient<TDto> refitTechMessagesClient, ILogger<TimeSeriesClient<TDto>> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.timeSeriesClient = refitTechMessagesClientFactory.Create();
|
this.timeSeriesClient = refitTechMessagesClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
|
public async Task<int> AddRange(IEnumerable<TDto> dtos, CancellationToken token)
|
||||||
|
@ -9,9 +9,9 @@ public class TimestampedSetClient : BaseClient, ITimestampedSetClient
|
|||||||
{
|
{
|
||||||
private readonly IRefitTimestampedSetClient refitTimestampedSetClient;
|
private readonly IRefitTimestampedSetClient refitTimestampedSetClient;
|
||||||
|
|
||||||
public TimestampedSetClient(IRefitClientFactory<IRefitTimestampedSetClient> refitTimestampedSetClientFactory, ILogger<TimestampedSetClient> logger) : base(logger)
|
public TimestampedSetClient(IRefitTimestampedSetClient refitTimestampedSetClient, ILogger<TimestampedSetClient> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.refitTimestampedSetClient = refitTimestampedSetClientFactory.Create();
|
this.refitTimestampedSetClient = refitTimestampedSetClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
public async Task<int> AddRange(Guid idDiscriminator, IEnumerable<TimestampedSetDto> sets, CancellationToken token)
|
||||||
|
@ -9,9 +9,9 @@ public class WitsDataClient : BaseClient, IWitsDataClient
|
|||||||
{
|
{
|
||||||
private readonly IRefitWitsDataClient refitWitsDataClient;
|
private readonly IRefitWitsDataClient refitWitsDataClient;
|
||||||
|
|
||||||
public WitsDataClient(IRefitClientFactory<IRefitWitsDataClient> refitWitsDataClientFactory, ILogger<WitsDataClient> logger) : base(logger)
|
public WitsDataClient(IRefitWitsDataClient refitWitsDataClient, ILogger<WitsDataClient> logger) : base(logger)
|
||||||
{
|
{
|
||||||
this.refitWitsDataClient = refitWitsDataClientFactory.Create();
|
this.refitWitsDataClient = refitWitsDataClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> AddRange(IEnumerable<WitsDataDto> dtos, CancellationToken token)
|
public async Task<int> AddRange(IEnumerable<WitsDataDto> dtos, CancellationToken token)
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
<!--Генерация NuGet пакета при сборке-->
|
<!--Генерация NuGet пакета при сборке-->
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
<!--Наименование-->
|
<!--Наименование-->
|
||||||
<Title>DD.Persistence.Client</Title>
|
<Title>Persistence.Client</Title>
|
||||||
<!--Версия пакета-->
|
<!--Версия пакета-->
|
||||||
<VersionPrefix>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
|
<VersionPrefix>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
|
||||||
<!--Версия сборки-->
|
<!--Версия сборки-->
|
||||||
<AssemblyVersion>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
|
<AssemblyVersion>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
|
||||||
<!--Id пакета-->
|
<!--Id пакета-->
|
||||||
<PackageId>DD.Persistence.Client</PackageId>
|
<PackageId>Persistence.Client</PackageId>
|
||||||
|
|
||||||
<!--Автор-->
|
<!--Автор-->
|
||||||
<Authors>Digital Drilling</Authors>
|
<Authors>Digital Drilling</Authors>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<!--Формат пакета с символами-->
|
<!--Формат пакета с символами-->
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
<!--Путь к пакету-->
|
<!--Путь к пакету-->
|
||||||
<PackageOutputPath>C:\Projects\Nuget\Persistence\Client</PackageOutputPath>
|
<PackageOutputPath>C:\Projects\Nuget</PackageOutputPath>
|
||||||
|
|
||||||
<!--Readme-->
|
<!--Readme-->
|
||||||
<PackageReadmeFile>Readme.md</PackageReadmeFile>
|
<PackageReadmeFile>Readme.md</PackageReadmeFile>
|
||||||
@ -53,12 +53,11 @@
|
|||||||
<PackageReference Include="Refit" Version="8.0.0" />
|
<PackageReference Include="Refit" Version="8.0.0" />
|
||||||
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
|
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
|
||||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
|
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DD.Persistence.Models\DD.Persistence.Models.csproj" />
|
<ProjectReference Include="..\DD.Persistence\DD.Persistence.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
using DD.Persistence.Client.Clients;
|
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
|
||||||
using DD.Persistence.Models;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
|
|
||||||
namespace DD.Persistence.Client;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public static class DependencyInjection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="services"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static IServiceCollection AddPersistenceClients(this IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.AddTransient(typeof(IRefitClientFactory<>), typeof(RefitClientFactory<>));
|
|
||||||
services.AddTransient<IChangeLogClient, ChangeLogClient>();
|
|
||||||
services.AddTransient<IDataSourceSystemClient, DataSourceSystemClient>();
|
|
||||||
services.AddTransient<ISetpointClient, SetpointClient>();
|
|
||||||
services.AddTransient<ITechMessagesClient, TechMessagesClient>();
|
|
||||||
services.AddTransient<ITimeSeriesClient<DataSaubDto>, TimeSeriesClient<DataSaubDto>>();
|
|
||||||
services.AddTransient<ITimestampedSetClient, TimestampedSetClient>();
|
|
||||||
services.AddTransient<IWitsDataClient, WitsDataClient>();
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
|
|
||||||
namespace DD.Persistence.Client;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс для фабрики, которая создает refit-клиентов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public interface IRefitClientFactory<T> where T : IRefitClient
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Создание refit-клиента
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T Create();
|
|
||||||
}
|
|
150
DD.Persistence.Client/PersistenceClientFactory.cs
Normal file
150
DD.Persistence.Client/PersistenceClientFactory.cs
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
|
using DD.Persistence.Client.Clients;
|
||||||
|
using DD.Persistence.Client.Helpers;
|
||||||
|
using 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 DD.Persistence.Client
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Фабрика клиентов для доступа к Persistence - сервису
|
||||||
|
/// </summary>
|
||||||
|
public class PersistenceClientFactory
|
||||||
|
{
|
||||||
|
private static readonly JsonSerializerOptions JsonSerializerOptions = new()
|
||||||
|
{
|
||||||
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
private static readonly RefitSettings RefitSettings = new(new SystemTextJsonContentSerializer(JsonSerializerOptions));
|
||||||
|
private readonly IServiceProvider provider;
|
||||||
|
private HttpClient httpClient;
|
||||||
|
public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IServiceProvider provider, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
this.provider = provider;
|
||||||
|
|
||||||
|
httpClient = httpClientFactory.CreateClient();
|
||||||
|
|
||||||
|
httpClient.Authorize(configuration);
|
||||||
|
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(6000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PersistenceClientFactory(IHttpClientFactory httpClientFactory, IAuthTokenFactory authTokenFactory, IServiceProvider provider, IConfiguration configuration)
|
||||||
|
{
|
||||||
|
this.provider = provider;
|
||||||
|
|
||||||
|
httpClient = httpClientFactory.CreateClient();
|
||||||
|
|
||||||
|
var token = authTokenFactory.GetToken();
|
||||||
|
httpClient.Authorize(token);
|
||||||
|
|
||||||
|
httpClient.Timeout = TimeSpan.FromSeconds(6000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы с уставками
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ISetpointClient GetSetpointClient()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<SetpointClient>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitSetpointClient>(httpClient, RefitSettings);
|
||||||
|
var client = new SetpointClient(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы с технологическими сообщениями
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ITechMessagesClient GetTechMessagesClient()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<TechMessagesClient>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitTechMessagesClient>(httpClient, RefitSettings);
|
||||||
|
var client = new TechMessagesClient(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы с временными данными
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TDto"></typeparam>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ITimeSeriesClient<TDto> GetTimeSeriesClient<TDto>()
|
||||||
|
where TDto : class, new()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<TimeSeriesClient<TDto>>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitTimeSeriesClient<TDto>>(httpClient, RefitSettings);
|
||||||
|
var client = new TimeSeriesClient<TDto>(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы с данными с отметкой времени
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ITimestampedSetClient GetTimestampedSetClient()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<TimestampedSetClient>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitTimestampedSetClient>(httpClient, RefitSettings);
|
||||||
|
var client = new TimestampedSetClient(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы с записями ChangeLog
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IChangeLogClient GetChangeLogClient()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<ChangeLogClient>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitChangeLogClient>(httpClient, RefitSettings);
|
||||||
|
var client = new ChangeLogClient(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы c параметрами Wits
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IWitsDataClient GetWitsDataClient()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<WitsDataClient>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitWitsDataClient>(httpClient, RefitSettings);
|
||||||
|
var client = new WitsDataClient(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получить клиент для работы c системами
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public IDataSourceSystemClient GetDataSourceSystemClient()
|
||||||
|
{
|
||||||
|
var logger = provider.GetRequiredService<ILogger<DataSourceSystemClient>>();
|
||||||
|
|
||||||
|
var restClient = RestService.For<IRefitDataSourceSystemClient>(httpClient, RefitSettings);
|
||||||
|
var client = new DataSourceSystemClient(restClient, logger);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,52 +0,0 @@
|
|||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Client.Helpers;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Refit;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace DD.Persistence.Client;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Фабрика, которая создает refit-клиентов
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
public class RefitClientFactory<T> : IRefitClientFactory<T> where T : IRefitClient
|
|
||||||
{
|
|
||||||
private HttpClient client;
|
|
||||||
private RefitSettings refitSettings;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public RefitClientFactory(IConfiguration configuration, ILogger<IRefitClientFactory<T>> logger, HttpClient client)
|
|
||||||
{
|
|
||||||
//this.client = factory.CreateClient();
|
|
||||||
this.client = client;
|
|
||||||
|
|
||||||
var baseUrl = configuration.GetSection("ClientUrl").Get<string>();
|
|
||||||
if (String.IsNullOrEmpty(baseUrl))
|
|
||||||
{
|
|
||||||
var exception = new SettingsPropertyNotFoundException("В настройках конфигурации не указан адрес Persistence сервиса.");
|
|
||||||
|
|
||||||
logger.LogError(exception.Message);
|
|
||||||
|
|
||||||
throw exception;
|
|
||||||
}
|
|
||||||
client.BaseAddress = new Uri(baseUrl);
|
|
||||||
|
|
||||||
JsonSerializerOptions JsonSerializerOptions = new()
|
|
||||||
{
|
|
||||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
|
||||||
PropertyNameCaseInsensitive = true
|
|
||||||
};
|
|
||||||
refitSettings = new(new SystemTextJsonContentSerializer(JsonSerializerOptions));
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// создание клиента
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public T Create()
|
|
||||||
{
|
|
||||||
return RestService.For<T>(client, refitSettings);
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
namespace DD.Persistence.Database.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PersistencePostgresContext))]
|
[DbContext(typeof(PersistencePostgresContext))]
|
||||||
[Migration("20241220062251_Init")]
|
[Migration("20241225122815_Init")]
|
||||||
partial class Init
|
partial class Init
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -20,7 +20,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "9.0.0")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -43,7 +43,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("SystemId");
|
b.HasKey("SystemId");
|
||||||
|
|
||||||
b.ToTable("DataSourceSystem");
|
b.ToTable("data_source_system");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
||||||
@ -60,14 +60,14 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasComment("Временная отметка");
|
.HasComment("Временная отметка");
|
||||||
|
|
||||||
b.Property<string>("Value")
|
b.Property<object>("Value")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("varchar(256)")
|
.HasColumnType("jsonb")
|
||||||
.HasComment("Значение параметра в виде строки");
|
.HasComment("Значение параметра");
|
||||||
|
|
||||||
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("ParameterData");
|
b.ToTable("parameter_data");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
@ -102,7 +102,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SystemId");
|
b.HasIndex("SystemId");
|
||||||
|
|
||||||
b.ToTable("TechMessage");
|
b.ToTable("tech_message");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
||||||
@ -122,7 +122,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("IdDiscriminator", "Timestamp");
|
b.HasKey("IdDiscriminator", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("TimestampedSets", t =>
|
b.ToTable("timestamped_set", t =>
|
||||||
{
|
{
|
||||||
t.HasComment("Общая таблица данных временных рядов");
|
t.HasComment("Общая таблица данных временных рядов");
|
||||||
});
|
});
|
||||||
@ -178,7 +178,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("ChangeLog");
|
b.ToTable("change_log");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
||||||
@ -261,7 +261,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Date");
|
b.HasKey("Date");
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
b.ToTable("data_saub");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
||||||
@ -285,7 +285,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Key", "Created");
|
b.HasKey("Key", "Created");
|
||||||
|
|
||||||
b.ToTable("Setpoint");
|
b.ToTable("setpoint");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
@ -12,7 +12,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ChangeLog",
|
name: "change_log",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ записи"),
|
Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ записи"),
|
||||||
@ -29,11 +29,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_ChangeLog", x => x.Id);
|
table.PrimaryKey("PK_change_log", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "DataSaub",
|
name: "data_saub",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
@ -58,11 +58,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_DataSaub", x => x.date);
|
table.PrimaryKey("PK_data_saub", x => x.date);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "DataSourceSystem",
|
name: "data_source_system",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
||||||
@ -71,25 +71,25 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId);
|
table.PrimaryKey("PK_data_source_system", x => x.SystemId);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "ParameterData",
|
name: "parameter_data",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
||||||
ParameterId = table.Column<int>(type: "integer", nullable: false, comment: "Id параметра"),
|
ParameterId = table.Column<int>(type: "integer", nullable: false, comment: "Id параметра"),
|
||||||
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
|
||||||
Value = table.Column<string>(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки")
|
Value = table.Column<object>(type: "jsonb", nullable: false, comment: "Значение параметра")
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
|
table.PrimaryKey("PK_parameter_data", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Setpoint",
|
name: "setpoint",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
||||||
@ -99,11 +99,11 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created });
|
table.PrimaryKey("PK_setpoint", x => new { x.Key, x.Created });
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "TimestampedSets",
|
name: "timestamped_set",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"),
|
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"),
|
||||||
@ -112,12 +112,12 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp });
|
table.PrimaryKey("PK_timestamped_set", x => new { x.IdDiscriminator, x.Timestamp });
|
||||||
},
|
},
|
||||||
comment: "Общая таблица данных временных рядов");
|
comment: "Общая таблица данных временных рядов");
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "TechMessage",
|
name: "tech_message",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
EventId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
EventId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
||||||
@ -129,44 +129,47 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_TechMessage", x => x.EventId);
|
table.PrimaryKey("PK_tech_message", x => x.EventId);
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_TechMessage_DataSourceSystem_SystemId",
|
name: "FK_tech_message_data_source_system_SystemId",
|
||||||
column: x => x.SystemId,
|
column: x => x.SystemId,
|
||||||
principalTable: "DataSourceSystem",
|
principalTable: "data_source_system",
|
||||||
principalColumn: "SystemId",
|
principalColumn: "SystemId",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_TechMessage_SystemId",
|
name: "IX_tech_message_SystemId",
|
||||||
table: "TechMessage",
|
table: "tech_message",
|
||||||
column: "SystemId");
|
column: "SystemId");
|
||||||
|
|
||||||
|
migrationBuilder.Sql
|
||||||
|
("SELECT create_hypertable('parameter_data','Timestamp','ParameterId',2,chunk_time_interval => INTERVAL '5 day');");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ChangeLog");
|
name: "change_log");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "DataSaub");
|
name: "data_saub");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ParameterData");
|
name: "parameter_data");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Setpoint");
|
name: "setpoint");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "TechMessage");
|
name: "tech_message");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "TimestampedSets");
|
name: "timestamped_set");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "DataSourceSystem");
|
name: "data_source_system");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "9.0.0")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
@ -40,7 +40,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("SystemId");
|
b.HasKey("SystemId");
|
||||||
|
|
||||||
b.ToTable("DataSourceSystem");
|
b.ToTable("data_source_system");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
||||||
@ -57,14 +57,14 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
.HasColumnType("timestamp with time zone")
|
.HasColumnType("timestamp with time zone")
|
||||||
.HasComment("Временная отметка");
|
.HasComment("Временная отметка");
|
||||||
|
|
||||||
b.Property<string>("Value")
|
b.Property<object>("Value")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("varchar(256)")
|
.HasColumnType("jsonb")
|
||||||
.HasComment("Значение параметра в виде строки");
|
.HasComment("Значение параметра");
|
||||||
|
|
||||||
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("ParameterData");
|
b.ToTable("parameter_data");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
@ -99,7 +99,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasIndex("SystemId");
|
b.HasIndex("SystemId");
|
||||||
|
|
||||||
b.ToTable("TechMessage");
|
b.ToTable("tech_message");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
||||||
@ -119,7 +119,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("IdDiscriminator", "Timestamp");
|
b.HasKey("IdDiscriminator", "Timestamp");
|
||||||
|
|
||||||
b.ToTable("TimestampedSets", t =>
|
b.ToTable("timestamped_set", t =>
|
||||||
{
|
{
|
||||||
t.HasComment("Общая таблица данных временных рядов");
|
t.HasComment("Общая таблица данных временных рядов");
|
||||||
});
|
});
|
||||||
@ -175,7 +175,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("ChangeLog");
|
b.ToTable("change_log");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
||||||
@ -258,7 +258,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Date");
|
b.HasKey("Date");
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
b.ToTable("data_saub");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
||||||
@ -282,7 +282,7 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
|
|
||||||
b.HasKey("Key", "Created");
|
b.HasKey("Key", "Created");
|
||||||
|
|
||||||
b.ToTable("Setpoint");
|
b.ToTable("setpoint");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
|
@ -9,6 +9,7 @@ namespace DD.Persistence.Database.Model;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Часть записи, описывающая изменение
|
/// Часть записи, описывающая изменение
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Table("change_log")]
|
||||||
public class ChangeLog : IChangeLog, IWithSectionPart
|
public class ChangeLog : IChangeLog, IWithSectionPart
|
||||||
{
|
{
|
||||||
[Key, Comment("Ключ записи")]
|
[Key, Comment("Ключ записи")]
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Model;
|
namespace DD.Persistence.Database.Model;
|
||||||
|
|
||||||
|
[Table("data_saub")]
|
||||||
public class DataSaub : ITimestampedData
|
public class DataSaub : ITimestampedData
|
||||||
{
|
{
|
||||||
[Key, Column("date")]
|
[Key, Column("date")]
|
||||||
|
@ -3,6 +3,8 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Entity;
|
namespace DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
|
[Table("data_source_system")]
|
||||||
public class DataSourceSystem
|
public class DataSourceSystem
|
||||||
{
|
{
|
||||||
[Key, Comment("Id системы - источника данных")]
|
[Key, Comment("Id системы - источника данных")]
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Entity;
|
namespace DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
|
[Table("parameter_data")]
|
||||||
[PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))]
|
[PrimaryKey(nameof(DiscriminatorId), nameof(ParameterId), nameof(Timestamp))]
|
||||||
public class ParameterData
|
public class ParameterData
|
||||||
{
|
{
|
||||||
@ -13,8 +14,8 @@ public class ParameterData
|
|||||||
[Comment("Id параметра")]
|
[Comment("Id параметра")]
|
||||||
public int ParameterId { get; set; }
|
public int ParameterId { get; set; }
|
||||||
|
|
||||||
[Column(TypeName = "varchar(256)"), Comment("Значение параметра в виде строки")]
|
[Column(TypeName = "jsonb"), Comment("Значение параметра")]
|
||||||
public required string Value { get; set; }
|
public required object Value { get; set; }
|
||||||
|
|
||||||
[Comment("Временная отметка")]
|
[Comment("Временная отметка")]
|
||||||
public DateTimeOffset Timestamp { get; set; }
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Model
|
namespace DD.Persistence.Database.Model
|
||||||
{
|
{
|
||||||
|
[Table("setpoint")]
|
||||||
[PrimaryKey(nameof(Key), nameof(Created))]
|
[PrimaryKey(nameof(Key), nameof(Created))]
|
||||||
public class Setpoint
|
public class Setpoint
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Entity
|
namespace DD.Persistence.Database.Entity
|
||||||
{
|
{
|
||||||
|
[Table("tech_message")]
|
||||||
public class TechMessage
|
public class TechMessage
|
||||||
{
|
{
|
||||||
[Key, Comment("Id события")]
|
[Key, Comment("Id события")]
|
||||||
|
@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||||||
|
|
||||||
namespace DD.Persistence.Database.Entity;
|
namespace DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
|
[Table("timestamped_set")]
|
||||||
[Comment("Общая таблица данных временных рядов")]
|
[Comment("Общая таблица данных временных рядов")]
|
||||||
[PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))]
|
[PrimaryKey(nameof(IdDiscriminator), nameof(Timestamp))]
|
||||||
public record TimestampedSet(
|
public record TimestampedSet(
|
||||||
|
@ -4,7 +4,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace DD.Persistence.Client.Clients.Interfaces.Refit;
|
namespace DD.Persistence.Database.UsefulQueries
|
||||||
public interface IRefitClient
|
{
|
||||||
|
class partition_function
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
|
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DD.Persistence.Database.UsefulQueries
|
||||||
|
{
|
||||||
|
class partition_function
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -7,11 +7,6 @@ using DD.Persistence.Models.Requests;
|
|||||||
using Xunit;
|
using Xunit;
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
using DD.Persistence.Client;
|
using DD.Persistence.Client;
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Client.Clients;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Refit;
|
|
||||||
using System.Net.Http;
|
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers;
|
namespace DD.Persistence.IntegrationTests.Controllers;
|
||||||
public class ChangeLogControllerTest : BaseIntegrationTest
|
public class ChangeLogControllerTest : BaseIntegrationTest
|
||||||
@ -21,12 +16,10 @@ public class ChangeLogControllerTest : BaseIntegrationTest
|
|||||||
|
|
||||||
public ChangeLogControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public ChangeLogControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitChangeLogClient>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<ChangeLogClient>>();
|
|
||||||
|
|
||||||
client = scope.ServiceProvider
|
client = persistenceClientFactory.GetChangeLogClient();
|
||||||
.GetRequiredService<IChangeLogClient>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -6,8 +6,6 @@ using DD.Persistence.Client.Clients.Interfaces;
|
|||||||
using DD.Persistence.Database.Entity;
|
using DD.Persistence.Database.Entity;
|
||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers
|
namespace DD.Persistence.IntegrationTests.Controllers
|
||||||
{
|
{
|
||||||
@ -18,12 +16,11 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
private readonly IMemoryCache memoryCache;
|
private readonly IMemoryCache memoryCache;
|
||||||
public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var scope = factory.Services.CreateScope();
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitDataSourceSystemClient>>();
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<DataSourceSystemClient>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
dataSourceSystemClient = scope.ServiceProvider
|
dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient();
|
||||||
.GetRequiredService<IDataSourceSystemClient>();
|
|
||||||
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,6 @@ using DD.Persistence.Client.Clients.Interfaces;
|
|||||||
using DD.Persistence.Database.Model;
|
using DD.Persistence.Database.Model;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Client.Clients;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers
|
namespace DD.Persistence.IntegrationTests.Controllers
|
||||||
{
|
{
|
||||||
@ -20,12 +17,11 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
}
|
}
|
||||||
public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public SetpointControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var scope = factory.Services.CreateScope();
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitSetpointClient>>();
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<SetpointClient>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
setpointClient = scope.ServiceProvider
|
setpointClient = persistenceClientFactory.GetSetpointClient();
|
||||||
.GetRequiredService<ISetpointClient>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
using DD.Persistence.Client;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using DD.Persistence.Client.Clients;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using DD.Persistence.Client;
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Database.Entity;
|
using DD.Persistence.Database.Entity;
|
||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
using DD.Persistence.Models.Enumerations;
|
using DD.Persistence.Models.Enumerations;
|
||||||
using DD.Persistence.Models.Requests;
|
using DD.Persistence.Models.Requests;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using System.Net;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers
|
namespace DD.Persistence.IntegrationTests.Controllers
|
||||||
@ -20,12 +18,11 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
private readonly IMemoryCache memoryCache;
|
private readonly IMemoryCache memoryCache;
|
||||||
public TechMessagesControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public TechMessagesControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var scope = factory.Services.CreateScope();
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitTechMessagesClient>>();
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<TechMessagesClient>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
techMessagesClient = scope.ServiceProvider
|
techMessagesClient = persistenceClientFactory.GetTechMessagesClient();
|
||||||
.GetRequiredService<ITechMessagesClient>();
|
|
||||||
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
using DD.Persistence.Client;
|
|
||||||
using DD.Persistence.Client.Clients;
|
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Database.Model;
|
|
||||||
using DD.Persistence.Models;
|
|
||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using DD.Persistence.Client;
|
||||||
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
|
using DD.Persistence.Database.Model;
|
||||||
|
using System.Net;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers;
|
namespace DD.Persistence.IntegrationTests.Controllers;
|
||||||
|
|
||||||
public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrationTest
|
public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrationTest
|
||||||
where TEntity : class, ITimestampedData, new()
|
where TEntity : class, ITimestampedData, new()
|
||||||
where TDto : class, ITimeSeriesAbstractDto, new()
|
where TDto : class, new()
|
||||||
{
|
{
|
||||||
private readonly ITimeSeriesClient<TDto> timeSeriesClient;
|
private readonly ITimeSeriesClient<TDto> timeSeriesClient;
|
||||||
|
|
||||||
@ -21,12 +18,11 @@ public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrat
|
|||||||
{
|
{
|
||||||
dbContext.CleanupDbSet<TEntity>();
|
dbContext.CleanupDbSet<TEntity>();
|
||||||
|
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var scope = factory.Services.CreateScope();
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitTimeSeriesClient<TDto>>>();
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<TimeSeriesClient<TDto>>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
timeSeriesClient = scope.ServiceProvider
|
timeSeriesClient = persistenceClientFactory.GetTimeSeriesClient<TDto>();
|
||||||
.GetRequiredService<ITimeSeriesClient<TDto>>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InsertRangeSuccess(TDto dto)
|
public async Task InsertRangeSuccess(TDto dto)
|
||||||
|
@ -3,9 +3,6 @@ using DD.Persistence.Client;
|
|||||||
using DD.Persistence.Client.Clients.Interfaces;
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Client.Clients;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers;
|
namespace DD.Persistence.IntegrationTests.Controllers;
|
||||||
public class TimestampedSetControllerTest : BaseIntegrationTest
|
public class TimestampedSetControllerTest : BaseIntegrationTest
|
||||||
@ -14,12 +11,10 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
|
|
||||||
public TimestampedSetControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public TimestampedSetControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitTimestampedSetClient>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<TimestampedSetClient>>();
|
|
||||||
|
|
||||||
client = scope.ServiceProvider
|
client = persistenceClientFactory.GetTimestampedSetClient();
|
||||||
.GetRequiredService<ITimestampedSetClient>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
using DD.Persistence.Client;
|
|
||||||
using DD.Persistence.Client.Clients;
|
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
|
||||||
using DD.Persistence.Client.Clients.Interfaces.Refit;
|
|
||||||
using DD.Persistence.Database.Entity;
|
|
||||||
using DD.Persistence.Models;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using DD.Persistence.Models;
|
||||||
|
using System.Net;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
|
using DD.Persistence.Client;
|
||||||
|
using DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers;
|
namespace DD.Persistence.IntegrationTests.Controllers;
|
||||||
public class WitsDataControllerTest : BaseIntegrationTest
|
public class WitsDataControllerTest : BaseIntegrationTest
|
||||||
@ -15,12 +13,11 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
|
|
||||||
public WitsDataControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public WitsDataControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var refitClientFactory = scope.ServiceProvider
|
var scope = factory.Services.CreateScope();
|
||||||
.GetRequiredService<IRefitClientFactory<IRefitWitsDataClient>>();
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
var logger = scope.ServiceProvider.GetRequiredService<ILogger<WitsDataClient>>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
witsDataClient = scope.ServiceProvider
|
witsDataClient = persistenceClientFactory.GetWitsDataClient();
|
||||||
.GetRequiredService<IWitsDataClient>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using DD.Persistence.Client.Helpers;
|
namespace DD.Persistence.IntegrationTests
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Фабрика HTTP клиентов для интеграционных тестов
|
/// Фабрика HTTP клиентов для интеграционных тестов
|
||||||
@ -9,19 +6,14 @@ namespace DD.Persistence.IntegrationTests
|
|||||||
public class TestHttpClientFactory : IHttpClientFactory
|
public class TestHttpClientFactory : IHttpClientFactory
|
||||||
{
|
{
|
||||||
private readonly WebAppFactoryFixture factory;
|
private readonly WebAppFactoryFixture factory;
|
||||||
private readonly IConfiguration configuration;
|
|
||||||
|
|
||||||
public TestHttpClientFactory(WebAppFactoryFixture factory, IConfiguration configuration)
|
public TestHttpClientFactory(WebAppFactoryFixture factory)
|
||||||
{
|
{
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.configuration = configuration;
|
|
||||||
}
|
}
|
||||||
public HttpClient CreateClient(string name)
|
public HttpClient CreateClient(string name)
|
||||||
{
|
{
|
||||||
var client = factory.CreateClient();
|
return factory.CreateClient();
|
||||||
client.Authorize(configuration);
|
|
||||||
|
|
||||||
return client;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,6 @@ using DD.Persistence.Database.Model;
|
|||||||
using DD.Persistence.Database.Postgres;
|
using DD.Persistence.Database.Postgres;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
using DD.Persistence.App;
|
using DD.Persistence.App;
|
||||||
using DD.Persistence.Client.Helpers;
|
|
||||||
using DD.Persistence.Factories;
|
|
||||||
using System.Net;
|
|
||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests;
|
namespace DD.Persistence.IntegrationTests;
|
||||||
public class WebAppFactoryFixture : WebApplicationFactory<Program>
|
public class WebAppFactoryFixture : WebApplicationFactory<Program>
|
||||||
@ -43,12 +40,12 @@ public class WebAppFactoryFixture : WebApplicationFactory<Program>
|
|||||||
services.AddLogging(builder => builder.AddConsole());
|
services.AddLogging(builder => builder.AddConsole());
|
||||||
|
|
||||||
services.RemoveAll<IHttpClientFactory>();
|
services.RemoveAll<IHttpClientFactory>();
|
||||||
services.AddSingleton<IHttpClientFactory>((provider) =>
|
services.AddSingleton<IHttpClientFactory>(provider =>
|
||||||
{
|
{
|
||||||
return new TestHttpClientFactory(this, provider.GetRequiredService<IConfiguration>());
|
return new TestHttpClientFactory(this);
|
||||||
});
|
});
|
||||||
services.AddHttpClient();
|
|
||||||
services.AddPersistenceClients();
|
services.AddSingleton<PersistenceClientFactory>();
|
||||||
|
|
||||||
var serviceProvider = services.BuildServiceProvider();
|
var serviceProvider = services.BuildServiceProvider();
|
||||||
|
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
||||||
|
|
||||||
<!--Генерация NuGet пакета при сборке-->
|
|
||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
|
||||||
<!--Наименование-->
|
|
||||||
<Title>DD.Persistence.Models</Title>
|
|
||||||
<!--Версия пакета-->
|
|
||||||
<VersionPrefix>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
|
|
||||||
<!--Версия сборки-->
|
|
||||||
<AssemblyVersion>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
|
|
||||||
<!--Id пакета-->
|
|
||||||
<PackageId>DD.Persistence.Models</PackageId>
|
|
||||||
|
|
||||||
<!--Автор-->
|
|
||||||
<Authors>Digital Drilling</Authors>
|
|
||||||
<!--Компания-->
|
|
||||||
<Company>Digital Drilling</Company>
|
|
||||||
<!--Описание-->
|
|
||||||
<Description>Пакет для получения dtos для работы с Persistence сервисом</Description>
|
|
||||||
|
|
||||||
<!--Url репозитория-->
|
|
||||||
<RepositoryUrl>https://git.ddrilling.ru/on.nemtina/persistence.git</RepositoryUrl>
|
|
||||||
<!--тип репозитория-->
|
|
||||||
<RepositoryType>git</RepositoryType>
|
|
||||||
<!--Символы отладки-->
|
|
||||||
<IncludeSymbols>true</IncludeSymbols>
|
|
||||||
<!--Формат пакета с символами-->
|
|
||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
|
||||||
<!--Путь к пакету-->
|
|
||||||
<PackageOutputPath>C:\Projects\Nuget\Persistence\Models</PackageOutputPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.3.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,8 +1,8 @@
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using DD.Persistence.Database.Entity;
|
|
||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
using DD.Persistence.Repositories;
|
using DD.Persistence.Repositories;
|
||||||
|
using DD.Persistence.Database.Entity;
|
||||||
|
|
||||||
namespace DD.Persistence.Repository.Repositories;
|
namespace DD.Persistence.Repository.Repositories;
|
||||||
public class ParameterRepository : IParameterRepository
|
public class ParameterRepository : IParameterRepository
|
||||||
@ -83,4 +83,105 @@ public class ParameterRepository : IParameterRepository
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public async Task<int> AddRange(IEnumerable<ParameterDto> dtos, CancellationToken token)
|
||||||
|
//{
|
||||||
|
// int result = 0;
|
||||||
|
|
||||||
|
// var groups = dtos.GroupBy(e => e.ParameterId / 1000);
|
||||||
|
// foreach (var group in groups)
|
||||||
|
// {
|
||||||
|
// switch (group.Key)
|
||||||
|
// {
|
||||||
|
// case 1:
|
||||||
|
// result += await AddRange<ParameterData1>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 2:
|
||||||
|
// result += await AddRange<ParameterData2>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 3:
|
||||||
|
// result += await AddRange<ParameterData3>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 4:
|
||||||
|
// result += await AddRange<ParameterData4>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 5:
|
||||||
|
// result += await AddRange<ParameterData5>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 6:
|
||||||
|
// result += await AddRange<ParameterData6>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 7:
|
||||||
|
// result += await AddRange<ParameterData7>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 8:
|
||||||
|
// result += await AddRange<ParameterData8>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 9:
|
||||||
|
// result += await AddRange<ParameterData9>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 10:
|
||||||
|
// result += await AddRange<ParameterData10>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 11:
|
||||||
|
// result += await AddRange<ParameterData11>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 12:
|
||||||
|
// result += await AddRange<ParameterData12>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 13:
|
||||||
|
// result += await AddRange<ParameterData13>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 14:
|
||||||
|
// result += await AddRange<ParameterData14>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 15:
|
||||||
|
// result += await AddRange<ParameterData15>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 16:
|
||||||
|
// result += await AddRange<ParameterData16>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 17:
|
||||||
|
// result += await AddRange<ParameterData17>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 18:
|
||||||
|
// result += await AddRange<ParameterData18>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 19:
|
||||||
|
// result += await AddRange<ParameterData19>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 20:
|
||||||
|
// result += await AddRange<ParameterData20>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 21:
|
||||||
|
// result += await AddRange<ParameterData21>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 22:
|
||||||
|
// result += await AddRange<ParameterData22>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 23:
|
||||||
|
// result += await AddRange<ParameterData23>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 24:
|
||||||
|
// result += await AddRange<ParameterData24>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// case 25:
|
||||||
|
// result += await AddRange<ParameterData25>(dtos, token);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return result;
|
||||||
|
//}
|
||||||
|
//private async Task<int> AddRange<T>(IEnumerable<ParameterDto> dtos, CancellationToken token)
|
||||||
|
// where T : ParameterData
|
||||||
|
//{
|
||||||
|
// var t = dtos.Where(e => e.Value == null);
|
||||||
|
// var entities = dtos.Select(e => e.Adapt<T>());
|
||||||
|
// var tt = entities.Where(e => e.Value == null);
|
||||||
|
// await db.Set<T>().AddRangeAsync(entities, token);
|
||||||
|
// var result = await db.SaveChangesAsync(token);
|
||||||
|
|
||||||
|
// return result;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,6 @@ namespace DD.Persistence.Repository.Repositories
|
|||||||
await CreateSystemIfNotExist(systemId, token);
|
await CreateSystemIfNotExist(systemId, token);
|
||||||
|
|
||||||
entity.SystemId = systemId;
|
entity.SystemId = systemId;
|
||||||
entity.Timestamp = dto.Timestamp.ToUniversalTime();
|
|
||||||
|
|
||||||
entities.Add(entity);
|
entities.Add(entity);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.9.34714.143
|
VisualStudioVersion = 17.9.34714.143
|
||||||
@ -19,7 +18,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.Client", "DD
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.App", "DD.Persistence.App\DD.Persistence.App.csproj", "{063238BF-E982-43FA-9DDB-7D7D279086D8}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DD.Persistence.App", "DD.Persistence.App\DD.Persistence.App.csproj", "{063238BF-E982-43FA-9DDB-7D7D279086D8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DD.Persistence.Models", "DD.Persistence.Models\DD.Persistence.Models.csproj", "{698B4571-BB7A-4A42-8B0B-6C7F2F5360FB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DD.Persistence.Benchmark", "DD.Persistence.Benchmark\DD.Persistence.Benchmark.csproj", "{89975A38-C78B-4464-A04D-D63E8745062D}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -59,10 +58,10 @@ Global
|
|||||||
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
|
||||||
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{063238BF-E982-43FA-9DDB-7D7D279086D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{698B4571-BB7A-4A42-8B0B-6C7F2F5360FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{89975A38-C78B-4464-A04D-D63E8745062D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{698B4571-BB7A-4A42-8B0B-6C7F2F5360FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{89975A38-C78B-4464-A04D-D63E8745062D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{698B4571-BB7A-4A42-8B0B-6C7F2F5360FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{89975A38-C78B-4464-A04D-D63E8745062D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{698B4571-BB7A-4A42-8B0B-6C7F2F5360FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
{89975A38-C78B-4464-A04D-D63E8745062D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -18,10 +18,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
||||||
</ItemGroup>
|
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.3.0" />
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\DD.Persistence.Models\DD.Persistence.Models.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -19,7 +19,6 @@ namespace DD.Persistence.Repositories
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление новых сообщений
|
/// Добавление новых сообщений
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="systemId"></param>
|
|
||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
22
Persistence.Benchmark/Database/Entities/ParameterData.cs
Normal file
22
Persistence.Benchmark/Database/Entities/ParameterData.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace Persistence.Benchmark.Database.Entities;
|
||||||
|
public class ParameterData
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
[Required, Comment("Дискриминатор системы")]
|
||||||
|
public Guid DiscriminatorId { get; set; }
|
||||||
|
|
||||||
|
[Comment("Id параметра")]
|
||||||
|
public int ParameterId { get; set; }
|
||||||
|
|
||||||
|
[Column(TypeName = "varchar(256)"), Comment("Значение параметра в виде строки")]
|
||||||
|
public required string Value { get; set; }
|
||||||
|
|
||||||
|
[Comment("Временная отметка")]
|
||||||
|
public DateTimeOffset Timestamp { get; set; }
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user