diff --git a/MP.AppAuth/Controllers/AppAuthController.cs b/MP.AppAuth/Controllers/AppAuthController.cs index fec0b23a..03b2c650 100644 --- a/MP.AppAuth/Controllers/AppAuthController.cs +++ b/MP.AppAuth/Controllers/AppAuthController.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Configuration; +using MP.AppAuth.Models; using NLog; using System; using System.Collections.Generic; @@ -14,7 +15,7 @@ namespace MP.AppAuth.Controllers private static IConfiguration _configuration; private static AppAuthContext dbCtx; - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + private static Logger Log = LogManager.GetCurrentClassLogger(); #endregion Private Fields @@ -35,9 +36,9 @@ namespace MP.AppAuth.Controllers /// Elenco Record x Gruppi /// /// - public List AnagGruppiFilt(string codTipo) + public List AnagGruppiFilt(string codTipo) { - List dbResult = new List(); + List dbResult = new List(); using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { dbResult = localDbCtx @@ -51,9 +52,9 @@ namespace MP.AppAuth.Controllers /// Elenco Record x Gruppi /// /// - public List AnagGruppiGetAll() + public List AnagGruppiGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { dbResult = localDbCtx @@ -63,9 +64,9 @@ namespace MP.AppAuth.Controllers return dbResult; } - public List AnagOpGetAll(string searchVal) + public List AnagOpGetAll(string searchVal) { - List dbResult = new List(); + List dbResult = new List(); using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { if (!string.IsNullOrEmpty(searchVal)) @@ -85,9 +86,9 @@ namespace MP.AppAuth.Controllers // ritorno return dbResult; } - public List AnagOpByGruppoGetFilt(string codGruppo, string searchVal) + public List AnagOpByGruppoGetFilt(string codGruppo, string searchVal) { - List dbResult = new List(); + List dbResult = new List(); using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { if (!string.IsNullOrEmpty(searchVal)) @@ -159,9 +160,9 @@ namespace MP.AppAuth.Controllers /// Elenco Record x gestione Update /// /// - public List UpdManGetAll() + public List UpdManGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { dbResult = localDbCtx @@ -176,9 +177,9 @@ namespace MP.AppAuth.Controllers /// Elenco Record x gestione Update /// /// - public List VocabolarioGetAll() + public List VocabolarioGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (AppAuthContext localDbCtx = new AppAuthContext(_configuration)) { dbResult = localDbCtx diff --git a/MP.AppAuth/Controllers/MPController .cs b/MP.AppAuth/Controllers/MPController .cs index 19542ec7..66fb1868 100644 --- a/MP.AppAuth/Controllers/MPController .cs +++ b/MP.AppAuth/Controllers/MPController .cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Configuration; +using MP.AppAuth.Models; using NLog; using System; using System.Collections.Generic; @@ -26,14 +27,13 @@ namespace MP.AppAuth.Controllers #region Public Methods - /// /// Elenco Record x AnagKeyValue /// /// - public List AnagKeyValuesGetAll() + public List AnagKeyValuesGetAll() { - List dbResult = new List(); + List dbResult = new List(); using (MoonProContext localDbCtx = new MoonProContext(_configuration)) { dbResult = localDbCtx @@ -43,6 +43,22 @@ namespace MP.AppAuth.Controllers return dbResult; } + /// + /// Elenco Record x Config + /// + /// + public List ConfigGetAll() + { + List dbResult = new List(); + using (MoonProContext localDbCtx = new MoonProContext(_configuration)) + { + dbResult = localDbCtx + .DbSetConfig + .ToList(); + } + return dbResult; + } + public void Dispose() { if (dbController != null) @@ -52,6 +68,22 @@ namespace MP.AppAuth.Controllers } } + /// + /// Elenco Record x Vocabolario + /// + /// + public List VocabolarioGetAll() + { + List dbResult = new List(); + using (MoonProContext localDbCtx = new MoonProContext(_configuration)) + { + dbResult = localDbCtx + .DbSetVocabolario + .ToList(); + } + return dbResult; + } + #endregion Public Methods #region Private Fields diff --git a/MP.AppAuth/Models/AnagKeyValueModel.cs b/MP.AppAuth/Models/AnagKeyValueModel.cs index 6efcc279..76556cd7 100644 --- a/MP.AppAuth/Models/AnagKeyValueModel.cs +++ b/MP.AppAuth/Models/AnagKeyValueModel.cs @@ -15,11 +15,19 @@ namespace MP.AppAuth.Models { #region Public Properties - [Key] + [Key, Column("nomeVar")] public string NomeVar { get; set; } + + [Column("valInt")] public int? ValInt { get; set; } + + [Column("valFloat")] public double? ValFloat { get; set; } + + [Column("valString")] public string ValString { get; set; } + + [Column("descrizione")] public string Descrizione { get; set; } #endregion Public Properties diff --git a/MP.AppAuth/Models/ConfigModel.cs b/MP.AppAuth/Models/ConfigModel.cs index 995d09aa..a5cc1553 100644 --- a/MP.AppAuth/Models/ConfigModel.cs +++ b/MP.AppAuth/Models/ConfigModel.cs @@ -1,18 +1,27 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations; #nullable disable namespace MP.AppAuth.Models { - public partial class Config + public partial class ConfigModel { #region Public Properties - public string Chiave { get; set; } - public string Note { get; set; } - public string Valore { get; set; } - public string ValoreStd { get; set; } + [Key, Column("chiave")] + public string Chiave { get; set; } = ""; + + [Column("valore")] + public string Valore { get; set; } = ""; + + [Column("valoreStd")] + public string ValoreStd { get; set; } = ""; + + [Column("note")] + public string Note { get; set; } = ""; #endregion Public Properties } diff --git a/MP.AppAuth/Models/Vocabolario.cs b/MP.AppAuth/Models/Vocabolario.cs index 15b6f1c6..4e48b850 100644 --- a/MP.AppAuth/Models/Vocabolario.cs +++ b/MP.AppAuth/Models/Vocabolario.cs @@ -12,9 +12,9 @@ namespace MP.AppAuth.Models { #region Public Properties - public string Lemma { get; set; } - public string Lingua { get; set; } - public string Traduzione { get; set; } + public string Lemma { get; set; } = ""; + public string Lingua { get; set; } = ""; + public string Traduzione { get; set; } = ""; #endregion Public Properties } diff --git a/MP.AppAuth/MoonProContext.cs b/MP.AppAuth/MoonProContext.cs index d8bb56a6..7f99d0b8 100644 --- a/MP.AppAuth/MoonProContext.cs +++ b/MP.AppAuth/MoonProContext.cs @@ -61,7 +61,7 @@ namespace MP.AppAuth public virtual DbSet AnagraficaIngressis { get; set; } public virtual DbSet AnagraficaMicroStatis { get; set; } public virtual DbSet AnagraficaOperatoris { get; set; } - public virtual DbSet Configs { get; set; } + public virtual DbSet DbSetConfig { get; set; } public virtual DbSet DatiMacchines { get; set; } public virtual DbSet DbSetAnagKeyValues { get; set; } public virtual DbSet FamigliaTipoIngressis { get; set; } @@ -263,7 +263,7 @@ namespace MP.AppAuth entity.Property(e => e.Nome).HasMaxLength(50); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.HasKey(e => e.Chiave); diff --git a/MP.Land/Components/CompareAnagKeyVal.razor b/MP.Land/Components/CompareAnagKeyVal.razor new file mode 100644 index 00000000..918fa73a --- /dev/null +++ b/MP.Land/Components/CompareAnagKeyVal.razor @@ -0,0 +1,5 @@ +

