Files
lux/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor.cs
T
2025-12-23 17:57:41 +01:00

126 lines
3.0 KiB
C#

using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Core.RestPayload;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Compo.WorkLoad
{
public partial class TimeEstim
{
#region Public Properties
[Parameter]
public WorkLoadDetailDTO DetailRecord { get; set; } = null!;
[Parameter]
public EventCallback<bool> EC_ClosePopup { get; set; }
[Parameter]
public EventCallback<bool> EC_ReRunReq { get; set; }
[Parameter]
public EventCallback<BalanceReqDto> EC_RunBalance { get; set; }
#endregion Public Properties
#region Protected Fields
protected BalanceReqDto cBalanceReq = new BalanceReqDto();
#endregion Protected Fields
#region Protected Properties
protected int BarLenght
{
get => cBalanceReq.BarLenght;
set => cBalanceReq.BarLenght = value;
}
protected bool checkSend
{
get => DictPercReq != null && DictPercReq.Count > 0 && DictPercReq.Sum(x => x.Value) == 1;
}
protected Dictionary<string, double> DictPercReq
{
get => cBalanceReq.MachineBalance;
set => cBalanceReq.MachineBalance = value;
}
protected List<string> ListTargetMachine
{
get
{
var answ = DetailRecord.ListMachines;
// aggiungo la macchina EXT...
answ.Add("EXT");
return answ;
}
}
protected string MainCss
{
get => string.IsNullOrEmpty(selUid) ? "col-12" : "col-6";
}
#endregion Protected Properties
#region Protected Methods
protected async Task ClosePopup()
{
await EC_ClosePopup.InvokeAsync(true);
}
protected override void OnParametersSet()
{
ResetDictReq();
}
protected async Task ReqBalance()
{
await EC_RunBalance.InvokeAsync(cBalanceReq);
}
protected async Task ReRunJob()
{
await EC_ReRunReq.InvokeAsync(true);
}
protected void ToggleBalance(List<string> listTag)
{
setBalance = !setBalance;
if (setBalance)
{
cBalanceReq.TagsList = listTag;
ResetDictReq();
}
}
#endregion Protected Methods
#region Private Fields
private string selUid = "";
private bool setBalance = false;
#endregion Private Fields
#region Private Methods
private void ResetDictReq()
{
DictPercReq.Clear();
var cList = ListTargetMachine;
double stdPerc = 1.0;
if (cList.Count > 1)
{
stdPerc = 1.0 / (cList.Count - 1);
}
DictPercReq = cList.ToDictionary(x => x, x => x != "EXT" ? stdPerc : 0);
}
#endregion Private Methods
}
}