From 0cd1367ef607ff9598d23ca1b7f16b72bde580e2 Mon Sep 17 00:00:00 2001 From: GiuseppeS Date: Thu, 25 Sep 2025 19:37:18 +0200 Subject: [PATCH] Elenco clienti funzionante --- .../Pages/Customers.razor | 11 +- .../Controllers/CustomerAnagInfoController.cs | 177 +-- .../Data/IntegryControlPanelDbContext.cs | 1144 +++++++++-------- ...162221_AddCustomerAnagInfoView.Designer.cs | 980 ++++++++++++++ .../20250925162221_AddCustomerAnagInfoView.cs | 36 + ...tegryControlPanelDbContextModelSnapshot.cs | 7 + .../CustomerWithAnagInfo.cs | 17 + .../IntegryControlPanel/VwCustomerAnagInfo.cs | 9 + .../Services/IIntegryControlPanelService.cs | 16 +- .../Services/IntegryControlPanelService.cs | 245 ++-- 10 files changed, 1861 insertions(+), 781 deletions(-) create mode 100644 IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.Designer.cs create mode 100644 IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.cs create mode 100644 IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/CustomerWithAnagInfo.cs create mode 100644 IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/VwCustomerAnagInfo.cs diff --git a/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor b/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor index 1349c59..afc44ea 100644 --- a/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor +++ b/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor @@ -39,12 +39,15 @@ + + @context.Item.DisplayName + + + @context.Item.Name + @* #@context.Item.Id - @context.Item.Slug *@ - P. Iva: @context.Item.PartitaIva - - - @context.Item.Name + @context.Item.PartitaIva diff --git a/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs b/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs index 7355be9..11820f9 100644 --- a/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs +++ b/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs @@ -1,3 +1,4 @@ +using IntegryControlPanel.Models.IntegryControlPanel; using IntegryControlPanel.Services; using Microsoft.AspNetCore.Mvc; @@ -19,100 +20,100 @@ namespace IntegryControlPanel.Controllers /// /// Ottiene tutti i customer con le informazioni anagrafiche joinate dalla vista vw_customer_anag_info /// - //[HttpGet] - //public async Task>> GetCustomersWithAnagInfo() - //{ - // try - // { - // var customers = await _service.GetCustomersWithAnagInfoAsync(); - // return Ok(customers); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving customers with anag info"); - // return StatusCode(500, "Errore interno del server"); - // } - //} + [HttpGet] + public async Task>> GetCustomersWithAnagInfo() + { + try + { + var customers = await _service.GetCustomersWithAnagInfoAsync(); + return Ok(customers); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving customers with anag info"); + return StatusCode(500, "Errore interno del server"); + } + } - ///// - ///// Ottiene tutti i customer attivi con le informazioni anagrafiche - ///// - //[HttpGet("active")] - //public async Task>> GetActiveCustomersWithAnagInfo() - //{ - // try - // { - // var customers = await _service.GetActiveCustomersWithAnagInfoAsync(); - // return Ok(customers); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving active customers with anag info"); - // return StatusCode(500, "Errore interno del server"); - // } - //} + /// + /// Ottiene tutti i customer attivi con le informazioni anagrafiche + /// + [HttpGet("active")] + public async Task>> GetActiveCustomersWithAnagInfo() + { + try + { + var customers = await _service.GetActiveCustomersWithAnagInfoAsync(); + return Ok(customers); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving active customers with anag info"); + return StatusCode(500, "Errore interno del server"); + } + } - ///// - ///// Ottiene un customer con informazioni anagrafiche tramite ID - ///// - //[HttpGet("{id:int}")] - //public async Task> GetCustomerWithAnagInfoById(int id) - //{ - // try - // { - // var customer = await _service.GetCustomerWithAnagInfoByIdAsync(id); - // if (customer == null) - // return NotFound($"Customer con ID {id} non trovato"); + /// + /// Ottiene un customer con informazioni anagrafiche tramite ID + /// + [HttpGet("{id:int}")] + public async Task> GetCustomerWithAnagInfoById(int id) + { + try + { + var customer = await _service.GetCustomerWithAnagInfoByIdAsync(id); + if (customer == null) + return NotFound($"Customer con ID {id} non trovato"); - // return Ok(customer); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving customer with anag info by id {CustomerId}", id); - // return StatusCode(500, "Errore interno del server"); - // } - //} + return Ok(customer); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving customer with anag info by id {CustomerId}", id); + return StatusCode(500, "Errore interno del server"); + } + } - ///// - ///// Ottiene un customer con informazioni anagrafiche tramite slug - ///// - //[HttpGet("slug/{slug}")] - //public async Task> GetCustomerWithAnagInfoBySlug(string slug) - //{ - // try - // { - // var customer = await _service.GetCustomerWithAnagInfoBySlugAsync(slug); - // if (customer == null) - // return NotFound($"Customer con slug '{slug}' non trovato"); + /// + /// Ottiene un customer con informazioni anagrafiche tramite slug + /// + [HttpGet("slug/{slug}")] + public async Task> GetCustomerWithAnagInfoBySlug(string slug) + { + try + { + var customer = await _service.GetCustomerWithAnagInfoBySlugAsync(slug); + if (customer == null) + return NotFound($"Customer con slug '{slug}' non trovato"); - // return Ok(customer); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving customer with anag info by slug {Slug}", slug); - // return StatusCode(500, "Errore interno del server"); - // } - //} + return Ok(customer); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving customer with anag info by slug {Slug}", slug); + return StatusCode(500, "Errore interno del server"); + } + } - ///// - ///// Cerca customer con informazioni anagrafiche per termine di ricerca - ///// - //[HttpGet("search")] - //public async Task>> SearchCustomersWithAnagInfo([FromQuery] string term) - //{ - // if (string.IsNullOrWhiteSpace(term)) - // return BadRequest("Il termine di ricerca non può essere vuoto"); + /// + /// Cerca customer con informazioni anagrafiche per termine di ricerca + /// + [HttpGet("search")] + public async Task>> SearchCustomersWithAnagInfo([FromQuery] string term) + { + if (string.IsNullOrWhiteSpace(term)) + return BadRequest("Il termine di ricerca non può essere vuoto"); - // try - // { - // var customers = await _service.SearchCustomersWithAnagInfoAsync(term); - // return Ok(customers); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error searching customers with anag info for term {SearchTerm}", term); - // return StatusCode(500, "Errore interno del server"); - // } - //} + try + { + var customers = await _service.SearchCustomersWithAnagInfoAsync(term); + return Ok(customers); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error searching customers with anag info for term {SearchTerm}", term); + return StatusCode(500, "Errore interno del server"); + } + } } } \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs b/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs index fa94716..4a5ed40 100644 --- a/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs +++ b/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs @@ -7,553 +7,597 @@ namespace IntegryControlPanel.Data; public partial class IntegryControlPanelDbContext : DbContext { - public IntegryControlPanelDbContext() - { - } - - public IntegryControlPanelDbContext(DbContextOptions options) - : base(options) - { - } - - public virtual DbSet ApplicationInfos { get; set; } - - public virtual DbSet Clients { get; set; } - - public virtual DbSet Configurazionis { get; set; } - - public virtual DbSet Customers { get; set; } - - public virtual DbSet DatabaseEngines { get; set; } - - public virtual DbSet DatabasesInfos { get; set; } - - public virtual DbSet Devices { get; set; } - - public virtual DbSet Installations { get; set; } - - public virtual DbSet PvmsInfos { get; set; } - - public virtual DbSet Releases { get; set; } - - public virtual DbSet SalvataggiSoaps { get; set; } - - public virtual DbSet Servers { get; set; } - - public virtual DbSet Services { get; set; } - - public virtual DbSet VwCustomerServerInfos { get; set; } - - public virtual DbSet VwServerLastUpdates { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - // Rimossa la connection string hard-coded - sarà configurata tramite DI - if (!optionsBuilder.IsConfigured) - { - // Configurazione di fallback solo per il design-time se necessaria - optionsBuilder.UseSqlServer("Server=SERVERDB2019;Database=integry_control_panel_test;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;"); - } - } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__applicat__3213E83F4185DE9F"); - - entity.ToTable("application_infos"); - - entity.HasIndex(e => e.CustomerId, "IDX_D5E65179395C3F3"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.AnnoContab).HasColumnName("anno_contab"); - entity.Property(e => e.AnnoMagaz).HasColumnName("anno_magaz"); - entity.Property(e => e.AnsiPadding) - .IsRequired() - .HasDefaultValueSql("('0')") - .HasColumnName("ansi_padding"); - entity.Property(e => e.ConcatNullYieldsNull) - .IsRequired() - .HasDefaultValueSql("('0')") - .HasColumnName("concat_null_yields_null"); - entity.Property(e => e.CustomerId).HasColumnName("customer_id"); - entity.Property(e => e.DelimitedIdentifier) - .IsRequired() - .HasDefaultValueSql("('0')") - .HasColumnName("delimited_identifier"); - entity.Property(e => e.MenuPersonalizzato) - .HasMaxLength(255) - .HasColumnName("menu_personalizzato"); - entity.Property(e => e.Name) - .HasMaxLength(255) - .HasColumnName("name"); - entity.Property(e => e.NewUpdProgMaga).HasColumnName("new_upd_prog_maga"); - - entity.HasOne(d => d.Customer).WithMany(p => p.ApplicationInfos) - .HasForeignKey(d => d.CustomerId) - .HasConstraintName("FK_D5E65179395C3F3"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__clients__3213E83FFF8DC3E2"); - - entity.ToTable("clients"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.DeviceId) - .HasMaxLength(255) - .HasColumnName("device_id"); - entity.Property(e => e.InsertDate) - .HasPrecision(6) - .HasColumnName("insert_date"); - entity.Property(e => e.LastUpdate) - .HasPrecision(6) - .HasColumnName("last_update"); - entity.Property(e => e.NomeAzienda) - .HasMaxLength(255) - .HasColumnName("nome_azienda"); - entity.Property(e => e.RemoteAddr) - .HasMaxLength(255) - .HasColumnName("remote_addr"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__configur__3213E83FB9077FED"); - - entity.ToTable("configurazioni"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.JavaVersion) - .HasMaxLength(255) - .HasColumnName("java_version"); - entity.Property(e => e.LastUpdate) - .HasPrecision(6) - .HasColumnName("last_update"); - entity.Property(e => e.MaxPermSize) - .HasMaxLength(255) - .HasColumnName("max_perm_size"); - entity.Property(e => e.NomeAzienda) - .HasMaxLength(255) - .HasColumnName("nome_azienda"); - entity.Property(e => e.OsArch) - .HasMaxLength(255) - .HasColumnName("os_arch"); - entity.Property(e => e.OsName) - .HasMaxLength(255) - .HasColumnName("os_name"); - entity.Property(e => e.RemoteAddr) - .HasMaxLength(255) - .HasColumnName("remote_addr"); - entity.Property(e => e.Xms) - .HasMaxLength(255) - .HasColumnName("xms"); - entity.Property(e => e.Xmx) - .HasMaxLength(255) - .HasColumnName("xmx"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__customer__3213E83FD00417AC"); - - entity.ToTable("customers"); - - entity.HasIndex(e => e.Slug, "UNIQ_62534E21989D9B62") - .IsUnique() - .HasFilter("([slug] IS NOT NULL)"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.Active) - .IsRequired() - .HasDefaultValueSql("('0')") - .HasColumnName("active"); - entity.Property(e => e.Name) - .HasMaxLength(255) - .HasColumnName("name"); - entity.Property(e => e.PartitaIva) - .HasMaxLength(255) - .HasColumnName("partita_iva"); - entity.Property(e => e.Slug) - .HasMaxLength(191) - .HasColumnName("slug"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__database__3213E83F8526E221"); - - entity.ToTable("database_engines"); - - entity.HasIndex(e => e.CustomerId, "UNIQ_1D94CC5C9395C3F3") - .IsUnique() - .HasFilter("([customer_id] IS NOT NULL)"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.CustomerId).HasColumnName("customer_id"); - entity.Property(e => e.ProductEdition) - .HasMaxLength(255) - .HasColumnName("product_edition"); - entity.Property(e => e.ProductLevel) - .HasMaxLength(255) - .HasColumnName("product_level"); - entity.Property(e => e.ProductVersion) - .HasMaxLength(255) - .HasColumnName("product_version"); - entity.Property(e => e.ProductVersionName) - .HasMaxLength(255) - .HasColumnName("product_version_name"); - - entity.HasOne(d => d.Customer).WithOne(p => p.DatabaseEngine) - .HasForeignKey(d => d.CustomerId) - .HasConstraintName("FK_1D94CC5C9395C3F3"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__database__3213E83FC619B4B0"); - - entity.ToTable("databases_info"); - - entity.HasIndex(e => e.DatabaseEngineId, "IDX_99DAF4F8AB25983"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.DatabaseEngineId).HasColumnName("database_engine_id"); - entity.Property(e => e.LogicalName) - .HasMaxLength(255) - .HasColumnName("logical_name"); - entity.Property(e => e.MaxSizeMb).HasColumnName("max_size_mb"); - entity.Property(e => e.Name) - .HasMaxLength(255) - .HasColumnName("name"); - entity.Property(e => e.SizeMb).HasColumnName("size_mb"); - - entity.HasOne(d => d.DatabaseEngine).WithMany(p => p.DatabasesInfos) - .HasForeignKey(d => d.DatabaseEngineId) - .HasConstraintName("FK_99DAF4F8AB25983"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__devices__3213E83F185C7B65"); - - entity.ToTable("devices"); - - entity.HasIndex(e => e.CustomerId, "IDX_11074E9A9395C3F3"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.CustomerId).HasColumnName("customer_id"); - entity.Property(e => e.Info) - .IsUnicode(false) - .HasComment("(DC2Type:simple_array)") - .HasColumnName("info"); - entity.Property(e => e.Ip) - .HasMaxLength(255) - .HasColumnName("ip"); - entity.Property(e => e.Port).HasColumnName("port"); - - entity.HasOne(d => d.Customer).WithMany(p => p.Devices) - .HasForeignKey(d => d.CustomerId) - .HasConstraintName("FK_11074E9A9395C3F3"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__installa__3213E83F11ECD973"); - - entity.ToTable("installations"); - - entity.HasIndex(e => e.ServerId, "IDX_A774F67B1844E6B7"); - - entity.HasIndex(e => e.DeviceId, "IDX_A774F67B94A4C7D4"); - - entity.HasIndex(e => e.ReleaseId, "IDX_A774F67BB12A727D"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.DeviceId).HasColumnName("device_id"); - entity.Property(e => e.InstallDate) - .HasPrecision(6) - .HasColumnName("install_date"); - entity.Property(e => e.LastUpdate) - .HasPrecision(6) - .HasColumnName("last_update"); - entity.Property(e => e.Notes) - .HasMaxLength(255) - .HasColumnName("notes"); - entity.Property(e => e.Options) - .IsUnicode(false) - .HasComment("(DC2Type:simple_array)") - .HasColumnName("options"); - entity.Property(e => e.ReleaseId).HasColumnName("release_id"); - entity.Property(e => e.ServerId).HasColumnName("server_id"); - - entity.HasOne(d => d.Device).WithMany(p => p.Installations) - .HasForeignKey(d => d.DeviceId) - .HasConstraintName("FK_A774F67B94A4C7D4"); - - entity.HasOne(d => d.Release).WithMany(p => p.Installations) - .HasForeignKey(d => d.ReleaseId) - .HasConstraintName("FK_A774F67BB12A727D"); - - entity.HasOne(d => d.Server).WithMany(p => p.Installations) - .HasForeignKey(d => d.ServerId) - .HasConstraintName("FK_A774F67B1844E6B7"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__pvms_inf__3213E83F8EA1FE36"); - - entity.ToTable("pvms_info"); - - entity.HasIndex(e => e.CustomerId, "IDX_4BCCAB779395C3F3"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.CustomerId).HasColumnName("customer_id"); - entity.Property(e => e.DefaultCharset) - .HasMaxLength(255) - .HasColumnName("default_charset"); - entity.Property(e => e.Imagick) - .HasMaxLength(255) - .HasColumnName("imagick"); - entity.Property(e => e.MagicQuotesGpc).HasColumnName("magic_quotes_gpc"); - entity.Property(e => e.MaxExecutionTime).HasColumnName("max_execution_time"); - entity.Property(e => e.MaxInputVars).HasColumnName("max_input_vars"); - entity.Property(e => e.MemoryLimit) - .HasMaxLength(255) - .HasColumnName("memory_limit"); - entity.Property(e => e.PhpVersion) - .HasMaxLength(255) - .HasColumnName("php_version"); - entity.Property(e => e.PostMaxSize) - .HasMaxLength(255) - .HasColumnName("post_max_size"); - entity.Property(e => e.SodiumMissing).HasColumnName("sodium_missing"); - entity.Property(e => e.Timezone) - .HasMaxLength(255) - .HasColumnName("timezone"); - entity.Property(e => e.UploadMaxSize) - .HasMaxLength(255) - .HasColumnName("upload_max_size"); - - entity.HasOne(d => d.Customer).WithMany(p => p.PvmsInfos) - .HasForeignKey(d => d.CustomerId) - .HasConstraintName("FK_4BCCAB779395C3F3"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__releases__3213E83F59E90B83"); - - entity.ToTable("releases"); - - entity.HasIndex(e => e.ServiceId, "IDX_7896E4D1ED5CA9E6"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.Changelog) - .IsUnicode(false) - .HasColumnName("changelog"); - entity.Property(e => e.ReleaseDate) - .HasPrecision(6) - .HasColumnName("release_date"); - entity.Property(e => e.ServiceId).HasColumnName("service_id"); - entity.Property(e => e.Version) - .HasMaxLength(255) - .HasColumnName("version"); - - entity.HasOne(d => d.Service).WithMany(p => p.Releases) - .HasForeignKey(d => d.ServiceId) - .HasConstraintName("FK_7896E4D1ED5CA9E6"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__salvatag__3213E83F51C2D8BF"); - - entity.ToTable("salvataggi_soap"); - - entity.HasIndex(e => e.ApplicationInfoId, "IDX_BC9B16D5B635C4CB"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.ApplicationInfoId).HasColumnName("application_info_id"); - entity.Property(e => e.Name) - .HasMaxLength(255) - .HasColumnName("name"); - - entity.HasOne(d => d.ApplicationInfo).WithMany(p => p.SalvataggiSoaps) - .HasForeignKey(d => d.ApplicationInfoId) - .HasConstraintName("FK_BC9B16D5B635C4CB"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__servers__3213E83F0E4B2C74"); - - entity.ToTable("servers"); - - entity.HasIndex(e => e.CustomerId, "IDX_4F8AF5F79395C3F3"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.CreatedAt) - .HasPrecision(6) - .HasColumnName("created_at"); - entity.Property(e => e.CustomerId).HasColumnName("customer_id"); - entity.Property(e => e.Info) - .IsUnicode(false) - .HasComment("(DC2Type:simple_array)") - .HasColumnName("info"); - entity.Property(e => e.Ip) - .HasMaxLength(255) - .HasColumnName("ip"); - entity.Property(e => e.JavaVersion) - .HasMaxLength(255) - .HasColumnName("java_version"); - entity.Property(e => e.LastUpdate) - .HasPrecision(6) - .HasColumnName("last_update"); - entity.Property(e => e.MaxPermSize) - .HasMaxLength(255) - .HasColumnName("max_perm_size"); - entity.Property(e => e.OsArch) - .HasMaxLength(255) - .HasColumnName("os_arch"); - entity.Property(e => e.OsName) - .HasMaxLength(255) - .HasColumnName("os_name"); - entity.Property(e => e.Port).HasColumnName("port"); - entity.Property(e => e.RemoteAddr) - .HasMaxLength(255) - .HasColumnName("remote_addr"); - entity.Property(e => e.UpdatedAt) - .HasPrecision(6) - .HasColumnName("updated_at"); - entity.Property(e => e.Xms) - .HasMaxLength(255) - .HasColumnName("xms"); - entity.Property(e => e.Xmx) - .HasMaxLength(255) - .HasColumnName("xmx"); - - entity.HasOne(d => d.Customer).WithMany(p => p.Servers) - .HasForeignKey(d => d.CustomerId) - .HasConstraintName("FK_4F8AF5F79395C3F3"); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.Id).HasName("PK__services__3213E83FB43C1FE2"); - - entity.ToTable("services"); - - entity.HasIndex(e => e.Slug, "UNIQ_7332E169989D9B62") - .IsUnique() - .HasFilter("([slug] IS NOT NULL)"); - - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.Description) - .IsUnicode(false) - .HasColumnName("description"); - entity.Property(e => e.InsertDate) - .HasPrecision(6) - .HasColumnName("insert_date"); - entity.Property(e => e.Language) - .HasMaxLength(255) - .HasColumnName("language"); - entity.Property(e => e.Name) - .HasMaxLength(255) - .HasColumnName("name"); - entity.Property(e => e.Slug) - .HasMaxLength(191) - .HasColumnName("slug"); - }); - - modelBuilder.Entity(entity => - { - entity - .HasNoKey() - .ToView("vw_customer_server_info"); - - entity.Property(e => e.JavaVersion) - .HasMaxLength(255) - .HasColumnName("java_version"); - entity.Property(e => e.Name) - .HasMaxLength(298) - .HasColumnName("name"); - entity.Property(e => e.OsArch) - .HasMaxLength(255) - .HasColumnName("os_arch"); - entity.Property(e => e.OsName) - .HasMaxLength(255) - .HasColumnName("os_name"); - entity.Property(e => e.PartitaIva) - .HasMaxLength(255) - .HasColumnName("partita_iva"); - entity.Property(e => e.RagSoc) - .HasMaxLength(40) - .IsUnicode(false) - .HasColumnName("rag_soc"); - entity.Property(e => e.RemoteAddr) - .HasMaxLength(255) - .HasColumnName("remote_addr"); - entity.Property(e => e.SimpleName) - .HasMaxLength(255) - .HasColumnName("simple_name"); - entity.Property(e => e.UpdatedAt) - .HasPrecision(6) - .HasColumnName("updated_at"); - }); - - modelBuilder.Entity(entity => - { - entity - .HasNoKey() - .ToView("vw_server_last_update"); - - entity.Property(e => e.CreatedAt) - .HasPrecision(6) - .HasColumnName("created_at"); - entity.Property(e => e.CustomerId).HasColumnName("customer_id"); - entity.Property(e => e.Id).HasColumnName("id"); - entity.Property(e => e.Info) - .IsUnicode(false) - .HasColumnName("info"); - entity.Property(e => e.Ip) - .HasMaxLength(255) - .HasColumnName("ip"); - entity.Property(e => e.JavaVersion) - .HasMaxLength(255) - .HasColumnName("java_version"); - entity.Property(e => e.LastUpdate) - .HasPrecision(6) - .HasColumnName("last_update"); - entity.Property(e => e.MaxPermSize) - .HasMaxLength(255) - .HasColumnName("max_perm_size"); - entity.Property(e => e.OsArch) - .HasMaxLength(255) - .HasColumnName("os_arch"); - entity.Property(e => e.OsName) - .HasMaxLength(255) - .HasColumnName("os_name"); - entity.Property(e => e.Port).HasColumnName("port"); - entity.Property(e => e.RemoteAddr) - .HasMaxLength(255) - .HasColumnName("remote_addr"); - entity.Property(e => e.UpdatedAt) - .HasPrecision(6) - .HasColumnName("updated_at"); - entity.Property(e => e.Xms) - .HasMaxLength(255) - .HasColumnName("xms"); - entity.Property(e => e.Xmx) - .HasMaxLength(255) - .HasColumnName("xmx"); - }); - - OnModelCreatingPartial(modelBuilder); - } - - partial void OnModelCreatingPartial(ModelBuilder modelBuilder); -} + public IntegryControlPanelDbContext() + { + } + + public IntegryControlPanelDbContext(DbContextOptions options) + : base(options) + { + } + + public virtual DbSet ApplicationInfos { get; set; } + + public virtual DbSet Clients { get; set; } + + public virtual DbSet Configurazionis { get; set; } + + public virtual DbSet Customers { get; set; } + + public virtual DbSet DatabaseEngines { get; set; } + + public virtual DbSet DatabasesInfos { get; set; } + + public virtual DbSet Devices { get; set; } + + public virtual DbSet Installations { get; set; } + + public virtual DbSet PvmsInfos { get; set; } + + public virtual DbSet Releases { get; set; } + + public virtual DbSet SalvataggiSoaps { get; set; } + + public virtual DbSet Servers { get; set; } + + public virtual DbSet Services { get; set; } + + public virtual DbSet VwCustomerServerInfos { get; set; } + + public virtual DbSet VwServerLastUpdates { get; set; } + + public virtual DbSet CustomerWithAnagInfos { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + // Rimossa la connection string hard-coded - sarà configurata tramite DI + if (!optionsBuilder.IsConfigured) + { + // Configurazione di fallback solo per il design-time se necessaria + optionsBuilder.UseSqlServer( + "Server=SERVERDB2019;Database=integry_control_panel_test;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;"); + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__applicat__3213E83F4185DE9F"); + + entity.ToTable("application_infos"); + + entity.HasIndex(e => e.CustomerId, "IDX_D5E65179395C3F3"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.AnnoContab).HasColumnName("anno_contab"); + entity.Property(e => e.AnnoMagaz).HasColumnName("anno_magaz"); + entity.Property(e => e.AnsiPadding) + .IsRequired() + .HasDefaultValueSql("('0')") + .HasColumnName("ansi_padding"); + entity.Property(e => e.ConcatNullYieldsNull) + .IsRequired() + .HasDefaultValueSql("('0')") + .HasColumnName("concat_null_yields_null"); + entity.Property(e => e.CustomerId).HasColumnName("customer_id"); + entity.Property(e => e.DelimitedIdentifier) + .IsRequired() + .HasDefaultValueSql("('0')") + .HasColumnName("delimited_identifier"); + entity.Property(e => e.MenuPersonalizzato) + .HasMaxLength(255) + .HasColumnName("menu_personalizzato"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.NewUpdProgMaga).HasColumnName("new_upd_prog_maga"); + + entity.HasOne(d => d.Customer).WithMany(p => p.ApplicationInfos) + .HasForeignKey(d => d.CustomerId) + .HasConstraintName("FK_D5E65179395C3F3"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__clients__3213E83FFF8DC3E2"); + + entity.ToTable("clients"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.DeviceId) + .HasMaxLength(255) + .HasColumnName("device_id"); + entity.Property(e => e.InsertDate) + .HasPrecision(6) + .HasColumnName("insert_date"); + entity.Property(e => e.LastUpdate) + .HasPrecision(6) + .HasColumnName("last_update"); + entity.Property(e => e.NomeAzienda) + .HasMaxLength(255) + .HasColumnName("nome_azienda"); + entity.Property(e => e.RemoteAddr) + .HasMaxLength(255) + .HasColumnName("remote_addr"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__configur__3213E83FB9077FED"); + + entity.ToTable("configurazioni"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.JavaVersion) + .HasMaxLength(255) + .HasColumnName("java_version"); + entity.Property(e => e.LastUpdate) + .HasPrecision(6) + .HasColumnName("last_update"); + entity.Property(e => e.MaxPermSize) + .HasMaxLength(255) + .HasColumnName("max_perm_size"); + entity.Property(e => e.NomeAzienda) + .HasMaxLength(255) + .HasColumnName("nome_azienda"); + entity.Property(e => e.OsArch) + .HasMaxLength(255) + .HasColumnName("os_arch"); + entity.Property(e => e.OsName) + .HasMaxLength(255) + .HasColumnName("os_name"); + entity.Property(e => e.RemoteAddr) + .HasMaxLength(255) + .HasColumnName("remote_addr"); + entity.Property(e => e.Xms) + .HasMaxLength(255) + .HasColumnName("xms"); + entity.Property(e => e.Xmx) + .HasMaxLength(255) + .HasColumnName("xmx"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__customer__3213E83FD00417AC"); + + entity.ToTable("customers"); + + entity.HasIndex(e => e.Slug, "UNIQ_62534E21989D9B62") + .IsUnique() + .HasFilter("([slug] IS NOT NULL)"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Active) + .IsRequired() + .HasDefaultValueSql("('0')") + .HasColumnName("active"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.PartitaIva) + .HasMaxLength(255) + .HasColumnName("partita_iva"); + entity.Property(e => e.Slug) + .HasMaxLength(191) + .HasColumnName("slug"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__database__3213E83F8526E221"); + + entity.ToTable("database_engines"); + + entity.HasIndex(e => e.CustomerId, "UNIQ_1D94CC5C9395C3F3") + .IsUnique() + .HasFilter("([customer_id] IS NOT NULL)"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.CustomerId).HasColumnName("customer_id"); + entity.Property(e => e.ProductEdition) + .HasMaxLength(255) + .HasColumnName("product_edition"); + entity.Property(e => e.ProductLevel) + .HasMaxLength(255) + .HasColumnName("product_level"); + entity.Property(e => e.ProductVersion) + .HasMaxLength(255) + .HasColumnName("product_version"); + entity.Property(e => e.ProductVersionName) + .HasMaxLength(255) + .HasColumnName("product_version_name"); + + entity.HasOne(d => d.Customer).WithOne(p => p.DatabaseEngine) + .HasForeignKey(d => d.CustomerId) + .HasConstraintName("FK_1D94CC5C9395C3F3"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__database__3213E83FC619B4B0"); + + entity.ToTable("databases_info"); + + entity.HasIndex(e => e.DatabaseEngineId, "IDX_99DAF4F8AB25983"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.DatabaseEngineId).HasColumnName("database_engine_id"); + entity.Property(e => e.LogicalName) + .HasMaxLength(255) + .HasColumnName("logical_name"); + entity.Property(e => e.MaxSizeMb).HasColumnName("max_size_mb"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.SizeMb).HasColumnName("size_mb"); + + entity.HasOne(d => d.DatabaseEngine).WithMany(p => p.DatabasesInfos) + .HasForeignKey(d => d.DatabaseEngineId) + .HasConstraintName("FK_99DAF4F8AB25983"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__devices__3213E83F185C7B65"); + + entity.ToTable("devices"); + + entity.HasIndex(e => e.CustomerId, "IDX_11074E9A9395C3F3"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.CustomerId).HasColumnName("customer_id"); + entity.Property(e => e.Info) + .IsUnicode(false) + .HasComment("(DC2Type:simple_array)") + .HasColumnName("info"); + entity.Property(e => e.Ip) + .HasMaxLength(255) + .HasColumnName("ip"); + entity.Property(e => e.Port).HasColumnName("port"); + + entity.HasOne(d => d.Customer).WithMany(p => p.Devices) + .HasForeignKey(d => d.CustomerId) + .HasConstraintName("FK_11074E9A9395C3F3"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__installa__3213E83F11ECD973"); + + entity.ToTable("installations"); + + entity.HasIndex(e => e.ServerId, "IDX_A774F67B1844E6B7"); + + entity.HasIndex(e => e.DeviceId, "IDX_A774F67B94A4C7D4"); + + entity.HasIndex(e => e.ReleaseId, "IDX_A774F67BB12A727D"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.DeviceId).HasColumnName("device_id"); + entity.Property(e => e.InstallDate) + .HasPrecision(6) + .HasColumnName("install_date"); + entity.Property(e => e.LastUpdate) + .HasPrecision(6) + .HasColumnName("last_update"); + entity.Property(e => e.Notes) + .HasMaxLength(255) + .HasColumnName("notes"); + entity.Property(e => e.Options) + .IsUnicode(false) + .HasComment("(DC2Type:simple_array)") + .HasColumnName("options"); + entity.Property(e => e.ReleaseId).HasColumnName("release_id"); + entity.Property(e => e.ServerId).HasColumnName("server_id"); + + entity.HasOne(d => d.Device).WithMany(p => p.Installations) + .HasForeignKey(d => d.DeviceId) + .HasConstraintName("FK_A774F67B94A4C7D4"); + + entity.HasOne(d => d.Release).WithMany(p => p.Installations) + .HasForeignKey(d => d.ReleaseId) + .HasConstraintName("FK_A774F67BB12A727D"); + + entity.HasOne(d => d.Server).WithMany(p => p.Installations) + .HasForeignKey(d => d.ServerId) + .HasConstraintName("FK_A774F67B1844E6B7"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__pvms_inf__3213E83F8EA1FE36"); + + entity.ToTable("pvms_info"); + + entity.HasIndex(e => e.CustomerId, "IDX_4BCCAB779395C3F3"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.CustomerId).HasColumnName("customer_id"); + entity.Property(e => e.DefaultCharset) + .HasMaxLength(255) + .HasColumnName("default_charset"); + entity.Property(e => e.Imagick) + .HasMaxLength(255) + .HasColumnName("imagick"); + entity.Property(e => e.MagicQuotesGpc).HasColumnName("magic_quotes_gpc"); + entity.Property(e => e.MaxExecutionTime).HasColumnName("max_execution_time"); + entity.Property(e => e.MaxInputVars).HasColumnName("max_input_vars"); + entity.Property(e => e.MemoryLimit) + .HasMaxLength(255) + .HasColumnName("memory_limit"); + entity.Property(e => e.PhpVersion) + .HasMaxLength(255) + .HasColumnName("php_version"); + entity.Property(e => e.PostMaxSize) + .HasMaxLength(255) + .HasColumnName("post_max_size"); + entity.Property(e => e.SodiumMissing).HasColumnName("sodium_missing"); + entity.Property(e => e.Timezone) + .HasMaxLength(255) + .HasColumnName("timezone"); + entity.Property(e => e.UploadMaxSize) + .HasMaxLength(255) + .HasColumnName("upload_max_size"); + + entity.HasOne(d => d.Customer).WithMany(p => p.PvmsInfos) + .HasForeignKey(d => d.CustomerId) + .HasConstraintName("FK_4BCCAB779395C3F3"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__releases__3213E83F59E90B83"); + + entity.ToTable("releases"); + + entity.HasIndex(e => e.ServiceId, "IDX_7896E4D1ED5CA9E6"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Changelog) + .IsUnicode(false) + .HasColumnName("changelog"); + entity.Property(e => e.ReleaseDate) + .HasPrecision(6) + .HasColumnName("release_date"); + entity.Property(e => e.ServiceId).HasColumnName("service_id"); + entity.Property(e => e.Version) + .HasMaxLength(255) + .HasColumnName("version"); + + entity.HasOne(d => d.Service).WithMany(p => p.Releases) + .HasForeignKey(d => d.ServiceId) + .HasConstraintName("FK_7896E4D1ED5CA9E6"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__salvatag__3213E83F51C2D8BF"); + + entity.ToTable("salvataggi_soap"); + + entity.HasIndex(e => e.ApplicationInfoId, "IDX_BC9B16D5B635C4CB"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.ApplicationInfoId).HasColumnName("application_info_id"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + + entity.HasOne(d => d.ApplicationInfo).WithMany(p => p.SalvataggiSoaps) + .HasForeignKey(d => d.ApplicationInfoId) + .HasConstraintName("FK_BC9B16D5B635C4CB"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__servers__3213E83F0E4B2C74"); + + entity.ToTable("servers"); + + entity.HasIndex(e => e.CustomerId, "IDX_4F8AF5F79395C3F3"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.CreatedAt) + .HasPrecision(6) + .HasColumnName("created_at"); + entity.Property(e => e.CustomerId).HasColumnName("customer_id"); + entity.Property(e => e.Info) + .IsUnicode(false) + .HasComment("(DC2Type:simple_array)") + .HasColumnName("info"); + entity.Property(e => e.Ip) + .HasMaxLength(255) + .HasColumnName("ip"); + entity.Property(e => e.JavaVersion) + .HasMaxLength(255) + .HasColumnName("java_version"); + entity.Property(e => e.LastUpdate) + .HasPrecision(6) + .HasColumnName("last_update"); + entity.Property(e => e.MaxPermSize) + .HasMaxLength(255) + .HasColumnName("max_perm_size"); + entity.Property(e => e.OsArch) + .HasMaxLength(255) + .HasColumnName("os_arch"); + entity.Property(e => e.OsName) + .HasMaxLength(255) + .HasColumnName("os_name"); + entity.Property(e => e.Port).HasColumnName("port"); + entity.Property(e => e.RemoteAddr) + .HasMaxLength(255) + .HasColumnName("remote_addr"); + entity.Property(e => e.UpdatedAt) + .HasPrecision(6) + .HasColumnName("updated_at"); + entity.Property(e => e.Xms) + .HasMaxLength(255) + .HasColumnName("xms"); + entity.Property(e => e.Xmx) + .HasMaxLength(255) + .HasColumnName("xmx"); + + entity.HasOne(d => d.Customer).WithMany(p => p.Servers) + .HasForeignKey(d => d.CustomerId) + .HasConstraintName("FK_4F8AF5F79395C3F3"); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id).HasName("PK__services__3213E83FB43C1FE2"); + + entity.ToTable("services"); + + entity.HasIndex(e => e.Slug, "UNIQ_7332E169989D9B62") + .IsUnique() + .HasFilter("([slug] IS NOT NULL)"); + + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Description) + .IsUnicode(false) + .HasColumnName("description"); + entity.Property(e => e.InsertDate) + .HasPrecision(6) + .HasColumnName("insert_date"); + entity.Property(e => e.Language) + .HasMaxLength(255) + .HasColumnName("language"); + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("name"); + entity.Property(e => e.Slug) + .HasMaxLength(191) + .HasColumnName("slug"); + }); + + modelBuilder.Entity(entity => + { + entity + .HasNoKey() + .ToView("vw_customer_server_info"); + + entity.Property(e => e.JavaVersion) + .HasMaxLength(255) + .HasColumnName("java_version"); + entity.Property(e => e.Name) + .HasMaxLength(298) + .HasColumnName("name"); + entity.Property(e => e.OsArch) + .HasMaxLength(255) + .HasColumnName("os_arch"); + entity.Property(e => e.OsName) + .HasMaxLength(255) + .HasColumnName("os_name"); + entity.Property(e => e.PartitaIva) + .HasMaxLength(255) + .HasColumnName("partita_iva"); + entity.Property(e => e.RagSoc) + .HasMaxLength(40) + .IsUnicode(false) + .HasColumnName("rag_soc"); + entity.Property(e => e.RemoteAddr) + .HasMaxLength(255) + .HasColumnName("remote_addr"); + entity.Property(e => e.SimpleName) + .HasMaxLength(255) + .HasColumnName("simple_name"); + entity.Property(e => e.UpdatedAt) + .HasPrecision(6) + .HasColumnName("updated_at"); + }); + + modelBuilder.Entity(entity => + { + entity + .HasNoKey() + .ToView("vw_server_last_update"); + + entity.Property(e => e.CreatedAt) + .HasPrecision(6) + .HasColumnName("created_at"); + entity.Property(e => e.CustomerId).HasColumnName("customer_id"); + entity.Property(e => e.Id).HasColumnName("id"); + entity.Property(e => e.Info) + .IsUnicode(false) + .HasColumnName("info"); + entity.Property(e => e.Ip) + .HasMaxLength(255) + .HasColumnName("ip"); + entity.Property(e => e.JavaVersion) + .HasMaxLength(255) + .HasColumnName("java_version"); + entity.Property(e => e.LastUpdate) + .HasPrecision(6) + .HasColumnName("last_update"); + entity.Property(e => e.MaxPermSize) + .HasMaxLength(255) + .HasColumnName("max_perm_size"); + entity.Property(e => e.OsArch) + .HasMaxLength(255) + .HasColumnName("os_arch"); + entity.Property(e => e.OsName) + .HasMaxLength(255) + .HasColumnName("os_name"); + entity.Property(e => e.Port).HasColumnName("port"); + entity.Property(e => e.RemoteAddr) + .HasMaxLength(255) + .HasColumnName("remote_addr"); + entity.Property(e => e.UpdatedAt) + .HasPrecision(6) + .HasColumnName("updated_at"); + entity.Property(e => e.Xms) + .HasMaxLength(255) + .HasColumnName("xms"); + entity.Property(e => e.Xmx) + .HasMaxLength(255) + .HasColumnName("xmx"); + }); + + modelBuilder.Entity(entity => + { + entity + .HasNoKey() + .ToSqlQuery(@" + SELECT + c.id, + c.name, + c.slug, + c.active, + c.partita_iva, + COALESCE(va.name, c.name) AS display_name + FROM customers c + LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug + "); + + entity + .Property(e => e.Id) + .HasColumnName("id"); + + entity + .Property(e => e.Name) + .HasColumnName("name"); + + entity + .Property(e => e.Active) + .HasColumnName("active"); + + entity + .Property(e => e.Slug) + .HasColumnName("slug"); + + entity + .Property(e => e.PartitaIva) + .HasColumnName("partita_iva"); + + entity + .Property(e => e.DisplayName) + .HasColumnName("display_name"); + }); + + OnModelCreatingPartial(modelBuilder); + } + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); +} \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.Designer.cs b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.Designer.cs new file mode 100644 index 0000000..d9c7d75 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.Designer.cs @@ -0,0 +1,980 @@ +// +using System; +using IntegryControlPanel.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IntegryControlPanel.Migrations.IntegryControlPanelDb +{ + [DbContext(typeof(IntegryControlPanelDbContext))] + [Migration("20250925162221_AddCustomerAnagInfoView")] + partial class AddCustomerAnagInfoView + { + /// + 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("IntegryControlPanel.Models.IntegryControlPanel.ApplicationInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AnnoContab") + .HasColumnType("int") + .HasColumnName("anno_contab"); + + b.Property("AnnoMagaz") + .HasColumnType("int") + .HasColumnName("anno_magaz"); + + b.Property("AnsiPadding") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasColumnName("ansi_padding") + .HasDefaultValueSql("('0')"); + + b.Property("ConcatNullYieldsNull") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasColumnName("concat_null_yields_null") + .HasDefaultValueSql("('0')"); + + b.Property("CustomerId") + .HasColumnType("int") + .HasColumnName("customer_id"); + + b.Property("DelimitedIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasColumnName("delimited_identifier") + .HasDefaultValueSql("('0')"); + + b.Property("MenuPersonalizzato") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("menu_personalizzato"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("name"); + + b.Property("NewUpdProgMaga") + .HasColumnType("bit") + .HasColumnName("new_upd_prog_maga"); + + b.HasKey("Id") + .HasName("PK__applicat__3213E83F4185DE9F"); + + b.HasIndex(new[] { "CustomerId" }, "IDX_D5E65179395C3F3"); + + b.ToTable("application_infos", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeviceId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("device_id"); + + b.Property("InsertDate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("insert_date"); + + b.Property("LastUpdate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("last_update"); + + b.Property("NomeAzienda") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("nome_azienda"); + + b.Property("RemoteAddr") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("remote_addr"); + + b.HasKey("Id") + .HasName("PK__clients__3213E83FFF8DC3E2"); + + b.ToTable("clients", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Configurazioni", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("JavaVersion") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("java_version"); + + b.Property("LastUpdate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("last_update"); + + b.Property("MaxPermSize") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("max_perm_size"); + + b.Property("NomeAzienda") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("nome_azienda"); + + b.Property("OsArch") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_arch"); + + b.Property("OsName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_name"); + + b.Property("RemoteAddr") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("remote_addr"); + + b.Property("Xms") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("xms"); + + b.Property("Xmx") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("xmx"); + + b.HasKey("Id") + .HasName("PK__configur__3213E83FB9077FED"); + + b.ToTable("configurazioni", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Active") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasColumnName("active") + .HasDefaultValueSql("('0')"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("name"); + + b.Property("PartitaIva") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("partita_iva"); + + b.Property("Slug") + .IsRequired() + .HasMaxLength(191) + .HasColumnType("nvarchar(191)") + .HasColumnName("slug"); + + b.HasKey("Id") + .HasName("PK__customer__3213E83FD00417AC"); + + b.HasIndex(new[] { "Slug" }, "UNIQ_62534E21989D9B62") + .IsUnique() + .HasFilter("([slug] IS NOT NULL)"); + + b.ToTable("customers", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.CustomerWithAnagInfo", b => + { + b.ToTable((string)null); + + b.ToSqlQuery("\r\n SELECT \r\n c.id,\r\n c.name,\r\n c.slug,\r\n c.active,\r\n c.partita_iva,\r\n COALESCE(va.name, c.name) AS display_name\r\n FROM customers c\r\n LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug\r\n "); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.DatabaseEngine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("int") + .HasColumnName("customer_id"); + + b.Property("ProductEdition") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("product_edition"); + + b.Property("ProductLevel") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("product_level"); + + b.Property("ProductVersion") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("product_version"); + + b.Property("ProductVersionName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("product_version_name"); + + b.HasKey("Id") + .HasName("PK__database__3213E83F8526E221"); + + b.HasIndex(new[] { "CustomerId" }, "UNIQ_1D94CC5C9395C3F3") + .IsUnique() + .HasFilter("([customer_id] IS NOT NULL)"); + + b.ToTable("database_engines", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.DatabasesInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DatabaseEngineId") + .HasColumnType("int") + .HasColumnName("database_engine_id"); + + b.Property("LogicalName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("logical_name"); + + b.Property("MaxSizeMb") + .HasColumnType("int") + .HasColumnName("max_size_mb"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("name"); + + b.Property("SizeMb") + .HasColumnType("int") + .HasColumnName("size_mb"); + + b.HasKey("Id") + .HasName("PK__database__3213E83FC619B4B0"); + + b.HasIndex(new[] { "DatabaseEngineId" }, "IDX_99DAF4F8AB25983"); + + b.ToTable("databases_info", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("int") + .HasColumnName("customer_id"); + + b.Property("Info") + .IsRequired() + .IsUnicode(false) + .HasColumnType("varchar(max)") + .HasColumnName("info") + .HasComment("(DC2Type:simple_array)"); + + b.Property("Ip") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("ip"); + + b.Property("Port") + .HasColumnType("int") + .HasColumnName("port"); + + b.HasKey("Id") + .HasName("PK__devices__3213E83F185C7B65"); + + b.HasIndex(new[] { "CustomerId" }, "IDX_11074E9A9395C3F3"); + + b.ToTable("devices", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Installation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DeviceId") + .HasColumnType("int") + .HasColumnName("device_id"); + + b.Property("InstallDate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("install_date"); + + b.Property("LastUpdate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("last_update"); + + b.Property("Notes") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("notes"); + + b.Property("Options") + .IsRequired() + .IsUnicode(false) + .HasColumnType("varchar(max)") + .HasColumnName("options") + .HasComment("(DC2Type:simple_array)"); + + b.Property("ReleaseId") + .HasColumnType("int") + .HasColumnName("release_id"); + + b.Property("ServerId") + .HasColumnType("int") + .HasColumnName("server_id"); + + b.HasKey("Id") + .HasName("PK__installa__3213E83F11ECD973"); + + b.HasIndex(new[] { "ServerId" }, "IDX_A774F67B1844E6B7"); + + b.HasIndex(new[] { "DeviceId" }, "IDX_A774F67B94A4C7D4"); + + b.HasIndex(new[] { "ReleaseId" }, "IDX_A774F67BB12A727D"); + + b.ToTable("installations", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.PvmsInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CustomerId") + .HasColumnType("int") + .HasColumnName("customer_id"); + + b.Property("DefaultCharset") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("default_charset"); + + b.Property("Imagick") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("imagick"); + + b.Property("MagicQuotesGpc") + .HasColumnType("bit") + .HasColumnName("magic_quotes_gpc"); + + b.Property("MaxExecutionTime") + .HasColumnType("int") + .HasColumnName("max_execution_time"); + + b.Property("MaxInputVars") + .HasColumnType("int") + .HasColumnName("max_input_vars"); + + b.Property("MemoryLimit") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("memory_limit"); + + b.Property("PhpVersion") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("php_version"); + + b.Property("PostMaxSize") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("post_max_size"); + + b.Property("SodiumMissing") + .HasColumnType("bit") + .HasColumnName("sodium_missing"); + + b.Property("Timezone") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("timezone"); + + b.Property("UploadMaxSize") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("upload_max_size"); + + b.HasKey("Id") + .HasName("PK__pvms_inf__3213E83F8EA1FE36"); + + b.HasIndex(new[] { "CustomerId" }, "IDX_4BCCAB779395C3F3"); + + b.ToTable("pvms_info", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Release", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Changelog") + .IsUnicode(false) + .HasColumnType("varchar(max)") + .HasColumnName("changelog"); + + b.Property("ReleaseDate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("release_date"); + + b.Property("ServiceId") + .HasColumnType("int") + .HasColumnName("service_id"); + + b.Property("Version") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("version"); + + b.HasKey("Id") + .HasName("PK__releases__3213E83F59E90B83"); + + b.HasIndex(new[] { "ServiceId" }, "IDX_7896E4D1ED5CA9E6"); + + b.ToTable("releases", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.SalvataggiSoap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApplicationInfoId") + .HasColumnType("int") + .HasColumnName("application_info_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("PK__salvatag__3213E83F51C2D8BF"); + + b.HasIndex(new[] { "ApplicationInfoId" }, "IDX_BC9B16D5B635C4CB"); + + b.ToTable("salvataggi_soap", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Server", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("created_at"); + + b.Property("CustomerId") + .HasColumnType("int") + .HasColumnName("customer_id"); + + b.Property("Info") + .IsUnicode(false) + .HasColumnType("varchar(max)") + .HasColumnName("info") + .HasComment("(DC2Type:simple_array)"); + + b.Property("Ip") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("ip"); + + b.Property("JavaVersion") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("java_version"); + + b.Property("LastUpdate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("last_update"); + + b.Property("MaxPermSize") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("max_perm_size"); + + b.Property("OsArch") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_arch"); + + b.Property("OsName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_name"); + + b.Property("Port") + .HasColumnType("int") + .HasColumnName("port"); + + b.Property("RemoteAddr") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("remote_addr"); + + b.Property("UpdatedAt") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("updated_at"); + + b.Property("Xms") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("xms"); + + b.Property("Xmx") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("xmx"); + + b.HasKey("Id") + .HasName("PK__servers__3213E83F0E4B2C74"); + + b.HasIndex(new[] { "CustomerId" }, "IDX_4F8AF5F79395C3F3"); + + b.ToTable("servers", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int") + .HasColumnName("id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Description") + .IsUnicode(false) + .HasColumnType("varchar(max)") + .HasColumnName("description"); + + b.Property("InsertDate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("insert_date"); + + b.Property("Language") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("language"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("name"); + + b.Property("Slug") + .IsRequired() + .HasMaxLength(191) + .HasColumnType("nvarchar(191)") + .HasColumnName("slug"); + + b.HasKey("Id") + .HasName("PK__services__3213E83FB43C1FE2"); + + b.HasIndex(new[] { "Slug" }, "UNIQ_7332E169989D9B62") + .IsUnique() + .HasFilter("([slug] IS NOT NULL)"); + + b.ToTable("services", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.VwCustomerServerInfo", b => + { + b.Property("JavaVersion") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("java_version"); + + b.Property("Name") + .HasMaxLength(298) + .HasColumnType("nvarchar(298)") + .HasColumnName("name"); + + b.Property("OsArch") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_arch"); + + b.Property("OsName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_name"); + + b.Property("PartitaIva") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("partita_iva"); + + b.Property("RagSoc") + .HasMaxLength(40) + .IsUnicode(false) + .HasColumnType("varchar(40)") + .HasColumnName("rag_soc"); + + b.Property("RemoteAddr") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("remote_addr"); + + b.Property("SimpleName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("simple_name"); + + b.Property("UpdatedAt") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("updated_at"); + + b.ToTable((string)null); + + b.ToView("vw_customer_server_info", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.VwServerLastUpdate", b => + { + b.Property("CreatedAt") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("created_at"); + + b.Property("CustomerId") + .HasColumnType("int") + .HasColumnName("customer_id"); + + b.Property("Id") + .HasColumnType("int") + .HasColumnName("id"); + + b.Property("Info") + .IsUnicode(false) + .HasColumnType("varchar(max)") + .HasColumnName("info"); + + b.Property("Ip") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("ip"); + + b.Property("JavaVersion") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("java_version"); + + b.Property("LastUpdate") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("last_update"); + + b.Property("MaxPermSize") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("max_perm_size"); + + b.Property("OsArch") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_arch"); + + b.Property("OsName") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("os_name"); + + b.Property("Port") + .HasColumnType("int") + .HasColumnName("port"); + + b.Property("RemoteAddr") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("remote_addr"); + + b.Property("UpdatedAt") + .HasPrecision(6) + .HasColumnType("datetime2(6)") + .HasColumnName("updated_at"); + + b.Property("Xms") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("xms"); + + b.Property("Xmx") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("xmx"); + + b.ToTable((string)null); + + b.ToView("vw_server_last_update", (string)null); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.ApplicationInfo", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Customer", "Customer") + .WithMany("ApplicationInfos") + .HasForeignKey("CustomerId") + .HasConstraintName("FK_D5E65179395C3F3"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.DatabaseEngine", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Customer", "Customer") + .WithOne("DatabaseEngine") + .HasForeignKey("IntegryControlPanel.Models.IntegryControlPanel.DatabaseEngine", "CustomerId") + .HasConstraintName("FK_1D94CC5C9395C3F3"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.DatabasesInfo", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.DatabaseEngine", "DatabaseEngine") + .WithMany("DatabasesInfos") + .HasForeignKey("DatabaseEngineId") + .HasConstraintName("FK_99DAF4F8AB25983"); + + b.Navigation("DatabaseEngine"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Device", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Customer", "Customer") + .WithMany("Devices") + .HasForeignKey("CustomerId") + .HasConstraintName("FK_11074E9A9395C3F3"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Installation", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Device", "Device") + .WithMany("Installations") + .HasForeignKey("DeviceId") + .HasConstraintName("FK_A774F67B94A4C7D4"); + + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Release", "Release") + .WithMany("Installations") + .HasForeignKey("ReleaseId") + .HasConstraintName("FK_A774F67BB12A727D"); + + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Server", "Server") + .WithMany("Installations") + .HasForeignKey("ServerId") + .HasConstraintName("FK_A774F67B1844E6B7"); + + b.Navigation("Device"); + + b.Navigation("Release"); + + b.Navigation("Server"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.PvmsInfo", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Customer", "Customer") + .WithMany("PvmsInfos") + .HasForeignKey("CustomerId") + .HasConstraintName("FK_4BCCAB779395C3F3"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Release", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Service", "Service") + .WithMany("Releases") + .HasForeignKey("ServiceId") + .HasConstraintName("FK_7896E4D1ED5CA9E6"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.SalvataggiSoap", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.ApplicationInfo", "ApplicationInfo") + .WithMany("SalvataggiSoaps") + .HasForeignKey("ApplicationInfoId") + .HasConstraintName("FK_BC9B16D5B635C4CB"); + + b.Navigation("ApplicationInfo"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Server", b => + { + b.HasOne("IntegryControlPanel.Models.IntegryControlPanel.Customer", "Customer") + .WithMany("Servers") + .HasForeignKey("CustomerId") + .HasConstraintName("FK_4F8AF5F79395C3F3"); + + b.Navigation("Customer"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.ApplicationInfo", b => + { + b.Navigation("SalvataggiSoaps"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Customer", b => + { + b.Navigation("ApplicationInfos"); + + b.Navigation("DatabaseEngine"); + + b.Navigation("Devices"); + + b.Navigation("PvmsInfos"); + + b.Navigation("Servers"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.DatabaseEngine", b => + { + b.Navigation("DatabasesInfos"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Device", b => + { + b.Navigation("Installations"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Release", b => + { + b.Navigation("Installations"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Server", b => + { + b.Navigation("Installations"); + }); + + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.Service", b => + { + b.Navigation("Releases"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.cs b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.cs new file mode 100644 index 0000000..38e8b96 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925162221_AddCustomerAnagInfoView.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IntegryControlPanel.Migrations.IntegryControlPanelDb +{ + /// + public partial class AddCustomerAnagInfoView : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@"CREATE VIEW vw_customer_anag_info AS +SELECT + slug, + ISNULL(rag_soc, customers.name) + + IIF(COUNT(partita_iva) OVER (partition by partita_iva) > 1, + CONCAT(' (', customers.name, ')'), + '' + ) AS name +FROM customers +LEFT OUTER JOIN ( + SELECT DISTINCT part_iva, rag_soc + FROM studioml.dbo.gtb_anag + INNER JOIN studioml.dbo.vtb_clie ON vtb_clie.cod_anag = gtb_anag.cod_anag + WHERE flag_stato = 'A' +) gtb_anag ON customers.partita_iva = gtb_anag.part_iva"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DROP VIEW vw_customer_anag_info"); + } + } +} diff --git a/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs index 97ed373..cc3cdd1 100644 --- a/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs +++ b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs @@ -229,6 +229,13 @@ namespace IntegryControlPanel.Migrations.IntegryControlPanelDb b.ToTable("customers", (string)null); }); + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.CustomerWithAnagInfo", b => + { + b.ToTable((string)null); + + b.ToSqlQuery("\r\n SELECT \r\n c.id,\r\n c.name,\r\n c.slug,\r\n c.active,\r\n c.partita_iva,\r\n COALESCE(va.name, c.name) AS display_name\r\n FROM customers c\r\n LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug\r\n "); + }); + modelBuilder.Entity("IntegryControlPanel.Models.IntegryControlPanel.DatabaseEngine", b => { b.Property("Id") diff --git a/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/CustomerWithAnagInfo.cs b/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/CustomerWithAnagInfo.cs new file mode 100644 index 0000000..34f7c18 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/CustomerWithAnagInfo.cs @@ -0,0 +1,17 @@ +namespace IntegryControlPanel.Models.IntegryControlPanel; + +public partial class CustomerWithAnagInfo +{ + + public int Id { get; set; } + + public string Name { get; set; } = null!; + + public string Slug { get; set; } = null!; + + public bool? Active { get; set; } + + public string? PartitaIva { get; set; } + + public string? DisplayName { get; set; } +} \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/VwCustomerAnagInfo.cs b/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/VwCustomerAnagInfo.cs new file mode 100644 index 0000000..cdcf814 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/VwCustomerAnagInfo.cs @@ -0,0 +1,9 @@ +namespace IntegryControlPanel.Models.IntegryControlPanel; + +public partial class VwCustomerAnagInfo +{ + + public string Name { get; set; } = null!; + + public string Slug { get; set; } = null!; +} \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs b/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs index 1fbf6ef..6687aa0 100644 --- a/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs +++ b/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs @@ -53,15 +53,11 @@ namespace IntegryControlPanel.Services Task GetTotalDevicesAsync(); Task GetTotalInstallationsAsync(); - // Customer Server Info View operations - //Task> GetCustomerServerInfoAsync(); - //Task> GetCustomerServerInfoBySlugAsync(string slug); - - //// CustomerWithAnagInfo operations - //Task> GetCustomersWithAnagInfoAsync(); - //Task GetCustomerWithAnagInfoByIdAsync(int id); - //Task GetCustomerWithAnagInfoBySlugAsync(string slug); - //Task> GetActiveCustomersWithAnagInfoAsync(); - //Task> SearchCustomersWithAnagInfoAsync(string searchTerm); + // CustomerWithAnagInfo operations + Task> GetCustomersWithAnagInfoAsync(); + Task GetCustomerWithAnagInfoByIdAsync(int id); + Task GetCustomerWithAnagInfoBySlugAsync(string slug); + Task> GetActiveCustomersWithAnagInfoAsync(); + Task> SearchCustomersWithAnagInfoAsync(string searchTerm); } } \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs b/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs index eceb2fa..2b37981 100644 --- a/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs +++ b/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs @@ -581,144 +581,131 @@ namespace IntegryControlPanel.Services #endregion - //#region CustomerWithAnagInfo Operations + #region CustomerWithAnagInfo Operations - //public async Task> GetCustomersWithAnagInfoAsync() - //{ - // try - // { - // var query = @" - // SELECT - // c.id, - // c.name, - // c.slug, - // c.active, - // c.partita_iva, - // COALESCE(va.name, c.name) AS display_name - // FROM customers c - // LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug - // ORDER BY COALESCE(va.name, c.name), c.name - // "; + public async Task> GetCustomersWithAnagInfoAsync() + { + try + { + return await _context.CustomerWithAnagInfos.ToListAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving customers with anag info"); + throw; + } + } - // return await _context.Database.SqlQueryRaw(query).ToListAsync(); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving customers with anag info"); - // throw; - // } - //} + public async Task GetCustomerWithAnagInfoByIdAsync(int id) + { + try + { + var query = @" + SELECT + c.id, + c.name, + c.slug, + c.active, + c.partita_iva, + COALESCE(va.name, c.name) AS display_name + FROM customers c + LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug + WHERE c.id = {0} + "; - //public async Task GetCustomerWithAnagInfoByIdAsync(int id) - //{ - // try - // { - // var query = @" - // SELECT - // c.id, - // c.name, - // c.slug, - // c.active, - // c.partita_iva, - // COALESCE(va.name, c.name) AS display_name - // FROM customers c - // LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug - // WHERE c.id = {0} - // "; + return await _context.Database.SqlQueryRaw(query, id).FirstOrDefaultAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving customer with anag info by id {CustomerId}", id); + throw; + } + } - // return await _context.Database.SqlQueryRaw(query, id).FirstOrDefaultAsync(); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving customer with anag info by id {CustomerId}", id); - // throw; - // } - //} + public async Task GetCustomerWithAnagInfoBySlugAsync(string slug) + { + try + { + var query = @" + SELECT + c.id, + c.name, + c.slug, + c.active, + c.partita_iva, + COALESCE(va.name, c.name) AS display_name + FROM customers c + LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug + WHERE c.slug = {0} + "; - //public async Task GetCustomerWithAnagInfoBySlugAsync(string slug) - //{ - // try - // { - // var query = @" - // SELECT - // c.id, - // c.name, - // c.slug, - // c.active, - // c.partita_iva, - // COALESCE(va.name, c.name) AS display_name - // FROM customers c - // LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug - // WHERE c.slug = {0} - // "; + return await _context.Database.SqlQueryRaw(query, slug).FirstOrDefaultAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving customer with anag info by slug {Slug}", slug); + throw; + } + } - // return await _context.Database.SqlQueryRaw(query, slug).FirstOrDefaultAsync(); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving customer with anag info by slug {Slug}", slug); - // throw; - // } - //} + public async Task> GetActiveCustomersWithAnagInfoAsync() + { + try + { + var query = @" + SELECT + c.id, + c.name, + c.slug, + c.active, + c.partita_iva, + COALESCE(va.name, c.name) AS display_name + FROM customers c + LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug + WHERE c.active = 1 + ORDER BY COALESCE(va.name, c.name), c.name + "; - //public async Task> GetActiveCustomersWithAnagInfoAsync() - //{ - // try - // { - // var query = @" - // SELECT - // c.id, - // c.name, - // c.slug, - // c.active, - // c.partita_iva, - // COALESCE(va.name, c.name) AS display_name - // FROM customers c - // LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug - // WHERE c.active = 1 - // ORDER BY COALESCE(va.name, c.name), c.name - // "; + return await _context.Database.SqlQueryRaw(query).ToListAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error retrieving active customers with anag info"); + throw; + } + } - // return await _context.Database.SqlQueryRaw(query).ToListAsync(); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error retrieving active customers with anag info"); - // throw; - // } - //} + public async Task> SearchCustomersWithAnagInfoAsync(string searchTerm) + { + try + { + var query = @" + SELECT + c.id, + c.name, + c.slug, + c.active, + c.partita_iva, + COALESCE(va.name, c.name) AS display_name + FROM customers c + LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug + WHERE COALESCE(va.name, c.name) LIKE {0} + OR c.name LIKE {0} + OR c.slug LIKE {0} + OR c.partita_iva LIKE {0} + ORDER BY COALESCE(va.name, c.name), c.name + "; - //public async Task> SearchCustomersWithAnagInfoAsync(string searchTerm) - //{ - // try - // { - // var query = @" - // SELECT - // c.id, - // c.name, - // c.slug, - // c.active, - // c.partita_iva, - // COALESCE(va.name, c.name) AS display_name - // FROM customers c - // LEFT JOIN vw_customer_anag_info va ON c.slug = va.slug - // WHERE COALESCE(va.name, c.name) LIKE {0} - // OR c.name LIKE {0} - // OR c.slug LIKE {0} - // OR c.partita_iva LIKE {0} - // ORDER BY COALESCE(va.name, c.name), c.name - // "; + var searchPattern = $"%{searchTerm}%"; + return await _context.Database.SqlQueryRaw(query, searchPattern).ToListAsync(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error searching customers with anag info for term {SearchTerm}", searchTerm); + throw; + } + } - // var searchPattern = $"%{searchTerm}%"; - // return await _context.Database.SqlQueryRaw(query, searchPattern).ToListAsync(); - // } - // catch (Exception ex) - // { - // _logger.LogError(ex, "Error searching customers with anag info for term {SearchTerm}", searchTerm); - // throw; - // } - //} - - //#endregion + #endregion } } \ No newline at end of file