diff --git a/IntegryControlPanel.Client/Models/CustomerModels.cs b/IntegryControlPanel.Client/Models/CustomerModels.cs new file mode 100644 index 0000000..acb87e8 --- /dev/null +++ b/IntegryControlPanel.Client/Models/CustomerModels.cs @@ -0,0 +1,86 @@ +namespace IntegryControlPanel.Client.Models; + +public class Customer +{ + 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 List ApplicationInfos { get; set; } = new List(); + public List Devices { get; set; } = new List(); + public List PvmsInfos { get; set; } = new List(); + public List Servers { get; set; } = new List(); +} + +public class Server +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string? Ip { get; set; } + public int? Port { get; set; } + public string? Info { get; set; } + public string? JavaVersion { get; set; } + public string? OsArch { get; set; } + public string? OsName { get; set; } + public string? Xmx { get; set; } + public string? Xms { get; set; } + public string? MaxPermSize { get; set; } + public DateTime? LastUpdate { get; set; } + public string? RemoteAddr { get; set; } + public DateTime? CreatedAt { get; set; } + public DateTime? UpdatedAt { get; set; } +} + +public class Device +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string Ip { get; set; } = null!; + public int Port { get; set; } + public string Info { get; set; } = null!; +} + +public class ApplicationInfo +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string Name { get; set; } = null!; + public bool NewUpdProgMaga { get; set; } + public string? MenuPersonalizzato { get; set; } + public int? AnnoMagaz { get; set; } + public int? AnnoContab { get; set; } + public bool? AnsiPadding { get; set; } + public bool? DelimitedIdentifier { get; set; } + public bool? ConcatNullYieldsNull { get; set; } +} + +public class PvmsInfo +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string PhpVersion { get; set; } = null!; + public string Timezone { get; set; } = null!; + public string Imagick { get; set; } = null!; + public string MemoryLimit { get; set; } = null!; + public int MaxExecutionTime { get; set; } + public int MaxInputVars { get; set; } + public string PostMaxSize { get; set; } = null!; + public string UploadMaxSize { get; set; } = null!; + public string DefaultCharset { get; set; } = null!; + public bool MagicQuotesGpc { get; set; } + public bool SodiumMissing { get; set; } +} + +public class CustomerServerInfo +{ + public string Name { get; set; } = null!; + public string? PartitaIva { get; set; } + public string? OsName { get; set; } + public string? OsArch { get; set; } + public string? JavaVersion { get; set; } + public string? RemoteAddr { get; set; } + public DateTime? UpdatedAt { get; set; } + public string SimpleName { get; set; } = null!; + public string? RagSoc { get; set; } +} \ No newline at end of file diff --git a/IntegryControlPanel/CUSTOMER_WITH_ANAG_INFO.md b/IntegryControlPanel/CUSTOMER_WITH_ANAG_INFO.md new file mode 100644 index 0000000..6db4ae8 --- /dev/null +++ b/IntegryControlPanel/CUSTOMER_WITH_ANAG_INFO.md @@ -0,0 +1,163 @@ +# Customer with Anag Info - Documentazione + +## Panoramica + +Questa implementazione crea un'entit composta che combina i dati della tabella `customers` con le informazioni anagrafiche dalla vista `vw_customer_anag_info`, permettendo di ottenere un nome di visualizzazione che considera la ragione sociale dall'anagrafica esterna. + +## Componenti Implementati + +### 1. Vista Database: `vw_customer_anag_info` + +**Percorso:** `Migrations/IntegryControlPanelDb/20250924165009_AddCustomerServerInfoView.cs` + +La vista esegue una LEFT JOIN tra la tabella `customers` e l'anagrafica esterna `studioml.dbo.gtb_anag`, restituendo: +- `slug`: Chiave di join con la tabella customers +- `name`: Nome combinato che preferisce `rag_soc` se disponibile, altrimenti usa `customers.name` + +**Query SQL:** +```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 +``` + +### 2. Entit EF: `VwCustomerAnagInfo` + +**Percorso:** `Models/IntegryControlPanel/VwCustomerAnagInfo.cs` + +Mappatura Entity Framework della vista che restituisce solo `Slug` e `Name`. + +### 3. Entit Composta: `CustomerWithAnagInfo` + +**Percorso:** `Models/IntegryControlPanel/CustomerWithAnagInfo.cs` + +Entit che combina tutti i campi del Customer con il `DisplayName` dalla vista, creando un'unica entit per l'uso in query. + +**Propriet principali:** +- Tutti i campi di `Customer` (Id, Name, Slug, Active, PartitaIva) +- `DisplayName`: Nome da visualizzare che considera `rag_soc` +- Navigazioni verso entit correlate (ApplicationInfos, Servers, ecc.) + +### 4. Configurazione Entity Framework + +**Percorso:** `Data/IntegryControlPanelDbContext.cs` + +```csharp +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 + "); +}); +``` + +### 5. Servizi Business Logic + +**Percorso:** `Services/IntegryControlPanelService.cs` e `Services/IIntegryControlPanelService.cs` + +Metodi implementati: +- `GetCustomersWithAnagInfoAsync()`: Tutti i clienti con info anagrafiche +- `GetCustomerWithAnagInfoByIdAsync(int id)`: Cliente per ID +- `GetCustomerWithAnagInfoBySlugAsync(string slug)`: Cliente per slug +- `GetActiveCustomersWithAnagInfoAsync()`: Solo clienti attivi +- `SearchCustomersWithAnagInfoAsync(string searchTerm)`: Ricerca full-text + +### 6. API Controller + +**Percorso:** `Controllers/CustomerAnagInfoController.cs` + +Endpoints REST: +- `GET /api/CustomerAnagInfo` - Tutti i clienti +- `GET /api/CustomerAnagInfo/active` - Solo clienti attivi +- `GET /api/CustomerAnagInfo/{id}` - Cliente per ID +- `GET /api/CustomerAnagInfo/slug/{slug}` - Cliente per slug +- `GET /api/CustomerAnagInfo/search?term={term}` - Ricerca + +### 7. DTO per Blazor Client + +**Percorso:** `IntegryControlPanel.Client/Models/CustomerWithAnagInfoDto.cs` + +Include propriet aggiuntiva `HasExternalRagSoc` per determinare se il nome visualizzato proviene dall'anagrafica esterna. + +### 8. Pagina Blazor + +**Percorso:** `IntegryControlPanel.Client/Pages/CustomersWithAnag.razor` + +Interfaccia completa che include: +- Tabella responsiva con dati dei clienti +- Ricerca full-text +- Filtro per clienti attivi +- Indicatori visivi per distinguere nomi con ragione sociale esterna +- Gestione degli stati di caricamento ed errore + +## Utilizzo + +### Nel Service Layer +```csharp +// Ottieni tutti i clienti con nomi display +var customers = await _service.GetCustomersWithAnagInfoAsync(); + +// Cerca clienti +var searchResults = await _service.SearchCustomersWithAnagInfoAsync("termine di ricerca"); + +// Solo clienti attivi +var activeCustomers = await _service.GetActiveCustomersWithAnagInfoAsync(); +``` + +### Nelle API +```csharp +[HttpGet] +public async Task>> GetCustomersWithAnagInfo() +{ + var customers = await _service.GetCustomersWithAnagInfoAsync(); + return Ok(customers); +} +``` + +### In Blazor +```csharp +var customers = await Http.GetFromJsonAsync>("api/CustomerAnagInfo"); +``` + +## Vantaggi dell'Implementazione + +1. **Performance**: La vista database pre-calcola i nomi display +2. **Separazione dei Concern**: Logica di business nel servizio, presentazione nel controller +3. **Type Safety**: Entit strongly-typed per IntelliSense completo +4. **Flessibilit**: Multiple modalit di accesso (per ID, slug, ricerca) +5. **UI/UX**: Indicatori visivi per distinguere fonti dei nomi +6. **Scalabilit**: Query ottimizzate con indici appropriati + +## Note Tecniche + +- La vista gestisce automaticamente i duplicati per P.IVA +- L'entit composta non ha chiave primaria (HasNoKey) poich read-only +- Il DTO client include helper methods per logica di presentazione +- La ricerca include tutti i campi rilevanti (nome, display name, slug, P.IVA) + +## URL della Pagina Blazor + +Dopo aver implementato tutto, la pagina sar accessibile all'indirizzo: +`https://localhost:xxxx/customers-with-anag` \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel.Client/App.razor b/IntegryControlPanel/IntegryControlPanel.Client/App.razor new file mode 100644 index 0000000..b01eb82 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel.Client/App.razor @@ -0,0 +1,29 @@ +@using IntegryControlPanel.Client.Layout + + + + + + @if (context.User.Identity?.IsAuthenticated != true) + { + + } + else + { +
+

