Fix gestione rimbalzo doppio update totalcount

This commit is contained in:
Samuele Locatelli
2022-12-28 12:11:56 +01:00
parent 665f259370
commit cab86305cf
9 changed files with 187 additions and 141 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
@if (elencoOPeratori != null)
@if (elencoOperatori != null)
{
<div class="d-flex justify-content-between" style="flex-flow: wrap;">
@foreach (var item in elencoOPeratori)
@foreach (var item in elencoOperatori)
{
<div class="card col-4">
<div class="card-header list-group-item-info">
+106 -73
View File
@@ -1,65 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.INVE;
using MP.INVE.Shared;
using MP.INVE.Components;
using MP.INVE.Data;
using MP.Data.DatabaseModels;
using MP.INVE.Data;
namespace MP.INVE.Components
{
public partial class ListQrOpr
{
#region Public Properties
[Parameter]
public SelectQrOperatoreParams currParams { get; set; } = null!;
[Parameter]
public bool isLoading { get; set; }
[Inject]
protected MiDataService MIService { get; set; } = null!;
[Inject]
private IConfiguration Configuration { get; set; } = null!;
protected List<AnagOperatoriModel>? elencoOPeratori = new List<AnagOperatoriModel>();
[Parameter]
public EventCallback<int> TotalChanged { get; set; }
private SelectQrOperatoreParams? lastParams { get; set; } = null;
#endregion Public Properties
#region Protected Fields
protected List<AnagOperatoriModel>? elencoOperatori = new List<AnagOperatoriModel>();
protected List<AnagOperatoriModel>? SearchRecords = new List<AnagOperatoriModel>();
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await Task.Delay(50);
if (firstRender)
{
//await reloadData(true);
}
}
protected override async Task OnParametersSetAsync()
{
await reloadData(true);
}
private int _idOperatore = 0;
protected int idOperatore
{
get => _idOperatore;
set => _idOperatore = value;
}
private string _authKey = "";
#endregion Protected Fields
#region Protected Properties
protected string authKey
{
get => _authKey;
set => _authKey = value;
}
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; }
protected int idOperatore
{
get => _idOperatore;
set => _idOperatore = value;
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MiDataService MIService { get; set; } = null!;
protected string rawCode
{
get
@@ -70,23 +63,89 @@ namespace MP.INVE.Components
}
}
#endregion Protected Properties
#region Protected Methods
//protected override async Task OnAfterRenderAsync(bool firstRender)
//{
// await Task.Delay(50);
// if (firstRender)
// {
// //await reloadData(true);
// }
//}
protected override async Task OnParametersSetAsync()
{
bool doReload = lastParams == null;
if (doReload || !currParams.Equals(lastParams))
{
lastParams = currParams.Clone();
await reloadData(true);
}
}
#endregion Protected Methods
#region Private Fields
private string _authKey = "";
private int _idOperatore = 0;
private int _totalCount = 0;
#endregion Private Fields
#region Private Properties
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private int currPage
{
get => currParams.CurrPage;
}
private int numRecord
{
get => currParams.NumRec;
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
TotalChanged.InvokeAsync(value);
}
}
}
#endregion Private Properties
#region Private Methods
private async Task reloadData(bool first)
{
elencoOPeratori = null;
elencoOperatori = null;
isLoading = true;
SearchRecords = MIService.ElencoOperatori();
totalCount = SearchRecords.Count;
elencoOPeratori = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
elencoOperatori = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
await Task.Delay(1);
if (first)
{
if (elencoOPeratori != null)
if (elencoOperatori != null)
{
foreach (var item in elencoOPeratori)
foreach (var item in elencoOperatori)
{
idOperatore = item.MatrOpr;
authKey = MIService.EncriptData(item.authKey);
@@ -98,33 +157,7 @@ namespace MP.INVE.Components
}
isLoading = false;
}
private int numRecord
{
get => currParams.NumRec;
set
{
currParams.NumRec = value;
StateHasChanged();
}
}
private int currPage
{
get => currParams.CurrPage;
set
{
currParams.CurrPage = value;
StateHasChanged();
}
}
private int totalCount
{
get => currParams.TotCount;
set
{
currParams.TotCount = value;
StateHasChanged();
}
}
#endregion Private Methods
}
}
+10 -9
View File
@@ -1,6 +1,4 @@
using MP.Data;
namespace MP.INVE.Data
namespace MP.INVE.Data
{
public class SelectQrOperatoreParams
{
@@ -14,15 +12,21 @@ namespace MP.INVE.Data
#region Public Properties
public int CurrPage { get; set; } = 1;
public int MaxRecord { get; set; } = 100;
public int NumRec { get; set; } = 6;
public int TotCount { get; set; } = 0;
public int MaxRecord { get; set; } = 100;
public string searchVal { get; set; } = "";
#endregion Public Properties
#region Public Methods
public SelectQrOperatoreParams Clone()
{
return (SelectQrOperatoreParams)this.MemberwiseClone();
}
public override bool Equals(object obj)
{
if (!(obj is SelectQrOperatoreParams item))
@@ -34,15 +38,12 @@ namespace MP.INVE.Data
if (MaxRecord != item.MaxRecord)
return false;
if (TotCount != item.TotCount)
return false;
if (NumRec != item.NumRec)
return false;
if (CurrPage != item.CurrPage)
return false;
return true;
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.INVE</RootNamespace>
<Version>6.16.2212.2811</Version>
<Version>6.16.2212.2812</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -13,7 +13,7 @@
}
else
{
<ListQrOpr currParams="@currParams" isLoading="@isLoading"></ListQrOpr>
<ListQrOpr currParams="@currParams" isLoading="@isLoading" TotalChanged="UpdateTotCount"></ListQrOpr>
}
</div>
<div class="card-footer py-1">
+64 -52
View File
@@ -1,65 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using MP.INVE;
using MP.INVE.Shared;
using MP.INVE.Components;
using MP.Data.DatabaseModels;
using MP.INVE.Data;
using Microsoft.AspNetCore.Http;
namespace MP.INVE.Pages
{
public partial class OperatoreQR
{
[Inject]
protected MiDataService MIService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
private IConfiguration Configuration { get; set; } = null!;
#region Protected Fields
protected SelectQrOperatoreParams currParams = new SelectQrOperatoreParams();
protected List<AnagOperatoriModel> listOperatori = new List<AnagOperatoriModel>();
protected SelectQrOperatoreParams currParams = new SelectQrOperatoreParams();
#endregion Protected Fields
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MiDataService MIService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
await Task.Delay(1);
}
private int totalCount
{
get => currParams.TotCount;
set
{
if (currParams.TotCount != value)
{
currParams.TotCount = value;
}
}
}
private int numRecord
{
get => currParams.NumRec;
set
{
if (currParams.NumRec != value)
{
currParams.NumRec = value;
}
}
}
#endregion Protected Methods
#region Private Properties
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private int currPage
{
get => currParams.CurrPage;
@@ -71,15 +60,38 @@ namespace MP.INVE.Pages
}
}
}
protected void ForceReload(int newNum)
private bool isLoading { get; set; } = false;
private int numRecord
{
numRecord = newNum;
get => currParams.NumRec;
set
{
if (currParams.NumRec != value)
{
currParams.NumRec = value;
}
}
}
protected void UpdateTotCount(int newTotCount)
{
totalCount = newTotCount;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
private bool isLoading { get; set; } = false;
private int totalCount { get; set; } = 0;
//{
// get => currParams.TotCount;
// set
// {
// if (currParams.TotCount != value)
// {
// currParams.TotCount = value;
// }
// }
//}
#endregion Private Properties
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOINVE </i>
<h4>Versione: 6.16.2212.2811</h4>
<h4>Versione: 6.16.2212.2812</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2212.2811
6.16.2212.2812
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2212.2811</version>
<version>6.16.2212.2812</version>
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>