From 5ec3776f6f7af46a5209fd1b29cfdb29f1d41672 Mon Sep 17 00:00:00 2001 From: "HOME-LAPTOP\\kshkulev" Date: Sat, 22 Nov 2025 19:03:45 +0900 Subject: [PATCH] Add supply contract entity --- Hcs.WebApp/Data/Hcs/HcsDbContext.cs | 2 + ...100029_AddSupplyContractEntity.Designer.cs | 340 ++++++++++++++++++ .../20251122100029_AddSupplyContractEntity.cs | 46 +++ .../Migrations/HcsDbContextModelSnapshot.cs | 36 ++ Hcs.WebApp/Data/Hcs/SupplyContract.cs | 17 + 5 files changed, 441 insertions(+) create mode 100644 Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.Designer.cs create mode 100644 Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.cs create mode 100644 Hcs.WebApp/Data/Hcs/SupplyContract.cs diff --git a/Hcs.WebApp/Data/Hcs/HcsDbContext.cs b/Hcs.WebApp/Data/Hcs/HcsDbContext.cs index 1d40527..f383730 100644 --- a/Hcs.WebApp/Data/Hcs/HcsDbContext.cs +++ b/Hcs.WebApp/Data/Hcs/HcsDbContext.cs @@ -17,6 +17,8 @@ namespace Hcs.WebApp.Data.Hcs public DbSet FilesToParse { get; set; } + public DbSet SupplyContracts { get; set; } + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { optionsBuilder diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.Designer.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.Designer.cs new file mode 100644 index 0000000..e1eb791 --- /dev/null +++ b/Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.Designer.cs @@ -0,0 +1,340 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable +namespace Hcs.WebApp.Data.Hcs.Migrations +{ + [DbContext(typeof(HcsDbContext))] + [Migration("20251122100029_AddSupplyContractEntity")] + public partial class AddSupplyContractEntity + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Args") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("EndedAt") + .HasColumnType("datetime2"); + + b.Property("FailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("InitiatorId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Progress") + .HasColumnType("int"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Step") + .HasColumnType("int"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Campaigns"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.FileToParse", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("LastParseOperationId") + .HasColumnType("int"); + + b.Property("ParsedAt") + .HasColumnType("datetime2"); + + b.Property("Path") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UploadedAt") + .HasColumnType("datetime2"); + + b.Property("UploaderId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("LastParseOperationId"); + + b.ToTable("FilesToParse"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.House", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FiasId") + .HasColumnType("uniqueidentifier"); + + b.Property("HcsId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsMkd") + .HasColumnType("bit"); + + b.Property("IsZhd") + .HasColumnType("bit"); + + b.Property("LastSyncOperationId") + .HasColumnType("int"); + + b.Property("SyncedAt") + .HasColumnType("datetime2"); + + b.Property("ThirdPartyId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("FiasId") + .IsUnique() + .HasFilter("[FiasId] IS NOT NULL"); + + b.HasIndex("LastSyncOperationId"); + + b.ToTable("Houses"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CampaignId") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("EndedAt") + .HasColumnType("datetime2"); + + b.Property("FailureReason") + .HasColumnType("nvarchar(max)"); + + b.Property("MessageGuid") + .HasColumnType("nvarchar(max)"); + + b.Property("StartedAt") + .HasColumnType("datetime2"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CampaignId"); + + b.ToTable("Operations"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IsCommon") + .HasColumnType("bit"); + + b.Property("LastSyncOperationId") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .HasColumnType("int"); + + b.Property("SyncedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("LastSyncOperationId"); + + b.ToTable("Registries"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GUID") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Json") + .HasColumnType("nvarchar(max)"); + + b.Property("RegistryId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("RegistryId"); + + b.ToTable("Elements"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.SupplyContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HcsId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSyncOperationId") + .HasColumnType("int"); + + b.Property("SyncedAt") + .HasColumnType("datetime2"); + + b.Property("ThirdPartyId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("LastSyncOperationId"); + + b.ToTable("SupplyContracts"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.FileToParse", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastParseOperation") + .WithMany("FilesToParse") + .HasForeignKey("LastParseOperationId"); + + b.Navigation("LastParseOperation"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.House", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastSyncOperation") + .WithMany("Houses") + .HasForeignKey("LastSyncOperationId"); + + b.Navigation("LastSyncOperation"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Campaign", "Campaign") + .WithMany("Operations") + .HasForeignKey("CampaignId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Campaign"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastSyncOperation") + .WithMany("Registries") + .HasForeignKey("LastSyncOperationId"); + + b.Navigation("LastSyncOperation"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.RegistryElement", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Registry", "Registry") + .WithMany("Elements") + .HasForeignKey("RegistryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Registry"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.SupplyContract", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastSyncOperation") + .WithMany() + .HasForeignKey("LastSyncOperationId"); + + b.Navigation("LastSyncOperation"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b => + { + b.Navigation("Operations"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Operation", b => + { + b.Navigation("FilesToParse"); + + b.Navigation("Houses"); + + b.Navigation("Registries"); + }); + + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Registry", b => + { + b.Navigation("Elements"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.cs b/Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.cs new file mode 100644 index 0000000..9a4a92b --- /dev/null +++ b/Hcs.WebApp/Data/Hcs/Migrations/20251122100029_AddSupplyContractEntity.cs @@ -0,0 +1,46 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable +namespace Hcs.WebApp.Data.Hcs.Migrations +{ + /// + public partial class AddSupplyContractEntity : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SupplyContracts", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + HcsId = table.Column(type: "uniqueidentifier", nullable: true), + ThirdPartyId = table.Column(type: "nvarchar(max)", nullable: true), + SyncedAt = table.Column(type: "datetime2", nullable: true), + LastSyncOperationId = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SupplyContracts", x => x.Id); + table.ForeignKey( + name: "FK_SupplyContracts_Operations_LastSyncOperationId", + column: x => x.LastSyncOperationId, + principalTable: "Operations", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_SupplyContracts_LastSyncOperationId", + table: "SupplyContracts", + column: "LastSyncOperationId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "SupplyContracts"); + } + } +} diff --git a/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs b/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs index 0206084..5b03e75 100644 --- a/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs +++ b/Hcs.WebApp/Data/Hcs/Migrations/HcsDbContextModelSnapshot.cs @@ -228,6 +228,33 @@ namespace Hcs.WebApp.Data.Hcs.Migrations b.ToTable("Elements"); }); + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.SupplyContract", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("HcsId") + .HasColumnType("uniqueidentifier"); + + b.Property("LastSyncOperationId") + .HasColumnType("int"); + + b.Property("SyncedAt") + .HasColumnType("datetime2"); + + b.Property("ThirdPartyId") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("LastSyncOperationId"); + + b.ToTable("SupplyContracts"); + }); + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.FileToParse", b => { b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastParseOperation") @@ -277,6 +304,15 @@ namespace Hcs.WebApp.Data.Hcs.Migrations b.Navigation("Registry"); }); + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.SupplyContract", b => + { + b.HasOne("Hcs.WebApp.Data.Hcs.Operation", "LastSyncOperation") + .WithMany() + .HasForeignKey("LastSyncOperationId"); + + b.Navigation("LastSyncOperation"); + }); + modelBuilder.Entity("Hcs.WebApp.Data.Hcs.Campaign", b => { b.Navigation("Operations"); diff --git a/Hcs.WebApp/Data/Hcs/SupplyContract.cs b/Hcs.WebApp/Data/Hcs/SupplyContract.cs new file mode 100644 index 0000000..8931af0 --- /dev/null +++ b/Hcs.WebApp/Data/Hcs/SupplyContract.cs @@ -0,0 +1,17 @@ +namespace Hcs.WebApp.Data.Hcs +{ + public class SupplyContract + { + public int Id { get; set; } + + public Guid? HcsId { get; set; } + + public string? ThirdPartyId { get; set; } + + public DateTime? SyncedAt { get; set; } + + public int? LastSyncOperationId { get; set; } + + public virtual Operation? LastSyncOperation { get; set; } + } +}