Non hai i permessi necessari per accedere a questa risorsa.

+
+ } +
+
+ +
+ + Not found + +
+

Pagina non trovata!

+
+
+
+
\ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel.Client/Layout/NavMenu.razor b/IntegryControlPanel/IntegryControlPanel.Client/Layout/NavMenu.razor index efa7e3a..f4b2fb1 100644 --- a/IntegryControlPanel/IntegryControlPanel.Client/Layout/NavMenu.razor +++ b/IntegryControlPanel/IntegryControlPanel.Client/Layout/NavMenu.razor @@ -8,9 +8,10 @@ Dashboard + Clienti Server - Client - Servizi + @* Client *@ + @* Servizi *@ ApplicationInfos { get; set; } = new List(); + public List Devices { get; set; } = new List(); + public List PvmsInfos { get; set; } = new List(); + public List Servers { get; set; } = new List(); +} + +public class Server +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string? Ip { get; set; } + public int? Port { get; set; } + public string? Info { get; set; } + public string? JavaVersion { get; set; } + public string? OsArch { get; set; } + public string? OsName { get; set; } + public string? Xmx { get; set; } + public string? Xms { get; set; } + public string? MaxPermSize { get; set; } + public DateTime? LastUpdate { get; set; } + public string? RemoteAddr { get; set; } + public DateTime? CreatedAt { get; set; } + public DateTime? UpdatedAt { get; set; } +} + +public class Device +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string Ip { get; set; } = null!; + public int Port { get; set; } + public string Info { get; set; } = null!; +} + +public class ApplicationInfo +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string Name { get; set; } = null!; + public bool NewUpdProgMaga { get; set; } + public string? MenuPersonalizzato { get; set; } + public int? AnnoMagaz { get; set; } + public int? AnnoContab { get; set; } + public bool? AnsiPadding { get; set; } + public bool? DelimitedIdentifier { get; set; } + public bool? ConcatNullYieldsNull { get; set; } +} + +public class PvmsInfo +{ + public int Id { get; set; } + public int? CustomerId { get; set; } + public string PhpVersion { get; set; } = null!; + public string Timezone { get; set; } = null!; + public string Imagick { get; set; } = null!; + public bool SodiumMissing { get; set; } + public int MaxExecutionTime { get; set; } + public bool MagicQuotesGpc { get; set; } + public string DefaultCharset { get; set; } = null!; + public string MemoryLimit { get; set; } = null!; + public string PostMaxSize { get; set; } = null!; + public string UploadMaxSize { get; set; } = null!; + public int MaxInputVars { get; set; } +} \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel.Client/Models/CustomerWithAnagInfoDto.cs b/IntegryControlPanel/IntegryControlPanel.Client/Models/CustomerWithAnagInfoDto.cs new file mode 100644 index 0000000..266b69e --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel.Client/Models/CustomerWithAnagInfoDto.cs @@ -0,0 +1,23 @@ +namespace IntegryControlPanel.Client.Models; + +/// +/// DTO per il client che rappresenta un Customer con le informazioni anagrafiche della vista vw_customer_anag_info +/// +public class CustomerWithAnagInfoDto +{ + 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; } + + /// + /// Nome da visualizzare che considera la ragione sociale dall'anagrafica esterna (rag_soc) + /// + public string DisplayName { get; set; } = null!; + + /// + /// Indica se il DisplayName diverso dal Name (ovvero se c' una ragione sociale dall'anagrafica esterna) + /// + public bool HasExternalRagSoc => !string.Equals(DisplayName?.Trim(), Name?.Trim(), StringComparison.OrdinalIgnoreCase); +} \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor b/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor new file mode 100644 index 0000000..1349c59 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel.Client/Pages/Customers.razor @@ -0,0 +1,367 @@ +@page "/customers" +@rendermode InteractiveWebAssembly +@using IntegryControlPanel.Client.Models +@using Microsoft.AspNetCore.Authorization +@using System.Net.Http.Json +@attribute [Authorize] + +@inject HttpClient Http +@inject ISnackbar Snackbar + +Gestione Clienti + + + + + Gestione Clienti + + + + + @if (isLoading) + { + + + + Caricamento clienti... + + + } + else if (customers?.Any() == true) + { + + + + + + @* #@context.Item.Id - @context.Item.Slug *@ + P. Iva: @context.Item.PartitaIva + + + @context.Item.Name + + + + + + @* + @(context.Item.Active == true ? "Attivo" : "Inattivo") + *@ + + @(context.Item.Active == true ? "Attivo" : "Inattivo") + + @* *@ + + + + + + Dettagli + + + + + + } + else + { + + Nessun cliente trovato. + + } + + + + + + + + + Dettagli Cliente: @selectedCustomer?.Name + + + + @if (selectedCustomer != null) + { + + + + + + + + + + + + + + + + + + + + + + + + + @if (isLoadingServers) + { + + Caricamento server... + } + else if (customerServers?.Any() == true) + { + + + + + + + + + + + } + else + { + Nessun server configurato per questo cliente. + } + + + + + @if (isLoadingDevices) + { + + Caricamento dispositivi... + } + else if (customerDevices?.Any() == true) + { + + + + + + + + + } + else + { + Nessun dispositivo configurato per questo cliente. + } + + + + + @if (selectedCustomer.ApplicationInfos?.Any() == true) + { + + + + + + + + + + @(context.Item.NewUpdProgMaga ? "Sì" : "No") + + + + + + } + else + { + Nessuna applicazione configurata per questo cliente. + } + + + + + @if (selectedCustomer.PvmsInfos?.Any() == true) + { + @foreach (var pvms in selectedCustomer.PvmsInfos) + { + + + + + + + + + + + + + + + + + + + + + + + + + } + } + else + { + Nessuna informazione PVMS disponibile per questo cliente. + } + + + } + + + + Chiudi + + + + + +@code { + private List? customers; + private long? selectedCustomerId; + private Customer? selectedCustomer; + private List? customerServers; + private List? customerDevices; + + private bool isLoading = true; + private bool isLoadingServers = false; + private bool isLoadingDevices = false; + private bool isDetailsDialogVisible = false; + + private DialogOptions dialogOptions = new() + { + MaxWidth = MaxWidth.ExtraLarge, + FullWidth = true, + CloseButton = true + }; + + protected override async Task OnInitializedAsync() + { + try + { + await LoadCustomers(); + } + catch (Exception ex) + { + Console.WriteLine($"❌ Customers page - OnInitializedAsync error: {ex.Message}"); + Console.WriteLine($"📋 Stack trace: {ex.StackTrace}"); + Snackbar.Add($"Errore nell'inizializzazione della pagina: {ex.Message}", Severity.Error); + } + } + + private async Task LoadCustomers() + { + try + { + isLoading = true; + StateHasChanged(); // Force UI update + + customers = await Http.GetFromJsonAsync>("api/CustomerAnagInfo/"); + } + catch (HttpRequestException httpEx) + { + Console.WriteLine($"🌐 LoadCustomers - HTTP error: {httpEx.Message}"); + Snackbar.Add($"Errore di connessione: {httpEx.Message}", Severity.Error); + } + catch (Exception ex) + { + Console.WriteLine($"❌ LoadCustomers - Generic error: {ex.Message}"); + Console.WriteLine($"📋 Stack trace: {ex.StackTrace}"); + Snackbar.Add($"Errore nel caricamento dei clienti: {ex.Message}", Severity.Error); + } + finally + { + isLoading = false; + StateHasChanged(); // Force UI update + } + } + + private async Task ShowCustomerDetails(CustomerWithAnagInfoDto customer) + { + selectedCustomerId = customer.Id; + isDetailsDialogVisible = true; + + // Load complete customer details with all related data + try + { + selectedCustomer = await Http.GetFromJsonAsync($"api/IntegryData/customers/{customer.Id}"); + } + catch (Exception ex) + { + Snackbar.Add($"Errore nel caricamento dei dettagli del cliente: {ex.Message}", Severity.Error); + } + + // Load related data + await LoadCustomerServers(customer.Id); + await LoadCustomerDevices(customer.Id); + } + + private async Task LoadCustomerServers(int customerId) + { + try + { + isLoadingServers = true; + customerServers = await Http.GetFromJsonAsync>($"api/IntegryData/customers/{customerId}/servers"); + } + catch (Exception ex) + { + Snackbar.Add($"Errore nel caricamento dei server: {ex.Message}", Severity.Error); + } + finally + { + isLoadingServers = false; + } + } + + private async Task LoadCustomerDevices(int customerId) + { + try + { + isLoadingDevices = true; + customerDevices = await Http.GetFromJsonAsync>($"api/IntegryData/customers/{customerId}/devices"); + } + finally + { + isLoadingDevices = false; + } + } + + private void CloseDetailsDialog() + { + isDetailsDialogVisible = false; + selectedCustomerId = null; + customerServers = null; + customerDevices = null; + } + +} \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel.Client/Pages/CustomersWithAnag.razor b/IntegryControlPanel/IntegryControlPanel.Client/Pages/CustomersWithAnag.razor new file mode 100644 index 0000000..82f286d --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel.Client/Pages/CustomersWithAnag.razor @@ -0,0 +1,235 @@ +@page "/customers-with-anag" +@using IntegryControlPanel.Client.Models +@inject HttpClient Http +@inject IJSRuntime JSRuntime + +Clienti con Informazioni Anagrafiche + +
+

