Fix comportmaenti dispose vari

This commit is contained in:
Samuele Locatelli
2024-06-29 11:55:15 +02:00
parent d8f462f9ec
commit eefc5bd65a
11 changed files with 205 additions and 114 deletions
+88 -54
View File
@@ -11,7 +11,7 @@ using Microsoft.JSInterop;
namespace MagMan.UI.Components
{
public partial class MacStatusMan
public partial class MacStatusMan : IDisposable
{
#region Public Properties
@@ -23,6 +23,15 @@ namespace MagMan.UI.Components
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
}
#endregion Public Methods
#region Protected Properties
[Inject]
@@ -34,6 +43,8 @@ namespace MagMan.UI.Components
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected int maxRec { get; set; } = 1000;
[Inject]
protected MTAdminService MTService { get; set; } = null!;
@@ -43,35 +54,54 @@ namespace MagMan.UI.Components
protected TenantService TService { get; set; } = null!;
#endregion Protected Properties
private List<MachineModel> MachineList = new List<MachineModel>();
private List<LogMachineModel>? SearchRecords = null;
private List<LogMachineModel>? ListRecords = null;
private string currSearch = "";
private bool sortAsc = true;
private string sortField = "";
private int currPage { get; set; } = 1;
private bool isLoading { get; set; } = false;
private int machIdSel = 0;
private int MachineIdSel
#region Protected Methods
protected string CheckSel(LogMachineModel curItem)
{
get => machIdSel;
set
string answ = "";
#if false
if (CurrItem != null)
{
if (machIdSel != value)
{
machIdSel = value;
InvokeAsync(ReloadData);
}
answ = curItem.ProjDbId == CurrItem.ProjDbId ? "table-info" : "";
}
else
{
answ = curItem.ProjDbId == ProjDbId ? "table-info" : "";
}
#endif
return answ;
}
private int numRecord { get; set; } = 10;
protected void DoSelect(LogMachineModel? selItem)
{
#if false
if (selItem != null)
{
ProjDbId = selItem.ProjDbId;
}
else
{
ProjDbId = 0;
}
E_ProjSel.InvokeAsync(selItem);
#endif
}
protected async Task ForceReload(bool force)
{
#if false
CurrItem = null;
#endif
await ReloadData();
}
protected override void OnInitialized()
{
currSearch = "";
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
@@ -90,57 +120,58 @@ namespace MagMan.UI.Components
DoSelect(null);
InvokeAsync(ReloadData);
}
protected async Task SortRequested(Sorter.SortCallBack e)
{
sortField = e.ParamName;
sortAsc = e.IsAscending;
await ReloadData();
}
protected void DoSelect(LogMachineModel? selItem)
#endregion Protected Methods
#region Private Fields
private string currSearch = "";
private List<LogMachineModel>? ListRecords = null;
private int machIdSel = 0;
private List<MachineModel> MachineList = new List<MachineModel>();
private List<LogMachineModel>? SearchRecords = null;
private bool sortAsc = true;
private string sortField = "";
#endregion Private Fields
#region Private Properties
private int currPage { get; set; } = 1;
private bool isLoading { get; set; } = false;
private int MachineIdSel
{
#if false
if (selItem != null)
get => machIdSel;
set
{
ProjDbId = selItem.ProjDbId;
if (machIdSel != value)
{
machIdSel = value;
InvokeAsync(ReloadData);
}
}
else
{
ProjDbId = 0;
}
E_ProjSel.InvokeAsync(selItem);
#endif
}
protected async Task ForceReload(bool force)
{
#if false
CurrItem = null;
#endif
await ReloadData();
}
protected string CheckSel(LogMachineModel curItem)
{
string answ = "";
#if false
if (CurrItem != null)
{
answ = curItem.ProjDbId == CurrItem.ProjDbId ? "table-info" : "";
}
else
{
answ = curItem.ProjDbId == ProjDbId ? "table-info" : "";
}
#endif
return answ;
}
private int numRecord { get; set; } = 10;
#endregion Private Properties
#region Private Methods
private async void AppMService_EA_SearchUpdated()
{
currSearch = AppMService.SearchVal;
await ReloadData();
}
protected int maxRec { get; set; } = 1000;
private async Task ReloadData()
{
isLoading = true;
@@ -163,6 +194,7 @@ namespace MagMan.UI.Components
isLoading = false;
await InvokeAsync(StateHasChanged);
}
private void SortTable()
{
if (SearchRecords != null)
@@ -296,7 +328,7 @@ namespace MagMan.UI.Components
default:
break;
}
}
#endif
}
@@ -311,5 +343,7 @@ namespace MagMan.UI.Components
ListRecords = new List<LogMachineModel>();
}
}
#endregion Private Methods
}
}
+12 -5
View File
@@ -7,15 +7,13 @@ using Microsoft.JSInterop;
namespace MagMan.UI.Components
{
public partial class MovMag
public partial class MovMag : IDisposable
{
#region Public Properties
[Parameter]
public int CustomerId { get; set; } = 0;
[Parameter]
public int KeyNum { get; set; } = 0;
@@ -24,6 +22,15 @@ namespace MagMan.UI.Components
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
}
#endregion Public Methods
#region Protected Properties
[Inject]
@@ -58,7 +65,6 @@ namespace MagMan.UI.Components
return answ;
}
#if false
protected async Task CreateNew()
{
@@ -105,7 +111,7 @@ namespace MagMan.UI.Components
RawItemId = 0;
}
E_RawItemSel.InvokeAsync(RawItemId);
}
}
#endif
protected async Task ForceReload(bool force)
@@ -267,6 +273,7 @@ namespace MagMan.UI.Components
SearchRecords = SearchRecords.OrderByDescending(x => x.Note).ToList();
}
break;
case "UserId":
if (sortAsc)
{
+2 -4
View File
@@ -162,10 +162,8 @@
</div>
</td>
<td class="text-end">
@* <span class="@cssTime">@($"{item.ProgPerc:P2}")</span> *@
<ProgBar currVal="@(randPerc*100)" maxVal="100" yelLim="80" redLim="40"></ProgBar>
@* <ProgBar currVal="@item.ProgPerc" maxVal="1" yelLim="0.8" redLim="0.4"></ProgBar> *@
@* <ProgBar currVal="@(randPerc*100)" maxVal="100" yelLim="80" redLim="40"></ProgBar> *@
<ProgBar currVal="@item.ValAct" maxVal="@item.ValMax" yelLim="@(yLim*item.ValMax)" redLim="@(rLim*item.ValMax)"></ProgBar>
</td>
<td class="text-end">
@if (item.ProcTimeReal > 0)
+16 -9
View File
@@ -1,5 +1,4 @@
using EgwCoreLib.Razor;
using k8s.Models;
using MagMan.Core.Services;
using MagMan.Data.Admin.DbModels;
using MagMan.Data.Admin.Services;
@@ -10,7 +9,7 @@ using Microsoft.JSInterop;
namespace MagMan.UI.Components
{
public partial class ProjectMan
public partial class ProjectMan : IDisposable
{
#region Public Properties
@@ -25,6 +24,15 @@ namespace MagMan.UI.Components
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
}
#endregion Public Methods
#region Protected Properties
[Inject]
@@ -93,6 +101,8 @@ namespace MagMan.UI.Components
{
currSearch = "";
AppMService.EA_SearchUpdated += AppMService_EA_SearchUpdated;
yLim = Configuration.GetValue<double>("OptConf:projProgYLim");
rLim = Configuration.GetValue<double>("OptConf:projProgRLim");
}
protected override async Task OnParametersSetAsync()
@@ -174,6 +184,10 @@ namespace MagMan.UI.Components
private int numRecord { get; set; } = 10;
private double rLim { get; set; } = 0.4;
private double yLim { get; set; } = 0.8;
#endregion Private Properties
#region Private Methods
@@ -373,13 +387,6 @@ namespace MagMan.UI.Components
return isActive ? "text-dark" : "text-secondary text-decoration-line-through";
}
private Random rnd = new Random();
private double randPerc
{
get => rnd.NextDouble();
}
#endregion Private Methods
}
}
+10 -1
View File
@@ -8,7 +8,7 @@ using Microsoft.JSInterop;
namespace MagMan.UI.Components
{
public partial class ResourcesAct
public partial class ResourcesAct : IDisposable
{
#region Public Properties
@@ -20,6 +20,15 @@ namespace MagMan.UI.Components
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
}
#endregion Public Methods
#region Protected Properties
[Inject]
+10 -1
View File
@@ -7,7 +7,7 @@ using Microsoft.JSInterop;
namespace MagMan.UI.Components
{
public partial class ResourcesEstim
public partial class ResourcesEstim : IDisposable
{
#region Public Properties
@@ -19,6 +19,15 @@ namespace MagMan.UI.Components
#endregion Public Properties
#region Public Methods
public void Dispose()
{
AppMService.EA_SearchUpdated -= AppMService_EA_SearchUpdated;
}
#endregion Public Methods
#region Protected Properties
[Inject]
+32 -29
View File
@@ -143,6 +143,9 @@ namespace MagMan.UI.Components
#region Protected Properties
[Inject]
protected UserManager<IdentityUser> _UserManager { get; set; } = null!;
[Inject]
protected MessageService AppMService { get; set; } = null!;
@@ -172,15 +175,6 @@ namespace MagMan.UI.Components
#endif
}
/// <summary>
/// Abilitazoine gestione ROLES multipli
/// </summary>
private bool MultiRoleEnab = false;
/// <summary>
/// Abilitazoine gestione CLAIM multipli
/// </summary>
private bool MultiClaimEnab = false;
protected override async Task OnInitializedAsync()
{
currSearch = "";
@@ -218,8 +212,11 @@ namespace MagMan.UI.Components
#region Private Fields
private const string ADMIN_ROLE = "SuperAdmin";
private const string STD_CLAIM = "None";
private const string STD_CLAIM_VAL = "0";
private const string UNDEF_ROLE = "Undef";
/// <summary>
@@ -232,6 +229,16 @@ namespace MagMan.UI.Components
private string currSearch = "";
/// <summary>
/// Abilitazoine gestione CLAIM multipli
/// </summary>
private bool MultiClaimEnab = false;
/// <summary>
/// Abilitazoine gestione ROLES multipli
/// </summary>
private bool MultiRoleEnab = false;
/// <summary>
/// User corrente
/// </summary>
@@ -267,6 +274,19 @@ namespace MagMan.UI.Components
private string _CurrClaimType { get; set; } = "None";
private string _filtUserRole { get; set; } = "0";
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private Claim CurrentUserClaim
{
get => new Claim(CurrentUserClaimType, CurrentUserClaimVal);
}
/// <summary>
/// Claims attuali utente
/// </summary>
private List<ClaimRec> CurrentUserClaims { get; set; } = new List<ClaimRec>();
/// <summary>
/// Claim di default (Tipo)
/// </summary>
@@ -294,19 +314,13 @@ namespace MagMan.UI.Components
/// </summary>
private string CurrentUserRole { get; set; } = "User";
private int currPage { get; set; } = 1;
/// <summary>
/// Ruoli correnti utente
/// </summary>
private string[] CurrUserRoles { get; set; } = new string[] { "User" };
/// <summary>
/// Claims attuali utente
/// </summary>
private List<ClaimRec> CurrentUserClaims { get; set; } = new List<ClaimRec>();
private int currPage { get; set; } = 1;
/// <summary>
/// Gestione filtraggio dati
/// </summary>
@@ -380,11 +394,6 @@ namespace MagMan.UI.Components
// Refresh Users
await GetUsers();
}
[Inject]
protected UserManager<IdentityUser> _UserManager { get; set; } = null!;
[Inject]
private IConfiguration Configuration { get; set; } = null!;
private void EditUser(IdentityUser _IdentityUser)
{
@@ -518,11 +527,6 @@ namespace MagMan.UI.Components
isLoading = false;
}
private Claim CurrentUserClaim
{
get => new Claim(CurrentUserClaimType, CurrentUserClaimVal);
}
private async Task SaveUser()
{
try
@@ -694,6 +698,7 @@ namespace MagMan.UI.Components
}
}
#endregion Private Methods
#if false
protected async Task AddClaim(string rawClaim)
@@ -716,9 +721,7 @@ namespace MagMan.UI.Components
await InvokeAsync(StateHasChanged);
}
}
}
}
#endif
#endregion Private Methods
}
}
+10 -1
View File
@@ -8,8 +8,17 @@ using Microsoft.AspNetCore.Components;
namespace MagMan.UI.Pages
{
public partial class MachineStatus
public partial class MachineStatus : IDisposable
{
#region Public Methods
public void Dispose()
{
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
}
#endregion Public Methods
#region Protected Fields
protected int nKey = 0;
+10 -2
View File
@@ -5,8 +5,17 @@ using Microsoft.AspNetCore.Components;
namespace MagMan.UI.Pages
{
public partial class ProjectsStatus
public partial class ProjectsStatus : IDisposable
{
#region Public Methods
public void Dispose()
{
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
}
#endregion Public Methods
#region Protected Fields
protected int nKey = 0;
@@ -42,7 +51,6 @@ namespace MagMan.UI.Pages
await ReloadData();
}
protected void SaveProj(ProjModel? newRec)
{
ProjSel = newRec;
+12 -7
View File
@@ -11,6 +11,7 @@ namespace MagMan.UI.Shared
{
AppMService.EA_ShowSearch -= OnShowSearch;
AppMService.EA_ShowSearch -= OnHideSearch;
AppMService.EA_ShowCustomers -= AppMService_EA_ShowCustomers;
}
public void OnHideSearch()
@@ -52,11 +53,6 @@ namespace MagMan.UI.Shared
AppMService.EA_ShowCustomers += AppMService_EA_ShowCustomers;
}
private void AppMService_EA_ShowCustomers(bool obj)
{
ShowCustomers = obj;
}
protected void UpdateNavDisplay()
{
navLarge = !navLarge;
@@ -67,10 +63,19 @@ namespace MagMan.UI.Shared
#region Private Properties
private bool ShowSearch { get; set; } = false;
private bool ShowCustomers { get; set; } = false;
private bool ShowSearch { get; set; } = false;
#endregion Private Properties
#region Private Methods
private void AppMService_EA_ShowCustomers(bool obj)
{
ShowCustomers = obj;
}
#endregion Private Methods
}
}
+3 -1
View File
@@ -31,7 +31,9 @@
"CodModulo": "MagMan",
"MultiRoleEnab": false,
"MultiClaimEnab": true,
"ScanOpDelay": 3000
"ScanOpDelay": 3000,
"projProgRLim": 0.4,
"projProgYLim": 0.8
},
"AlarmDest": "samuele.locatelli@egalware.com, ceo@steamware.net",
"MailKitMailSettings": {