CompareAnagKeyVal

+ +@code { + +} diff --git a/MP.Land/Components/CompareConfig.razor b/MP.Land/Components/CompareConfig.razor new file mode 100644 index 00000000..dbadb4f1 --- /dev/null +++ b/MP.Land/Components/CompareConfig.razor @@ -0,0 +1,5 @@ +

CompareConfig

+ +@code { + +} diff --git a/MP.Land/Components/CompareVocabolario.razor b/MP.Land/Components/CompareVocabolario.razor new file mode 100644 index 00000000..52c03f5b --- /dev/null +++ b/MP.Land/Components/CompareVocabolario.razor @@ -0,0 +1,5 @@ +

CompareVocabolario

+ +@code { + +} diff --git a/MP.Land/Components/DataPager.razor b/MP.Land/Components/DataPager.razor deleted file mode 100644 index 7c046b68..00000000 --- a/MP.Land/Components/DataPager.razor +++ /dev/null @@ -1,54 +0,0 @@ -
-
-
-
- @if (totalCount > 0) - { -
    -
  • -
  • - @for (int i = @startPage; i <= endPage; ++i) - { - var pageNum = i; -
  • - } -
  • -
  • -
- } -
-
-
-
- @if (showLoading) - { -
-
-
- } -
-
-
-
-
-
- @if (!showLoading) - { - @totalCount records - } -
-
- @if (totalCount > 0) - { -
- -
- } -
-
-
-
\ No newline at end of file diff --git a/MP.Land/Components/DataPager.razor.cs b/MP.Land/Components/DataPager.razor.cs deleted file mode 100644 index 62cd969c..00000000 --- a/MP.Land/Components/DataPager.razor.cs +++ /dev/null @@ -1,189 +0,0 @@ -using Microsoft.AspNetCore.Components; -using System; -using System.Threading.Tasks; - -namespace MP.Land.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; } = 6; - - 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 numPageChanged { get; set; } - - [Parameter] - public EventCallback 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 - } -} \ No newline at end of file diff --git a/MP.Land/Components/LoadingData.razor b/MP.Land/Components/LoadingData.razor deleted file mode 100644 index 2aa17997..00000000 --- a/MP.Land/Components/LoadingData.razor +++ /dev/null @@ -1,7 +0,0 @@ -@*

