Merge branch 'feature/DataLayerSetup' into develop
This commit is contained in:
@@ -7,11 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWare", "..\SteamWare\S
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamWareGestioneLicenze", "GeLiSt\SteamWareGestioneLicenze.csproj", "{4F110C8C-7C12-4D40-BDE4-A577CCEAD330}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiMan.Serv", "LiMan.Serv\LiMan.Serv.csproj", "{A89BDE27-D52A-4AB8-91B0-FB0DC36C4BCB}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiMan.Serv", "LiMan.Serv\LiMan.Serv.csproj", "{A89BDE27-D52A-4AB8-91B0-FB0DC36C4BCB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiMan.DL", "LiMan.DL\LiMan.DL.csproj", "{D9E7520A-2CB8-403A-A147-B7880FA47ED8}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiMan.DL", "LiMan.DL\LiMan.DL.csproj", "{D9E7520A-2CB8-403A-A147-B7880FA47ED8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LiMan.UI", "LiMan.UI\LiMan.UI.csproj", "{34200CA2-489C-435A-A60B-34DE7B7BA04D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LiMan.UI", "LiMan.UI\LiMan.UI.csproj", "{34200CA2-489C-435A-A60B-34DE7B7BA04D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace LiMan.DL
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using LiMan.DL.DatabaseModels;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.DL.Controllers
|
||||
{
|
||||
public class LicManController : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public LicManController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public bool DbForceMigrate()
|
||||
{
|
||||
bool answ = false;
|
||||
using (LicManContext localDbCtx = new LicManContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
localDbCtx.DbForceMigrate();
|
||||
answ = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in DbForceMigrate");
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
//Log.Info("Dispose di GWMSController");
|
||||
}
|
||||
|
||||
public List<AnagApplicazioni> GetApplicazioni()
|
||||
{
|
||||
List<AnagApplicazioni> dbResult = new List<AnagApplicazioni>();
|
||||
using (LicManContext localDbCtx = new LicManContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetApplicazioni
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public List<AnagInstallazioni> GetInstallazioni()
|
||||
{
|
||||
List<AnagInstallazioni> dbResult = new List<AnagInstallazioni>();
|
||||
using (LicManContext localDbCtx = new LicManContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetInstallazioni
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public List<LicenzeAttive> GetLicenze()
|
||||
{
|
||||
List<LicenzeAttive> dbResult = new List<LicenzeAttive>();
|
||||
using (LicManContext localDbCtx = new LicManContext(_configuration))
|
||||
{
|
||||
dbResult = localDbCtx
|
||||
.DbSetLicenzeAttive
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class AnagApplicazioni
|
||||
{
|
||||
public AnagApplicazioni()
|
||||
{
|
||||
LicenzeAttives = new HashSet<LicenzeAttive>();
|
||||
}
|
||||
|
||||
public string Applicativo { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
|
||||
public virtual ICollection<LicenzeAttive> LicenzeAttives { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class AnagInstallazioni
|
||||
{
|
||||
public AnagInstallazioni()
|
||||
{
|
||||
LicenzeAttives = new HashSet<LicenzeAttive>();
|
||||
}
|
||||
|
||||
public string Installazione { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
public string Contatto { get; set; }
|
||||
public string Email { get; set; }
|
||||
|
||||
public virtual ICollection<LicenzeAttive> LicenzeAttives { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NLog;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class LicManContext : DbContext
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public LicManContext()
|
||||
{
|
||||
}
|
||||
|
||||
public LicManContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public LicManContext(DbContextOptions<LicManContext> options) : base(options)
|
||||
{
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error(exc, "Exception during context initialization 02");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public virtual DbSet<AnagApplicazioni> DbSetApplicazioni { get; set; }
|
||||
|
||||
public virtual DbSet<AnagInstallazioni> DbSetInstallazioni { get; set; }
|
||||
|
||||
public virtual DbSet<LicenzeAttive> DbSetLicenzeAttive { get; set; }
|
||||
|
||||
public virtual DbSet<LogUpdateDb> DbSetLogUpdateDb { get; set; }
|
||||
|
||||
public virtual DbSet<Permessi> DbSetPermessi { get; set; }
|
||||
|
||||
public virtual DbSet<Permessi2Funzione> DbSetPermessi2Funzione { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
// default
|
||||
string connString = "Server=SQLSTEAM;Database=SteamWare_Auth;Trusted_Connection=True;";
|
||||
|
||||
// tento setup da config
|
||||
try
|
||||
{
|
||||
string srv = _configuration["DbConfig:srv"];
|
||||
string db = _configuration["DbConfig:db"];
|
||||
string usr = _configuration["DbConfig:usr"];
|
||||
string pwd = _configuration["DbConfig:pwd"];
|
||||
|
||||
//DbConfig.InitDb(server, nKey, sKey);
|
||||
//DbConfig.CheckUser(nKey, sKey);
|
||||
|
||||
// uso conn string calcolata
|
||||
connString = $"Server={srv};Database={db};User ID={usr}Password={pwd};";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
||||
|
||||
modelBuilder.Entity<AnagApplicazioni>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Applicativo);
|
||||
|
||||
entity.ToTable("AnagApplicazioni");
|
||||
|
||||
entity.Property(e => e.Applicativo)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("applicativo");
|
||||
|
||||
entity.Property(e => e.Descrizione)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("descrizione");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<AnagInstallazioni>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Installazione);
|
||||
|
||||
entity.ToTable("AnagInstallazioni");
|
||||
|
||||
entity.Property(e => e.Installazione)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("installazione");
|
||||
|
||||
entity.Property(e => e.Contatto)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("contatto");
|
||||
|
||||
entity.Property(e => e.Descrizione)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("descrizione");
|
||||
|
||||
entity.Property(e => e.Email)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("email");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<LicenzeAttive>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.IdxLic)
|
||||
.HasName("PK_AnagKeyValue");
|
||||
|
||||
entity.ToTable("LicenzeAttive");
|
||||
|
||||
entity.Property(e => e.IdxLic).HasColumnName("idxLic");
|
||||
|
||||
entity.Property(e => e.Applicativo)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("applicativo")
|
||||
.HasDefaultValueSql("(N'-')");
|
||||
|
||||
entity.Property(e => e.Descrizione)
|
||||
.HasMaxLength(250)
|
||||
.HasColumnName("descrizione")
|
||||
.HasDefaultValueSql("('-')");
|
||||
|
||||
entity.Property(e => e.Installazione)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("installazione")
|
||||
.HasDefaultValueSql("(N'SteamWare')");
|
||||
|
||||
entity.Property(e => e.Licenza)
|
||||
.HasMaxLength(250)
|
||||
.HasColumnName("licenza")
|
||||
.HasDefaultValueSql("('')");
|
||||
|
||||
entity.Property(e => e.NumLicenze)
|
||||
.HasColumnName("numLicenze")
|
||||
.HasDefaultValueSql("((0))");
|
||||
|
||||
entity.Property(e => e.Scadenza)
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("scadenza");
|
||||
|
||||
entity.HasOne(d => d.ApplicativoNavigation)
|
||||
.WithMany(p => p.LicenzeAttives)
|
||||
.HasForeignKey(d => d.Applicativo)
|
||||
.HasConstraintName("FK_AnagKeyValue_AnagApplicazioni");
|
||||
|
||||
entity.HasOne(d => d.InstallazioneNavigation)
|
||||
.WithMany(p => p.LicenzeAttives)
|
||||
.HasForeignKey(d => d.Installazione)
|
||||
.HasConstraintName("FK_AnagKeyValue_AnagInstallazioni");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<LogUpdateDb>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Versione);
|
||||
|
||||
entity.ToTable("LogUpdateDb");
|
||||
|
||||
entity.Property(e => e.Versione).ValueGeneratedNever();
|
||||
|
||||
entity.Property(e => e.Data).HasColumnType("datetime");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Permessi>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.CodPermesso);
|
||||
|
||||
entity.ToTable("Permessi");
|
||||
|
||||
entity.Property(e => e.CodPermesso)
|
||||
.HasMaxLength(50)
|
||||
.IsUnicode(false)
|
||||
.HasColumnName("COD_PERMESSO");
|
||||
|
||||
entity.Property(e => e.Descrizione)
|
||||
.HasMaxLength(50)
|
||||
.IsUnicode(false)
|
||||
.HasColumnName("DESCRIZIONE");
|
||||
|
||||
entity.Property(e => e.Gruppo).HasColumnName("GRUPPO");
|
||||
|
||||
entity.Property(e => e.Nome)
|
||||
.HasMaxLength(50)
|
||||
.IsUnicode(false)
|
||||
.HasColumnName("NOME");
|
||||
|
||||
entity.Property(e => e.Numero).HasColumnName("NUMERO");
|
||||
|
||||
entity.Property(e => e.Url)
|
||||
.IsRequired()
|
||||
.HasMaxLength(250)
|
||||
.IsUnicode(false)
|
||||
.HasColumnName("URL");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<Permessi2Funzione>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.CodPermesso, e.CodFunzione });
|
||||
|
||||
entity.ToTable("Permessi2Funzione");
|
||||
|
||||
entity.Property(e => e.CodPermesso)
|
||||
.HasMaxLength(50)
|
||||
.IsUnicode(false)
|
||||
.HasColumnName("COD_PERMESSO");
|
||||
|
||||
entity.Property(e => e.CodFunzione)
|
||||
.HasMaxLength(31)
|
||||
.HasColumnName("COD_FUNZIONE");
|
||||
|
||||
entity.Property(e => e.Readwrite)
|
||||
.HasMaxLength(1)
|
||||
.IsUnicode(false)
|
||||
.HasColumnName("READWRITE")
|
||||
.IsFixedLength(true);
|
||||
|
||||
entity.HasOne(d => d.CodPermessoNavigation)
|
||||
.WithMany(p => p.Permessi2Funziones)
|
||||
.HasForeignKey(d => d.CodPermesso)
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.HasConstraintName("FK_Permessi2Funzione_Permessi");
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void DbForceMigrate()
|
||||
{
|
||||
try
|
||||
{
|
||||
// se non ci fosse... crea o migra!
|
||||
Database.Migrate();
|
||||
Log.Info("DbForceMigrate: done!");
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error(exc, "DbForceMigrate: Exception during context initialization 01");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class LicenzeAttive
|
||||
{
|
||||
public int IdxLic { get; set; }
|
||||
public string Installazione { get; set; }
|
||||
public string Applicativo { get; set; }
|
||||
public int? NumLicenze { get; set; }
|
||||
public string Licenza { get; set; }
|
||||
public DateTime? Scadenza { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
|
||||
public virtual AnagApplicazioni ApplicativoNavigation { get; set; }
|
||||
public virtual AnagInstallazioni InstallazioneNavigation { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class LogUpdateDb
|
||||
{
|
||||
public int Versione { get; set; }
|
||||
public DateTime? Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class Permessi
|
||||
{
|
||||
public Permessi()
|
||||
{
|
||||
Permessi2Funziones = new HashSet<Permessi2Funzione>();
|
||||
}
|
||||
|
||||
public string CodPermesso { get; set; }
|
||||
public string Url { get; set; }
|
||||
public int? Gruppo { get; set; }
|
||||
public int? Numero { get; set; }
|
||||
public string Nome { get; set; }
|
||||
public string Descrizione { get; set; }
|
||||
|
||||
public virtual ICollection<Permessi2Funzione> Permessi2Funziones { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace LiMan.DL.DatabaseModels
|
||||
{
|
||||
public partial class Permessi2Funzione
|
||||
{
|
||||
public string CodPermesso { get; set; }
|
||||
public string CodFunzione { get; set; }
|
||||
public string Readwrite { get; set; }
|
||||
|
||||
public virtual Permessi CodPermessoNavigation { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
<ItemGroup>
|
||||
<Folder Include="DTO\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="5.0.1" />
|
||||
<PackageReference Include="NLog" Version="4.7.11" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -8,4 +8,8 @@
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LiMan.DL\LiMan.DL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<div class="form-row text-light">
|
||||
<div class="col-5 pr-0 text-left">
|
||||
GWMS <span class="small">v.@version</span>
|
||||
</div>
|
||||
<div class="col-7 pl-0 text-right">
|
||||
<span class="small">@adesso</span>
|
||||
<a class="text-light" href="https://www.egalware.com/" target="_blank">Egalware<img class="img-fluid" width="16" src="img/LogoBlu.svg" /></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
protected DateTime adesso = DateTime.Now;
|
||||
|
||||
Version version = typeof(Program).Assembly.GetName().Version;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
@using LiMan.UI.Components
|
||||
@using System.Security.Claims
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using LiMan.UI.Data
|
||||
|
||||
@inject MessageService AppMessages
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
|
||||
<div class="form-row pt-3">
|
||||
<div class="col-7 col-md-6 col-lg-4 col-xl-3">
|
||||
@*<LoginDisplay></LoginDisplay>*@
|
||||
</div>
|
||||
<div class="col-12 col-lg-4 col-xl-6 d-none d-lg-block text-center h4 text-truncate">
|
||||
<span class="@PageIcon" aria-hidden="true"></span> @PageName
|
||||
</div>
|
||||
<div class="col-5 col-md-6 col-lg-4 col-xl-3 text-right">
|
||||
@if (ShowSearch)
|
||||
{
|
||||
<SearchMod></SearchMod>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[CascadingParameter]
|
||||
private Task<AuthenticationState> AuthenticationStateTask { get; set; }
|
||||
|
||||
[CascadingParameter(Name = "ShowSearch")]
|
||||
private bool ShowSearch { get; set; }
|
||||
|
||||
private string userName = "";
|
||||
|
||||
private string PageName { get; set; }
|
||||
private string PageIcon { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await forceReload();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AppMessages.EA_PageUpdated += OnPageUpdate;
|
||||
}
|
||||
public void OnPageUpdate()
|
||||
{
|
||||
PageName = AppMessages.PageName;
|
||||
PageIcon = AppMessages.PageIcon;
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
AppMessages.EA_PageUpdated -= OnPageUpdate;
|
||||
}
|
||||
|
||||
private async Task forceReload()
|
||||
{
|
||||
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var user = authState.User;
|
||||
|
||||
if (user.Identity.IsAuthenticated)
|
||||
{
|
||||
userName = $"{user.Identity.Name}";
|
||||
}
|
||||
else
|
||||
{
|
||||
userName = "N.A.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@* // Vedere anche:
|
||||
// https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-5.0#:~:text=Blazor%20uses%20the%20existing%20ASP.NET%20Core%20authentication%20mechanisms,all%20client-side%20code%20can%20be%20modified%20by%20users
|
||||
// https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-5.0*@
|
||||
@@ -0,0 +1,56 @@
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-9 text-left">
|
||||
<div class="row">
|
||||
<div class="col-12 small">
|
||||
@if (totalCount > 0)
|
||||
{
|
||||
<ul class="pagination pagination-sm mb-1">
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(1)"><i class="fas fa-angle-double-left"></i></button></li>
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(prevBlock)"><i class="fas fa-angle-left"></i></button></li>
|
||||
@for (int i = @startPage; i <= endPage; ++i)
|
||||
{
|
||||
var pageNum = i;
|
||||
<li class="page-item @cssActive(pageNum)"><button class="page-link" @onclick="() => PaginationItemClick(pageNum)">@pageNum</button></li>
|
||||
}
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(nextBlock)"><i class="fas fa-angle-right"></i></button></li>
|
||||
<li class="page-item"><button class="page-link" @onclick="() => PaginationItemClick(LastPage)"><i class="fas fa-angle-double-right"></i></button></li>
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 small">
|
||||
@if (showLoading)
|
||||
{
|
||||
<div class="progress" style="height: 10px;">
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-lg-3">
|
||||
<div class="d-flex">
|
||||
<div class="p-1 flex-fill text-right">
|
||||
@if (!showLoading)
|
||||
{
|
||||
<span>@totalCount records</span>
|
||||
}
|
||||
</div>
|
||||
<div class="p-1 flex-fill text-right small">
|
||||
@if (totalCount > 0)
|
||||
{
|
||||
<div class="input-group input-group-sm">
|
||||
<select @bind="@PageSize" class="form-control form-control-sm">
|
||||
<option value="5">5</option>
|
||||
<option value="10">10</option>
|
||||
<option value="25">25</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
</select>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,193 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using LiMan.UI.Components;
|
||||
using LiMan.UI.Data;
|
||||
|
||||
namespace LiMan.UI.Components
|
||||
{
|
||||
public partial class DataPager : ComponentBase
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected bool _showLoading = false;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int endPage
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = (int)(currPage / numPages) * numPages + numPages;
|
||||
answ = answ < LastPage ? answ : LastPage;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
private int LastPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return Math.Max((int)Math.Ceiling(totalCount / (double)PageSize), 1);
|
||||
}
|
||||
}
|
||||
|
||||
private int nextBlock
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = currPage + numPages;
|
||||
answ = answ < LastPage ? answ : LastPage;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
private int numPages { get; set; } = 10;
|
||||
|
||||
private int prevBlock
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = currPage - numPages;
|
||||
answ = answ > 0 ? answ : 1;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
// calcola un set 1 .. numPages centrato sulla pagina corrente...
|
||||
private int startPage
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = (int)(currPage / numPages) * numPages;
|
||||
answ = answ > 0 ? answ : 1;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected int _numPage { get; set; } = 1;
|
||||
|
||||
protected int _numRecord { get; set; } = 10;
|
||||
|
||||
protected int percLoading { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public int currPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return _numPage;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = !_numPage.Equals(value);
|
||||
if (doReport)
|
||||
{
|
||||
_numPage = value;
|
||||
reportChangePage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> numPageChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<int> numRecordChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int PageSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return _numRecord;
|
||||
}
|
||||
set
|
||||
{
|
||||
bool doReport = !_numRecord.Equals(value);
|
||||
if (doReport)
|
||||
{
|
||||
_numRecord = value;
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public bool showLoading
|
||||
{
|
||||
get
|
||||
{
|
||||
return _showLoading;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
Random random = new Random();
|
||||
percLoading = random.Next(30, 90);
|
||||
}
|
||||
else
|
||||
{
|
||||
percLoading = 5;
|
||||
}
|
||||
_showLoading = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Parameter]
|
||||
public int totalCount { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
numRecordChanged.InvokeAsync(PageSize);
|
||||
}
|
||||
|
||||
private void reportChangePage()
|
||||
{
|
||||
numPageChanged.InvokeAsync(currPage);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string cssActive(int numPage)
|
||||
{
|
||||
string answ = "";
|
||||
if (numPage == currPage)
|
||||
{
|
||||
answ = "active";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Task.Run(() => showLoading = false);
|
||||
}
|
||||
|
||||
protected void PaginationItemClick(int page)
|
||||
{
|
||||
currPage = page;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@*<h1 class="alert alert-info">Working</h1>*@
|
||||
<div class="row">
|
||||
<div class="col-12 text-center mt-5 py-5 alert alert-primary">
|
||||
<h3>loading data</h3>
|
||||
<i class="fas fa-spinner fa-spin fa-5x"></i>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,61 @@
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
|
||||
@inject AuthenticationStateProvider AuthenticationStateProvider
|
||||
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
<div class="input-group text-truncate">
|
||||
<div class="input-group-prepend">
|
||||
<a title="LogOut" href="Identity/Account/LogOut" class="btn btn-sm btn-danger"><i class="fas fa-sign-out-alt"></i></a>
|
||||
</div>
|
||||
<a title="Gestione account @userName" href="Identity/Account/Manage" class="btn btn-sm btn-outline-dark mx-0 px-1">
|
||||
<div class="d-none d-sm-block">
|
||||
<i class="fas fa-user-alt"></i> @StringLim(userName, 30)
|
||||
</div>
|
||||
<div class="d-block d-sm-none">
|
||||
<i class="fas fa-user-alt"></i> @StringLim(userName, 15)
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<a title="LogIn" href="Identity/Account/LogIn" class="btn btn-sm btn-success"><i class="fas fa-sign-in-alt"></i></a>
|
||||
</div>
|
||||
<div class="form-control form-control-sm">
|
||||
<i class="fas fa-user-alt"></i> @userName
|
||||
</div>
|
||||
</div>
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
|
||||
@code{
|
||||
|
||||
private string userName = "";
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await forceReload();
|
||||
}
|
||||
private async Task forceReload()
|
||||
{
|
||||
|
||||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var user = authState.User;
|
||||
|
||||
if (user.Identity.IsAuthenticated)
|
||||
{
|
||||
userName = $"{user.Identity.Name}";
|
||||
}
|
||||
else
|
||||
{
|
||||
userName = "Non Autenticato";
|
||||
}
|
||||
}
|
||||
|
||||
protected string StringLim(string original, int maxLen)
|
||||
{
|
||||
return original.Length <= maxLen ? original : $"{original.Substring(0, maxLen - 3)}...";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
@using LiMan.UI.Components
|
||||
@using LiMan.UI.Data
|
||||
@inject MessageService MessageService
|
||||
|
||||
<div class="input-group input-group-sm">
|
||||
<input @bind-value="searchVal" @bind-value:event="oninput" type="text" class="form-control" title="Campo Ricerca" placeholder="Ricerca [ALT-R]" accesskey="R" />
|
||||
<div class="input-group-append">
|
||||
<button @onclick="reset" class="btn btn-success input-group-text">reset</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> searchUpdated { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string searchVal
|
||||
{
|
||||
get
|
||||
{
|
||||
return MessageService.SearchVal;
|
||||
}
|
||||
set
|
||||
{
|
||||
MessageService.SearchVal = value;
|
||||
reportChange();
|
||||
}
|
||||
}
|
||||
|
||||
private void reportChange()
|
||||
{
|
||||
searchUpdated.InvokeAsync(searchVal);
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
searchVal = "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
{
|
||||
public class LiManDataService : IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
private static ILogger<LiManDataService> _logger;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IDistributedCache distributedCache;
|
||||
private readonly IMemoryCache memoryCache;
|
||||
|
||||
/// <summary>
|
||||
/// Durata assoluta massima della cache IN SECONDI
|
||||
/// </summary>
|
||||
private int chAbsExp = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire rimossa
|
||||
/// NON estende oltre il tempo massimo di validità della cache (chAbsExp)
|
||||
/// </summary>
|
||||
private int chSliExp = 60 * 1;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected static string connStringBBM = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Fields
|
||||
|
||||
public static LiMan.DL.Controllers.LicManController dbController;
|
||||
|
||||
#endregion Public Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public LiManDataService(IConfiguration configuration, ILogger<LiManDataService> logger, IMemoryCache memoryCache, IDistributedCache distributedCache)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
// conf cache
|
||||
this.memoryCache = memoryCache;
|
||||
this.distributedCache = distributedCache;
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("GWMS.Data");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
_logger.LogError("ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new LiMan.DL.Controllers.LicManController(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private DistributedCacheEntryOptions cacheOpt(bool fastCache)
|
||||
{
|
||||
var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10;
|
||||
var numSecSliExp = fastCache ? chSliExp : chSliExp * 10;
|
||||
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected string getCacheKey(string TableName, SelectData CurrFilter)
|
||||
{
|
||||
string answ = $"{TableName}:D_{CurrFilter.DateStart:yyyyMMddHHmm}_{CurrFilter.DateEnd:yyyyMMddHHmm}";
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Hash Redis contenente i dati MP di una specifico TYPE (es StatusMacchina, StateMachineIngressi, ...)
|
||||
/// </summary>
|
||||
/// <param name="dataType"></param>
|
||||
/// <returns></returns>
|
||||
public static string mHash(string dataType)
|
||||
{
|
||||
return $"DATA:{dataType}";
|
||||
}
|
||||
|
||||
public async Task<List<DL.DatabaseModels.AnagApplicazioni>> ApplicazioniGetAll()
|
||||
{
|
||||
List<DL.DatabaseModels.AnagApplicazioni> dbResult = new List<DL.DatabaseModels.AnagApplicazioni>();
|
||||
string cacheKey = mHash("Applicazioni");
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<DL.DatabaseModels.AnagApplicazioni>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.GetApplicazioni();
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per ApplicazioniGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> DbForceMigrate()
|
||||
{
|
||||
return await Task.FromResult(dbController.DbForceMigrate());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
public async Task<List<DL.DatabaseModels.AnagInstallazioni>> InstallazioniGetAll()
|
||||
{
|
||||
List<DL.DatabaseModels.AnagInstallazioni> dbResult = new List<DL.DatabaseModels.AnagInstallazioni>();
|
||||
string cacheKey = mHash("Installazioni");
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<DL.DatabaseModels.AnagInstallazioni>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.GetInstallazioni();
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per InstallazioniGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// invalida tutta la cache in caso di update
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task InvalidateAllCache()
|
||||
{
|
||||
await distributedCache.RemoveAsync(mHash("Applicazioni"));
|
||||
await distributedCache.RemoveAsync(mHash("Installazioni"));
|
||||
await distributedCache.RemoveAsync(mHash("Licenze"));
|
||||
//await distributedCache.RemoveAsync(mHash("SUPPL:List"));
|
||||
//await distributedCache.RemoveAsync(mHash("TRANSP:List"));
|
||||
//await distributedCache.RemoveAsync(mHash("WEEKPLAN:List"));
|
||||
}
|
||||
|
||||
public async Task<List<DL.DatabaseModels.LicenzeAttive>> LicenzeGetAll()
|
||||
{
|
||||
List<DL.DatabaseModels.LicenzeAttive> dbResult = new List<DL.DatabaseModels.LicenzeAttive>();
|
||||
string cacheKey = mHash("Licenze");
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<DL.DatabaseModels.LicenzeAttive>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.GetLicenze();
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per LicenzeGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
{
|
||||
public class MessageService
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private SelectData _detailFilter = SelectData.Init(5, 15);
|
||||
private string _pageIcon;
|
||||
private string _pageName;
|
||||
private string _searchVal;
|
||||
private bool showSearch;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Events
|
||||
|
||||
public event Action EA_FilterUpdated;
|
||||
|
||||
public event Action EA_HideSearch;
|
||||
|
||||
public event Action EA_PageUpdated;
|
||||
|
||||
public event Action EA_SearchUpdated;
|
||||
|
||||
public event Action EA_ShowSearch;
|
||||
|
||||
#endregion Public Events
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public SelectData DetailFilter
|
||||
{
|
||||
get => _detailFilter;
|
||||
set
|
||||
{
|
||||
if (_detailFilter != value)
|
||||
{
|
||||
_detailFilter = value;
|
||||
|
||||
if (EA_FilterUpdated != null)
|
||||
{
|
||||
EA_FilterUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string PageIcon
|
||||
{
|
||||
get => _pageIcon;
|
||||
set
|
||||
{
|
||||
if (_pageIcon != value)
|
||||
{
|
||||
_pageIcon = value;
|
||||
ReportPageUpd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string PageName
|
||||
{
|
||||
get => _pageName;
|
||||
set
|
||||
{
|
||||
if (_pageName != value)
|
||||
{
|
||||
_pageName = value;
|
||||
ReportPageUpd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int PageNum { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 10;
|
||||
|
||||
public string SearchVal
|
||||
{
|
||||
get => _searchVal;
|
||||
set
|
||||
{
|
||||
if (_searchVal != value)
|
||||
{
|
||||
_searchVal = value;
|
||||
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowSearch
|
||||
{
|
||||
get => showSearch;
|
||||
set
|
||||
{
|
||||
if (showSearch != value)
|
||||
{
|
||||
showSearch = value;
|
||||
if (showSearch)
|
||||
{
|
||||
if (EA_ShowSearch != null)
|
||||
{
|
||||
EA_ShowSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (EA_HideSearch != null)
|
||||
{
|
||||
EA_HideSearch?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void ReportPageUpd()
|
||||
{
|
||||
if (EA_PageUpdated != null)
|
||||
{
|
||||
EA_PageUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportSearch()
|
||||
{
|
||||
if (EA_SearchUpdated != null)
|
||||
{
|
||||
EA_SearchUpdated?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
{
|
||||
public class SelectData
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public DateTime DateEnd { get; set; } = DateTime.Now.AddMinutes(1);
|
||||
public DateTime DateStart { get; set; } = DateTime.Now.AddDays(-7);
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione con periodo e arrotondamento
|
||||
/// </summary>
|
||||
/// <param name="minRound"></param>
|
||||
/// <param name="numDayPrev"></param>
|
||||
/// <returns></returns>
|
||||
public static SelectData Init(int minRound, int numDayPrev)
|
||||
{
|
||||
DateTime endRounded = DateTime.Today.AddDays(1);
|
||||
SelectData answ = new SelectData()
|
||||
{
|
||||
DateEnd = endRounded,
|
||||
DateStart = endRounded.AddDays(-numDayPrev)
|
||||
};
|
||||
return answ;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is SelectData item))
|
||||
return false;
|
||||
|
||||
if (DateEnd != item.DateEnd)
|
||||
return false;
|
||||
if (DateStart != item.DateStart)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Data
|
||||
{
|
||||
public class WeatherForecastService
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
|
||||
{
|
||||
var rng = new Random();
|
||||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = startDate.AddDays(index),
|
||||
TemperatureC = rng.Next(-20, 55),
|
||||
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||
}).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
+30
-18
@@ -1,22 +1,34 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Remove="compilerconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="compilerconfig.json" />
|
||||
<None Include="wwwroot\fonts\lato-v17-latin-regular.svg" />
|
||||
<None Include="wwwroot\fonts\lato-v17-latin-regular.woff2" />
|
||||
<None Include="wwwroot\fonts\roboto-condensed-v19-latin-regular.svg" />
|
||||
<None Include="wwwroot\fonts\roboto-condensed-v19-latin-regular.woff2" />
|
||||
<None Include="wwwroot\fonts\roboto-v27-latin-regular.svg" />
|
||||
<None Include="wwwroot\fonts\roboto-v27-latin-regular.woff2" />
|
||||
<None Include="wwwroot\img\LogoBlu.svg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="compilerconfig.json" />
|
||||
<None Include="wwwroot\fonts\lato-v17-latin-regular.svg" />
|
||||
<None Include="wwwroot\fonts\lato-v17-latin-regular.woff2" />
|
||||
<None Include="wwwroot\fonts\roboto-condensed-v19-latin-regular.svg" />
|
||||
<None Include="wwwroot\fonts\roboto-condensed-v19-latin-regular.woff2" />
|
||||
<None Include="wwwroot\fonts\roboto-v27-latin-regular.svg" />
|
||||
<None Include="wwwroot\fonts\roboto-v27-latin-regular.woff2" />
|
||||
<None Include="wwwroot\img\LogoBlu.svg" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LiMan.DL\LiMan.DL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="logs\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,170 @@
|
||||
@page "/Applicazioni"
|
||||
|
||||
@using LiMan.UI.Components
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-4">
|
||||
<div class="d-flex">
|
||||
<div class="px-2">
|
||||
<h3>Elenco Programmi</h3>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="form-group mb-0">
|
||||
@*<button id="btnForceCheck" class="btn btn-warning btn-sm" @onclick="() => ForceCheck(30)" title="Analisi Modifiche ultimi 30gg">
|
||||
<i class="fas fa-sync-alt"></i> Update (30gg) <i class="far fa-folder-open"></i>
|
||||
</button>*@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@*<div class="col-12 col-lg-8 text-right">
|
||||
<div class="d-flex flex-row-reverse">
|
||||
<div class="px-2">
|
||||
<div class="form-group mb-0">
|
||||
<button id="btnReset" class="btn btn-info btn-sm" @onclick="() => ResetFilter()" title="Reset Filter"><span class="oi oi-loop-circular"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">
|
||||
<span class="fas fa-industry" aria-hidden="true"></span>
|
||||
</span>
|
||||
</div>
|
||||
<select @bind="@SelIdxMacc" class="form-control form-control-sm">
|
||||
@if (MacList != null)
|
||||
{
|
||||
foreach (var item in MacList)
|
||||
{
|
||||
<option value="@item.IdxMacchina">@item.Descrizione (@item.RuleName)</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togModificati" title="Solo Aperti / Mostra tutti" @bind-value="@OnlyMod" checked="@OnlyMod" />
|
||||
<label class="custom-control-label" for="togModificati"><sub>Mod</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togAttivi" title="Solo Attivi / Mostra tutti" @bind-value="@OnlyActive" checked="@OnlyActive" />
|
||||
<label class="custom-control-label" for="togAttivi"><sub>Attivi</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" id="togNoTag" title="Solo senza Tag / Mostra tutti" @bind-value="@OnlyNoTag" checked="@OnlyNoTag" />
|
||||
<label class="custom-control-label" for="togNoTag"><sub>No Tag</sub></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-2 text-truncate">
|
||||
@if (!string.IsNullOrEmpty(SelFileName))
|
||||
{
|
||||
<span class="badge badge-secondary" title="@SelFileName">@TextReduce(SelFileName, 20)</span>
|
||||
}
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-prepend">
|
||||
<button type="button" class="btn btn-sm btn-primary" @onclick="() => OpenDialog()" title="Aggiunta Tag">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
<span class="input-group-text">Tags</span>
|
||||
</div>
|
||||
<div class="form-control form-control-sm">
|
||||
@if (!string.IsNullOrEmpty(SelTag))
|
||||
{
|
||||
<span class="badge badge-info">@SelTag</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span> ... </span>
|
||||
}
|
||||
</div>
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-sm btn-secondary" @onclick="() => ResetTag()" title="Reset Tag">
|
||||
<i class="fas fa-sync"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@if (DeleteDialogOpen)
|
||||
{
|
||||
<MP.Prog.Components.TagSearch Title="Ricerca Tag" OnClose="@OnDialogClose"></MP.Prog.Components.TagSearch>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>*@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-1">
|
||||
@if (currRecord != null)
|
||||
{
|
||||
@*<FileEditor currItem="@currRecord" DataReset="ResetData" DataUpdated="UpdateData" TagList="@TagList" MacList="@MacList"></FileEditor>*@
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else if (totalCount == 0)
|
||||
{
|
||||
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table table-sm table-striped table-responsive-lg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Applicazione</th>
|
||||
<th class="text-right">Descrizione</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(record.Applicativo)">
|
||||
<td class="text-nowrap">
|
||||
@if (currRecord == null)
|
||||
{
|
||||
<button class="btn btn-sm btn-info" @onclick="() => Edit(record)" title="Edit record">
|
||||
<i class="oi oi-pencil"></i>
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="btn btn-sm btn-secondary disabled">
|
||||
<i class="oi oi-pencil"></i>
|
||||
</button>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<b>@record.Applicativo</b>
|
||||
</td>
|
||||
<td>
|
||||
<div>@record.Descrizione</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer p-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="PagerReloadNum" numPageChanged="PagerReloadPage" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,149 @@
|
||||
using LiMan.DL.DatabaseModels;
|
||||
using LiMan.UI.Data;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Pages
|
||||
{
|
||||
public partial class Applicazioni : ComponentBase, IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private AnagApplicazioni currRecord = null;
|
||||
private List<AnagApplicazioni> ListRecords;
|
||||
private List<AnagApplicazioni> SearchRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int totalCount = 0;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppMService.PageNum;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppMService.PageNum = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get
|
||||
{
|
||||
return AppMService.PageSize;
|
||||
}
|
||||
set
|
||||
{
|
||||
AppMService.PageSize = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected MessageService AppMService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected LiManDataService DataService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
|
||||
protected bool showCamera { get; set; } = false;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
await Task.Delay(1);
|
||||
//ListRecords = null;
|
||||
SearchRecords = await DataService.ApplicazioniGetAll();
|
||||
totalCount = SearchRecords.Count();
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void Edit(AnagApplicazioni selRecord)
|
||||
{
|
||||
currRecord = selRecord;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
AppMService.ShowSearch = false;
|
||||
AppMService.PageName = "Installazioni";
|
||||
AppMService.PageIcon = "fas fa-gas-pump pr-2";
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected async Task PagerReloadNum(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected async Task PagerReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadAllData();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public string checkSelect(string Applicativo)
|
||||
{
|
||||
string answ = "";
|
||||
if (currRecord != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
answ = (currRecord.Applicativo == Applicativo) ? "table-info" : "";
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
@page "/counter"
|
||||
|
||||
<h1>Counter</h1>
|
||||
|
||||
<p>Current count: @currentCount</p>
|
||||
|
||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
||||
|
||||
@code {
|
||||
private int currentCount = 0;
|
||||
|
||||
private void IncrementCount()
|
||||
{
|
||||
currentCount++;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
@page "/fetchdata"
|
||||
|
||||
@using LiMan.UI.Data
|
||||
@inject WeatherForecastService ForecastService
|
||||
|
||||
<h1>Weather forecast</h1>
|
||||
|
||||
<p>This component demonstrates fetching data from a service.</p>
|
||||
|
||||
@if (forecasts == null)
|
||||
{
|
||||
<p><em>Loading...</em></p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Temp. (C)</th>
|
||||
<th>Temp. (F)</th>
|
||||
<th>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var forecast in forecasts)
|
||||
{
|
||||
<tr>
|
||||
<td>@forecast.Date.ToShortDateString()</td>
|
||||
<td>@forecast.TemperatureC</td>
|
||||
<td>@forecast.TemperatureF</td>
|
||||
<td>@forecast.Summary</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
@code {
|
||||
private WeatherForecast[] forecasts;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
@page "/Installazioni"
|
||||
|
||||
<h1>Installazioni</h1>
|
||||
@@ -0,0 +1,80 @@
|
||||
using LiMan.DL.DatabaseModels;
|
||||
using LiMan.UI.Data;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LiMan.UI.Pages
|
||||
{
|
||||
public partial class Installazioni : ComponentBase, IDisposable
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private List<AnagInstallazioni> PlantsList;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected LiManDataService DataService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected MessageService MessageService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
|
||||
protected bool showCamera { get; set; } = false;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task ReloadAllData()
|
||||
{
|
||||
isLoading = true;
|
||||
PlantsList = null;
|
||||
PlantsList = await DataService.InstallazioniGetAll();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
MessageService.ShowSearch = false;
|
||||
MessageService.PageName = "Installazioni";
|
||||
MessageService.PageIcon = "fas fa-gas-pump pr-2";
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<h3>LicenseManager</h3>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
+37
-7
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Web;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -11,16 +12,45 @@ namespace LiMan.UI
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
})
|
||||
.ConfigureLogging(logging =>
|
||||
{
|
||||
logging.ClearProviders();
|
||||
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
||||
})
|
||||
.UseNLog();
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// inclusione NLog:
|
||||
// https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-5
|
||||
// https://codewithmukesh.com/blog/logging-with-nlog-in-aspnet-core/
|
||||
var logger = NLog.Web.NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
|
||||
try
|
||||
{
|
||||
logger.Info("LiMan.UI Application Starting Up");
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.Error(exception, "Stopped LiMan.UI program because of exception");
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
NLog.LogManager.Shutdown();
|
||||
}
|
||||
|
||||
//CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,13 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="counter">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Counter
|
||||
<NavLink class="nav-link" href="Applicazioni">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Applicazioni
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="fetchdata">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
|
||||
<NavLink class="nav-link" href="Installazioni">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Installazioni
|
||||
</NavLink>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -34,4 +34,4 @@
|
||||
{
|
||||
collapseNavMenu = !collapseNavMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<div class="alert alert-secondary mt-4" role="alert">
|
||||
<span class="oi oi-pencil mr-2" aria-hidden="true"></span>
|
||||
<strong>@Title</strong>
|
||||
|
||||
<span class="text-nowrap">
|
||||
Please take our
|
||||
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2137813">brief survey</a>
|
||||
</span>
|
||||
and tell us what you think.
|
||||
</div>
|
||||
|
||||
@code {
|
||||
// Demonstrates how a parent component can supply parameters
|
||||
[Parameter]
|
||||
public string Title { get; set; }
|
||||
}
|
||||
+61
-9
@@ -2,12 +2,15 @@ using LiMan.UI.Data;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -15,21 +18,22 @@ namespace LiMan.UI
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddRazorPages();
|
||||
services.AddServerSideBlazor();
|
||||
services.AddSingleton<WeatherForecastService>();
|
||||
}
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
@@ -45,6 +49,24 @@ namespace LiMan.UI
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
// cultura IT...
|
||||
var supportedCultures = new[]{
|
||||
new CultureInfo("it-IT")
|
||||
};
|
||||
app.UseRequestLocalization(new RequestLocalizationOptions
|
||||
{
|
||||
DefaultRequestCulture = new RequestCulture("it-IT"),
|
||||
SupportedCultures = supportedCultures,
|
||||
FallBackToParentCultures = false
|
||||
});
|
||||
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.CreateSpecificCulture("it-IT");
|
||||
|
||||
// fix forwarders
|
||||
app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
{
|
||||
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
||||
});
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
@@ -56,5 +78,35 @@ namespace LiMan.UI
|
||||
endpoints.MapFallbackToPage("/_Host");
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// cookie applicazione da 14 gg (defaul) a 30
|
||||
services.ConfigureApplicationCookie(o =>
|
||||
{
|
||||
o.ExpireTimeSpan = TimeSpan.FromDays(30);
|
||||
o.SlidingExpiration = true;
|
||||
});
|
||||
|
||||
services.AddStackExchangeRedisCache(options =>
|
||||
{
|
||||
//options.Configuration = "localhost:6379";
|
||||
options.ConfigurationOptions = new StackExchange.Redis.ConfigurationOptions() { KeepAlive = 180, DefaultDatabase = 5, EndPoints = { { "localhost", 6379 } } };
|
||||
options.InstanceName = "LiMan";
|
||||
});
|
||||
|
||||
services.AddLocalization();
|
||||
|
||||
services.AddRazorPages();
|
||||
services.AddServerSideBlazor();
|
||||
|
||||
services.AddSingleton<IConfiguration>(Configuration);
|
||||
services.AddScoped<MessageService>();
|
||||
services.AddSingleton<LiManDataService>();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user