diff --git a/docker-compose.dcproj b/docker-compose.dcproj index 4076c79..8e82e9e 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -1,4 +1,4 @@ - + 2.1 @@ -7,6 +7,7 @@ {Scheme}://localhost:{ServicePort} medica-info + 7e7ef294-40d8-48c7-933d-e9daf5c5602a diff --git a/medica-info/Components/Layout/MainLayout.razor b/medica-info/Components/Layout/MainLayout.razor index 3dc5218..3cd2827 100644 --- a/medica-info/Components/Layout/MainLayout.razor +++ b/medica-info/Components/Layout/MainLayout.razor @@ -6,9 +6,7 @@
-
- ТЕСТ - РКЛ + diff --git a/medica-info/Components/Pages/Rkl.razor b/medica-info/Components/Pages/Rkl.razor index da786b4..d6a4827 100644 --- a/medica-info/Components/Pages/Rkl.razor +++ b/medica-info/Components/Pages/Rkl.razor @@ -3,6 +3,7 @@ @using System.Threading.Tasks @inject HttpClient Http @rendermode RenderMode.InteractiveServer +@using medica_info.DB; RLK - Запрос данных @@ -57,8 +58,7 @@ private string responseMessage = ""; private string rawResponse = ""; // Переменная для хранения сырого контента private DateTime requestDate = DateTime.MinValue; - - private const string FixedToken = "f2d3394efba501f7e78f4f8d3a1b2e42"; + private const string FixedToken = "e96028d7a6ed72e22eb170964a165ab8"; private const string FixedType = "rkl"; private async Task HandleSubmit() @@ -76,7 +76,6 @@ $"docdate={requestModel.DocDate:dd.MM.yyyy}&" + $"birthdate={requestModel.BirthDate:dd.MM.yyyy}&" + $"token={FixedToken}"; - var result = await Http.GetAsync(url); // Получаем содержимое ответа как строку diff --git a/medica-info/DB/ApplicationDbContext.cs b/medica-info/DB/ApplicationDbContext.cs index 8ad7ef8..dca897b 100644 --- a/medica-info/DB/ApplicationDbContext.cs +++ b/medica-info/DB/ApplicationDbContext.cs @@ -1,6 +1,16 @@ -namespace medica_info.DB + +using medica_info.DB; +using Microsoft.EntityFrameworkCore; +public class AppDbContext : DbContext { - public class ApplicationDbContext + public DbSet rkl_Respons { set; get; } + public DbSet rkl_Requests { set; get; } + + public AppDbContext(DbContextOptions options) : base(options) { } -} + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + } +} \ No newline at end of file diff --git a/medica-info/DB/rkl_respons.cs b/medica-info/DB/rkl_respons.cs index 8db4772..b3ccf38 100644 --- a/medica-info/DB/rkl_respons.cs +++ b/medica-info/DB/rkl_respons.cs @@ -1,9 +1,22 @@ -namespace medica_info.DB +using DocumentFormat.OpenXml.Drawing; +using DocumentFormat.OpenXml.Presentation; +using medica_info.DB; +namespace medica_info.DB { public class rkl_respons { public int Id { set; get; } public bool Found { set; get; } public DateTime dateTime { set; get; } + public int rkq_request_id { set; get; } + public rkl_request rkl_Request { get; set; } = null; + + public override string ToString() + { + string ret = ""; + if (Found == true) ret = "найден в базе, приём запрещён"; + else ret = "не находмться в базе, приём разрешен"; + return $"{rkl_Request.Fio}: {ret}. Дата проверки: {dateTime}"; + } } } diff --git a/medica-info/Migrations/20260819084006_InitialCreate.Designer.cs b/medica-info/Migrations/20260819084006_InitialCreate.Designer.cs new file mode 100644 index 0000000..07006bc --- /dev/null +++ b/medica-info/Migrations/20260819084006_InitialCreate.Designer.cs @@ -0,0 +1,93 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace medica_info.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20260819084006_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("medica_info.DB.rkl_request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Bdate") + .HasColumnType("datetime2"); + + b.Property("DateDocum") + .HasColumnType("datetime2"); + + b.Property("Fio") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NumDocum") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("rkl_Requests"); + }); + + modelBuilder.Entity("medica_info.DB.rkl_respons", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Found") + .HasColumnType("bit"); + + b.Property("dateTime") + .HasColumnType("datetime2"); + + b.Property("rkl_RequestId") + .HasColumnType("int"); + + b.Property("rkq_request_id") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("rkl_RequestId"); + + b.ToTable("rkl_Respons"); + }); + + modelBuilder.Entity("medica_info.DB.rkl_respons", b => + { + b.HasOne("medica_info.DB.rkl_request", "rkl_Request") + .WithMany() + .HasForeignKey("rkl_RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("rkl_Request"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/medica-info/Migrations/20260819084006_InitialCreate.cs b/medica-info/Migrations/20260819084006_InitialCreate.cs new file mode 100644 index 0000000..7dcf6b1 --- /dev/null +++ b/medica-info/Migrations/20260819084006_InitialCreate.cs @@ -0,0 +1,68 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace medica_info.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "rkl_Requests", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Fio = table.Column(type: "nvarchar(max)", nullable: false), + Bdate = table.Column(type: "datetime2", nullable: false), + NumDocum = table.Column(type: "int", nullable: false), + DateDocum = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_rkl_Requests", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "rkl_Respons", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Found = table.Column(type: "bit", nullable: false), + dateTime = table.Column(type: "datetime2", nullable: false), + rkq_request_id = table.Column(type: "int", nullable: false), + rkl_RequestId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_rkl_Respons", x => x.Id); + table.ForeignKey( + name: "FK_rkl_Respons_rkl_Requests_rkl_RequestId", + column: x => x.rkl_RequestId, + principalTable: "rkl_Requests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_rkl_Respons_rkl_RequestId", + table: "rkl_Respons", + column: "rkl_RequestId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "rkl_Respons"); + + migrationBuilder.DropTable( + name: "rkl_Requests"); + } + } +} diff --git a/medica-info/Migrations/AppDbContextModelSnapshot.cs b/medica-info/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000..1be8d43 --- /dev/null +++ b/medica-info/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,90 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace medica_info.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("medica_info.DB.rkl_request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Bdate") + .HasColumnType("datetime2"); + + b.Property("DateDocum") + .HasColumnType("datetime2"); + + b.Property("Fio") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("NumDocum") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("rkl_Requests"); + }); + + modelBuilder.Entity("medica_info.DB.rkl_respons", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Found") + .HasColumnType("bit"); + + b.Property("dateTime") + .HasColumnType("datetime2"); + + b.Property("rkl_RequestId") + .HasColumnType("int"); + + b.Property("rkq_request_id") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("rkl_RequestId"); + + b.ToTable("rkl_Respons"); + }); + + modelBuilder.Entity("medica_info.DB.rkl_respons", b => + { + b.HasOne("medica_info.DB.rkl_request", "rkl_Request") + .WithMany() + .HasForeignKey("rkl_RequestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("rkl_Request"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/medica-info/Program.cs b/medica-info/Program.cs index c57847c..cd51bd9 100644 --- a/medica-info/Program.cs +++ b/medica-info/Program.cs @@ -2,6 +2,9 @@ using medica_info.Components; using Microsoft.AspNetCore.Hosting.StaticWebAssets; using Microsoft.AspNetCore.StaticWebAssets; using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.EntityFrameworkCore; +using medica_info.DB; + var builder = WebApplication.CreateBuilder(args); @@ -18,9 +21,17 @@ builder.Services.AddHttpClient("DocGPT", c => // c.BaseAddress = new Uri("http://host.docker.internal:1234/"); c.Timeout = TimeSpan.FromMinutes(10); // Устанавливаем лимит 10 минут вместо 100 секунд }); +var connectionString = builder.Configuration.GetConnectionString("msConnection"); + +builder.Services.AddDbContext(options => + options.UseSqlServer(connectionString)); var app = builder.Build(); + + + + // Configure the HTTP request pipeline. if (!app.Environment.IsProduction()) { diff --git a/medica-info/appsettings.json b/medica-info/appsettings.json index 0b6d690..e97192d 100644 --- a/medica-info/appsettings.json +++ b/medica-info/appsettings.json @@ -7,6 +7,6 @@ }, "AllowedHosts": "*", "ConnectionStrings": { - "DefaultConnection": "Server=192.168.232.100\\MEDICA_SQL;Database=MedicaMVD;User Id=rkl_user;Password=medica@n5k;TrustServerCertificate=False;" + "msConnection": "Server=192.168.232.100\\MEDICA_SQL;Database=Medica_rkl;User Id=rkl_user;Password=medica@n5k;Trusted_Connection=False;MultipleActiveResultSets=false;" } } \ No newline at end of file diff --git a/medica-info/medica-info.csproj b/medica-info/medica-info.csproj index 63b7bd9..e17eefd 100644 --- a/medica-info/medica-info.csproj +++ b/medica-info/medica-info.csproj @@ -13,6 +13,13 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +