From 1dcabdb5d633b5e071bbf4cddf8c6a86d6e2b2be Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 11 Oct 2021 11:12:47 +0200 Subject: [PATCH] Review libreria LicMan.DB --- LiMan.DB/Controllers/LicManController.cs | 155 ++++++++++- LiMan.DB/DBModels/ApplicativoModel.cs | 36 +++ .../InstallazioneModel.cs} | 24 +- LiMan.DB/DBModels/LicManContext.cs | 109 ++++++++ LiMan.DB/DBModels/LicenzaModel.cs | 60 ++++ LiMan.DB/DatabaseModels/AnagApplicazioni.cs | 28 -- LiMan.DB/DatabaseModels/LicManContext.cs | 259 ------------------ LiMan.DB/DatabaseModels/LicenzeAttive.cs | 24 -- LiMan.DB/DatabaseModels/Permessi.cs | 31 --- LiMan.DB/DatabaseModels/Permessi2Funzione.cs | 19 -- LiMan.DB/LiMan.DB.csproj | 1 + .../20211008094940_InitDb.Designer.cs | 233 ---------------- LiMan.DB/Migrations/20211008094940_InitDb.cs | 134 --------- .../Migrations/LicManContextModelSnapshot.cs | 231 ---------------- 14 files changed, 366 insertions(+), 978 deletions(-) create mode 100644 LiMan.DB/DBModels/ApplicativoModel.cs rename LiMan.DB/{DatabaseModels/AnagInstallazioni.cs => DBModels/InstallazioneModel.cs} (52%) create mode 100644 LiMan.DB/DBModels/LicManContext.cs create mode 100644 LiMan.DB/DBModels/LicenzaModel.cs delete mode 100644 LiMan.DB/DatabaseModels/AnagApplicazioni.cs delete mode 100644 LiMan.DB/DatabaseModels/LicManContext.cs delete mode 100644 LiMan.DB/DatabaseModels/LicenzeAttive.cs delete mode 100644 LiMan.DB/DatabaseModels/Permessi.cs delete mode 100644 LiMan.DB/DatabaseModels/Permessi2Funzione.cs delete mode 100644 LiMan.DB/Migrations/20211008094940_InitDb.Designer.cs delete mode 100644 LiMan.DB/Migrations/20211008094940_InitDb.cs delete mode 100644 LiMan.DB/Migrations/LicManContextModelSnapshot.cs diff --git a/LiMan.DB/Controllers/LicManController.cs b/LiMan.DB/Controllers/LicManController.cs index e5f9c17..7246a83 100644 --- a/LiMan.DB/Controllers/LicManController.cs +++ b/LiMan.DB/Controllers/LicManController.cs @@ -1,4 +1,5 @@ -using LiMan.DB.DatabaseModels; +using LiMan.DB.DBModels; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; using System; @@ -53,42 +54,176 @@ namespace LiMan.DB.Controllers //Log.Info("Dispose di GWMSController"); } - public List GetApplicazioni() + public List GetApplicazioni() { - List dbResult = new List(); + List dbResult = new List(); using (LicManContext localDbCtx = new LicManContext(_configuration)) { dbResult = localDbCtx - .DbSetApplicazioni + .DbSetApp .ToList(); } return dbResult; } - public List GetInstallazioni() + public List GetInstallazioni() { - List dbResult = new List(); + List dbResult = new List(); using (LicManContext localDbCtx = new LicManContext(_configuration)) { dbResult = localDbCtx - .DbSetInstallazioni + .DbSetInst .ToList(); } return dbResult; } - public List GetLicenze() + public List GetLicenze() { - List dbResult = new List(); + List dbResult = new List(); using (LicManContext localDbCtx = new LicManContext(_configuration)) { dbResult = localDbCtx - .DbSetLicenzeAttive + .DbSetLicenze .ToList(); } return dbResult; } + public List GetLicenzeFilt(bool OnlyActive, string CodApp, string CodInst) + { + List dbResult = new List(); + using (LicManContext localDbCtx = new LicManContext(_configuration)) + { + DateTime oggi = DateTime.Today; + dbResult = localDbCtx + .DbSetLicenze + .Where(x => (x.CodApp == CodApp || string.IsNullOrEmpty(CodApp)) && (x.CodInst == CodInst || string.IsNullOrEmpty(CodInst)) && (!OnlyActive || x.Scadenza > oggi)) + .OrderByDescending(o => o.Scadenza) + .ToList(); + } + return dbResult; + } + + /// + /// Annulla modifiche su una specifica entity (cancel update) + /// + /// + /// + public bool rollBackEntity(object item) + { + bool answ = false; + using (LicManContext localDbCtx = new LicManContext(_configuration)) + { + try + { + if (localDbCtx.Entry(item).State == EntityState.Deleted || localDbCtx.Entry(item).State == EntityState.Modified) + { + localDbCtx.Entry(item).Reload(); + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in rollBackEntity{Environment.NewLine}{exc}"); + } + } + return answ; + } + + public bool UpdateApplicazioni(ApplicativoModel updItem) + { + bool done = false; + using (LicManContext localDbCtx = new LicManContext(_configuration)) + { + try + { + ApplicativoModel currData = localDbCtx + .DbSetApp + .Where(x => x.CodApp == updItem.CodApp) + .FirstOrDefault(); + if (currData != null) + { + // aggiorno valori + currData.Descrizione = updItem.Descrizione; + localDbCtx.Entry(currData).State = EntityState.Modified; + localDbCtx.SaveChanges(); + } + done = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in UpdateApplicazioni:{Environment.NewLine}{exc}"); + } + } + return done; + } + + public bool UpdateInstallazioni(InstallazioneModel updItem) + { + bool done = false; + using (LicManContext localDbCtx = new LicManContext(_configuration)) + { + try + { + InstallazioneModel currData = localDbCtx + .DbSetInst + .Where(x => x.CodInst == updItem.CodInst) + .FirstOrDefault(); + if (currData != null) + { + // aggiorno valori + currData.Descrizione = updItem.Descrizione; + currData.Cliente = updItem.Cliente; + currData.Contatto = updItem.Contatto; + currData.Email = updItem.Email; + localDbCtx.Entry(currData).State = EntityState.Modified; + localDbCtx.SaveChanges(); + } + done = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in UpdateApplicazioni:{Environment.NewLine}{exc}"); + } + } + return done; + } + + public bool UpdateLicenze(LicenzaModel updItem) + { + bool done = false; + using (LicManContext localDbCtx = new LicManContext(_configuration)) + { + try + { + LicenzaModel currData = localDbCtx + .DbSetLicenze + .Where(x => x.IdxLic == updItem.IdxLic) + .FirstOrDefault(); + if (currData != null) + { + // aggiorno valori + currData.CodApp = updItem.CodApp; + currData.CodInst = updItem.CodInst; + currData.NumLicenze = updItem.NumLicenze; + currData.Descrizione = updItem.Descrizione; + currData.Chiave = updItem.Chiave; + currData.Locked = updItem.Locked; + currData.IdxLicParent = updItem.IdxLicParent; + currData.Scadenza = updItem.Scadenza; + localDbCtx.Entry(currData).State = EntityState.Modified; + localDbCtx.SaveChanges(); + } + done = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione in UpdateLicenze:{Environment.NewLine}{exc}"); + } + } + return done; + } + #endregion Public Methods } } \ No newline at end of file diff --git a/LiMan.DB/DBModels/ApplicativoModel.cs b/LiMan.DB/DBModels/ApplicativoModel.cs new file mode 100644 index 0000000..848172d --- /dev/null +++ b/LiMan.DB/DBModels/ApplicativoModel.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace LiMan.DB.DBModels +{ + [Table("Applicativi")] + public partial class ApplicativoModel + { + #region Public Constructors + + //public Applicativo() + //{ + // LicenzeAttives = new HashSet(); + //} + + #endregion Public Constructors + + #region Public Properties + + [Key] + [MaxLength(50)] + public string CodApp { get; set; } + + [MaxLength(250)] + public string Descrizione { get; set; } + + //public virtual ICollection LicenzeAttives { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/LiMan.DB/DatabaseModels/AnagInstallazioni.cs b/LiMan.DB/DBModels/InstallazioneModel.cs similarity index 52% rename from LiMan.DB/DatabaseModels/AnagInstallazioni.cs rename to LiMan.DB/DBModels/InstallazioneModel.cs index af1498a..b8a192c 100644 --- a/LiMan.DB/DatabaseModels/AnagInstallazioni.cs +++ b/LiMan.DB/DBModels/InstallazioneModel.cs @@ -6,26 +6,32 @@ using System.ComponentModel.DataAnnotations.Schema; #nullable disable -namespace LiMan.DB.DatabaseModels +namespace LiMan.DB.DBModels { // // This is here so CodeMaid doesn't reorganize this document // - [Table("AnagInstallazioni")] //[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))] - public partial class AnagInstallazioni + [Table("Installazioni")] + public partial class InstallazioneModel { - public AnagInstallazioni() - { - LicenzeAttives = new HashSet(); - } + //public Installazione() + //{ + // LicenzeAttives = new HashSet(); + //} [Key] - public string Installazione { get; set; } + [MaxLength(50)] + public string CodInst { get; set; } + [MaxLength(250)] public string Descrizione { get; set; } + [MaxLength(250)] + public string Cliente { get; set; } + [MaxLength(250)] public string Contatto { get; set; } + [MaxLength(250)] public string Email { get; set; } - public virtual ICollection LicenzeAttives { get; set; } + //public virtual ICollection LicenzeAttives { get; set; } } } diff --git a/LiMan.DB/DBModels/LicManContext.cs b/LiMan.DB/DBModels/LicManContext.cs new file mode 100644 index 0000000..2fa7423 --- /dev/null +++ b/LiMan.DB/DBModels/LicManContext.cs @@ -0,0 +1,109 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Configuration; +using NLog; + +#nullable disable + +namespace LiMan.DB.DBModels +{ + public partial class LicManContext : DbContext + { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private IConfiguration _configuration; + + #endregion Private Fields + + #region Public Constructors + + [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] + public LicManContext() + { + } + + public LicManContext(IConfiguration configuration) + { + _configuration = configuration; + } + + public LicManContext(DbContextOptions options) : base(options) + { + try + { + // se non ci fosse... crea o migra! + Database.Migrate(); + } + catch (Exception exc) + { + Log.Error(exc, "Exception during context initialization 02"); + } + } + + #endregion Public Constructors + + #region Public Properties + + public virtual DbSet DbSetApp { get; set; } + + public virtual DbSet DbSetInst { get; set; } + + public virtual DbSet DbSetLicenze { get; set; } + + #endregion Public Properties + + #region Private Methods + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + + #endregion Private Methods + + #region Protected Methods + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + string connString = _configuration.GetConnectionString("LiMan.DB"); + if (!string.IsNullOrEmpty(connString)) + { + optionsBuilder.UseSqlServer(connString); + } + else + { + optionsBuilder.UseSqlServer("Server=SQLSTEAM;Database=LiMan.DB;Trusted_Connection=True;"); + } + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + + OnModelCreatingPartial(modelBuilder); + } + + #endregion Protected Methods + + #region Public Methods + + public void DbForceMigrate() + { + try + { + // se non ci fosse... crea o migra! + Database.Migrate(); + Log.Info("DbForceMigrate: done!"); + } + catch (Exception exc) + { + Log.Error(exc, "DbForceMigrate: Exception during context initialization 01"); + } + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/LiMan.DB/DBModels/LicenzaModel.cs b/LiMan.DB/DBModels/LicenzaModel.cs new file mode 100644 index 0000000..cfcb957 --- /dev/null +++ b/LiMan.DB/DBModels/LicenzaModel.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace LiMan.DB.DBModels +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + //[Index(nameof(Installazione), nameof(Active), nameof(DiskStatus))] + [Table("Licenze")] + public partial class LicenzaModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxLic { get; set; } + public string CodApp { get; set; } + public string CodInst { get; set; } + public int NumLicenze { get; set; } = 0; + public string Descrizione { get; set; } + public DateTime Scadenza { get; set; } = DateTime.Today.AddYears(-1); + + public string Chiave { get; set; } + + public int IdxLicParent { get; set; } = 0; + public bool Locked { get; set; } = false; + + [NotMapped] + public string ChiaveCalc + { + get + { + return Core.licenseManGLS.getAuthKey(CodInst, CodApp, NumLicenze, Scadenza); + } + } + + [NotMapped] + public bool IsActive + { + get => (Scadenza.Subtract(DateTime.Today).TotalDays > 0); + } + + [NotMapped] + public bool IsValid + { + get => Chiave.Equals(ChiaveCalc); + } + + [ForeignKey("CodApp")] + public virtual ApplicativoModel ApplicativoNav{ get; set; } + [ForeignKey("CodInst")] + public virtual InstallazioneModel InstallazioneNav{ get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/LiMan.DB/DatabaseModels/AnagApplicazioni.cs b/LiMan.DB/DatabaseModels/AnagApplicazioni.cs deleted file mode 100644 index 44ff0f4..0000000 --- a/LiMan.DB/DatabaseModels/AnagApplicazioni.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; - -#nullable disable - -namespace LiMan.DB.DatabaseModels -{ - public partial class AnagApplicazioni - { - #region Public Constructors - - public AnagApplicazioni() - { - LicenzeAttives = new HashSet(); - } - - #endregion Public Constructors - - #region Public Properties - - public string Applicativo { get; set; } - public string Descrizione { get; set; } - - public virtual ICollection LicenzeAttives { get; set; } - - #endregion Public Properties - } -} \ No newline at end of file diff --git a/LiMan.DB/DatabaseModels/LicManContext.cs b/LiMan.DB/DatabaseModels/LicManContext.cs deleted file mode 100644 index 167a0b7..0000000 --- a/LiMan.DB/DatabaseModels/LicManContext.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.Extensions.Configuration; -using NLog; - -#nullable disable - -namespace LiMan.DB.DatabaseModels -{ - public partial class LicManContext : DbContext - { - #region Private Fields - - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - - private IConfiguration _configuration; - - #endregion Private Fields - - #region Public Constructors - - [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] - public LicManContext() - { - } - - public LicManContext(IConfiguration configuration) - { - _configuration = configuration; - } - - public LicManContext(DbContextOptions options) : base(options) - { - try - { - // se non ci fosse... crea o migra! - Database.Migrate(); - } - catch (Exception exc) - { - Log.Error(exc, "Exception during context initialization 02"); - } - } - - #endregion Public Constructors - - #region Public Properties - - public virtual DbSet DbSetApplicazioni { get; set; } - - public virtual DbSet DbSetInstallazioni { get; set; } - - public virtual DbSet DbSetLicenzeAttive { get; set; } - - public virtual DbSet DbSetPermessi { get; set; } - - public virtual DbSet DbSetPermessi2Funzione { get; set; } - - #endregion Public Properties - - #region Private Methods - - partial void OnModelCreatingPartial(ModelBuilder modelBuilder); - - #endregion Private Methods - - #region Protected Methods - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - if (!optionsBuilder.IsConfigured) - { - string connString = _configuration.GetConnectionString("LiMan.DB"); - if (!string.IsNullOrEmpty(connString)) - { - optionsBuilder.UseSqlServer(connString); - } - else - { - optionsBuilder.UseSqlServer("Server=SQLSTEAM;Database=LiMan.DB;Trusted_Connection=True;"); - } - } - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Applicativo); - - entity.ToTable("AnagApplicazioni"); - - entity.Property(e => e.Applicativo) - .HasMaxLength(50) - .HasColumnName("applicativo"); - - entity.Property(e => e.Descrizione) - .HasMaxLength(50) - .HasColumnName("descrizione"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Installazione); - - entity.ToTable("AnagInstallazioni"); - - entity.Property(e => e.Installazione) - .HasMaxLength(50) - .HasColumnName("installazione"); - - entity.Property(e => e.Contatto) - .HasMaxLength(50) - .HasColumnName("contatto"); - - entity.Property(e => e.Descrizione) - .HasMaxLength(50) - .HasColumnName("descrizione"); - - entity.Property(e => e.Email) - .HasMaxLength(50) - .HasColumnName("email"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.IdxLic) - .HasName("PK_AnagKeyValue"); - - entity.ToTable("LicenzeAttive"); - - entity.Property(e => e.IdxLic).HasColumnName("idxLic"); - - entity.Property(e => e.Applicativo) - .HasMaxLength(50) - .HasColumnName("applicativo") - .HasDefaultValueSql("(N'-')"); - - entity.Property(e => e.Descrizione) - .HasMaxLength(250) - .HasColumnName("descrizione") - .HasDefaultValueSql("('-')"); - - entity.Property(e => e.Installazione) - .HasMaxLength(50) - .HasColumnName("installazione") - .HasDefaultValueSql("(N'SteamWare')"); - - entity.Property(e => e.Licenza) - .HasMaxLength(250) - .HasColumnName("licenza") - .HasDefaultValueSql("('')"); - - entity.Property(e => e.NumLicenze) - .HasColumnName("numLicenze") - .HasDefaultValueSql("((0))"); - - entity.Property(e => e.Scadenza) - .HasColumnType("date") - .HasColumnName("scadenza"); - - entity.HasOne(d => d.ApplicativoNavigation) - .WithMany(p => p.LicenzeAttives) - .HasForeignKey(d => d.Applicativo) - .HasConstraintName("FK_AnagKeyValue_AnagApplicazioni"); - - entity.HasOne(d => d.InstallazioneNavigation) - .WithMany(p => p.LicenzeAttives) - .HasForeignKey(d => d.Installazione) - .HasConstraintName("FK_AnagKeyValue_AnagInstallazioni"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.CodPermesso); - - entity.ToTable("Permessi"); - - entity.Property(e => e.CodPermesso) - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnName("COD_PERMESSO"); - - entity.Property(e => e.Descrizione) - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnName("DESCRIZIONE"); - - entity.Property(e => e.Gruppo).HasColumnName("GRUPPO"); - - entity.Property(e => e.Nome) - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnName("NOME"); - - entity.Property(e => e.Numero).HasColumnName("NUMERO"); - - entity.Property(e => e.Url) - .IsRequired() - .HasMaxLength(250) - .IsUnicode(false) - .HasColumnName("URL"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => new { e.CodPermesso, e.CodFunzione }); - - entity.ToTable("Permessi2Funzione"); - - entity.Property(e => e.CodPermesso) - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnName("COD_PERMESSO"); - - entity.Property(e => e.CodFunzione) - .HasMaxLength(31) - .HasColumnName("COD_FUNZIONE"); - - entity.Property(e => e.Readwrite) - .HasMaxLength(1) - .IsUnicode(false) - .HasColumnName("READWRITE") - .IsFixedLength(true); - - entity.HasOne(d => d.CodPermessoNavigation) - .WithMany(p => p.Permessi2Funziones) - .HasForeignKey(d => d.CodPermesso) - .OnDelete(DeleteBehavior.ClientSetNull) - .HasConstraintName("FK_Permessi2Funzione_Permessi"); - }); - - OnModelCreatingPartial(modelBuilder); - } - - #endregion Protected Methods - - #region Public Methods - - public void DbForceMigrate() - { - try - { - // se non ci fosse... crea o migra! - Database.Migrate(); - Log.Info("DbForceMigrate: done!"); - } - catch (Exception exc) - { - Log.Error(exc, "DbForceMigrate: Exception during context initialization 01"); - } - } - - #endregion Public Methods - } -} \ No newline at end of file diff --git a/LiMan.DB/DatabaseModels/LicenzeAttive.cs b/LiMan.DB/DatabaseModels/LicenzeAttive.cs deleted file mode 100644 index b39fa1e..0000000 --- a/LiMan.DB/DatabaseModels/LicenzeAttive.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; - -#nullable disable - -namespace LiMan.DB.DatabaseModels -{ - public partial class LicenzeAttive - { - #region Public Properties - - public string Applicativo { get; set; } - public virtual AnagApplicazioni ApplicativoNavigation { get; set; } - public string Descrizione { get; set; } - public int IdxLic { get; set; } - public string Installazione { get; set; } - public virtual AnagInstallazioni InstallazioneNavigation { get; set; } - public string Licenza { get; set; } - public int? NumLicenze { get; set; } - public DateTime Scadenza { get; set; } = DateTime.Today.AddYears(-1); - - #endregion Public Properties - } -} \ No newline at end of file diff --git a/LiMan.DB/DatabaseModels/Permessi.cs b/LiMan.DB/DatabaseModels/Permessi.cs deleted file mode 100644 index 33ef1cd..0000000 --- a/LiMan.DB/DatabaseModels/Permessi.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; - -#nullable disable - -namespace LiMan.DB.DatabaseModels -{ - public partial class Permessi - { - #region Public Constructors - - public Permessi() - { - Permessi2Funziones = new HashSet(); - } - - #endregion Public Constructors - - #region Public Properties - - public string CodPermesso { get; set; } - public string Descrizione { get; set; } - public int? Gruppo { get; set; } - public string Nome { get; set; } - public int? Numero { get; set; } - public virtual ICollection Permessi2Funziones { get; set; } - public string Url { get; set; } - - #endregion Public Properties - } -} \ No newline at end of file diff --git a/LiMan.DB/DatabaseModels/Permessi2Funzione.cs b/LiMan.DB/DatabaseModels/Permessi2Funzione.cs deleted file mode 100644 index 9489562..0000000 --- a/LiMan.DB/DatabaseModels/Permessi2Funzione.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; - -#nullable disable - -namespace LiMan.DB.DatabaseModels -{ - public partial class Permessi2Funzione - { - #region Public Properties - - public string CodFunzione { get; set; } - public string CodPermesso { get; set; } - public virtual Permessi CodPermessoNavigation { get; set; } - public string Readwrite { get; set; } - - #endregion Public Properties - } -} \ No newline at end of file diff --git a/LiMan.DB/LiMan.DB.csproj b/LiMan.DB/LiMan.DB.csproj index f77e57e..290956b 100644 --- a/LiMan.DB/LiMan.DB.csproj +++ b/LiMan.DB/LiMan.DB.csproj @@ -6,6 +6,7 @@ + diff --git a/LiMan.DB/Migrations/20211008094940_InitDb.Designer.cs b/LiMan.DB/Migrations/20211008094940_InitDb.Designer.cs deleted file mode 100644 index c38b0f5..0000000 --- a/LiMan.DB/Migrations/20211008094940_InitDb.Designer.cs +++ /dev/null @@ -1,233 +0,0 @@ -// -using System; -using LiMan.DB.DatabaseModels; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace LiMan.DB.Migrations -{ - [DbContext(typeof(LicManContext))] - [Migration("20211008094940_InitDb")] - partial class InitDb - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.10") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagApplicazioni", b => - { - b.Property("Applicativo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("applicativo"); - - b.Property("Descrizione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("descrizione"); - - b.HasKey("Applicativo"); - - b.ToTable("AnagApplicazioni"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagInstallazioni", b => - { - b.Property("Installazione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("installazione"); - - b.Property("Contatto") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("contatto"); - - b.Property("Descrizione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("descrizione"); - - b.Property("Email") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("email"); - - b.HasKey("Installazione"); - - b.ToTable("AnagInstallazioni"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.LicenzeAttive", b => - { - b.Property("IdxLic") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasColumnName("idxLic") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("Applicativo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("applicativo") - .HasDefaultValueSql("(N'-')"); - - b.Property("Descrizione") - .ValueGeneratedOnAdd() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)") - .HasColumnName("descrizione") - .HasDefaultValueSql("('-')"); - - b.Property("Installazione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("installazione") - .HasDefaultValueSql("(N'SteamWare')"); - - b.Property("Licenza") - .ValueGeneratedOnAdd() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)") - .HasColumnName("licenza") - .HasDefaultValueSql("('')"); - - b.Property("NumLicenze") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasColumnName("numLicenze") - .HasDefaultValueSql("((0))"); - - b.Property("Scadenza") - .HasColumnType("date") - .HasColumnName("scadenza"); - - b.HasKey("IdxLic") - .HasName("PK_AnagKeyValue"); - - b.HasIndex("Applicativo"); - - b.HasIndex("Installazione"); - - b.ToTable("LicenzeAttive"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi", b => - { - b.Property("CodPermesso") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("COD_PERMESSO"); - - b.Property("Descrizione") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("DESCRIZIONE"); - - b.Property("Gruppo") - .HasColumnType("int") - .HasColumnName("GRUPPO"); - - b.Property("Nome") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("NOME"); - - b.Property("Numero") - .HasColumnType("int") - .HasColumnName("NUMERO"); - - b.Property("Url") - .IsRequired() - .HasMaxLength(250) - .IsUnicode(false) - .HasColumnType("varchar(250)") - .HasColumnName("URL"); - - b.HasKey("CodPermesso"); - - b.ToTable("Permessi"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi2Funzione", b => - { - b.Property("CodPermesso") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("COD_PERMESSO"); - - b.Property("CodFunzione") - .HasMaxLength(31) - .HasColumnType("nvarchar(31)") - .HasColumnName("COD_FUNZIONE"); - - b.Property("Readwrite") - .HasMaxLength(1) - .IsUnicode(false) - .HasColumnType("char(1)") - .HasColumnName("READWRITE") - .IsFixedLength(true); - - b.HasKey("CodPermesso", "CodFunzione"); - - b.ToTable("Permessi2Funzione"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.LicenzeAttive", b => - { - b.HasOne("LiMan.DB.DatabaseModels.AnagApplicazioni", "ApplicativoNavigation") - .WithMany("LicenzeAttives") - .HasForeignKey("Applicativo") - .HasConstraintName("FK_AnagKeyValue_AnagApplicazioni"); - - b.HasOne("LiMan.DB.DatabaseModels.AnagInstallazioni", "InstallazioneNavigation") - .WithMany("LicenzeAttives") - .HasForeignKey("Installazione") - .HasConstraintName("FK_AnagKeyValue_AnagInstallazioni"); - - b.Navigation("ApplicativoNavigation"); - - b.Navigation("InstallazioneNavigation"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi2Funzione", b => - { - b.HasOne("LiMan.DB.DatabaseModels.Permessi", "CodPermessoNavigation") - .WithMany("Permessi2Funziones") - .HasForeignKey("CodPermesso") - .HasConstraintName("FK_Permessi2Funzione_Permessi") - .IsRequired(); - - b.Navigation("CodPermessoNavigation"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagApplicazioni", b => - { - b.Navigation("LicenzeAttives"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagInstallazioni", b => - { - b.Navigation("LicenzeAttives"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi", b => - { - b.Navigation("Permessi2Funziones"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/LiMan.DB/Migrations/20211008094940_InitDb.cs b/LiMan.DB/Migrations/20211008094940_InitDb.cs deleted file mode 100644 index 102af8e..0000000 --- a/LiMan.DB/Migrations/20211008094940_InitDb.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace LiMan.DB.Migrations -{ - public partial class InitDb : Migration - { - #region Protected Methods - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "LicenzeAttive"); - - migrationBuilder.DropTable( - name: "Permessi2Funzione"); - - migrationBuilder.DropTable( - name: "AnagApplicazioni"); - - migrationBuilder.DropTable( - name: "AnagInstallazioni"); - - migrationBuilder.DropTable( - name: "Permessi"); - } - - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AnagApplicazioni", - columns: table => new - { - applicativo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - descrizione = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AnagApplicazioni", x => x.applicativo); - }); - - migrationBuilder.CreateTable( - name: "AnagInstallazioni", - columns: table => new - { - installazione = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - descrizione = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - contatto = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), - email = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AnagInstallazioni", x => x.installazione); - }); - - migrationBuilder.CreateTable( - name: "Permessi", - columns: table => new - { - COD_PERMESSO = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false), - URL = table.Column(type: "varchar(250)", unicode: false, maxLength: 250, nullable: false), - GRUPPO = table.Column(type: "int", nullable: true), - NUMERO = table.Column(type: "int", nullable: true), - NOME = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: true), - DESCRIZIONE = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Permessi", x => x.COD_PERMESSO); - }); - - migrationBuilder.CreateTable( - name: "LicenzeAttive", - columns: table => new - { - idxLic = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - applicativo = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true, defaultValueSql: "(N'-')"), - descrizione = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true, defaultValueSql: "('-')"), - installazione = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true, defaultValueSql: "(N'SteamWare')"), - licenza = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true, defaultValueSql: "('')"), - numLicenze = table.Column(type: "int", nullable: true, defaultValueSql: "((0))"), - scadenza = table.Column(type: "date", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AnagKeyValue", x => x.idxLic); - table.ForeignKey( - name: "FK_AnagKeyValue_AnagApplicazioni", - column: x => x.applicativo, - principalTable: "AnagApplicazioni", - principalColumn: "applicativo", - onDelete: ReferentialAction.Restrict); - table.ForeignKey( - name: "FK_AnagKeyValue_AnagInstallazioni", - column: x => x.installazione, - principalTable: "AnagInstallazioni", - principalColumn: "installazione", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Permessi2Funzione", - columns: table => new - { - COD_PERMESSO = table.Column(type: "varchar(50)", unicode: false, maxLength: 50, nullable: false), - COD_FUNZIONE = table.Column(type: "nvarchar(31)", maxLength: 31, nullable: false), - READWRITE = table.Column(type: "char(1)", unicode: false, fixedLength: true, maxLength: 1, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Permessi2Funzione", x => new { x.COD_PERMESSO, x.COD_FUNZIONE }); - table.ForeignKey( - name: "FK_Permessi2Funzione_Permessi", - column: x => x.COD_PERMESSO, - principalTable: "Permessi", - principalColumn: "COD_PERMESSO", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateIndex( - name: "IX_LicenzeAttive_applicativo", - table: "LicenzeAttive", - column: "applicativo"); - - migrationBuilder.CreateIndex( - name: "IX_LicenzeAttive_installazione", - table: "LicenzeAttive", - column: "installazione"); - } - - #endregion Protected Methods - } -} \ No newline at end of file diff --git a/LiMan.DB/Migrations/LicManContextModelSnapshot.cs b/LiMan.DB/Migrations/LicManContextModelSnapshot.cs deleted file mode 100644 index f231b76..0000000 --- a/LiMan.DB/Migrations/LicManContextModelSnapshot.cs +++ /dev/null @@ -1,231 +0,0 @@ -// -using System; -using LiMan.DB.DatabaseModels; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -namespace LiMan.DB.Migrations -{ - [DbContext(typeof(LicManContext))] - partial class LicManContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS") - .HasAnnotation("Relational:MaxIdentifierLength", 128) - .HasAnnotation("ProductVersion", "5.0.10") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagApplicazioni", b => - { - b.Property("Applicativo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("applicativo"); - - b.Property("Descrizione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("descrizione"); - - b.HasKey("Applicativo"); - - b.ToTable("AnagApplicazioni"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagInstallazioni", b => - { - b.Property("Installazione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("installazione"); - - b.Property("Contatto") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("contatto"); - - b.Property("Descrizione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("descrizione"); - - b.Property("Email") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("email"); - - b.HasKey("Installazione"); - - b.ToTable("AnagInstallazioni"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.LicenzeAttive", b => - { - b.Property("IdxLic") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasColumnName("idxLic") - .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn); - - b.Property("Applicativo") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("applicativo") - .HasDefaultValueSql("(N'-')"); - - b.Property("Descrizione") - .ValueGeneratedOnAdd() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)") - .HasColumnName("descrizione") - .HasDefaultValueSql("('-')"); - - b.Property("Installazione") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("installazione") - .HasDefaultValueSql("(N'SteamWare')"); - - b.Property("Licenza") - .ValueGeneratedOnAdd() - .HasMaxLength(250) - .HasColumnType("nvarchar(250)") - .HasColumnName("licenza") - .HasDefaultValueSql("('')"); - - b.Property("NumLicenze") - .ValueGeneratedOnAdd() - .HasColumnType("int") - .HasColumnName("numLicenze") - .HasDefaultValueSql("((0))"); - - b.Property("Scadenza") - .HasColumnType("date") - .HasColumnName("scadenza"); - - b.HasKey("IdxLic") - .HasName("PK_AnagKeyValue"); - - b.HasIndex("Applicativo"); - - b.HasIndex("Installazione"); - - b.ToTable("LicenzeAttive"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi", b => - { - b.Property("CodPermesso") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("COD_PERMESSO"); - - b.Property("Descrizione") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("DESCRIZIONE"); - - b.Property("Gruppo") - .HasColumnType("int") - .HasColumnName("GRUPPO"); - - b.Property("Nome") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("NOME"); - - b.Property("Numero") - .HasColumnType("int") - .HasColumnName("NUMERO"); - - b.Property("Url") - .IsRequired() - .HasMaxLength(250) - .IsUnicode(false) - .HasColumnType("varchar(250)") - .HasColumnName("URL"); - - b.HasKey("CodPermesso"); - - b.ToTable("Permessi"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi2Funzione", b => - { - b.Property("CodPermesso") - .HasMaxLength(50) - .IsUnicode(false) - .HasColumnType("varchar(50)") - .HasColumnName("COD_PERMESSO"); - - b.Property("CodFunzione") - .HasMaxLength(31) - .HasColumnType("nvarchar(31)") - .HasColumnName("COD_FUNZIONE"); - - b.Property("Readwrite") - .HasMaxLength(1) - .IsUnicode(false) - .HasColumnType("char(1)") - .HasColumnName("READWRITE") - .IsFixedLength(true); - - b.HasKey("CodPermesso", "CodFunzione"); - - b.ToTable("Permessi2Funzione"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.LicenzeAttive", b => - { - b.HasOne("LiMan.DB.DatabaseModels.AnagApplicazioni", "ApplicativoNavigation") - .WithMany("LicenzeAttives") - .HasForeignKey("Applicativo") - .HasConstraintName("FK_AnagKeyValue_AnagApplicazioni"); - - b.HasOne("LiMan.DB.DatabaseModels.AnagInstallazioni", "InstallazioneNavigation") - .WithMany("LicenzeAttives") - .HasForeignKey("Installazione") - .HasConstraintName("FK_AnagKeyValue_AnagInstallazioni"); - - b.Navigation("ApplicativoNavigation"); - - b.Navigation("InstallazioneNavigation"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi2Funzione", b => - { - b.HasOne("LiMan.DB.DatabaseModels.Permessi", "CodPermessoNavigation") - .WithMany("Permessi2Funziones") - .HasForeignKey("CodPermesso") - .HasConstraintName("FK_Permessi2Funzione_Permessi") - .IsRequired(); - - b.Navigation("CodPermessoNavigation"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagApplicazioni", b => - { - b.Navigation("LicenzeAttives"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.AnagInstallazioni", b => - { - b.Navigation("LicenzeAttives"); - }); - - modelBuilder.Entity("LiMan.DB.DatabaseModels.Permessi", b => - { - b.Navigation("Permessi2Funziones"); - }); -#pragma warning restore 612, 618 - } - } -}