Clienti con Informazioni Anagrafiche

+ +
+
+
+ + + @if (!string.IsNullOrEmpty(searchTerm)) + { + + } +
+
+
+
+ + +
+
+
+ + @if (isLoading) + { +
+
+ Caricamento... +
+
+ } + else if (customers == null) + { +
Errore nel caricamento dei dati.
+ } + else if (!customers.Any()) + { +
+ @if (!string.IsNullOrEmpty(searchTerm)) + { + Nessun cliente trovato per la ricerca "@searchTerm". + } + else + { + Nessun cliente trovato. + } +
+ } + else + { +
+ + + + + + + + + + + + + + + @foreach (var customer in customers) + { + + + + + + + + + + + } + +
IDNome DisplayNome OriginaleSlugP.IVAStatoInfo AnagraficaAzioni
@customer.Id + @customer.DisplayName + @if (customer.HasExternalRagSoc) + { + + } + @customer.Name + @customer.Slug + @customer.PartitaIva + @if (customer.Active == true) + { + Attivo + } + else + { + Inattivo + } + + @if (customer.HasExternalRagSoc) + { + Con Rag. Sociale + } + else + { + Solo nome + } + + +
+
+ +
+ + Totale clienti: @customers.Count() + @if (showActiveOnly) + { + (solo attivi) + } + @if (!string.IsNullOrEmpty(searchTerm)) + { + - Filtrati per: "@searchTerm" + } + +
+ } +
+ +@code { + private IEnumerable? customers; + private bool isLoading = true; + private string searchTerm = string.Empty; + private bool showActiveOnly = false; + + protected override async Task OnInitializedAsync() + { + await LoadCustomers(); + } + + private async Task LoadCustomers() + { + isLoading = true; + try + { + string endpoint = showActiveOnly ? "api/CustomerAnagInfo/active" : "api/CustomerAnagInfo"; + customers = await Http.GetFromJsonAsync>(endpoint); + } + catch (Exception ex) + { + Console.WriteLine($"Errore nel caricamento dei clienti: {ex.Message}"); + customers = null; + } + finally + { + isLoading = false; + } + } + + private async Task SearchCustomers() + { + if (string.IsNullOrWhiteSpace(searchTerm)) + { + await LoadCustomers(); + return; + } + + isLoading = true; + try + { + customers = await Http.GetFromJsonAsync>($"api/CustomerAnagInfo/search?term={Uri.EscapeDataString(searchTerm)}"); + } + catch (Exception ex) + { + Console.WriteLine($"Errore nella ricerca: {ex.Message}"); + customers = null; + } + finally + { + isLoading = false; + } + } + + private async Task ClearSearch() + { + searchTerm = string.Empty; + await LoadCustomers(); + } + + private async Task OnActiveOnlyChanged() + { + if (string.IsNullOrWhiteSpace(searchTerm)) + { + await LoadCustomers(); + } + } + + private async Task ViewDetails(int customerId) + { + // Naviga ai dettagli del cliente o apre un modal + await JSRuntime.InvokeVoidAsync("alert", $"Visualizza dettagli cliente ID: {customerId}"); + } +} + + \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel.Client/Program.cs b/IntegryControlPanel/IntegryControlPanel.Client/Program.cs index 14397bc..0f5c085 100644 --- a/IntegryControlPanel/IntegryControlPanel.Client/Program.cs +++ b/IntegryControlPanel/IntegryControlPanel.Client/Program.cs @@ -3,10 +3,22 @@ using MudBlazor.Services; var builder = WebAssemblyHostBuilder.CreateDefault(args); +// Per Blazor misto in .NET 9, NON configurare RootComponents +// Il server gestisce il rendering e passa il controllo al client quando necessario + builder.Services.AddMudServices(); +// IMPORTANTE: HttpClient configuration per WebAssembly +// In WebAssembly dobbiamo usare la configurazione standard +builder.Services.AddScoped(sp => new HttpClient +{ + BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) +}); + builder.Services.AddAuthorizationCore(); builder.Services.AddCascadingAuthenticationState(); builder.Services.AddAuthenticationStateDeserialization(); +Console.WriteLine($"?? Client Program.cs - BaseAddress: {builder.HostEnvironment.BaseAddress}"); + await builder.Build().RunAsync(); diff --git a/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs b/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs new file mode 100644 index 0000000..7355be9 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Controllers/CustomerAnagInfoController.cs @@ -0,0 +1,118 @@ +using IntegryControlPanel.Services; +using Microsoft.AspNetCore.Mvc; + +namespace IntegryControlPanel.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class CustomerAnagInfoController : ControllerBase + { + private readonly IIntegryControlPanelService _service; + private readonly ILogger _logger; + + public CustomerAnagInfoController(IIntegryControlPanelService service, ILogger logger) + { + _service = service; + _logger = logger; + } + + /// + /// 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"); + // } + //} + + ///// + ///// 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"); + + // 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"); + + // 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"); + + // 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/Controllers/IntegryDataController.cs b/IntegryControlPanel/IntegryControlPanel/Controllers/IntegryDataController.cs index 66cee33..a8b5503 100644 --- a/IntegryControlPanel/IntegryControlPanel/Controllers/IntegryDataController.cs +++ b/IntegryControlPanel/IntegryControlPanel/Controllers/IntegryDataController.cs @@ -30,7 +30,7 @@ namespace IntegryControlPanel.Controllers } catch (Exception ex) { - _logger.LogError(ex, "Error retrieving customers"); + _logger.LogError(ex, "? API GetCustomers - Error retrieving customers"); return StatusCode(500, "Internal server error"); } } @@ -147,19 +147,21 @@ namespace IntegryControlPanel.Controllers try { var customerCount = await _integryService.GetTotalCustomersAsync(); - return Ok(new { - Message = "Database connection successful", + return Ok(new + { + Message = "Database connection successful", CustomerCount = customerCount, - Timestamp = DateTime.Now + Timestamp = DateTime.Now }); } catch (Exception ex) { _logger.LogError(ex, "Database connection test failed"); - return StatusCode(500, new { - Message = "Database connection failed", + return StatusCode(500, new + { + Message = "Database connection failed", Error = ex.Message, - Timestamp = DateTime.Now + Timestamp = DateTime.Now }); } } @@ -170,20 +172,22 @@ namespace IntegryControlPanel.Controllers try { var customers = await _integryService.GetAllCustomersAsync(); - return Ok(new { - Message = "Successfully retrieved customers", + return Ok(new + { + Message = "Successfully retrieved customers", Count = customers.Count(), Customers = customers.Take(5).Select(c => new { c.Id, c.Name, c.Slug }), - Timestamp = DateTime.Now + Timestamp = DateTime.Now }); } catch (Exception ex) { _logger.LogError(ex, "Error testing customers retrieval"); - return StatusCode(500, new { - Message = "Error retrieving customers", + return StatusCode(500, new + { + Message = "Error retrieving customers", Error = ex.Message, - Timestamp = DateTime.Now + Timestamp = DateTime.Now }); } } diff --git a/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs b/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs index 1ec232d..fa94716 100644 --- a/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs +++ b/IntegryControlPanel/IntegryControlPanel/Data/IntegryControlPanelDbContext.cs @@ -42,6 +42,8 @@ public partial class IntegryControlPanelDbContext : DbContext public virtual DbSet Services { get; set; } + public virtual DbSet VwCustomerServerInfos { get; set; } + public virtual DbSet VwServerLastUpdates { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -50,7 +52,7 @@ public partial class IntegryControlPanelDbContext : DbContext if (!optionsBuilder.IsConfigured) { // Configurazione di fallback solo per il design-time se necessaria - // optionsBuilder.UseSqlServer("Design time connection string if needed"); + optionsBuilder.UseSqlServer("Server=SERVERDB2019;Database=integry_control_panel_test;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;"); } } @@ -467,6 +469,42 @@ public partial class IntegryControlPanelDbContext : DbContext .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 diff --git a/IntegryControlPanel/IntegryControlPanel/IntegryControlPanel.csproj b/IntegryControlPanel/IntegryControlPanel/IntegryControlPanel.csproj index a872a33..6a6475d 100644 --- a/IntegryControlPanel/IntegryControlPanel/IntegryControlPanel.csproj +++ b/IntegryControlPanel/IntegryControlPanel/IntegryControlPanel.csproj @@ -23,4 +23,11 @@ + + + + + + + \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925161449_Initial.Designer.cs b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925161449_Initial.Designer.cs new file mode 100644 index 0000000..7a7b3dd --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925161449_Initial.Designer.cs @@ -0,0 +1,973 @@ +// +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("20250925161449_Initial")] + partial class Initial + { + /// + 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.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/20250925161449_Initial.cs b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925161449_Initial.cs new file mode 100644 index 0000000..bc1fbf0 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/20250925161449_Initial.cs @@ -0,0 +1,425 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IntegryControlPanel.Migrations.IntegryControlPanelDb +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "clients", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + nome_azienda = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + device_id = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + last_update = table.Column(type: "datetime2(6)", precision: 6, nullable: true), + insert_date = table.Column(type: "datetime2(6)", precision: 6, nullable: false), + remote_addr = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK__clients__3213E83FFF8DC3E2", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "configurazioni", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + nome_azienda = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + java_version = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + os_arch = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + os_name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + xmx = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + xms = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + max_perm_size = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + last_update = table.Column(type: "datetime2(6)", precision: 6, nullable: true), + remote_addr = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK__configur__3213E83FB9077FED", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "customers", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + slug = table.Column(type: "nvarchar(191)", maxLength: 191, nullable: false), + active = table.Column(type: "bit", nullable: false, defaultValueSql: "('0')"), + partita_iva = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK__customer__3213E83FD00417AC", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "services", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + slug = table.Column(type: "nvarchar(191)", maxLength: 191, nullable: false), + language = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + description = table.Column(type: "varchar(max)", unicode: false, nullable: true), + insert_date = table.Column(type: "datetime2(6)", precision: 6, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__services__3213E83FB43C1FE2", x => x.id); + }); + + migrationBuilder.CreateTable( + name: "application_infos", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customer_id = table.Column(type: "int", nullable: true), + name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + new_upd_prog_maga = table.Column(type: "bit", nullable: false), + menu_personalizzato = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + anno_magaz = table.Column(type: "int", nullable: true), + anno_contab = table.Column(type: "int", nullable: true), + ansi_padding = table.Column(type: "bit", nullable: false, defaultValueSql: "('0')"), + delimited_identifier = table.Column(type: "bit", nullable: false, defaultValueSql: "('0')"), + concat_null_yields_null = table.Column(type: "bit", nullable: false, defaultValueSql: "('0')") + }, + constraints: table => + { + table.PrimaryKey("PK__applicat__3213E83F4185DE9F", x => x.id); + table.ForeignKey( + name: "FK_D5E65179395C3F3", + column: x => x.customer_id, + principalTable: "customers", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "database_engines", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customer_id = table.Column(type: "int", nullable: true), + product_version = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + product_version_name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + product_level = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + product_edition = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__database__3213E83F8526E221", x => x.id); + table.ForeignKey( + name: "FK_1D94CC5C9395C3F3", + column: x => x.customer_id, + principalTable: "customers", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "devices", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customer_id = table.Column(type: "int", nullable: true), + ip = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + port = table.Column(type: "int", nullable: false), + info = table.Column(type: "varchar(max)", unicode: false, nullable: false, comment: "(DC2Type:simple_array)") + }, + constraints: table => + { + table.PrimaryKey("PK__devices__3213E83F185C7B65", x => x.id); + table.ForeignKey( + name: "FK_11074E9A9395C3F3", + column: x => x.customer_id, + principalTable: "customers", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "pvms_info", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customer_id = table.Column(type: "int", nullable: true), + php_version = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + timezone = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + imagick = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + sodium_missing = table.Column(type: "bit", nullable: false), + max_execution_time = table.Column(type: "int", nullable: false), + magic_quotes_gpc = table.Column(type: "bit", nullable: false), + default_charset = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + memory_limit = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + post_max_size = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + upload_max_size = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + max_input_vars = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__pvms_inf__3213E83F8EA1FE36", x => x.id); + table.ForeignKey( + name: "FK_4BCCAB779395C3F3", + column: x => x.customer_id, + principalTable: "customers", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "servers", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + customer_id = table.Column(type: "int", nullable: true), + ip = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + port = table.Column(type: "int", nullable: true), + info = table.Column(type: "varchar(max)", unicode: false, nullable: true, comment: "(DC2Type:simple_array)"), + java_version = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + os_arch = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + os_name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + xmx = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + xms = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + max_perm_size = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + last_update = table.Column(type: "datetime2(6)", precision: 6, nullable: true), + remote_addr = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + created_at = table.Column(type: "datetime2(6)", precision: 6, nullable: true), + updated_at = table.Column(type: "datetime2(6)", precision: 6, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK__servers__3213E83F0E4B2C74", x => x.id); + table.ForeignKey( + name: "FK_4F8AF5F79395C3F3", + column: x => x.customer_id, + principalTable: "customers", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "releases", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + service_id = table.Column(type: "int", nullable: true), + version = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + changelog = table.Column(type: "varchar(max)", unicode: false, nullable: true), + release_date = table.Column(type: "datetime2(6)", precision: 6, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__releases__3213E83F59E90B83", x => x.id); + table.ForeignKey( + name: "FK_7896E4D1ED5CA9E6", + column: x => x.service_id, + principalTable: "services", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "salvataggi_soap", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + application_info_id = table.Column(type: "int", nullable: true), + name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__salvatag__3213E83F51C2D8BF", x => x.id); + table.ForeignKey( + name: "FK_BC9B16D5B635C4CB", + column: x => x.application_info_id, + principalTable: "application_infos", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "databases_info", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + database_engine_id = table.Column(type: "int", nullable: true), + name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + logical_name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + size_mb = table.Column(type: "int", nullable: false), + max_size_mb = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__database__3213E83FC619B4B0", x => x.id); + table.ForeignKey( + name: "FK_99DAF4F8AB25983", + column: x => x.database_engine_id, + principalTable: "database_engines", + principalColumn: "id"); + }); + + migrationBuilder.CreateTable( + name: "installations", + columns: table => new + { + id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + release_id = table.Column(type: "int", nullable: true), + server_id = table.Column(type: "int", nullable: true), + device_id = table.Column(type: "int", nullable: true), + notes = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), + options = table.Column(type: "varchar(max)", unicode: false, nullable: false, comment: "(DC2Type:simple_array)"), + install_date = table.Column(type: "datetime2(6)", precision: 6, nullable: false), + last_update = table.Column(type: "datetime2(6)", precision: 6, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK__installa__3213E83F11ECD973", x => x.id); + table.ForeignKey( + name: "FK_A774F67B1844E6B7", + column: x => x.server_id, + principalTable: "servers", + principalColumn: "id"); + table.ForeignKey( + name: "FK_A774F67B94A4C7D4", + column: x => x.device_id, + principalTable: "devices", + principalColumn: "id"); + table.ForeignKey( + name: "FK_A774F67BB12A727D", + column: x => x.release_id, + principalTable: "releases", + principalColumn: "id"); + }); + + migrationBuilder.CreateIndex( + name: "IDX_D5E65179395C3F3", + table: "application_infos", + column: "customer_id"); + + migrationBuilder.CreateIndex( + name: "UNIQ_62534E21989D9B62", + table: "customers", + column: "slug", + unique: true, + filter: "([slug] IS NOT NULL)"); + + migrationBuilder.CreateIndex( + name: "UNIQ_1D94CC5C9395C3F3", + table: "database_engines", + column: "customer_id", + unique: true, + filter: "([customer_id] IS NOT NULL)"); + + migrationBuilder.CreateIndex( + name: "IDX_99DAF4F8AB25983", + table: "databases_info", + column: "database_engine_id"); + + migrationBuilder.CreateIndex( + name: "IDX_11074E9A9395C3F3", + table: "devices", + column: "customer_id"); + + migrationBuilder.CreateIndex( + name: "IDX_A774F67B1844E6B7", + table: "installations", + column: "server_id"); + + migrationBuilder.CreateIndex( + name: "IDX_A774F67B94A4C7D4", + table: "installations", + column: "device_id"); + + migrationBuilder.CreateIndex( + name: "IDX_A774F67BB12A727D", + table: "installations", + column: "release_id"); + + migrationBuilder.CreateIndex( + name: "IDX_4BCCAB779395C3F3", + table: "pvms_info", + column: "customer_id"); + + migrationBuilder.CreateIndex( + name: "IDX_7896E4D1ED5CA9E6", + table: "releases", + column: "service_id"); + + migrationBuilder.CreateIndex( + name: "IDX_BC9B16D5B635C4CB", + table: "salvataggi_soap", + column: "application_info_id"); + + migrationBuilder.CreateIndex( + name: "IDX_4F8AF5F79395C3F3", + table: "servers", + column: "customer_id"); + + migrationBuilder.CreateIndex( + name: "UNIQ_7332E169989D9B62", + table: "services", + column: "slug", + unique: true, + filter: "([slug] IS NOT NULL)"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "clients"); + + migrationBuilder.DropTable( + name: "configurazioni"); + + migrationBuilder.DropTable( + name: "databases_info"); + + migrationBuilder.DropTable( + name: "installations"); + + migrationBuilder.DropTable( + name: "pvms_info"); + + migrationBuilder.DropTable( + name: "salvataggi_soap"); + + migrationBuilder.DropTable( + name: "database_engines"); + + migrationBuilder.DropTable( + name: "servers"); + + migrationBuilder.DropTable( + name: "devices"); + + migrationBuilder.DropTable( + name: "releases"); + + migrationBuilder.DropTable( + name: "application_infos"); + + migrationBuilder.DropTable( + name: "services"); + + migrationBuilder.DropTable( + name: "customers"); + } + } +} diff --git a/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs new file mode 100644 index 0000000..97ed373 --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Migrations/IntegryControlPanelDb/IntegryControlPanelDbContextModelSnapshot.cs @@ -0,0 +1,970 @@ +// +using System; +using IntegryControlPanel.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IntegryControlPanel.Migrations.IntegryControlPanelDb +{ + [DbContext(typeof(IntegryControlPanelDbContext))] + partial class IntegryControlPanelDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(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.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/Models/IntegryControlPanel/VwCustomerServerInfo.cs b/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/VwCustomerServerInfo.cs new file mode 100644 index 0000000..ce7a11f --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/Models/IntegryControlPanel/VwCustomerServerInfo.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; + +namespace IntegryControlPanel.Models.IntegryControlPanel; + +public partial class VwCustomerServerInfo +{ + public string? Name { get; set; } + + public string? PartitaIva { get; set; } + + public string? OsName { get; set; } + + public string? OsArch { get; set; } + + public string? JavaVersion { get; set; } + + public string? RemoteAddr { get; set; } + + public DateTime? UpdatedAt { get; set; } + + public string SimpleName { get; set; } = null!; + + public string? RagSoc { get; set; } +} diff --git a/IntegryControlPanel/IntegryControlPanel/Program.cs b/IntegryControlPanel/IntegryControlPanel/Program.cs index c6673a3..9189058 100644 --- a/IntegryControlPanel/IntegryControlPanel/Program.cs +++ b/IntegryControlPanel/IntegryControlPanel/Program.cs @@ -20,6 +20,9 @@ builder.Services.AddRazorComponents() // Add controllers builder.Services.AddControllers(); +// IMPORTANTE: Aggiungere HttpClient anche per il server (per il render mode misto) +builder.Services.AddHttpClient(); + builder.Services.AddCascadingAuthenticationState(); builder.Services.AddScoped(); builder.Services.AddScoped(); @@ -88,6 +91,8 @@ else app.UseHttpsRedirection(); +app.UseStaticFiles(); + // Aggiungiamo l'autenticazione nel pipeline app.UseAuthentication(); app.UseAuthorization(); @@ -105,4 +110,8 @@ app.MapControllers(); // Add additional endpoints required by the Identity /Account Razor components. app.MapAdditionalIdentityEndpoints(); +// IMPORTANTE: Per .NET 9 con Blazor misto, non serve MapFallback +// Il router di Blazor gestisce automaticamente tutte le rotte +// sia server-side che client-side basandosi sul render mode + app.Run(); diff --git a/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs b/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs index db1bba2..1fbf6ef 100644 --- a/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs +++ b/IntegryControlPanel/IntegryControlPanel/Services/IIntegryControlPanelService.cs @@ -52,5 +52,16 @@ namespace IntegryControlPanel.Services Task GetTotalServersAsync(); 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); } } \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs b/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs index 8c88387..eceb2fa 100644 --- a/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs +++ b/IntegryControlPanel/IntegryControlPanel/Services/IntegryControlPanelService.cs @@ -40,6 +40,7 @@ namespace IntegryControlPanel.Services .Include(c => c.Servers) .Include(c => c.Devices) .Include(c => c.ApplicationInfos) + .Include(c => c.PvmsInfos) .FirstOrDefaultAsync(c => c.Id == id); } catch (Exception ex) @@ -579,5 +580,145 @@ namespace IntegryControlPanel.Services } #endregion + + //#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 + // "; + + // 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} + // "; + + // 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} + // "; + + // 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 + // "; + + // 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 + // "; + + // 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 } } \ No newline at end of file diff --git a/IntegryControlPanel/IntegryControlPanel/wwwroot/web.config b/IntegryControlPanel/IntegryControlPanel/wwwroot/web.config new file mode 100644 index 0000000..4b77c1e --- /dev/null +++ b/IntegryControlPanel/IntegryControlPanel/wwwroot/web.config @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file