update x sync: abbozzo metodi, compila OK

This commit is contained in:
Samuele Locatelli
2024-07-18 19:14:10 +02:00
parent b38dcb5953
commit af27e297d9
23 changed files with 524 additions and 437 deletions
+14 -13
View File
@@ -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
/// </summary>
/// <returns></returns>
public List<Models.AnagraficaGruppi> AnagGruppiFilt(string codTipo)
public List<AnagraficaGruppi> AnagGruppiFilt(string codTipo)
{
List<Models.AnagraficaGruppi> dbResult = new List<Models.AnagraficaGruppi>();
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
{
dbResult = localDbCtx
@@ -51,9 +52,9 @@ namespace MP.AppAuth.Controllers
/// Elenco Record x Gruppi
/// </summary>
/// <returns></returns>
public List<Models.AnagraficaGruppi> AnagGruppiGetAll()
public List<AnagraficaGruppi> AnagGruppiGetAll()
{
List<Models.AnagraficaGruppi> dbResult = new List<Models.AnagraficaGruppi>();
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
{
dbResult = localDbCtx
@@ -63,9 +64,9 @@ namespace MP.AppAuth.Controllers
return dbResult;
}
public List<Models.AnagraficaOperatori> AnagOpGetAll(string searchVal)
public List<AnagraficaOperatori> AnagOpGetAll(string searchVal)
{
List<Models.AnagraficaOperatori> dbResult = new List<Models.AnagraficaOperatori>();
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
{
if (!string.IsNullOrEmpty(searchVal))
@@ -85,9 +86,9 @@ namespace MP.AppAuth.Controllers
// ritorno
return dbResult;
}
public List<Models.AnagraficaOperatori> AnagOpByGruppoGetFilt(string codGruppo, string searchVal)
public List<AnagraficaOperatori> AnagOpByGruppoGetFilt(string codGruppo, string searchVal)
{
List<Models.AnagraficaOperatori> dbResult = new List<Models.AnagraficaOperatori>();
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
{
if (!string.IsNullOrEmpty(searchVal))
@@ -159,9 +160,9 @@ namespace MP.AppAuth.Controllers
/// Elenco Record x gestione Update
/// </summary>
/// <returns></returns>
public List<Models.UpdMan> UpdManGetAll()
public List<UpdMan> UpdManGetAll()
{
List<Models.UpdMan> dbResult = new List<Models.UpdMan>();
List<UpdMan> dbResult = new List<UpdMan>();
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
{
dbResult = localDbCtx
@@ -176,9 +177,9 @@ namespace MP.AppAuth.Controllers
/// Elenco Record x gestione Update
/// </summary>
/// <returns></returns>
public List<Models.Vocabolario> VocabolarioGetAll()
public List<Vocabolario> VocabolarioGetAll()
{
List<Models.Vocabolario> dbResult = new List<Models.Vocabolario>();
List<Vocabolario> dbResult = new List<Vocabolario>();
using (AppAuthContext localDbCtx = new AppAuthContext(_configuration))
{
dbResult = localDbCtx
+35 -3
View File
@@ -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
/// <summary>
/// Elenco Record x AnagKeyValue
/// </summary>
/// <returns></returns>
public List<Models.AnagKeyValueModel> AnagKeyValuesGetAll()
public List<AnagKeyValueModel> AnagKeyValuesGetAll()
{
List<Models.AnagKeyValueModel> dbResult = new List<Models.AnagKeyValueModel>();
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
{
dbResult = localDbCtx
@@ -43,6 +43,22 @@ namespace MP.AppAuth.Controllers
return dbResult;
}
/// <summary>
/// Elenco Record x Config
/// </summary>
/// <returns></returns>
public List<ConfigModel> ConfigGetAll()
{
List<ConfigModel> dbResult = new List<ConfigModel>();
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
}
}
/// <summary>
/// Elenco Record x Vocabolario
/// </summary>
/// <returns></returns>
public List<Vocabolario> VocabolarioGetAll()
{
List<Vocabolario> dbResult = new List<Vocabolario>();
using (MoonProContext localDbCtx = new MoonProContext(_configuration))
{
dbResult = localDbCtx
.DbSetVocabolario
.ToList();
}
return dbResult;
}
#endregion Public Methods
#region Private Fields
+9 -1
View File
@@ -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
+14 -5
View File
@@ -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
}
+3 -3
View File
@@ -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
}
+2 -2
View File
@@ -61,7 +61,7 @@ namespace MP.AppAuth
public virtual DbSet<AnagraficaIngressi> AnagraficaIngressis { get; set; }
public virtual DbSet<AnagraficaMicroStati> AnagraficaMicroStatis { get; set; }
public virtual DbSet<AnagraficaOperatori> AnagraficaOperatoris { get; set; }
public virtual DbSet<Config> Configs { get; set; }
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
public virtual DbSet<DatiMacchine> DatiMacchines { get; set; }
public virtual DbSet<AnagKeyValueModel> DbSetAnagKeyValues { get; set; }
public virtual DbSet<FamigliaTipoIngressi> FamigliaTipoIngressis { get; set; }
@@ -263,7 +263,7 @@ namespace MP.AppAuth
entity.Property(e => e.Nome).HasMaxLength(50);
});
modelBuilder.Entity<Config>(entity =>
modelBuilder.Entity<ConfigModel>(entity =>
{
entity.HasKey(e => e.Chiave);
@@ -0,0 +1,5 @@
<h3>CompareAnagKeyVal</h3>
@code {
}
+5
View File
@@ -0,0 +1,5 @@
<h3>CompareConfig</h3>
@code {
}
@@ -0,0 +1,5 @@
<h3>CompareVocabolario</h3>
@code {
}
-54
View File
@@ -1,54 +0,0 @@
<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="3">3</option>
<option value="6">6</option>
<option value="9">9</option>
</select>
</div>
}
</div>
</div>
</div>
</div>
-189
View File
@@ -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<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
}
}
-7
View File
@@ -1,7 +0,0 @@
@*<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>
+162 -138
View File
@@ -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<AppAuthService> _logger;
private static List<MP.AppAuth.Models.Macchine> ElencoMacchine = new List<MP.AppAuth.Models.Macchine>();
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private readonly IDistributedCache distributedCache;
private readonly IMemoryCache memoryCache;
/// <summary>
/// Durata assoluta massima della cache
/// </summary>
private int chAbsExp = 15;
/// <summary>
/// Durata della cache in modalità inattiva (non acceduta) prima di venire rimossa
/// NON estende oltre il tempo massimo di validità della cache (chAbsExp)
/// </summary>
private int chSliExp = 5;
private Dictionary<string, string> Vocabolario = new Dictionary<string, string>();
#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<List<AnagraficaGruppi>> AnagGruppiAll()
{
get
{
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp));
}
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
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<List<AnagraficaGruppi>> AnagGruppiFilt(string codTipo)
{
get
{
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddMinutes(chAbsExp * 10)).SetSlidingExpiration(TimeSpan.FromMinutes(chSliExp));
}
List<AnagraficaGruppi> dbResult = new List<AnagraficaGruppi>();
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<List<AnagKeyValueModel>> AnagKeyValList()
{
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
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<List<AnagraficaOperatori>> AnagOperByGroupList(string codGruppo, string searchVal)
{
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
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<List<AnagraficaOperatori>> AnagOperList(string searchVal)
{
List<AnagraficaOperatori> dbResult = new List<AnagraficaOperatori>();
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<List<ConfigModel>> ConfigList()
{
List<ConfigModel> dbResult = new List<ConfigModel>();
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<string, string>();
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<List<UpdMan>> UpdManList()
{
List<UpdMan> dbResult = new List<UpdMan>();
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<List<Vocabolario>> VocabolarioList()
{
List<Vocabolario> dbResult = new List<Vocabolario>();
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<List<AppAuth.Models.AnagraficaGruppi>> AnagGruppiAll()
{
List<AppAuth.Models.AnagraficaGruppi> dbResult = new List<AppAuth.Models.AnagraficaGruppi>();
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<List<AppAuth.Models.AnagraficaGruppi>> AnagGruppiFilt(string codTipo)
{
List<AppAuth.Models.AnagraficaGruppi> dbResult = new List<AppAuth.Models.AnagraficaGruppi>();
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<List<AppAuth.Models.AnagraficaOperatori>> AnagOperByGroupList(string codGruppo, string searchVal)
{
List<AppAuth.Models.AnagraficaOperatori> dbResult = new List<AppAuth.Models.AnagraficaOperatori>();
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<AppAuthService> _logger;
public async Task<List<AppAuth.Models.AnagraficaOperatori>> AnagOperList(string searchVal)
{
List<AppAuth.Models.AnagraficaOperatori> dbResult = new List<AppAuth.Models.AnagraficaOperatori>();
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<Macchine> ElencoMacchine = new List<Macchine>();
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;
/// <summary>
/// Durata assoluta massima della cache
/// </summary>
private int chAbsExp = 15;
/// <summary>
/// Durata della cache in modalità inattiva (non acceduta) prima di venire rimossa NON
/// estende oltre il tempo massimo di validità della cache (chAbsExp)
/// </summary>
private int chSliExp = 5;
private Dictionary<string, string> Vocabolario = new Dictionary<string, string>();
#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<List<AppAuth.Models.UpdMan>> UpdManList()
private DistributedCacheEntryOptions cacheOptLong
{
List<AppAuth.Models.UpdMan> dbResult = new List<AppAuth.Models.UpdMan>();
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<List<AppAuth.Models.AnagKeyValueModel>> AnagKeyValList()
{
List<AppAuth.Models.AnagKeyValueModel> dbResult = new List<AppAuth.Models.AnagKeyValueModel>();
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<string, string>();
CheckVoc();
}
#endregion Public Methods
#endregion Private Properties
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>6.16.2407.1718</Version>
<Version>6.16.2407.1819</Version>
</PropertyGroup>
<ItemGroup>
+73
View File
@@ -0,0 +1,73 @@
@page "/ConfSync"
<div class="alert alert-secondary shadow">
<div class="row">
<div class="col-12 col-md-3">
<img src="img/LogoMapoFull.png" class="img-fluid" width="200" />
</div>
<div class="col-12 col-md-6 text-center">
<h1>Aggiornamento Configurazioni</h1>
<div>
<b>Gestione Sync configurazioni su DB</b>
</div>
<p>Selezionare la tabella da sincronizzare</p>
</div>
<div class="col-12 col-md-3 text-center">
<div class="h2">
Aggiorna <i class="fas fa-sync"></i>
</div>
<button class="btn btn-success btn-block" disabled @onclick="() => RefreshData()">Aggiorna Confronto</button>
</div>
</div>
</div>
@if (showUpdate)
{
<div class="alert alert-success alert-dismissible fade show">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<div class="row">
<div class="col-4">
@outMessages
</div>
<div class="col-8">
@if (showProgress)
{
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:@percLoading%;"></div>
</div>
}
</div>
</div>
</div>
<ProgressDisplay></ProgressDisplay>
}
<div class="card shadow">
<div class="card-body">
@if (isLoading)
{
<LoadingData></LoadingData>
}
@* else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
} *@
else
{
<div class="row text-center">
@* @foreach (var item in ListRecords)
{
<div class="col-12 col-sm-6 col-xl-4 my-1">
<SingleDownload CurrItem="@item"></SingleDownload>
</div>
} *@
<div class="col-12 col-sm-6 col-xl-4 my-1">
<CompareAnagKeyVal></CompareAnagKeyVal>
</div>
<div class="col-12 col-sm-6 col-xl-4 my-1">
<CompareConfig></CompareConfig>
</div>
<div class="col-12 col-sm-6 col-xl-4 my-1">
<CompareVocabolario></CompareVocabolario>
</div>
</div>
}
</div>
</div>
+173
View File
@@ -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
/// <summary>
/// Cicla su tutti i record ed effettua il download
/// </summary>
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<UpdMan> rawList = ListRecords
.Where(x => !string.IsNullOrEmpty(x.LicenseKey)).ToList();
List<UpdMan> authList = new List<UpdMan>();
// 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<AnagKeyValueModel> ListAnagKeyValLoc { get; set; } = new List<AnagKeyValueModel>();
private List<ConfigModel> ListConfigLoc { get; set; } = new List<ConfigModel>();
private List<Vocabolario> ListVocabolarioLoc { get; set; } = new List<Vocabolario>();
private List<AnagKeyValueModel> ListAnagKeyValRem { get; set; } = new List<AnagKeyValueModel>();
private List<ConfigModel> ListConfigRem { get; set; } = new List<ConfigModel>();
private List<Vocabolario> ListVocabolarioRem { get; set; } = new List<Vocabolario>();
#endregion Private Fields
#region Private Methods
private async Task<long> 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
}
}
-3
View File
@@ -1,8 +1,5 @@
@page "/UpdateManager"
@using MP.Land.Data
@using MP.Land.Components
@inject LicenseService LicServ
<div class="alert alert-secondary shadow">
<div class="row">
+10 -10
View File
@@ -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();
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo Tablet MAPO - DotNet6</i>
<h4>Versione: 6.16.2407.1718</h4>
<h4>Versione: 6.16.2407.1819</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
6.16.2407.1718
6.16.2407.1819
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2407.1718</version>
<version>6.16.2407.1819</version>
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+4 -4
View File
@@ -22,11 +22,11 @@
<span class="fas fa-download fa-2x pr-2" aria-hidden="true"></span> Update Manager
</NavLink>
</li>
@*<li class="nav-item px-3">
<NavLink class="nav-link" href="ConfImport">
<span class="fas fa-file-import fa-2x pr-2" aria-hidden="true"></span> Config Import
<li class="nav-item px-3">
<NavLink class="nav-link" href="ConfSync">
<span class="fas fa-file-import fa-2x pr-2" aria-hidden="true"></span> Config Sync
</NavLink>
</li>*@
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="About">
<span class="fas fa-info-circle fa-2x pr-2" aria-hidden="true"></span> About
+6 -1
View File
@@ -7,4 +7,9 @@
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using MP.Land
@using MP.Land.Shared
@using MP.Land.Components
@using MP.Land.Shared
@using EgwCoreLib
@using EgwCoreLib.Razor
@using EgwCoreLib.Razor.Data
@using EgwCoreLib.Utils