From a5b0865e3443087693c12f448a1a958006d1b5b3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 11 Jan 2025 10:14:09 +0100 Subject: [PATCH 1/2] Aggiunta modello dati x tracking licenze impiegate --- LiMan.DB/DBModels/InstalledReleasesModel.cs | 91 +++ LiMan.DB/LMDbContext.cs | 1 + ...091225_AddInstalledRelTrack_01.Designer.cs | 646 ++++++++++++++++++ .../20250111091225_AddInstalledRelTrack_01.cs | 60 ++ .../Migrations/LMDbContextModelSnapshot.cs | 63 ++ 5 files changed, 861 insertions(+) create mode 100644 LiMan.DB/DBModels/InstalledReleasesModel.cs create mode 100644 LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.Designer.cs create mode 100644 LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.cs diff --git a/LiMan.DB/DBModels/InstalledReleasesModel.cs b/LiMan.DB/DBModels/InstalledReleasesModel.cs new file mode 100644 index 0000000..a614bf5 --- /dev/null +++ b/LiMan.DB/DBModels/InstalledReleasesModel.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LiMan.DB.DBModels +{ + [Table("InstalledReleases")] + public partial class InstalledReleasesModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxInstall { get; set; } + + /// + /// CodApp Richiesta + /// + [MaxLength(50)] + public string CodApp { get; set; } = ""; + + /// + /// Master Key + /// + [MaxLength(500)] + public string MastKey { get; set; } = ""; + + /// + /// Codice Impiego istanza SubLic + /// + [MaxLength(500)] + public string CodImp { get; set; } = ""; + + /// + /// Chiave SubLic + /// + [MaxLength(500)] + public string AppKey { get; set; } = ""; + + /// + /// Versione applicativo formato semver numerico 4 blocchi + /// + [MaxLength(50)] + public string VersNum { get; set; } = "0.0.0.0"; + + /// + /// Numero impieghi dell'applicativo (es per MAPO IOB-WIN il num di iOB usati con uno specifico SW) + /// + public int NumImp { get; set; } = 1; + + /// + /// Data di ultima verifica versione + /// + public DateTime DtCheck { get; set; } = DateTime.Today.AddYears(-1); + + /// + /// Istanza (SubLic) associata + /// + public int IdxSubLic { get; set; } = 0; + + /// + /// Versione (calcolata) a partire dal valore Num + /// + [NotMapped] + public Version VersVal + { + get + { + Version answ = new Version(); + try + { + // solo se è una versione valida: SemVer = 2/3 punti + int numPunti = VersNum.Length - VersNum.Replace(".", "").Length; + if (numPunti >= 2 && numPunti <= 3) + { + answ = !string.IsNullOrEmpty(VersNum) ? new Version(VersNum) : new Version(); + } + } + catch { } + return answ; + } + } + + [ForeignKey("CodApp")] + public virtual ApplicativoModel ApplicativoNav { get; set; } + + [ForeignKey("IdxSubLic")] + public virtual LicenzaModel IstanzaNav { get; set; } + } +} diff --git a/LiMan.DB/LMDbContext.cs b/LiMan.DB/LMDbContext.cs index 712f0d2..3bd765d 100644 --- a/LiMan.DB/LMDbContext.cs +++ b/LiMan.DB/LMDbContext.cs @@ -62,6 +62,7 @@ namespace LiMan.DB public virtual DbSet DbSetClaims { get; set; } public virtual DbSet DbSetReleases { get; set; } public virtual DbSet DbSetEnrollReq { get; set; } + public virtual DbSet DbSetInstallRel { get; set; } #endregion Public Properties diff --git a/LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.Designer.cs b/LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.Designer.cs new file mode 100644 index 0000000..8ca117c --- /dev/null +++ b/LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.Designer.cs @@ -0,0 +1,646 @@ +// +using System; +using LiMan.DB; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace LiMan.DB.Migrations +{ + [DbContext(typeof(LMDbContext))] + [Migration("20250111091225_AddInstalledRelTrack_01")] + partial class AddInstalledRelTrack_01 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.28") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("LiMan.DB.DBModels.ApplicativoModel", b => + { + b.Property("CodApp") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Descrizione") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Tipo") + .HasColumnType("nvarchar(max)"); + + b.Property("TplConnString") + .HasMaxLength(2500) + .HasColumnType("nvarchar(2500)"); + + b.HasKey("CodApp"); + + b.ToTable("Applicativi"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.AuthClaimModel", b => + { + b.Property("ClaimID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ClaimID"), 1L, 1); + + b.Property("DtIns") + .HasColumnType("datetime2"); + + b.Property("DtMod") + .HasColumnType("datetime2"); + + b.Property("RoleID") + .HasColumnType("int"); + + b.Property("UserID") + .HasColumnType("int"); + + b.HasKey("ClaimID"); + + b.HasIndex("RoleID"); + + b.HasIndex("UserID"); + + b.ToTable("AuthClaims"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.AuthRoleModel", b => + { + b.Property("RoleID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("RoleID"), 1L, 1); + + b.Property("Descrizione") + .HasColumnType("nvarchar(max)"); + + b.Property("Ruolo") + .HasColumnType("nvarchar(max)"); + + b.HasKey("RoleID"); + + b.ToTable("AuthRoles"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.AuthUserModel", b => + { + b.Property("UserID") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UserID"), 1L, 1); + + b.Property("AD_Domain") + .HasColumnType("nvarchar(max)"); + + b.Property("AD_User") + .HasColumnType("nvarchar(max)"); + + b.Property("Cognome") + .HasColumnType("nvarchar(max)"); + + b.Property("Nome") + .HasColumnType("nvarchar(max)"); + + b.Property("Username") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserID"); + + b.ToTable("AuthUsers"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.EnrollRequestModel", b => + { + b.Property("IdReq") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdReq"), 1L, 1); + + b.Property("DtAppr") + .HasColumnType("datetime2"); + + b.Property("DtReq") + .HasColumnType("datetime2"); + + b.Property("IdxLic") + .HasColumnType("int"); + + b.Property("Passcode") + .HasColumnType("int"); + + b.Property("ReqPayload") + .HasColumnType("nvarchar(max)"); + + b.Property("UserAppr") + .HasColumnType("nvarchar(max)"); + + b.HasKey("IdReq"); + + b.ToTable("EnrollRequest"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.FileAttachModel", b => + { + b.Property("IdxFileAttach") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxFileAttach"), 1L, 1); + + b.Property("DtEvent") + .HasColumnType("datetime2"); + + b.Property("FullStoragePath") + .HasColumnType("nvarchar(max)"); + + b.Property("IdxTicket") + .HasColumnType("int"); + + b.Property("OriginalName") + .HasColumnType("nvarchar(max)"); + + b.Property("StorageName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("IdxFileAttach"); + + b.HasIndex("IdxTicket"); + + b.ToTable("FileAttach"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.InstallazioneModel", b => + { + b.Property("CodInst") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Cliente") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Contatto") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Descrizione") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("CodInst"); + + b.ToTable("Installazioni"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.InstalledReleasesModel", b => + { + b.Property("IdxInstall") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxInstall"), 1L, 1); + + b.Property("AppKey") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CodApp") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CodImp") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("DtCheck") + .HasColumnType("datetime2"); + + b.Property("IdxSubLic") + .HasColumnType("int"); + + b.Property("MastKey") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("NumImp") + .HasColumnType("int"); + + b.Property("VersNum") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("IdxInstall"); + + b.HasIndex("CodApp"); + + b.HasIndex("IdxSubLic"); + + b.ToTable("InstalledReleases"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.LicenzaModel", b => + { + b.Property("IdxLic") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxLic"), 1L, 1); + + b.Property("Chiave") + .HasColumnType("nvarchar(max)"); + + b.Property("CodApp") + .HasColumnType("nvarchar(50)"); + + b.Property("CodInst") + .HasColumnType("nvarchar(50)"); + + b.Property("DataEnigma") + .HasColumnType("datetime2"); + + b.Property("Descrizione") + .HasColumnType("nvarchar(max)"); + + b.Property("Enigma") + .HasColumnType("nvarchar(max)"); + + b.Property("Locked") + .HasColumnType("bit"); + + b.Property("NumLicenze") + .HasColumnType("int"); + + b.Property("Payload") + .HasColumnType("nvarchar(max)"); + + b.Property("Scadenza") + .HasColumnType("datetime2"); + + b.Property("Tipo") + .HasColumnType("int"); + + b.HasKey("IdxLic"); + + b.HasIndex("CodApp"); + + b.HasIndex("CodInst"); + + b.ToTable("Licenze"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.LogCallModel", b => + { + b.Property("DataRif") + .HasColumnType("datetime2"); + + b.Property("CodInst") + .HasColumnType("nvarchar(450)"); + + b.Property("CodApp") + .HasColumnType("nvarchar(450)"); + + b.Property("TargetUrl") + .HasColumnType("nvarchar(450)"); + + b.Property("NumCall") + .HasColumnType("int"); + + b.HasKey("DataRif", "CodInst", "CodApp", "TargetUrl"); + + b.ToTable("LogCall"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.LogLicenzaModel", b => + { + b.Property("IdxLogLic") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxLogLic"), 1L, 1); + + b.Property("Chiave") + .HasColumnType("nvarchar(max)"); + + b.Property("CodApp") + .HasColumnType("nvarchar(50)"); + + b.Property("CodInst") + .HasColumnType("nvarchar(50)"); + + b.Property("Descrizione") + .HasColumnType("nvarchar(max)"); + + b.Property("IdxLic") + .HasColumnType("int"); + + b.Property("NumLicenze") + .HasColumnType("int"); + + b.Property("Scadenza") + .HasColumnType("datetime2"); + + b.Property("Tipo") + .HasColumnType("int"); + + b.HasKey("IdxLogLic"); + + b.HasIndex("CodApp"); + + b.HasIndex("CodInst"); + + b.HasIndex("IdxLic"); + + b.ToTable("LogLicenze"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.ReleaseModel", b => + { + b.Property("IdxRel") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxRel"), 1L, 1); + + b.Property("CodApp") + .HasColumnType("nvarchar(50)"); + + b.Property("RelTags") + .HasColumnType("nvarchar(max)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("VersNum") + .HasColumnType("nvarchar(max)"); + + b.Property("VersText") + .HasColumnType("nvarchar(max)"); + + b.HasKey("IdxRel"); + + b.HasIndex("CodApp"); + + b.ToTable("Releases"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.StatsCallModel", b => + { + b.Property("YearRef") + .HasColumnType("int"); + + b.Property("CodInst") + .HasColumnType("nvarchar(450)"); + + b.Property("CodApp") + .HasColumnType("nvarchar(450)"); + + b.Property("TotCall") + .HasColumnType("int"); + + b.HasKey("YearRef", "CodInst", "CodApp"); + + b.ToView("v_StatsCall"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.SubLicenzaModel", b => + { + b.Property("IdxSubLic") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxSubLic"), 1L, 1); + + b.Property("Chiave") + .HasColumnType("nvarchar(max)"); + + b.Property("CodImpiego") + .HasColumnType("nvarchar(max)"); + + b.Property("IdxLic") + .HasColumnType("int"); + + b.Property("Tipo") + .HasColumnType("int"); + + b.Property("VetoUnlock") + .HasColumnType("datetime2"); + + b.HasKey("IdxSubLic"); + + b.HasIndex("IdxLic"); + + b.ToTable("SubLicenze"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.TicketModel", b => + { + b.Property("IdxTicket") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxTicket"), 1L, 1); + + b.Property("CodImpiego") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactName") + .HasColumnType("nvarchar(max)"); + + b.Property("ContactPhone") + .HasColumnType("nvarchar(max)"); + + b.Property("DtReq") + .HasColumnType("datetime2"); + + b.Property("IdxLic") + .HasColumnType("int"); + + b.Property("IdxSubLic") + .HasColumnType("int"); + + b.Property("ReqBody") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("SupplAnsw") + .HasColumnType("nvarchar(max)"); + + b.Property("SupplEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("SupplUserCode") + .HasColumnType("nvarchar(max)"); + + b.Property("TType") + .HasColumnType("int"); + + b.Property("Tipo") + .HasColumnType("int"); + + b.HasKey("IdxTicket"); + + b.HasIndex("IdxLic"); + + b.ToTable("TicketLog"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.AuthClaimModel", b => + { + b.HasOne("LiMan.DB.DBModels.AuthRoleModel", "RoleNav") + .WithMany("Claims") + .HasForeignKey("RoleID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LiMan.DB.DBModels.AuthUserModel", "UserNav") + .WithMany("Claims") + .HasForeignKey("UserID") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("RoleNav"); + + b.Navigation("UserNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.FileAttachModel", b => + { + b.HasOne("LiMan.DB.DBModels.TicketModel", "TicketNav") + .WithMany() + .HasForeignKey("IdxTicket") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("TicketNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.InstalledReleasesModel", b => + { + b.HasOne("LiMan.DB.DBModels.ApplicativoModel", "ApplicativoNav") + .WithMany() + .HasForeignKey("CodApp"); + + b.HasOne("LiMan.DB.DBModels.LicenzaModel", "IstanzaNav") + .WithMany() + .HasForeignKey("IdxSubLic") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicativoNav"); + + b.Navigation("IstanzaNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.LicenzaModel", b => + { + b.HasOne("LiMan.DB.DBModels.ApplicativoModel", "ApplicativoNav") + .WithMany() + .HasForeignKey("CodApp"); + + b.HasOne("LiMan.DB.DBModels.InstallazioneModel", "InstallazioneNav") + .WithMany() + .HasForeignKey("CodInst"); + + b.Navigation("ApplicativoNav"); + + b.Navigation("InstallazioneNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.LogLicenzaModel", b => + { + b.HasOne("LiMan.DB.DBModels.ApplicativoModel", "ApplicativoNav") + .WithMany() + .HasForeignKey("CodApp"); + + b.HasOne("LiMan.DB.DBModels.InstallazioneModel", "InstallazioneNav") + .WithMany() + .HasForeignKey("CodInst"); + + b.HasOne("LiMan.DB.DBModels.LicenzaModel", "LicenzaNav") + .WithMany() + .HasForeignKey("IdxLic") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicativoNav"); + + b.Navigation("InstallazioneNav"); + + b.Navigation("LicenzaNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.ReleaseModel", b => + { + b.HasOne("LiMan.DB.DBModels.ApplicativoModel", "ApplicativoNav") + .WithMany() + .HasForeignKey("CodApp"); + + b.Navigation("ApplicativoNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.SubLicenzaModel", b => + { + b.HasOne("LiMan.DB.DBModels.LicenzaModel", "LicenzaNav") + .WithMany("Attivazioni") + .HasForeignKey("IdxLic") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LicenzaNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.TicketModel", b => + { + b.HasOne("LiMan.DB.DBModels.LicenzaModel", "LicenzaNav") + .WithMany("Tickets") + .HasForeignKey("IdxLic") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LicenzaNav"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.AuthRoleModel", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.AuthUserModel", b => + { + b.Navigation("Claims"); + }); + + modelBuilder.Entity("LiMan.DB.DBModels.LicenzaModel", b => + { + b.Navigation("Attivazioni"); + + b.Navigation("Tickets"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.cs b/LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.cs new file mode 100644 index 0000000..3b43935 --- /dev/null +++ b/LiMan.DB/Migrations/20250111091225_AddInstalledRelTrack_01.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LiMan.DB.Migrations +{ + public partial class AddInstalledRelTrack_01 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "InstalledReleases", + columns: table => new + { + IdxInstall = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + CodApp = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + MastKey = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + CodImp = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + AppKey = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), + VersNum = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + NumImp = table.Column(type: "int", nullable: false), + DtCheck = table.Column(type: "datetime2", nullable: false), + IdxSubLic = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InstalledReleases", x => x.IdxInstall); + table.ForeignKey( + name: "FK_InstalledReleases_Applicativi_CodApp", + column: x => x.CodApp, + principalTable: "Applicativi", + principalColumn: "CodApp"); + table.ForeignKey( + name: "FK_InstalledReleases_Licenze_IdxSubLic", + column: x => x.IdxSubLic, + principalTable: "Licenze", + principalColumn: "IdxLic", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_InstalledReleases_CodApp", + table: "InstalledReleases", + column: "CodApp"); + + migrationBuilder.CreateIndex( + name: "IX_InstalledReleases_IdxSubLic", + table: "InstalledReleases", + column: "IdxSubLic"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "InstalledReleases"); + } + } +} diff --git a/LiMan.DB/Migrations/LMDbContextModelSnapshot.cs b/LiMan.DB/Migrations/LMDbContextModelSnapshot.cs index fb4f44c..0b705ba 100644 --- a/LiMan.DB/Migrations/LMDbContextModelSnapshot.cs +++ b/LiMan.DB/Migrations/LMDbContextModelSnapshot.cs @@ -209,6 +209,52 @@ namespace LiMan.DB.Migrations b.ToTable("Installazioni"); }); + modelBuilder.Entity("LiMan.DB.DBModels.InstalledReleasesModel", b => + { + b.Property("IdxInstall") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("IdxInstall"), 1L, 1); + + b.Property("AppKey") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("CodApp") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CodImp") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("DtCheck") + .HasColumnType("datetime2"); + + b.Property("IdxSubLic") + .HasColumnType("int"); + + b.Property("MastKey") + .HasMaxLength(500) + .HasColumnType("nvarchar(500)"); + + b.Property("NumImp") + .HasColumnType("int"); + + b.Property("VersNum") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("IdxInstall"); + + b.HasIndex("CodApp"); + + b.HasIndex("IdxSubLic"); + + b.ToTable("InstalledReleases"); + }); + modelBuilder.Entity("LiMan.DB.DBModels.LicenzaModel", b => { b.Property("IdxLic") @@ -490,6 +536,23 @@ namespace LiMan.DB.Migrations b.Navigation("TicketNav"); }); + modelBuilder.Entity("LiMan.DB.DBModels.InstalledReleasesModel", b => + { + b.HasOne("LiMan.DB.DBModels.ApplicativoModel", "ApplicativoNav") + .WithMany() + .HasForeignKey("CodApp"); + + b.HasOne("LiMan.DB.DBModels.LicenzaModel", "IstanzaNav") + .WithMany() + .HasForeignKey("IdxSubLic") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicativoNav"); + + b.Navigation("IstanzaNav"); + }); + modelBuilder.Entity("LiMan.DB.DBModels.LicenzaModel", b => { b.HasOne("LiMan.DB.DBModels.ApplicativoModel", "ApplicativoNav") From b8defd6f902c9da6883603122dd4d33066831676 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 11 Jan 2025 10:31:17 +0100 Subject: [PATCH 2/2] Aggiunta registrazione info versione registrata/impiegata x applicativo --- LiMan.Api/Controllers/ReleaseController.cs | 13 ++ LiMan.Api/Data/ApiDataService.cs | 192 +++++++++++--------- LiMan.Api/Resources/ChangeLog.html | 2 +- LiMan.Api/Resources/VersNum.txt | 2 +- LiMan.Api/Resources/manifest.xml | 2 +- LiMan.DB/Controllers/DbController.cs | 66 +++++++ LiMan.DB/DBModels/InstalledReleasesModel.cs | 2 +- LiMan.UI/Components/Activations.razor | 2 +- LiMan.UI/LiMan.UI.csproj | 2 +- LiMan.UI/Resources/ChangeLog.html | 2 +- LiMan.UI/Resources/VersNum.txt | 2 +- LiMan.UI/Resources/manifest.xml | 2 +- 12 files changed, 191 insertions(+), 98 deletions(-) diff --git a/LiMan.Api/Controllers/ReleaseController.cs b/LiMan.Api/Controllers/ReleaseController.cs index 10b8465..576a46d 100644 --- a/LiMan.Api/Controllers/ReleaseController.cs +++ b/LiMan.Api/Controllers/ReleaseController.cs @@ -130,6 +130,19 @@ namespace LiMan.APi.Controllers if (CheckReqKeys(CurrRequest)) { result = await dataService.ReleaseGetByAppVers(CurrRequest.CodApp, CurrRequest.VersMin); + // registro stato applicativi (da richiesta...) + InstalledReleasesModel checkRec = new InstalledReleasesModel() + { + AppKey = CurrRequest.AppKey, + CodApp = CurrRequest.CodApp, + CodImp = CurrRequest.CodImp, + DtCheck = DateTime.Now, + MastKey = CurrRequest.MastKey, + NumImp = 1,// cablato x ora + VersNum = CurrRequest.VersMin + }; + dataService.InstallRelUpsert(checkRec); + // registro infine chiamata await dataService.recordCall(CurrRequest.CodApp, CurrRequest.CodApp, $"POST:api/release/getfilt/ | {CurrRequest.MastKey} | {CurrRequest.CodImp} | {CurrRequest.CodApp}"); } return result; diff --git a/LiMan.Api/Data/ApiDataService.cs b/LiMan.Api/Data/ApiDataService.cs index 59a547c..8682d16 100644 --- a/LiMan.Api/Data/ApiDataService.cs +++ b/LiMan.Api/Data/ApiDataService.cs @@ -82,6 +82,15 @@ namespace LiMan.APi.Data #endregion Public Constructors + #region Public Properties + + /// + /// Wrapper x invio/ricezione messaggi sul canale dedicato agli eventi enroll + /// + public MessagePipe EnrollMessPipe { get; set; } = null!; + + #endregion Public Properties + #region Public Methods /// Elenco Applicativi (all) @@ -364,7 +373,7 @@ namespace LiMan.APi.Data TimeSpan ts = sw.Elapsed; Log.Trace($"Effettuata EnrollReqCreate: {ts.TotalMilliseconds} ms"); - // invio string in messagepipe x forzare refresh... + // invio string in messagepipe x forzare refresh... EnrollMessPipe.sendMessage("NewEnrollReq"); // restituisce record @@ -390,54 +399,6 @@ namespace LiMan.APi.Data return fatto; } - /// - /// Recupera una richiesta dato suo ID x verificare approvazione e dati associati... - /// - /// ID record - public async Task EnrollReqGetById(int idReq) - { - string source = "DB"; - EnrollRequestModel dbResult = new EnrollRequestModel() { IdReq = idReq }; - try - { - string currKey = $"{Const.rKeyConfig}:Enroll:ById:{idReq}"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - string? rawData = await redisDb.StringGetAsync(currKey); - if (!string.IsNullOrEmpty(rawData)) - { - source = "REDIS"; - var tempResult = JsonConvert.DeserializeObject(rawData); - if (tempResult == null) - { - dbResult = new EnrollRequestModel() { IdReq = idReq }; - } - else - { - dbResult = tempResult; - } - } - else - { - dbResult = dbController.EnrollReqGetById(idReq); - rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - await redisDb.StringSetAsync(currKey, rawData, FastCache); - } - if (dbResult == null) - { - dbResult = new EnrollRequestModel() { IdReq = idReq }; - } - sw.Stop(); - TimeSpan ts = sw.Elapsed; - Log.Debug($"EnrollReqGetById | {source} in: {ts.TotalMilliseconds} ms"); - } - catch (Exception exc) - { - Log.Error($"Error during EnrollReqGetById:{Environment.NewLine}{exc}"); - } - return dbResult; - } - /// /// Elenco richeiste enroll attive al momento /// @@ -486,13 +447,61 @@ namespace LiMan.APi.Data return dbResult; } + /// + /// Recupera una richiesta dato suo ID x verificare approvazione e dati associati... + /// + /// ID record + public async Task EnrollReqGetById(int idReq) + { + string source = "DB"; + EnrollRequestModel dbResult = new EnrollRequestModel() { IdReq = idReq }; + try + { + string currKey = $"{Const.rKeyConfig}:Enroll:ById:{idReq}"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + string? rawData = await redisDb.StringGetAsync(currKey); + if (!string.IsNullOrEmpty(rawData)) + { + source = "REDIS"; + var tempResult = JsonConvert.DeserializeObject(rawData); + if (tempResult == null) + { + dbResult = new EnrollRequestModel() { IdReq = idReq }; + } + else + { + dbResult = tempResult; + } + } + else + { + dbResult = dbController.EnrollReqGetById(idReq); + rawData = JsonConvert.SerializeObject(dbResult, JSSettings); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (dbResult == null) + { + dbResult = new EnrollRequestModel() { IdReq = idReq }; + } + sw.Stop(); + TimeSpan ts = sw.Elapsed; + Log.Debug($"EnrollReqGetById | {source} in: {ts.TotalMilliseconds} ms"); + } + catch (Exception exc) + { + Log.Error($"Error during EnrollReqGetById:{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// Elimino eventuali richieste non approvate e scadute /// public async Task EnrollReqPurgeInvalid() { var reqPurged = dbController.EnrollReqPurgeInvalid(); - // invio string in messagepipe x forzare refresh... + // invio string in messagepipe x forzare refresh... EnrollMessPipe.sendMessage("NewEnrollReq"); // svuota eventuale cache redis... await FlushRedisCachePattern("Enroll"); @@ -517,7 +526,7 @@ namespace LiMan.APi.Data sw.Stop(); TimeSpan ts = sw.Elapsed; Log.Trace($"Effettuata EnrollReqUpsert: {ts.TotalMilliseconds} ms"); - // invio string in messagepipe x forzare refresh... + // invio string in messagepipe x forzare refresh... EnrollMessPipe.sendMessage("NewEnrollReq"); // restituisce risultato return dbResult; @@ -562,11 +571,6 @@ namespace LiMan.APi.Data return await Task.FromResult(dbResult); } - /// - /// Wrapper x invio/ricezione messaggi sul canale dedicato agli eventi enroll - /// - public MessagePipe EnrollMessPipe { get; set; } = null!; - /// /// Refresh globale cache Redis /// @@ -600,6 +604,16 @@ namespace LiMan.APi.Data return answ; } + /// + /// Registro su DB il record della licenza attuale relativo alla richiesta di verifica licenza ricevuta + /// + /// record da inserire/aggiornare + public bool InstallRelUpsert(InstalledReleasesModel upRec) + { + bool fatto = dbController.InstallRelUpsert(upRec); + return fatto; + } + /// /// invalida tutta la cache in caso di update /// @@ -613,39 +627,6 @@ namespace LiMan.APi.Data cachedDataList = new List(); } - /// - /// Record licenza data masterKey - /// - /// Chiave Licenza x ricerca - /// - public async Task LicenzaByMasterKey(string chiave) - { - LicenzaModel dbResult = new LicenzaModel(); - string cacheKey = $"{rKeyLicByMKey}:{chiave}"; - trackCache(cacheKey); - string rawData = await getRSV(cacheKey); - if (!string.IsNullOrEmpty(rawData)) - { - dbResult = JsonConvert.DeserializeObject(rawData); - } - else - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.LicenzaByKey(chiave); - if (dbResult != null) - { - rawData = JsonConvert.SerializeObject(dbResult); - await setRSV(cacheKey, rawData, hourTTL); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per LicenzaByMasterKey: {ts.TotalMilliseconds} ms"); - } - - return await Task.FromResult(dbResult); - } - /// /// Elenco licenze dato ID /// @@ -679,6 +660,39 @@ namespace LiMan.APi.Data return dbResult; } + /// + /// Record licenza data masterKey + /// + /// Chiave Licenza x ricerca + /// + public async Task LicenzaByMasterKey(string chiave) + { + LicenzaModel dbResult = new LicenzaModel(); + string cacheKey = $"{rKeyLicByMKey}:{chiave}"; + trackCache(cacheKey); + string rawData = await getRSV(cacheKey); + if (!string.IsNullOrEmpty(rawData)) + { + dbResult = JsonConvert.DeserializeObject(rawData); + } + else + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.LicenzaByKey(chiave); + if (dbResult != null) + { + rawData = JsonConvert.SerializeObject(dbResult); + await setRSV(cacheKey, rawData, hourTTL); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per LicenzaByMasterKey: {ts.TotalMilliseconds} ms"); + } + + return await Task.FromResult(dbResult); + } + /// /// Effettua refresh del payload della licenza dato info + enigma generato dal client /// diff --git a/LiMan.Api/Resources/ChangeLog.html b/LiMan.Api/Resources/ChangeLog.html index 5707054..08637d0 100644 --- a/LiMan.Api/Resources/ChangeLog.html +++ b/LiMan.Api/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 2.1.2501.0919

+

Versione: 2.1.2501.1110


Note di rilascio:
  • diff --git a/LiMan.Api/Resources/VersNum.txt b/LiMan.Api/Resources/VersNum.txt index 8410170..dcdbc02 100644 --- a/LiMan.Api/Resources/VersNum.txt +++ b/LiMan.Api/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.0919 +2.1.2501.1110 diff --git a/LiMan.Api/Resources/manifest.xml b/LiMan.Api/Resources/manifest.xml index a8aad01..552072f 100644 --- a/LiMan.Api/Resources/manifest.xml +++ b/LiMan.Api/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.0919 + 2.1.2501.1110 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false diff --git a/LiMan.DB/Controllers/DbController.cs b/LiMan.DB/Controllers/DbController.cs index d65692c..2c72424 100644 --- a/LiMan.DB/Controllers/DbController.cs +++ b/LiMan.DB/Controllers/DbController.cs @@ -1399,6 +1399,72 @@ namespace LiMan.DB.Controllers return dbResult; } + /// + /// Update/insert record registrazione InstalledRelease applicativo + /// + /// + /// + public bool InstallRelUpsert(InstalledReleasesModel upRec) + { + bool fatto = false; + using (LMDbContext localDbCtx = new LMDbContext(_configuration)) + { + // cerco record esistente... + var currRec = localDbCtx + .DbSetInstallRel + .Where(x => x.CodApp == upRec.CodApp && x.CodImp == upRec.CodImp && x.AppKey == upRec.AppKey) + .FirstOrDefault(); + if (currRec != null) + { + // se idxSubLic mancante cerco... + if (currRec.IdxSubLic == 0) + { + // cerco idxSublic da info... + var recIst = localDbCtx + .DbSetSubLicenze + .FirstOrDefault(x => x.Chiave == upRec.AppKey && x.CodImpiego == upRec.CodImp); + if (recIst != null) + { + upRec.IdxSubLic = recIst.IdxSubLic; + } + } + // se trovo aggiorno... + currRec.DtCheck = upRec.DtCheck; + currRec.IdxSubLic = upRec.IdxSubLic; + currRec.MastKey = upRec.MastKey; + currRec.NumImp = upRec.NumImp; + currRec.VersNum = upRec.VersNum; + } + else + { + // cerco idxSublic da info... + var recIst = localDbCtx + .DbSetSubLicenze + .FirstOrDefault(x => x.Chiave == upRec.AppKey && x.CodImpiego == upRec.CodImp); + if (recIst != null) + { + upRec.IdxSubLic = recIst.IdxSubLic; + } + // altrimenti aggiungo... + localDbCtx + .DbSetInstallRel + .Add(upRec); + } + // salvataggio! + try + { + // salvo + var res = localDbCtx.SaveChanges(); + fatto = res != 0; + } + catch (Exception ex) + { + Log.Error($"Eccezoine in InstallRelUpsert{Environment.NewLine}{ex}"); + } + } + return fatto; + } + /// /// Effettua refresh del payload della licenza dato info + enigma generato dal client /// diff --git a/LiMan.DB/DBModels/InstalledReleasesModel.cs b/LiMan.DB/DBModels/InstalledReleasesModel.cs index a614bf5..077e80f 100644 --- a/LiMan.DB/DBModels/InstalledReleasesModel.cs +++ b/LiMan.DB/DBModels/InstalledReleasesModel.cs @@ -27,7 +27,7 @@ namespace LiMan.DB.DBModels public string MastKey { get; set; } = ""; /// - /// Codice Impiego istanza SubLic + /// Codice Impiego Istanza (SubLic) /// [MaxLength(500)] public string CodImp { get; set; } = ""; diff --git a/LiMan.UI/Components/Activations.razor b/LiMan.UI/Components/Activations.razor index b6281b0..acdf196 100644 --- a/LiMan.UI/Components/Activations.razor +++ b/LiMan.UI/Components/Activations.razor @@ -25,7 +25,7 @@
    -

    Attivazioni

    +

    Istanze/Attivazioni

    @if (CanEdit) diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index c726674..21ebec8 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 2.1.2501.0919 + 2.1.2501.1110 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index 5707054..08637d0 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

    Versione: 2.1.2501.0919

    +

    Versione: 2.1.2501.1110


    Note di rilascio:
    • diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index 8410170..dcdbc02 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.0919 +2.1.2501.1110 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index a8aad01..552072f 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.0919 + 2.1.2501.1110 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false