Merge pull request 'feature/#524-pipline' (#15) from feature/#524-pipline into master
All checks were successful
Unit tests / test (push) Successful in 1m2s
All checks were successful
Unit tests / test (push) Successful in 1m2s
Reviewed-on: #15
This commit is contained in:
commit
ebc2978df2
38
.gitea/workflows/test.yaml
Normal file
38
.gitea/workflows/test.yaml
Normal file
@ -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
|
@ -16,12 +16,12 @@ namespace DD.Persistence.API;
|
|||||||
|
|
||||||
public static class DependencyInjection
|
public static class DependencyInjection
|
||||||
{
|
{
|
||||||
public static void MapsterSetup()
|
//public static void MapsterSetup()
|
||||||
{
|
//{
|
||||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
// TypeAdapterConfig.GlobalSettings.Default.Config
|
||||||
.ForType<TechMessageDto, TechMessage>()
|
// .ForType<TechMessageDto, TechMessage>()
|
||||||
.Ignore(dest => dest.System, dest => dest.SystemId);
|
// .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 =>
|
||||||
|
@ -27,7 +27,7 @@ public class Startup
|
|||||||
services.AddMemoryCache();
|
services.AddMemoryCache();
|
||||||
services.AddServices();
|
services.AddServices();
|
||||||
|
|
||||||
DependencyInjection.MapsterSetup();
|
//DependencyInjection.MapsterSetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
using DD.Persistence.API;
|
using DD.Persistence.API;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace DD.Persistence.App;
|
namespace DD.Persistence.App;
|
||||||
|
|
||||||
@ -7,7 +8,8 @@ public class Program
|
|||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
CultureInfo uiCulture = CultureInfo.CurrentUICulture;
|
||||||
|
CultureInfo.CurrentUICulture = new CultureInfo("en-EN");
|
||||||
var host = CreateHostBuilder(args).Build();
|
var host = CreateHostBuilder(args).Build();
|
||||||
Startup.BeforeRunHandler(host);
|
Startup.BeforeRunHandler(host);
|
||||||
host.Run();
|
host.Run();
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
{
|
{
|
||||||
"DbConnection": {
|
"DbConnection": {
|
||||||
"Host": "localhost",
|
"Host": "postgres",
|
||||||
"Port": 5432,
|
"Port": 5432,
|
||||||
|
"Database": "persistence",
|
||||||
"Username": "postgres",
|
"Username": "postgres",
|
||||||
"Password": "q"
|
"Password": "postgres"
|
||||||
},
|
},
|
||||||
"NeedUseKeyCloak": false,
|
"NeedUseKeyCloak": false,
|
||||||
"AuthUser": {
|
"AuthUser": {
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Host=localhost;Database=persistence;Username=postgres;Password=q;Persist Security Info=True"
|
"DefaultConnection": "Host=localhost;Port=5432;Database=persistence;Username=postgres;Password=postgres;Persist Security Info=True"
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"NeedUseKeyCloak": false,
|
"NeedUseKeyCloak": false,
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class SetpointMigration : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Setpoint",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
|
||||||
Created = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата изменения уставки"),
|
|
||||||
Value = table.Column<object>(type: "jsonb", nullable: false, comment: "Значение уставки"),
|
|
||||||
IdUser = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id автора последнего изменения")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Setpoint", x => new { x.Key, x.Created });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Setpoint");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,169 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
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 DD.Persistence.Database.Model;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PersistenceDbContext))]
|
|
||||||
[Migration("20241126071115_Add_ChangeLog")]
|
|
||||||
partial class Add_ChangeLog
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
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("DD.Persistence.Database.Model.ChangeLog", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasColumnName("Id");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Creation")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("Creation");
|
|
||||||
|
|
||||||
b.Property<double>("DepthEnd")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("DepthEnd");
|
|
||||||
|
|
||||||
b.Property<double>("DepthStart")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("DepthStart");
|
|
||||||
|
|
||||||
b.Property<Guid>("IdAuthor")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasColumnName("IdAuthor");
|
|
||||||
|
|
||||||
b.Property<Guid>("IdDiscriminator")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasColumnName("IdDiscriminator");
|
|
||||||
|
|
||||||
b.Property<Guid?>("IdEditor")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasColumnName("IdEditor");
|
|
||||||
|
|
||||||
b.Property<Guid?>("IdNext")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasColumnName("IdNext");
|
|
||||||
|
|
||||||
b.Property<Guid>("IdSection")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasColumnName("IdSection");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset?>("Obsolete")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("Obsolete");
|
|
||||||
|
|
||||||
b.Property<IDictionary<string, object>>("Value")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasColumnName("Value");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("ChangeLog");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
|
||||||
{
|
|
||||||
b.Property<DateTimeOffset>("Date")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date");
|
|
||||||
|
|
||||||
b.Property<double?>("AxialLoad")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("axialLoad");
|
|
||||||
|
|
||||||
b.Property<double?>("BitDepth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("bitDepth");
|
|
||||||
|
|
||||||
b.Property<double?>("BlockPosition")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("blockPosition");
|
|
||||||
|
|
||||||
b.Property<double?>("BlockSpeed")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("blockSpeed");
|
|
||||||
|
|
||||||
b.Property<double?>("Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("flow");
|
|
||||||
|
|
||||||
b.Property<double?>("HookWeight")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("hookWeight");
|
|
||||||
|
|
||||||
b.Property<int>("IdFeedRegulator")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("idFeedRegulator");
|
|
||||||
|
|
||||||
b.Property<int?>("Mode")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("mode");
|
|
||||||
|
|
||||||
b.Property<double?>("Mse")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("mse");
|
|
||||||
|
|
||||||
b.Property<short>("MseState")
|
|
||||||
.HasColumnType("smallint")
|
|
||||||
.HasColumnName("mseState");
|
|
||||||
|
|
||||||
b.Property<double?>("Pressure")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pressure");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump0Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump0Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump1Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump1Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump2Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump2Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("RotorSpeed")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("rotorSpeed");
|
|
||||||
|
|
||||||
b.Property<double?>("RotorTorque")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("rotorTorque");
|
|
||||||
|
|
||||||
b.Property<string>("User")
|
|
||||||
.HasColumnType("text")
|
|
||||||
.HasColumnName("user");
|
|
||||||
|
|
||||||
b.Property<double?>("WellDepth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("wellDepth");
|
|
||||||
|
|
||||||
b.HasKey("Date");
|
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class Add_ChangeLog : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ChangeLog",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
IdAuthor = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
IdEditor = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
Creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
Obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
||||||
IdNext = table.Column<Guid>(type: "uuid", nullable: true),
|
|
||||||
DepthStart = table.Column<double>(type: "double precision", nullable: false),
|
|
||||||
DepthEnd = table.Column<double>(type: "double precision", nullable: false),
|
|
||||||
IdSection = table.Column<Guid>(type: "uuid", nullable: false),
|
|
||||||
Value = table.Column<IDictionary<string, object>>(type: "jsonb", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ChangeLog", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ChangeLog");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,162 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using DD.Persistence.Database.Model;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PersistencePostgresContext))]
|
|
||||||
[Migration("20241126100631_Init")]
|
|
||||||
partial class Init
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
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("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("IdDiscriminator")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Дискриминатор ссылка на тип сохраняемых данных");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Timestamp")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasComment("Отметка времени, строго в UTC");
|
|
||||||
|
|
||||||
b.Property<string>("Set")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasComment("Набор сохраняемых данных");
|
|
||||||
|
|
||||||
b.HasKey("IdDiscriminator", "Timestamp");
|
|
||||||
|
|
||||||
b.ToTable("TimestampedSets", t =>
|
|
||||||
{
|
|
||||||
t.HasComment("Общая таблица данных временных рядов");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
|
||||||
{
|
|
||||||
b.Property<DateTimeOffset>("Date")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date");
|
|
||||||
|
|
||||||
b.Property<double?>("AxialLoad")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("axialLoad");
|
|
||||||
|
|
||||||
b.Property<double?>("BitDepth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("bitDepth");
|
|
||||||
|
|
||||||
b.Property<double?>("BlockPosition")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("blockPosition");
|
|
||||||
|
|
||||||
b.Property<double?>("BlockSpeed")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("blockSpeed");
|
|
||||||
|
|
||||||
b.Property<double?>("Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("flow");
|
|
||||||
|
|
||||||
b.Property<double?>("HookWeight")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("hookWeight");
|
|
||||||
|
|
||||||
b.Property<int>("IdFeedRegulator")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("idFeedRegulator");
|
|
||||||
|
|
||||||
b.Property<int?>("Mode")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("mode");
|
|
||||||
|
|
||||||
b.Property<double?>("Mse")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("mse");
|
|
||||||
|
|
||||||
b.Property<short>("MseState")
|
|
||||||
.HasColumnType("smallint")
|
|
||||||
.HasColumnName("mseState");
|
|
||||||
|
|
||||||
b.Property<double?>("Pressure")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pressure");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump0Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump0Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump1Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump1Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump2Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump2Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("RotorSpeed")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("rotorSpeed");
|
|
||||||
|
|
||||||
b.Property<double?>("RotorTorque")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("rotorTorque");
|
|
||||||
|
|
||||||
b.Property<string>("User")
|
|
||||||
.HasColumnType("text")
|
|
||||||
.HasColumnName("user");
|
|
||||||
|
|
||||||
b.Property<double?>("WellDepth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("wellDepth");
|
|
||||||
|
|
||||||
b.HasKey("Date");
|
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Key")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Ключ");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Created")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasComment("Дата создания уставки");
|
|
||||||
|
|
||||||
b.Property<int>("IdUser")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasComment("Id автора последнего изменения");
|
|
||||||
|
|
||||||
b.Property<object>("Value")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasComment("Значение уставки");
|
|
||||||
|
|
||||||
b.HasKey("Key", "Created");
|
|
||||||
|
|
||||||
b.ToTable("Setpoint");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class Init : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AlterDatabase()
|
|
||||||
.Annotation("Npgsql:PostgresExtension:adminpack", ",,");
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "DataSaub",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
||||||
mode = table.Column<int>(type: "integer", nullable: true),
|
|
||||||
user = table.Column<string>(type: "text", nullable: true),
|
|
||||||
wellDepth = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
bitDepth = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
blockPosition = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
blockSpeed = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
pressure = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
axialLoad = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
hookWeight = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
rotorTorque = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
rotorSpeed = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
flow = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
mseState = table.Column<short>(type: "smallint", nullable: false),
|
|
||||||
idFeedRegulator = table.Column<int>(type: "integer", nullable: false),
|
|
||||||
mse = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
pump0Flow = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
pump1Flow = table.Column<double>(type: "double precision", nullable: true),
|
|
||||||
pump2Flow = table.Column<double>(type: "double precision", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_DataSaub", x => x.date);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Setpoint",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Key = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
|
||||||
Created = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"),
|
|
||||||
Value = table.Column<object>(type: "jsonb", nullable: false, comment: "Значение уставки"),
|
|
||||||
IdUser = table.Column<int>(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<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"),
|
|
||||||
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Отметка времени, строго в UTC"),
|
|
||||||
Set = table.Column<string>(type: "jsonb", nullable: false, comment: "Набор сохраняемых данных")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_TimestampedSets", x => new { x.IdDiscriminator, x.Timestamp });
|
|
||||||
},
|
|
||||||
comment: "Общая таблица данных временных рядов");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "DataSaub");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Setpoint");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "TimestampedSets");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,257 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
using DD.Persistence.Database.Model;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PersistenceDbContext))]
|
|
||||||
[Migration("20241203120141_ParameterDataMigration")]
|
|
||||||
partial class ParameterDataMigration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
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("DD.Persistence.Database.Entity.DrillingSystem", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("SystemId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Id системы автобурения");
|
|
||||||
|
|
||||||
b.Property<string>("Description")
|
|
||||||
.HasColumnType("text")
|
|
||||||
.HasComment("Описание системы автобурения");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("varchar(256)")
|
|
||||||
.HasComment("Наименование системы автобурения");
|
|
||||||
|
|
||||||
b.HasKey("SystemId");
|
|
||||||
|
|
||||||
b.ToTable("DrillingSystem");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("DiscriminatorId")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasComment("Дискриминатор системы");
|
|
||||||
|
|
||||||
b.Property<int>("ParameterId")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasComment("Id параметра");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Timestamp")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasComment("Временная отметка");
|
|
||||||
|
|
||||||
b.Property<string>("Value")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("varchar(256)")
|
|
||||||
.HasComment("Значение параметра в виде строки");
|
|
||||||
|
|
||||||
b.HasKey("DiscriminatorId", "ParameterId", "Timestamp");
|
|
||||||
|
|
||||||
b.ToTable("ParameterData");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("EventId")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Id события");
|
|
||||||
|
|
||||||
b.Property<int>("CategoryId")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasComment("Id Категории важности");
|
|
||||||
|
|
||||||
b.Property<double?>("Depth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasComment("Глубина забоя");
|
|
||||||
|
|
||||||
b.Property<string>("MessageText")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("varchar(512)")
|
|
||||||
.HasComment("Текст сообщения");
|
|
||||||
|
|
||||||
b.Property<Guid>("SystemId")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Id системы автобурения, к которой относится сообщение");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Timestamp")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasComment("Дата возникновения");
|
|
||||||
|
|
||||||
b.Property<Guid>("UserId")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Id пользователя за пультом бурильщика");
|
|
||||||
|
|
||||||
b.HasKey("EventId");
|
|
||||||
|
|
||||||
b.HasIndex("SystemId");
|
|
||||||
|
|
||||||
b.ToTable("TechMessage");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TimestampedSet", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("IdDiscriminator")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Дискриминатор ссылка на тип сохраняемых данных");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Timestamp")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasComment("Отметка времени, строго в UTC");
|
|
||||||
|
|
||||||
b.Property<string>("Set")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasComment("Набор сохраняемых данных");
|
|
||||||
|
|
||||||
b.HasKey("IdDiscriminator", "Timestamp");
|
|
||||||
|
|
||||||
b.ToTable("TimestampedSets", t =>
|
|
||||||
{
|
|
||||||
t.HasComment("Общая таблица данных временных рядов");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.DataSaub", b =>
|
|
||||||
{
|
|
||||||
b.Property<DateTimeOffset>("Date")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasColumnName("date");
|
|
||||||
|
|
||||||
b.Property<double?>("AxialLoad")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("axialLoad");
|
|
||||||
|
|
||||||
b.Property<double?>("BitDepth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("bitDepth");
|
|
||||||
|
|
||||||
b.Property<double?>("BlockPosition")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("blockPosition");
|
|
||||||
|
|
||||||
b.Property<double?>("BlockSpeed")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("blockSpeed");
|
|
||||||
|
|
||||||
b.Property<double?>("Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("flow");
|
|
||||||
|
|
||||||
b.Property<double?>("HookWeight")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("hookWeight");
|
|
||||||
|
|
||||||
b.Property<int>("IdFeedRegulator")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("idFeedRegulator");
|
|
||||||
|
|
||||||
b.Property<int?>("Mode")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("mode");
|
|
||||||
|
|
||||||
b.Property<double?>("Mse")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("mse");
|
|
||||||
|
|
||||||
b.Property<short>("MseState")
|
|
||||||
.HasColumnType("smallint")
|
|
||||||
.HasColumnName("mseState");
|
|
||||||
|
|
||||||
b.Property<double?>("Pressure")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pressure");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump0Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump0Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump1Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump1Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("Pump2Flow")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("pump2Flow");
|
|
||||||
|
|
||||||
b.Property<double?>("RotorSpeed")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("rotorSpeed");
|
|
||||||
|
|
||||||
b.Property<double?>("RotorTorque")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("rotorTorque");
|
|
||||||
|
|
||||||
b.Property<string>("User")
|
|
||||||
.HasColumnType("text")
|
|
||||||
.HasColumnName("user");
|
|
||||||
|
|
||||||
b.Property<double?>("WellDepth")
|
|
||||||
.HasColumnType("double precision")
|
|
||||||
.HasColumnName("wellDepth");
|
|
||||||
|
|
||||||
b.HasKey("Date");
|
|
||||||
|
|
||||||
b.ToTable("DataSaub");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Model.Setpoint", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("Key")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Ключ");
|
|
||||||
|
|
||||||
b.Property<DateTimeOffset>("Created")
|
|
||||||
.HasColumnType("timestamp with time zone")
|
|
||||||
.HasComment("Дата создания уставки");
|
|
||||||
|
|
||||||
b.Property<Guid>("IdUser")
|
|
||||||
.HasColumnType("uuid")
|
|
||||||
.HasComment("Id автора последнего изменения");
|
|
||||||
|
|
||||||
b.Property<object>("Value")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("jsonb")
|
|
||||||
.HasComment("Значение уставки");
|
|
||||||
|
|
||||||
b.HasKey("Key", "Created");
|
|
||||||
|
|
||||||
b.ToTable("Setpoint");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("DD.Persistence.Database.Entity.DrillingSystem", "System")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("SystemId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("System");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class ParameterDataMigration : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "ParameterData",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
|
||||||
ParameterId = table.Column<int>(type: "integer", nullable: false, comment: "Id параметра"),
|
|
||||||
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
|
|
||||||
Value = table.Column<string>(type: "varchar(256)", nullable: false, comment: "Значение параметра в виде строки")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_ParameterData", x => new { x.DiscriminatorId, x.ParameterId, x.Timestamp });
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "ParameterData");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class TechMessageMigration : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "DataSourceSystem",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
|
||||||
Name = table.Column<string>(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"),
|
|
||||||
Description = table.Column<string>(type: "text", nullable: true, comment: "Описание системы - источника данных")
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "TechMessage",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
EventId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
|
||||||
CategoryId = table.Column<int>(type: "integer", nullable: false, comment: "Id Категории важности"),
|
|
||||||
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"),
|
|
||||||
Text = table.Column<string>(type: "varchar(512)", nullable: false, comment: "Текст сообщения"),
|
|
||||||
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"),
|
|
||||||
EventState = table.Column<int>(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");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "TechMessage");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "DataSourceSystem");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +1,49 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
|
using DD.Persistence.Database.Model;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using DD.Persistence.Database.Model;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres
|
namespace DD.Persistence.Database.Postgres.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PersistencePostgresContext))]
|
[DbContext(typeof(PersistencePostgresContext))]
|
||||||
[Migration("20241212041758_TechMessageMigration")]
|
[Migration("20241220062251_Init")]
|
||||||
partial class TechMessageMigration
|
partial class Init
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.UseCollation("Russian_Russia.1251")
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.DrillingSystem", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("SystemId")
|
b.Property<Guid>("SystemId")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
.HasColumnType("uuid")
|
.HasColumnType("uuid")
|
||||||
.HasComment("Id системы автобурения");
|
.HasComment("Id системы - источника данных");
|
||||||
|
|
||||||
b.Property<string>("Description")
|
b.Property<string>("Description")
|
||||||
.HasColumnType("text")
|
.HasColumnType("text")
|
||||||
.HasComment("Описание системы автобурения");
|
.HasComment("Описание системы - источника данных");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("varchar(256)")
|
.HasColumnType("varchar(256)")
|
||||||
.HasComment("Наименование системы автобурения");
|
.HasComment("Наименование системы - источника данных");
|
||||||
|
|
||||||
b.HasKey("SystemId");
|
b.HasKey("SystemId");
|
||||||
|
|
||||||
b.ToTable("DrillingSystem");
|
b.ToTable("DataSourceSystem");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.ParameterData", b =>
|
||||||
@ -292,7 +290,7 @@ namespace DD.Persistence.Database.Postgres.Migrations.PersistencePostgres
|
|||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.TechMessage", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("DD.Persistence.Database.Entity.DrillingSystem", "System")
|
b.HasOne("DD.Persistence.Database.Entity.DataSourceSystem", "System")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("SystemId")
|
.HasForeignKey("SystemId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
@ -0,0 +1,172 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace DD.Persistence.Database.Postgres.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Init : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ChangeLog",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ записи"),
|
||||||
|
IdDiscriminator = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор таблицы"),
|
||||||
|
IdAuthor = table.Column<Guid>(type: "uuid", nullable: false, comment: "Автор изменения"),
|
||||||
|
IdEditor = table.Column<Guid>(type: "uuid", nullable: true, comment: "Редактор"),
|
||||||
|
Creation = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата создания записи"),
|
||||||
|
Obsolete = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true, comment: "Дата устаревания (например при удалении)"),
|
||||||
|
IdNext = table.Column<Guid>(type: "uuid", nullable: true, comment: "Id заменяющей записи"),
|
||||||
|
DepthStart = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина забоя на дату начала интервала"),
|
||||||
|
DepthEnd = table.Column<double>(type: "double precision", nullable: false, comment: "Глубина забоя на дату окончания интервала"),
|
||||||
|
IdSection = table.Column<Guid>(type: "uuid", nullable: false, comment: "Ключ секции"),
|
||||||
|
Value = table.Column<string>(type: "jsonb", nullable: false, comment: "Значение")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ChangeLog", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DataSaub",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
date = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
mode = table.Column<int>(type: "integer", nullable: true),
|
||||||
|
user = table.Column<string>(type: "text", nullable: true),
|
||||||
|
wellDepth = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
bitDepth = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
blockPosition = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
blockSpeed = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
pressure = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
axialLoad = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
hookWeight = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
rotorTorque = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
rotorSpeed = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
flow = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
mseState = table.Column<short>(type: "smallint", nullable: false),
|
||||||
|
idFeedRegulator = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
mse = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
pump0Flow = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
pump1Flow = table.Column<double>(type: "double precision", nullable: true),
|
||||||
|
pump2Flow = table.Column<double>(type: "double precision", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DataSaub", x => x.date);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DataSourceSystem",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы - источника данных"),
|
||||||
|
Name = table.Column<string>(type: "varchar(256)", nullable: false, comment: "Наименование системы - источника данных"),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: true, comment: "Описание системы - источника данных")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DataSourceSystem", x => x.SystemId);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ParameterData",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
DiscriminatorId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор системы"),
|
||||||
|
ParameterId = table.Column<int>(type: "integer", nullable: false, comment: "Id параметра"),
|
||||||
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Временная отметка"),
|
||||||
|
Value = table.Column<string>(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<Guid>(type: "uuid", nullable: false, comment: "Ключ"),
|
||||||
|
Created = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата создания уставки"),
|
||||||
|
Value = table.Column<object>(type: "jsonb", nullable: false, comment: "Значение уставки"),
|
||||||
|
IdUser = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false, comment: "Дискриминатор ссылка на тип сохраняемых данных"),
|
||||||
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Отметка времени, строго в UTC"),
|
||||||
|
Set = table.Column<string>(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<Guid>(type: "uuid", nullable: false, comment: "Id события"),
|
||||||
|
CategoryId = table.Column<int>(type: "integer", nullable: false, comment: "Id Категории важности"),
|
||||||
|
Timestamp = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, comment: "Дата возникновения"),
|
||||||
|
Text = table.Column<string>(type: "varchar(512)", nullable: false, comment: "Текст сообщения"),
|
||||||
|
SystemId = table.Column<Guid>(type: "uuid", nullable: false, comment: "Id системы, к которой относится сообщение"),
|
||||||
|
EventState = table.Column<int>(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");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
|
using DD.Persistence.Database.Model;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using DD.Persistence.Database.Model;
|
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
@ -17,11 +17,9 @@ namespace DD.Persistence.Database.Postgres.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.UseCollation("Russian_Russia.1251")
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
.HasAnnotation("ProductVersion", "8.0.10")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b =>
|
modelBuilder.Entity("DD.Persistence.Database.Entity.DataSourceSystem", b =>
|
||||||
|
@ -13,10 +13,6 @@ public partial class PersistencePostgresContext : PersistenceDbContext
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.HasPostgresExtension("adminpack")
|
|
||||||
.HasAnnotation("Relational:Collation", "Russian_Russia.1251");
|
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class ChangeLogControllerTest : BaseIntegrationTest
|
|||||||
var result = await client.ClearAndAddRange(idDiscriminator, dtos, new CancellationToken());
|
var result = await client.ClearAndAddRange(idDiscriminator, dtos, new CancellationToken());
|
||||||
|
|
||||||
// assert
|
// assert
|
||||||
Assert.Equal(insertedCount*2, result);
|
Assert.Equal(insertedCount * 2, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
@ -115,11 +115,11 @@ public class ChangeLogControllerTest : BaseIntegrationTest
|
|||||||
Assert.NotNull(changeLogResult);
|
Assert.NotNull(changeLogResult);
|
||||||
|
|
||||||
var obsoleteDto = changeLogResult
|
var obsoleteDto = changeLogResult
|
||||||
.Where(e => e.Obsolete.HasValue)
|
.Where(e => e.Obsolete.HasValue)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
var activeDto = changeLogResult
|
var activeDto = changeLogResult
|
||||||
.Where(e => !e.Obsolete.HasValue)
|
.Where(e => !e.Obsolete.HasValue)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (obsoleteDto == null || activeDto == null)
|
if (obsoleteDto == null || activeDto == null)
|
||||||
|
@ -9,74 +9,74 @@ using Xunit;
|
|||||||
|
|
||||||
namespace DD.Persistence.IntegrationTests.Controllers
|
namespace DD.Persistence.IntegrationTests.Controllers
|
||||||
{
|
{
|
||||||
public class DataSourceSystemControllerTest : BaseIntegrationTest
|
public class DataSourceSystemControllerTest : BaseIntegrationTest
|
||||||
{
|
{
|
||||||
private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey";
|
private static readonly string SystemCacheKey = $"{typeof(Database.Entity.DataSourceSystem).FullName}CacheKey";
|
||||||
private readonly IDataSourceSystemClient dataSourceSystemClient;
|
private readonly IDataSourceSystemClient dataSourceSystemClient;
|
||||||
private readonly IMemoryCache memoryCache;
|
private readonly IMemoryCache memoryCache;
|
||||||
public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory)
|
public DataSourceSystemControllerTest(WebAppFactoryFixture factory) : base(factory)
|
||||||
{
|
{
|
||||||
var scope = factory.Services.CreateScope();
|
var scope = factory.Services.CreateScope();
|
||||||
var persistenceClientFactory = scope.ServiceProvider
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
.GetRequiredService<PersistenceClientFactory>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient();
|
dataSourceSystemClient = persistenceClientFactory.GetDataSourceSystemClient();
|
||||||
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
memoryCache = scope.ServiceProvider.GetRequiredService<IMemoryCache>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Get_returns_success()
|
public async Task Get_returns_success()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
memoryCache.Remove(SystemCacheKey);
|
memoryCache.Remove(SystemCacheKey);
|
||||||
dbContext.CleanupDbSet<DataSourceSystem>();
|
dbContext.CleanupDbSet<DataSourceSystem>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await dataSourceSystemClient.Get(CancellationToken.None);
|
var response = await dataSourceSystemClient.Get(CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Get_AfterSave_returns_success()
|
public async Task Get_AfterSave_returns_success()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
await Add();
|
await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await dataSourceSystemClient.Get(CancellationToken.None);
|
var response = await dataSourceSystemClient.Get(CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
|
|
||||||
var expectedSystemCount = 1;
|
var expectedSystemCount = 1;
|
||||||
var actualSystemCount = response!.Count();
|
var actualSystemCount = response!.Count();
|
||||||
Assert.Equal(expectedSystemCount, actualSystemCount);
|
Assert.Equal(expectedSystemCount, actualSystemCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Add_returns_success()
|
public async Task Add_returns_success()
|
||||||
{
|
{
|
||||||
await Add();
|
await Add();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Add()
|
private async Task Add()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
memoryCache.Remove(SystemCacheKey);
|
memoryCache.Remove(SystemCacheKey);
|
||||||
dbContext.CleanupDbSet<DataSourceSystem>();
|
dbContext.CleanupDbSet<DataSourceSystem>();
|
||||||
|
|
||||||
var dto = new DataSourceSystemDto()
|
var dto = new DataSourceSystemDto()
|
||||||
{
|
{
|
||||||
SystemId = Guid.NewGuid(),
|
SystemId = Guid.NewGuid(),
|
||||||
Name = "Test",
|
Name = "Test",
|
||||||
Description = "Test"
|
Description = "Test"
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
await dataSourceSystemClient.Add(dto, CancellationToken.None);
|
await dataSourceSystemClient.Add(dto, CancellationToken.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
var persistenceClientFactory = scope.ServiceProvider
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
.GetRequiredService<PersistenceClientFactory>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
setpointClient = persistenceClientFactory.GetSetpointClient();
|
setpointClient = persistenceClientFactory.GetSetpointClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetCurrent_returns_success()
|
public async Task GetCurrent_returns_success()
|
||||||
@ -34,13 +34,13 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
Guid.NewGuid()
|
Guid.NewGuid()
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetCurrent(setpointKeys, new CancellationToken());
|
var response = await setpointClient.GetCurrent(setpointKeys, new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetCurrent_AfterSave_returns_success()
|
public async Task GetCurrent_AfterSave_returns_success()
|
||||||
@ -48,14 +48,14 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
//arrange
|
//arrange
|
||||||
var setpointKey = await Add();
|
var setpointKey = await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetCurrent([setpointKey], new CancellationToken());
|
var response = await setpointClient.GetCurrent([setpointKey], new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.NotEmpty(response);
|
Assert.NotEmpty(response);
|
||||||
Assert.Equal(setpointKey, response.FirstOrDefault()?.Key);
|
Assert.Equal(setpointKey, response.FirstOrDefault()?.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetHistory_returns_success()
|
public async Task GetHistory_returns_success()
|
||||||
@ -68,13 +68,13 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
};
|
};
|
||||||
var historyMoment = DateTimeOffset.UtcNow;
|
var historyMoment = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetHistory(setpointKeys, historyMoment, new CancellationToken());
|
var response = await setpointClient.GetHistory(setpointKeys, historyMoment, new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetHistory_AfterSave_returns_success()
|
public async Task GetHistory_AfterSave_returns_success()
|
||||||
@ -84,14 +84,14 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
var historyMoment = DateTimeOffset.UtcNow;
|
var historyMoment = DateTimeOffset.UtcNow;
|
||||||
historyMoment = historyMoment.AddDays(1);
|
historyMoment = historyMoment.AddDays(1);
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetHistory([setpointKey], historyMoment, new CancellationToken());
|
var response = await setpointClient.GetHistory([setpointKey], historyMoment, new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.NotEmpty(response);
|
Assert.NotEmpty(response);
|
||||||
Assert.Equal(setpointKey, response.FirstOrDefault()?.Key);
|
Assert.Equal(setpointKey, response.FirstOrDefault()?.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetLog_returns_success()
|
public async Task GetLog_returns_success()
|
||||||
@ -103,13 +103,13 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
Guid.NewGuid()
|
Guid.NewGuid()
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetLog(setpointKeys, new CancellationToken());
|
var response = await setpointClient.GetLog(setpointKeys, new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetLog_AfterSave_returns_success()
|
public async Task GetLog_AfterSave_returns_success()
|
||||||
@ -117,14 +117,14 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
//arrange
|
//arrange
|
||||||
var setpointKey = await Add();
|
var setpointKey = await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetLog([setpointKey], new CancellationToken());
|
var response = await setpointClient.GetLog([setpointKey], new CancellationToken());
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.NotEmpty(response);
|
Assert.NotEmpty(response);
|
||||||
Assert.Equal(setpointKey, response.FirstOrDefault().Key);
|
Assert.Equal(setpointKey, response.FirstOrDefault().Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetDatesRange_returns_success()
|
public async Task GetDatesRange_returns_success()
|
||||||
@ -132,14 +132,14 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
//arrange
|
//arrange
|
||||||
dbContext.CleanupDbSet<Setpoint>();
|
dbContext.CleanupDbSet<Setpoint>();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None);
|
var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Equal(DateTimeOffset.MinValue, response!.From);
|
Assert.Equal(DateTimeOffset.MinValue, response!.From);
|
||||||
Assert.Equal(DateTimeOffset.MaxValue, response!.To);
|
Assert.Equal(DateTimeOffset.MaxValue, response!.To);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetDatesRange_AfterSave_returns_success()
|
public async Task GetDatesRange_AfterSave_returns_success()
|
||||||
@ -149,27 +149,27 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
|
|
||||||
await Add();
|
await Add();
|
||||||
|
|
||||||
var dateBegin = DateTimeOffset.MinValue;
|
var dateBegin = DateTimeOffset.MinValue;
|
||||||
var take = 1;
|
var take = 1;
|
||||||
var part = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
var part = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None);
|
var response = await setpointClient.GetDatesRangeAsync(CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
|
|
||||||
var expectedValue = part!
|
var expectedValue = part!
|
||||||
.FirstOrDefault()!.Created
|
.FirstOrDefault()!.Created
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
var actualValueFrom = response.From
|
var actualValueFrom = response.From
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
Assert.Equal(expectedValue, actualValueFrom);
|
Assert.Equal(expectedValue, actualValueFrom);
|
||||||
|
|
||||||
var actualValueTo = response.To
|
var actualValueTo = response.To
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
Assert.Equal(expectedValue, actualValueTo);
|
Assert.Equal(expectedValue, actualValueTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetPart_returns_success()
|
public async Task GetPart_returns_success()
|
||||||
@ -178,13 +178,13 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
var dateBegin = DateTimeOffset.UtcNow;
|
var dateBegin = DateTimeOffset.UtcNow;
|
||||||
var take = 2;
|
var take = 2;
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetPart_AfterSave_returns_success()
|
public async Task GetPart_AfterSave_returns_success()
|
||||||
@ -194,13 +194,13 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
var take = 1;
|
var take = 1;
|
||||||
await Add();
|
await Add();
|
||||||
|
|
||||||
//act
|
//act
|
||||||
var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
var response = await setpointClient.GetPart(dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.NotEmpty(response);
|
Assert.NotEmpty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Save_returns_success()
|
public async Task Save_returns_success()
|
||||||
@ -218,10 +218,10 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
Value2 = 2
|
Value2 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
//act
|
//act
|
||||||
await setpointClient.Add(setpointKey, setpointValue, new CancellationToken());
|
await setpointClient.Add(setpointKey, setpointValue, new CancellationToken());
|
||||||
|
|
||||||
return setpointKey;
|
return setpointKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using DD.Persistence.Client;
|
using DD.Persistence.Client;
|
||||||
using DD.Persistence.Client.Clients.Interfaces;
|
using DD.Persistence.Client.Clients.Interfaces;
|
||||||
@ -209,20 +209,20 @@ namespace DD.Persistence.IntegrationTests.Controllers
|
|||||||
Assert.NotNull(response?.To);
|
Assert.NotNull(response?.To);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
// [Fact]
|
||||||
public async Task GetPart_returns_success()
|
// public async Task GetPart_returns_success()
|
||||||
{
|
// {
|
||||||
//arrange
|
// //arrange
|
||||||
var dateBegin = DateTimeOffset.UtcNow;
|
// var dateBegin = DateTimeOffset.UtcNow;
|
||||||
var take = 2;
|
// var take = 2;
|
||||||
|
|
||||||
//act
|
// //act
|
||||||
var response = await techMessagesClient.GetPart(dateBegin, take, CancellationToken.None);
|
// var response = await techMessagesClient.GetPart(dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
// //assert
|
||||||
Assert.NotNull(response);
|
// Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
// Assert.Empty(response);
|
||||||
}
|
//}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetPart_AfterSave_returns_success()
|
public async Task GetPart_AfterSave_returns_success()
|
||||||
|
@ -22,7 +22,7 @@ public abstract class TimeSeriesBaseControllerTest<TEntity, TDto> : BaseIntegrat
|
|||||||
var persistenceClientFactory = scope.ServiceProvider
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
.GetRequiredService<PersistenceClientFactory>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
timeSeriesClient = persistenceClientFactory.GetTimeSeriesClient<TDto>();
|
timeSeriesClient = persistenceClientFactory.GetTimeSeriesClient<TDto>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InsertRangeSuccess(TDto dto)
|
public async Task InsertRangeSuccess(TDto dto)
|
||||||
|
@ -72,7 +72,7 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Get_geDate()
|
public async Task Get_geDate()
|
||||||
{
|
{
|
||||||
// arrange
|
// arrange
|
||||||
@ -112,11 +112,11 @@ public class TimestampedSetControllerTest : BaseIntegrationTest
|
|||||||
|
|
||||||
// assert
|
// assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Equal(expectedCount, response.Count());
|
Assert.Equal(expectedCount, response.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Get_with_big_skip_take()
|
public async Task Get_with_big_skip_take()
|
||||||
{
|
{
|
||||||
// arrange
|
// arrange
|
||||||
|
@ -17,8 +17,8 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
var persistenceClientFactory = scope.ServiceProvider
|
var persistenceClientFactory = scope.ServiceProvider
|
||||||
.GetRequiredService<PersistenceClientFactory>();
|
.GetRequiredService<PersistenceClientFactory>();
|
||||||
|
|
||||||
witsDataClient = persistenceClientFactory.GetWitsDataClient();
|
witsDataClient = persistenceClientFactory.GetWitsDataClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetDatesRangeAsync_returns_success()
|
public async Task GetDatesRangeAsync_returns_success()
|
||||||
@ -31,9 +31,9 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None);
|
var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetPart_returns_success()
|
public async Task GetPart_returns_success()
|
||||||
@ -48,10 +48,10 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.GetPart(discriminatorId, dateBegin, take, CancellationToken.None);
|
var response = await witsDataClient.GetPart(discriminatorId, dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task InsertRange_returns_success()
|
public async Task InsertRange_returns_success()
|
||||||
@ -77,10 +77,10 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointCount, CancellationToken.None);
|
var response = await witsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointCount, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Empty(response);
|
Assert.Empty(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetDatesRangeAsync_AfterSave_returns_success()
|
public async Task GetDatesRangeAsync_AfterSave_returns_success()
|
||||||
@ -94,25 +94,25 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None);
|
var response = await witsDataClient.GetDatesRangeAsync(discriminatorId, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
|
|
||||||
var expectedDateFrom = dtos
|
var expectedDateFrom = dtos
|
||||||
.Select(e => e.Timestamped)
|
.Select(e => e.Timestamped)
|
||||||
.Min()
|
.Min()
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
var actualDateFrom = response.From.DateTime
|
var actualDateFrom = response.From.DateTime
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
Assert.Equal(expectedDateFrom, actualDateFrom);
|
Assert.Equal(expectedDateFrom, actualDateFrom);
|
||||||
|
|
||||||
var expectedDateTo = dtos
|
var expectedDateTo = dtos
|
||||||
.Select(e => e.Timestamped)
|
.Select(e => e.Timestamped)
|
||||||
.Max()
|
.Max()
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
var actualDateTo = response.To.DateTime
|
var actualDateTo = response.To.DateTime
|
||||||
.ToString("dd.MM.yyyy-HH:mm:ss");
|
.ToString("dd.MM.yyyy-HH:mm:ss");
|
||||||
Assert.Equal(expectedDateTo, actualDateTo);
|
Assert.Equal(expectedDateTo, actualDateTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetPart_AfterSave_returns_success()
|
public async Task GetPart_AfterSave_returns_success()
|
||||||
@ -128,14 +128,14 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.GetPart(discriminatorId, dateBegin, take, CancellationToken.None);
|
var response = await witsDataClient.GetPart(discriminatorId, dateBegin, take, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.NotEmpty(response);
|
Assert.NotEmpty(response);
|
||||||
Assert.Equal(take, response.Count());
|
Assert.Equal(take, response.Count());
|
||||||
|
|
||||||
var expectedDto = dtos.FirstOrDefault();
|
var expectedDto = dtos.FirstOrDefault();
|
||||||
var actualDto = response.FirstOrDefault();
|
var actualDto = response.FirstOrDefault();
|
||||||
Assert.Equal(expectedDto?.DiscriminatorId, actualDto?.DiscriminatorId);
|
Assert.Equal(expectedDto?.DiscriminatorId, actualDto?.DiscriminatorId);
|
||||||
|
|
||||||
var expectedValueDto = expectedDto?.Values.FirstOrDefault();
|
var expectedValueDto = expectedDto?.Values.FirstOrDefault();
|
||||||
var actualValueDto = actualDto?.Values.FirstOrDefault();
|
var actualValueDto = actualDto?.Values.FirstOrDefault();
|
||||||
@ -158,27 +158,27 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointCount, CancellationToken.None);
|
var response = await witsDataClient.GetValuesForGraph(discriminatorId, dateFrom, dateTo, approxPointCount, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
Assert.NotNull(response);
|
Assert.NotNull(response);
|
||||||
Assert.Equal(approxPointCount, response.Count());
|
Assert.Equal(approxPointCount, response.Count());
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task AddRange_returns_BadRequest()
|
public async Task AddRange_returns_BadRequest()
|
||||||
{
|
{
|
||||||
//arrange
|
//arrange
|
||||||
const string exceptionMessage = "Ошибка валидации, формата или маршрутизации запроса";
|
const string exceptionMessage = "Ошибка валидации, формата или маршрутизации запроса";
|
||||||
var dtos = new List<WitsDataDto>()
|
var dtos = new List<WitsDataDto>()
|
||||||
{
|
{
|
||||||
new WitsDataDto()
|
new WitsDataDto()
|
||||||
{
|
{
|
||||||
DiscriminatorId = Guid.NewGuid(),
|
DiscriminatorId = Guid.NewGuid(),
|
||||||
Timestamped = DateTimeOffset.UtcNow,
|
Timestamped = DateTimeOffset.UtcNow,
|
||||||
Values = new List<WitsValueDto>()
|
Values = new List<WitsValueDto>()
|
||||||
{
|
{
|
||||||
new WitsValueDto()
|
new WitsValueDto()
|
||||||
{
|
{
|
||||||
RecordId = -1, // < 0
|
RecordId = -1, // < 0
|
||||||
ItemId = 101, // > 100
|
ItemId = 101, // > 100
|
||||||
Value = string.Empty
|
Value = string.Empty
|
||||||
}
|
}
|
||||||
@ -186,17 +186,17 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//act
|
//act
|
||||||
var response = await witsDataClient.AddRange(dtos, CancellationToken.None);
|
var response = await witsDataClient.AddRange(dtos, CancellationToken.None);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
//assert
|
//assert
|
||||||
Assert.Equal(exceptionMessage, ex.Message);
|
Assert.Equal(exceptionMessage, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IEnumerable<WitsDataDto>> AddRange(int countToCreate = 10)
|
private async Task<IEnumerable<WitsDataDto>> AddRange(int countToCreate = 10)
|
||||||
{
|
{
|
||||||
@ -225,9 +225,9 @@ public class WitsDataControllerTest : BaseIntegrationTest
|
|||||||
//act
|
//act
|
||||||
var response = await witsDataClient.AddRange(dtos, CancellationToken.None);
|
var response = await witsDataClient.AddRange(dtos, CancellationToken.None);
|
||||||
|
|
||||||
//assert
|
//assert
|
||||||
var count = dtos.SelectMany(e => e.Values).Count();
|
var count = dtos.SelectMany(e => e.Values).Count();
|
||||||
Assert.Equal(count, response);
|
Assert.Equal(count, response);
|
||||||
|
|
||||||
return dtos;
|
return dtos;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ public class WebAppFactoryFixture : WebApplicationFactory<Program>
|
|||||||
|
|
||||||
var dbConnection = config.Build().GetSection("DbConnection").Get<DbConnection>()!;
|
var dbConnection = config.Build().GetSection("DbConnection").Get<DbConnection>()!;
|
||||||
connectionString = dbConnection.GetConnectionString();
|
connectionString = dbConnection.GetConnectionString();
|
||||||
|
//connectionString = "Host=postgres;Port=5442;Username=postgres;Password=postgres;Database=persistence";
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.ConfigureServices(services =>
|
builder.ConfigureServices(services =>
|
||||||
|
@ -4,6 +4,8 @@ using DD.Persistence.Database.Model;
|
|||||||
using DD.Persistence.Models;
|
using DD.Persistence.Models;
|
||||||
using DD.Persistence.Repositories;
|
using DD.Persistence.Repositories;
|
||||||
using DD.Persistence.Repository.Repositories;
|
using DD.Persistence.Repository.Repositories;
|
||||||
|
using DD.Persistence.Database.Entity;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace DD.Persistence.Repository;
|
namespace DD.Persistence.Repository;
|
||||||
public static class DependencyInjection
|
public static class DependencyInjection
|
||||||
@ -11,7 +13,10 @@ public static class DependencyInjection
|
|||||||
public static void MapsterSetup()
|
public static void MapsterSetup()
|
||||||
{
|
{
|
||||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||||
.ForType<ChangeLog, ChangeLogDto>()
|
.ForType<TechMessageDto, TechMessage>()
|
||||||
|
.Ignore(dest => dest.System, dest => dest.SystemId);
|
||||||
|
|
||||||
|
TypeAdapterConfig<ChangeLog, ChangeLogDto>.NewConfig()
|
||||||
.Map(dest => dest.Value, src => new DataWithWellDepthAndSectionDto()
|
.Map(dest => dest.Value, src => new DataWithWellDepthAndSectionDto()
|
||||||
{
|
{
|
||||||
DepthEnd = src.DepthEnd,
|
DepthEnd = src.DepthEnd,
|
||||||
@ -20,11 +25,14 @@ public static class DependencyInjection
|
|||||||
Value = src.Value,
|
Value = src.Value,
|
||||||
Id = src.Id
|
Id = src.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services)
|
public static IServiceCollection AddInfrastructure(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
var typeAdapterConfig = TypeAdapterConfig.GlobalSettings;
|
||||||
|
typeAdapterConfig.RuleMap.Clear();
|
||||||
|
typeAdapterConfig.Scan(Assembly.GetExecutingAssembly());
|
||||||
|
|
||||||
MapsterSetup();
|
MapsterSetup();
|
||||||
|
|
||||||
services.AddTransient<ITimeSeriesDataRepository<DataSaubDto>, TimeSeriesDataRepository<DataSaub, DataSaubDto>>();
|
services.AddTransient<ITimeSeriesDataRepository<DataSaubDto>, TimeSeriesDataRepository<DataSaub, DataSaubDto>>();
|
||||||
|
0
package-lock.json
generated
Normal file
0
package-lock.json
generated
Normal file
Loading…
Reference in New Issue
Block a user