diff --git a/MP.AppAuth/Controllers/MPController .cs b/MP.AppAuth/Controllers/MPController .cs index 6245b06a..ef49774c 100644 --- a/MP.AppAuth/Controllers/MPController .cs +++ b/MP.AppAuth/Controllers/MPController .cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using MP.AppAuth.Models; using NLog; using System; @@ -42,6 +43,58 @@ namespace MP.AppAuth.Controllers } return dbResult; } + /// + /// Elenco Record x AnagKeyValue + /// + /// + public bool AnagKeyValuesDelete(string NomeVar) + { + bool fatto = false; + using (MoonProContext localDbCtx = new MoonProContext(_configuration)) + { + var rec2del = localDbCtx + .DbSetAnagKeyValues + .Where(x => x.NomeVar == NomeVar) + .FirstOrDefault(); + if (rec2del != null) + { + localDbCtx.Remove(rec2del); + var res = localDbCtx.SaveChanges(); + fatto = res > 0; + } + } + return fatto; + } + /// + /// Upsert AnagKeyValue + /// + /// + public bool AnagKeyValuesUpsert(AnagKeyValueModel newRec) + { + bool fatto = false; + using (MoonProContext localDbCtx = new MoonProContext(_configuration)) + { + var currRec = localDbCtx + .DbSetAnagKeyValues + .Where(x => x.NomeVar == newRec.NomeVar) + .FirstOrDefault(); + if (currRec != null) + { + currRec.Descrizione = newRec.Descrizione; + currRec.ValInt = newRec.ValInt; + currRec.ValFloat = newRec.ValFloat; + currRec.ValString = newRec.ValString; + localDbCtx.Entry(currRec).State = EntityState.Modified; + } + else + { + localDbCtx.DbSetAnagKeyValues.Add(newRec); + } + var res = localDbCtx.SaveChanges(); + fatto = res > 0; + } + return fatto; + } /// /// Elenco Record x Config diff --git a/MP.AppAuth/DTO/CompAnagKeyVal.cs b/MP.AppAuth/DTO/CompAnagKeyVal.cs index 404f59d9..2cf38aa0 100644 --- a/MP.AppAuth/DTO/CompAnagKeyVal.cs +++ b/MP.AppAuth/DTO/CompAnagKeyVal.cs @@ -10,6 +10,7 @@ namespace MP.AppAuth.DTO public class CompAnagKeyVal { public int Idx { get; set; } = 0; + public string NomeVar { get; set; } = ""; public AnagKeyValueModel? Source { get; set; } = null; public AnagKeyValueModel? Dest { get; set; } = null; diff --git a/MP.Land/Components/CmpCompType.razor b/MP.Land/Components/CmpCompType.razor new file mode 100644 index 00000000..d659c619 --- /dev/null +++ b/MP.Land/Components/CmpCompType.razor @@ -0,0 +1,6 @@ +
+ + + + +
diff --git a/MP.Land/Components/CmpCompType.razor.cs b/MP.Land/Components/CmpCompType.razor.cs new file mode 100644 index 00000000..dd5e1124 --- /dev/null +++ b/MP.Land/Components/CmpCompType.razor.cs @@ -0,0 +1,90 @@ +using Microsoft.AspNetCore.Components; +using System.Threading.Tasks; + +namespace MP.Land.Components +{ + public partial class CmpCompType + { + #region Public Properties + + [Parameter] + public EventCallback EC_filtUpd { get; set; } + + #endregion Public Properties + + #region Public Classes + + public class Display + { + #region Public Properties + + public bool Dx { get; set; } = true; + public bool Equal { get; set; } = true; + public bool Diff { get; set; } = true; + public bool Sx { get; set; } = true; + + #endregion Public Properties + } + + #endregion Public Classes + + #region Protected Properties + + protected string cssDx + { + get => CurrDisp.Dx ? "btn-danger" : "btn-secondary"; + } + + protected string cssEq + { + get => CurrDisp.Equal ? "btn-info" : "btn-secondary"; + } + protected string cssDiff + { + get => CurrDisp.Diff ? "btn-primary" : "btn-secondary"; + } + + protected string cssSx + { + get => CurrDisp.Sx ? "btn-success" : "btn-secondary"; + } + + protected Display CurrDisp { get; set; } = new Display(); + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnInitialized() + { + CurrDisp = new Display(); + } + + protected async Task ToggleDx() + { + CurrDisp.Dx = !CurrDisp.Dx; + await EC_filtUpd.InvokeAsync(CurrDisp); + } + + protected async Task ToggleEqual() + { + CurrDisp.Equal = !CurrDisp.Equal; + await EC_filtUpd.InvokeAsync(CurrDisp); + } + + protected async Task ToggleDiff() + { + CurrDisp.Diff = !CurrDisp.Diff; + await EC_filtUpd.InvokeAsync(CurrDisp); + } + + + protected async Task ToggleSx() + { + CurrDisp.Sx = !CurrDisp.Sx; + await EC_filtUpd.InvokeAsync(CurrDisp); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP.Land/Components/CompareAnagKeyVal.razor b/MP.Land/Components/CompareAnagKeyVal.razor index 797b70e4..b75147ed 100644 --- a/MP.Land/Components/CompareAnagKeyVal.razor +++ b/MP.Land/Components/CompareAnagKeyVal.razor @@ -1,15 +1,17 @@ @if (ShowDetail) {
-
-
- Tabella AnagKeyVal - Confronto dati -
-
- + = - -
-
- +
+
+
+ Tabella AnagKeyVal - Confronto dati +
+
+ +
+
+ +
@@ -34,12 +36,22 @@ @foreach (var item in ListCompare) { - + - + @if (!item.IsEqual) + { + if (!item.DestExist) + { + + } + else if ( item.SrcExist) + { + + } + } - - @item.Source.NomeVar + + @item.NomeVar @if (item.SrcExist) @@ -82,21 +94,25 @@ } - @if (!item.IsEqual) + @if (item.DestExist) { - if (!item.DestExist) - { - - } - else if (!item.SrcExist) - { - - } - else - { - - } + } + @* else + { + if (!item.DestExist) + { + + } + else if (!item.SrcExist) + { + + } + else + { + + } + } *@ } diff --git a/MP.Land/Components/CompareAnagKeyVal.razor.cs b/MP.Land/Components/CompareAnagKeyVal.razor.cs index 82a87165..bf492783 100644 --- a/MP.Land/Components/CompareAnagKeyVal.razor.cs +++ b/MP.Land/Components/CompareAnagKeyVal.razor.cs @@ -1,6 +1,9 @@ using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Mvc.Formatters; +using Microsoft.JSInterop; using MP.AppAuth.DTO; using MP.AppAuth.Models; +using MP.Land.Data; using System; using System.Collections.Generic; using System.Linq; @@ -15,6 +18,9 @@ namespace MP.Land.Components [Parameter] public EventCallback EC_reqAct { get; set; } + [Parameter] + public EventCallback EC_reqReload { get; set; } + [Parameter] public List ListAnagKeyValLoc { get; set; } = new List(); @@ -26,19 +32,212 @@ namespace MP.Land.Components #endregion Public Properties - protected List ListCompareAll = new List(); + #region Protected Fields + protected List ListCompare = new List(); + protected List ListCompareAll = new List(); + + #endregion Protected Fields + #region Protected Properties + [Inject] + protected AppAuthService DataService { get; set; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + protected int numLoc { get; set; } = 0; protected int numRem { get; set; } = 0; - private bool isLoading { get; set; } = false; - private int totalCount { get; set; } = 0; - private int numRecord { get; set; } = 10; - private int currPage { get; set; } = 1; + #endregion Protected Properties + + #region Protected Methods + + protected string genClass(CompAnagKeyVal currItem) + { + string answ = currItem.IsEqual ? "text-dark" : currItem.SrcExist && currItem.DestExist ? "text-warning" : currItem.SrcExist ? "text-success" : "text-danger"; + //string answ = currItem.IsEqual ? "far fa-thumbs-up text-success" : "far fa-thumbs-down text-danger"; + return answ; + } + + protected override void OnParametersSet() + { + ForceReload(); + } + + private void ForceReload() + { + numLoc = ListAnagKeyValLoc != null ? ListAnagKeyValLoc.Count : 0; + numRem = ListAnagKeyValRem != null ? ListAnagKeyValRem.Count : 0; + // predispongo lista comparazione... + ListCompareAll = new List(); + int cIdx = 0; + // filtro EQUAL + if (currFilt.Equal) + { + foreach (var item in ListAnagKeyValRem) + { + CompAnagKeyVal newRec = new CompAnagKeyVal() + { + Idx = cIdx++, + NomeVar = item.NomeVar, + Source = item, + Dest = ListAnagKeyValLoc.Find(x => x.NomeVar == item.NomeVar) + }; + if (newRec.IsEqual) + { + ListCompareAll.Add(newRec); + } + } + } + + // ciclo valori src... + if (currFilt.Diff) + { + foreach (var item in ListAnagKeyValRem) + { + CompAnagKeyVal newRec = new CompAnagKeyVal() + { + Idx = cIdx++, + NomeVar = item.NomeVar, + Source = item, + Dest = ListAnagKeyValLoc.Find(x => x.NomeVar == item.NomeVar) + }; + if (!newRec.IsEqual && currFilt.Diff && newRec.SrcExist && newRec.DestExist) + { + ListCompareAll.Add(newRec); + } + } + } + + if (currFilt.Sx) + { + foreach (var item in ListAnagKeyValRem) + { + // se non c'è... + if (ListAnagKeyValLoc.Where(x => x.NomeVar == item.NomeVar).Count() == 0) + { + CompAnagKeyVal newRec = new CompAnagKeyVal() + { + Idx = cIdx++, + NomeVar = item.NomeVar, + Source = item, + Dest = ListAnagKeyValLoc.Find(x => x.NomeVar == item.NomeVar) + }; + if (!newRec.IsEqual) + { + ListCompareAll.Add(newRec); + } + } + } + } + if (currFilt.Dx) + { + // cerco eventuali record SOLO locali... + foreach (var item in ListAnagKeyValLoc) + { + // se non c'è... + if (ListAnagKeyValRem.Where(x => x.NomeVar == item.NomeVar).Count() == 0) + { + CompAnagKeyVal newRec = new CompAnagKeyVal() + { + Idx = cIdx++, + NomeVar = item.NomeVar, + Source = null, + Dest = item + }; + ListCompareAll.Add(newRec); + } + } + } + totalCount = ListCompareAll.Count; + // riordino... + ListCompareAll = ListCompareAll.OrderBy(x => x.NomeVar).ToList(); + // ciclo eventuali record locali rimasti + UpdPaging(); + } + + protected void SetFilter(CmpCompType.Display filtDisplay) + { + currFilt = filtDisplay; + ForceReload(); + } + + protected CmpCompType.Display currFilt { get; set; } = new CmpCompType.Display(); + + protected async Task RemLocal(CompAnagKeyVal currItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare il record?")) + return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.AnagKeyValDelete(currItem.Dest.NomeVar); + } + if (fatto) + { + await ReqReload(); + } + } + + protected async Task AddLocal(CompAnagKeyVal currItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.AnagKeyValAdd(currItem.Source); + } + if (fatto) + { + await ReqReload(); + } + } + protected async Task UpdLocal(CompAnagKeyVal currItem) + { + if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler aggiungere il record?")) + return; + + bool fatto = false; + if (currItem != null) + { + fatto = await DataService.AnagKeyValUpd(currItem.Source); + } + if (fatto) + { + await ReqReload(); + } + } + + /// + /// Report evento richiesta confronto AnagKeyVal + /// + protected async Task ReqCompare() + { + await EC_reqAct.InvokeAsync("AnagKeyVal"); + } + + /// + /// Report evento richiesta confronto AnagKeyVal + /// + protected async Task ReqReload() + { + await EC_reqReload.InvokeAsync("AnagKeyVal"); + } + + /// + /// Report evento richiesta reset confronto + /// + protected async Task ResetCompare() + { + await EC_reqAct.InvokeAsync(""); + } protected async Task SetNumRec(int newNum) { @@ -53,7 +252,7 @@ namespace MP.Land.Components protected async Task SetPage(int newNum) { - //isLoading = true; + isLoading = true; //ListCompare = null; //await Task.Delay(1); ////StateHasChanged(); @@ -66,61 +265,24 @@ namespace MP.Land.Components isLoading = false; } + #endregion Protected Methods - protected string genClass(CompAnagKeyVal currItem) - { - string answ = currItem.IsEqual? "far fa-thumbs-up text-success" : "far fa-thumbs-down text-danger"; - return answ; - } + #region Private Properties - #endregion Protected Properties + private int currPage { get; set; } = 1; + private bool isLoading { get; set; } = false; + private int numRecord { get; set; } = 10; + private int totalCount { get; set; } = 0; - #region Protected Methods + #endregion Private Properties - protected override void OnParametersSet() - { - numLoc = ListAnagKeyValLoc != null ? ListAnagKeyValLoc.Count : 0; - numRem = ListAnagKeyValRem != null ? ListAnagKeyValRem.Count : 0; - // predispongo lista comparazione... - ListCompareAll = new List(); - int cIdx = 0; - // ciclo valori src... - foreach (var item in ListAnagKeyValRem) - { - CompAnagKeyVal newRec = new CompAnagKeyVal() - { - Idx = cIdx, - Source = item, - Dest = ListAnagKeyValLoc.Find(x => x.NomeVar == item.NomeVar) - }; - ListCompareAll.Add(newRec); - } - totalCount = ListCompareAll.Count; - // ciclo eventuali record locali rimasti - UpdPaging(); - } + #region Private Methods private void UpdPaging() { ListCompare = ListCompareAll.Skip((currPage - 1) * numRecord).Take(numRecord).ToList(); } - /// - /// Report evento richiesta confronto AnagKeyVal - /// - protected async Task ReqCompare() - { - await EC_reqAct.InvokeAsync("AnagKeyVal"); - } - - /// - /// Report evento richiesta reset confronto - /// - protected async Task ResetCompare() - { - await EC_reqAct.InvokeAsync(""); - } - - #endregion Protected Methods + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Land/Data/AppAuthService.cs b/MP.Land/Data/AppAuthService.cs index f533d564..e85dae56 100644 --- a/MP.Land/Data/AppAuthService.cs +++ b/MP.Land/Data/AppAuthService.cs @@ -87,6 +87,42 @@ namespace MP.Land.Data return await Task.FromResult(dbResult); } + public async Task AnagKeyValDelete(string NomeVar) + { + bool answ = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + answ = MpDbController.AnagKeyValuesDelete(NomeVar); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"AnagKeyValDelete | Effettuata cancellazione | NomeVar: {NomeVar} | durata: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(answ); + } + + public async Task AnagKeyValAdd(AnagKeyValueModel currRec) + { + bool answ = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + answ = MpDbController.AnagKeyValuesUpsert(currRec); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"AnagKeyValAdd | Aggiunto rec | NomeVar: {currRec.NomeVar} | durata: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(answ); + } + + public async Task AnagKeyValUpd(AnagKeyValueModel currRec) + { + bool answ = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + answ = MpDbController.AnagKeyValuesUpsert(currRec); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"AnagKeyValUpd | Effettuata modifica | NomeVar: {currRec.NomeVar} | durata: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(answ); + } + public async Task> AnagOperByGroupList(string codGruppo, string searchVal) { List dbResult = new List(); diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 83f0afbb..b6b84ef3 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.16.2407.2212 + 6.16.2407.2219 diff --git a/MP.Land/Pages/ConfSync.razor b/MP.Land/Pages/ConfSync.razor index 0aa7b096..e9e04765 100644 --- a/MP.Land/Pages/ConfSync.razor +++ b/MP.Land/Pages/ConfSync.razor @@ -48,7 +48,7 @@ @if (string.IsNullOrEmpty(CompType) || showDetail("AnagKeyVal")) {
- +
} @if (string.IsNullOrEmpty(CompType) || showDetail("Config")) diff --git a/MP.Land/Pages/ConfSync.razor.cs b/MP.Land/Pages/ConfSync.razor.cs index ac804dcc..33e2dd9f 100644 --- a/MP.Land/Pages/ConfSync.razor.cs +++ b/MP.Land/Pages/ConfSync.razor.cs @@ -106,7 +106,34 @@ namespace MP.Land.Pages numDone++; await Task.Delay(100); showUpdate = false; - //await InvokeAsync(StateHasChanged); + } + + /// + /// rilettura parziale dati locali secondo codice richiesto + /// + /// + protected async Task ReloadPartial(string valReq) + { + isLoadingLoc = true; + await InvokeAsync(StateHasChanged); + switch (valReq) + { + case "AnagKeyVal": + await Task.Delay(tDelay); + listAnagKeyValLoc = await DataService.AnagKeyValList(); + break; + case "Config": + await Task.Delay(tDelay); + listConfigLoc = await DataService.ConfigList(); + break; + case "Vocabolario": + await Task.Delay(tDelay); + listVocabolarioLoc = await DataService.VocabolarioList(); + break; + default: + break; + } + isLoadingLoc = false; } protected void doClose() @@ -181,24 +208,6 @@ namespace MP.Land.Pages } } -#if false - 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); - } -#endif - #endregion Private Methods protected async Task DoCompare(string compType) diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index 746f8d04..e5506560 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.2212

+

Versione: 6.16.2407.2219


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index b743ce5f..53adf15e 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2407.2212 +6.16.2407.2219 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index 44fdbab7..8c0610fb 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2407.2212 + 6.16.2407.2219 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