Working

*@ -
-
-

loading data

- -
-
\ No newline at end of file diff --git a/MP.Land/Data/AppAuthService.cs b/MP.Land/Data/AppAuthService.cs index e8b83494..2b966a89 100644 --- a/MP.Land/Data/AppAuthService.cs +++ b/MP.Land/Data/AppAuthService.cs @@ -11,40 +11,12 @@ using System.Diagnostics; using System.Text; using Newtonsoft.Json; using System.Diagnostics.Eventing.Reader; +using MP.AppAuth.Models; namespace MP.Land.Data { public class AppAuthService : IDisposable { - #region Private Fields - - private static IConfiguration _configuration; - - private static ILogger _logger; - - private static List ElencoMacchine = new List(); - - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - - private readonly IDistributedCache distributedCache; - - private readonly IMemoryCache memoryCache; - - /// - /// Durata assoluta massima della cache - /// - private int chAbsExp = 15; - - /// - /// Durata della cache in modalità inattiva (non acceduta) prima di venire rimossa - /// NON estende oltre il tempo massimo di validità della cache (chAbsExp) - /// - private int chSliExp = 5; - - private Dictionary Vocabolario = new Dictionary(); - - #endregion Private Fields - #region Public Fields public static AppAuth.Controllers.AppAuthController dbController; @@ -75,29 +47,141 @@ namespace MP.Land.Data } } - - #endregion Public Constructors - #region Private Properties + #region Public Methods - private DistributedCacheEntryOptions cacheOpt + public async Task> AnagGruppiAll() { - get - { - return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp)); - } + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.AnagGruppiGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagGruppiAll: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); } - private DistributedCacheEntryOptions cacheOptLong + public async Task> AnagGruppiFilt(string codTipo) { - get - { - return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp * 10)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp)); - } + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.AnagGruppiFilt(codTipo); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagGruppiFilt: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); } - #endregion Private Properties + public async Task> AnagKeyValList() + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = MpDbController.AnagKeyValuesGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagKeyValList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + public async Task> AnagOperByGroupList(string codGruppo, string searchVal) + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + var rawData = dbController + .AnagOpByGruppoGetFilt(codGruppo, searchVal); + dbResult = rawData + .GroupBy(user => user.MatrOpr) + .Select(grp => grp.First()) + .ToList(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagOperByGroupList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + public async Task> AnagOperList(string searchVal) + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.AnagOpGetAll(searchVal); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per AnagOperList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + public async Task> ConfigList() + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = MpDbController.ConfigGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per ConfigList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + public void Dispose() + { + // Clear database controller + dbController.Dispose(); + MpDbController.Dispose(); + } + + public async Task ResetCache() + { + string cacheKey = ":MP:VOCAB"; + await distributedCache.RemoveAsync(cacheKey); + // reset in RAM + Vocabolario = new Dictionary(); + CheckVoc(); + } + + public string Traduci(string lemma, string lingua = "IT") + { + string answ = $"__{lemma}__"; + string keyReq = $"{lingua}#{lemma}"; + CheckVoc(); + // cerco in vocabolario... + if (Vocabolario.ContainsKey(keyReq)) + { + answ = Vocabolario[keyReq]; + } + return answ; + } + + public async Task> UpdManList() + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.UpdManGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per UpdManList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + public async Task> VocabolarioList() + { + List dbResult = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = MpDbController.VocabolarioGetAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata lettura da DB per VocabolarioList: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); + } + + #endregion Public Methods #region Protected Methods @@ -130,113 +214,53 @@ namespace MP.Land.Data #endregion Protected Methods - #region Public Methods + #region Private Fields - public async Task> AnagGruppiAll() - { - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.AnagGruppiGetAll(); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AnagGruppiAll: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); - } + private static IConfiguration _configuration; - public async Task> AnagGruppiFilt(string codTipo) - { - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.AnagGruppiFilt(codTipo); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AnagGruppiFilt: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); - } - public async Task> AnagOperByGroupList(string codGruppo, string searchVal) - { - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - var rawData = dbController - .AnagOpByGruppoGetFilt(codGruppo, searchVal); - dbResult = rawData - .GroupBy(user => user.MatrOpr) - .Select(grp => grp.First()) - .ToList(); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AnagOperByGroupList: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); - } + private static ILogger _logger; - public async Task> AnagOperList(string searchVal) - { - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.AnagOpGetAll(searchVal); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AnagOperList: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); - } + private static List ElencoMacchine = new List(); - public void Dispose() - { - // Clear database controller - dbController.Dispose(); - MpDbController.Dispose(); - } + private static Logger Log = LogManager.GetCurrentClassLogger(); - public string Traduci(string lemma, string lingua = "IT") + private readonly IDistributedCache distributedCache; + + private readonly IMemoryCache memoryCache; + + /// + /// Durata assoluta massima della cache + /// + private int chAbsExp = 15; + + /// + /// Durata della cache in modalità inattiva (non acceduta) prima di venire rimossa NON + /// estende oltre il tempo massimo di validità della cache (chAbsExp) + /// + private int chSliExp = 5; + + private Dictionary Vocabolario = new Dictionary(); + + #endregion Private Fields + + #region Private Properties + + private DistributedCacheEntryOptions cacheOpt { - string answ = $"__{lemma}__"; - string keyReq = $"{lingua}#{lemma}"; - CheckVoc(); - // cerco in vocabolario... - if (Vocabolario.ContainsKey(keyReq)) + get { - answ = Vocabolario[keyReq]; + return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp)); } - return answ; } - public async Task> UpdManList() + private DistributedCacheEntryOptions cacheOptLong { - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.UpdManGetAll(); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per UpdManList: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); + get + { + return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp * 10)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp)); + } } - public async Task> AnagKeyValList() - { - List dbResult = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = MpDbController.AnagKeyValuesGetAll(); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AnagKeyValList: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(dbResult); - } - - public async Task ResetCache() - { - string cacheKey = ":MP:VOCAB"; - await distributedCache.RemoveAsync(cacheKey); - // reset in RAM - Vocabolario = new Dictionary(); - CheckVoc(); - } - - #endregion Public Methods + #endregion Private Properties } } \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 32ed5ef7..9a0e9d39 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.16.2407.1718 + 6.16.2407.1819 diff --git a/MP.Land/Pages/ConfSync.razor b/MP.Land/Pages/ConfSync.razor new file mode 100644 index 00000000..b5650add --- /dev/null +++ b/MP.Land/Pages/ConfSync.razor @@ -0,0 +1,73 @@ +@page "/ConfSync" +
+
+
+ +
+
+

Aggiornamento Configurazioni

+
+ Gestione Sync configurazioni su DB +
+

Selezionare la tabella da sincronizzare

+
+
+
+ Aggiorna +
+ +
+
+
+@if (showUpdate) +{ +
+ +
+
+ @outMessages +
+
+ @if (showProgress) + { +
+
+
+ } +
+
+
+ +} +
+
+ @if (isLoading) + { + + } + @* else if (totalCount == 0) + { +
Nessun record trovato
+ } *@ + else + { +
+ @* @foreach (var item in ListRecords) + { +
+ +
+ } *@ +
+ +
+
+ +
+
+ +
+
+ } +
+
\ No newline at end of file diff --git a/MP.Land/Pages/ConfSync.razor.cs b/MP.Land/Pages/ConfSync.razor.cs new file mode 100644 index 00000000..94bf26d3 --- /dev/null +++ b/MP.Land/Pages/ConfSync.razor.cs @@ -0,0 +1,173 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Configuration; +using MP.AppAuth; +using MP.AppAuth.Models; +using MP.Land.Data; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Land.Pages +{ + public partial class ConfSync : IDisposable + { + #region Public Methods + + public void Dispose() + { + ListAnagKeyValLoc = null; + ListConfigLoc = null; + ListVocabolarioLoc = null; + ListAnagKeyValRem = null; + ListConfigRem = null; + ListVocabolarioRem = null; + GC.Collect(); + } + + #endregion Public Methods + + #region Protected Fields + + protected int numDone = 0; + protected int numTot = 0; + protected double TotalMb = 0; + protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16"); + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService AppMService { get; set; } + + [Inject] + protected IConfiguration Configuration { get; set; } + + [Inject] + protected AppAuthService DataService { get; set; } + + [Inject] + protected LicenseService LicServ { get; set; } = null!; + + protected string outMessages { get; set; } = ""; + protected int percLoading { get; set; } = 0; + protected bool showProgress { get; set; } = false; + protected bool showUpdate { get; set; } = false; + protected bool isLoading { get; set; } = false; + + #endregion Protected Properties + + #region Protected Methods + + /// + /// Cicla su tutti i record ed effettua il download + /// + protected async Task RefreshData() + { + // init progress... + showProgress = true; + showUpdate = true; +#if false + outMessages = $"Iniziato download per {numTot} packages"; + StateHasChanged(); + percLoading = 0; + TotalMb = 0; + numDone = 0; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + // ciclo su tutti quelli con licenza valida... + List rawList = ListRecords + .Where(x => !string.IsNullOrEmpty(x.LicenseKey)).ToList(); + List authList = new List(); + + // ciclo SOLO tra quelli davvero autorizzati... + foreach (var item in rawList) + { + if (LicServ.checkLicenseActive(item.LicenseKey)) + { + authList.Add(item); + } + } + numTot = authList.Count; + foreach (var item in authList) + { + long size = 0; + size = await scaricaSingolo(item); + TotalMb += (double)size / (1024 * 1024); + outMessages = $"Scaricati {numDone}/{numTot} packages | {TotalMb:N2} Mb"; + StateHasChanged(); + await Task.Delay(1); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + outMessages = $"Effettuato download di {numDone} update | {TotalMb:N2} Mb in {ts.TotalSeconds:N2} s"; + StateHasChanged(); +#endif + await Task.Delay(1000); + showProgress = false; + StateHasChanged(); + } + + protected string localPath(string localRepo) + { + return @$"{Configuration["ServerConf:downloadPath"]}\{localRepo}\{Configuration["appVers"]}"; ; + } + + protected override async Task OnInitializedAsync() + { + AppMService.ShowSearch = false; + AppMService.PageName = "Config Sync"; + AppMService.PageIcon = "fas fa-file-import pr-2"; + await ReloadData(); + } + + protected async Task ReloadData() + { + isLoading = true; + await Task.Delay(1); + ListAnagKeyValLoc = await DataService.AnagKeyValList(); + await Task.Delay(1); + ListConfigLoc = await DataService.ConfigList(); + await Task.Delay(1); + ListVocabolarioLoc = await DataService.VocabolarioList(); + isLoading = false; + } + + #endregion Protected Methods + + #region Private Fields + + + private List ListAnagKeyValLoc { get; set; } = new List(); + private List ListConfigLoc { get; set; } = new List(); + private List ListVocabolarioLoc { get; set; } = new List(); + + private List ListAnagKeyValRem { get; set; } = new List(); + private List ListConfigRem { get; set; } = new List(); + private List ListVocabolarioRem { get; set; } = new List(); + + #endregion Private Fields + + #region Private Methods + + private async Task scaricaSingolo(UpdMan item) + { + long size = 0; + if (item.IsAuth) + { + size = updateManAuth.downloadLatest(item.ManifestUrl, localPath(item.LocalRepo), item.PackName); + } + else + { + size = UpdateMan.obj.downloadLatest(item.ManifestUrl, localPath(item.LocalRepo), item.PackName); + } + numDone++; + percLoading = 100 * numDone / numTot; + return await Task.FromResult(size); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.Land/Pages/UpdateManager.razor b/MP.Land/Pages/UpdateManager.razor index 8e50d9b2..0226e4b8 100644 --- a/MP.Land/Pages/UpdateManager.razor +++ b/MP.Land/Pages/UpdateManager.razor @@ -1,8 +1,5 @@ @page "/UpdateManager" -@using MP.Land.Data -@using MP.Land.Components -@inject LicenseService LicServ
diff --git a/MP.Land/Pages/UpdateManager.razor.cs b/MP.Land/Pages/UpdateManager.razor.cs index 83737913..5a74ffdf 100644 --- a/MP.Land/Pages/UpdateManager.razor.cs +++ b/MP.Land/Pages/UpdateManager.razor.cs @@ -25,9 +25,13 @@ namespace MP.Land.Pages #region Protected Fields protected int numDone = 0; + protected int numTot = 0; + protected int totalCount = 0; + protected double TotalMb = 0; + protected UpdateMan updateManAuth = new UpdateMan("SWDownloader", "viaD@nte16"); #endregion Protected Fields @@ -43,6 +47,9 @@ namespace MP.Land.Pages [Inject] protected AppAuthService DataService { get; set; } + [Inject] + protected LicenseService LicServ { get; set; } = null!; + protected string outMessages { get; set; } = ""; protected int percLoading { get; set; } = 0; protected bool showProgress { get; set; } = false; @@ -104,20 +111,13 @@ namespace MP.Land.Pages return @$"{Configuration["ServerConf:downloadPath"]}\{localRepo}\{Configuration["appVers"]}"; ; } - protected override void OnInitialized() + protected override async Task OnInitializedAsync() { + ListRecords = null; + await Task.Delay(1); AppMService.ShowSearch = false; AppMService.PageName = "Update Manager"; AppMService.PageIcon = "fas fa-download pr-2"; - } - - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } - - protected async Task ReloadAllData() - { await ReloadData(); } diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index a1db7913..b8f14feb 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo Tablet MAPO - DotNet6 -

Versione: 6.16.2407.1718

+

Versione: 6.16.2407.1819


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index 71c23879..799ff6e0 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2407.1718 +6.16.2407.1819 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index 198630c5..b45f6295 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2407.1718 + 6.16.2407.1819 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false diff --git a/MP.Land/Shared/NavMenu.razor b/MP.Land/Shared/NavMenu.razor index 83676332..6d5d66a5 100644 --- a/MP.Land/Shared/NavMenu.razor +++ b/MP.Land/Shared/NavMenu.razor @@ -22,11 +22,11 @@ Update Manager - @**@ +