1f4b48ac8c
- Fix gestione Task su multi-gruppo MacchineEnergy: - update gestione nuove view
248 lines
6.7 KiB
C#
248 lines
6.7 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.TaskMan.Models;
|
|
using MP.TaskMan.Services;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.TaskMan
|
|
{
|
|
public partial class TaskListTable
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int CodGroup { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public List<TaskListModel> AllRecords { get; set; } = new List<TaskListModel>();
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_Cancel { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<TaskListModel> EC_Clone { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_DoReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<TaskListModel> EC_Edit { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ForceAll { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<ActionParam> EC_Move { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<TaskListModel> EC_Run { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<TaskListModel> EC_Select { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Classes
|
|
|
|
public class ActionParam
|
|
{
|
|
#region Public Properties
|
|
|
|
public TaskListModel CurrRec { get; set; } = null!;
|
|
public bool GoUp { get; set; } = true;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Public Classes
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected TaskService TService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string alCss(TaskListModel TaskRec)
|
|
{
|
|
return TaskRec.LastIsError ? "alert-danger" : "alert-success";
|
|
}
|
|
|
|
protected string btnCss(TaskListModel TaskRec)
|
|
{
|
|
string answ = DetailTaskId != null && DetailTaskId.TaskId == TaskRec.TaskId ? "btn-" : "btn-outline-";
|
|
answ += TaskRec.LastIsError ? "danger" : "success";
|
|
return answ;
|
|
}
|
|
|
|
protected string checkDis(TaskListModel selRec)
|
|
{
|
|
string answ = "";
|
|
// verifico se sia disabilitato...
|
|
if (!selRec.Enabled)
|
|
{
|
|
answ += " text-secondary text-opacity-75 textStriked";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected string checkSelect(TaskListModel selRec)
|
|
{
|
|
string answ = "";
|
|
if (currRecord != null)
|
|
{
|
|
answ = (currRecord.Equals(selRec)) ? "table-info" : "";
|
|
}
|
|
else if (detRecord != null)
|
|
{
|
|
answ = detRecord.Equals(selRec) ? "table-info" : "";
|
|
}
|
|
#if false
|
|
// verifico se sia disabilitato...
|
|
if (!selRec.Enabled)
|
|
{
|
|
answ += " text-secondary text-opacity-50 textStriked";
|
|
}
|
|
#endif
|
|
return answ;
|
|
}
|
|
|
|
protected async Task DoCancel()
|
|
{
|
|
await EC_Cancel.InvokeAsync(true);
|
|
}
|
|
|
|
protected async Task DoClone(TaskListModel currRec)
|
|
{
|
|
await EC_Clone.InvokeAsync(currRec);
|
|
}
|
|
|
|
protected async Task DoEdit(TaskListModel currRec)
|
|
{
|
|
await EC_Edit.InvokeAsync(currRec);
|
|
}
|
|
|
|
protected async Task DoMove(TaskListModel currRec, bool goUp)
|
|
{
|
|
ActionParam retVal = new ActionParam()
|
|
{
|
|
CurrRec = currRec,
|
|
GoUp = goUp
|
|
};
|
|
await EC_Move.InvokeAsync(retVal);
|
|
}
|
|
|
|
protected async Task DoReset()
|
|
{
|
|
detRecord = null;
|
|
DetailTaskId = null;
|
|
await EC_DoReset.InvokeAsync(true);
|
|
}
|
|
|
|
protected async Task DoRun(TaskListModel currRec)
|
|
{
|
|
await EC_Run.InvokeAsync(currRec);
|
|
}
|
|
|
|
protected async Task DoSelect(TaskListModel currRec)
|
|
{
|
|
detRecord = currRec;
|
|
DetailTaskId = null;
|
|
await EC_Select.InvokeAsync(currRec);
|
|
}
|
|
|
|
protected async Task ForceAll()
|
|
{
|
|
await EC_ForceAll.InvokeAsync(true);
|
|
}
|
|
|
|
protected string iconCss(TaskListModel TaskRec)
|
|
{
|
|
return TaskRec.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up";
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
ReloadData();
|
|
}
|
|
|
|
protected void SetNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
ReloadData();
|
|
}
|
|
|
|
protected void SetPage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
ReloadData();
|
|
}
|
|
|
|
protected string TextReduce(string textOriginal, int maxChar)
|
|
{
|
|
string answ = textOriginal;
|
|
if (answ.Length > maxChar)
|
|
{
|
|
answ = $"{textOriginal.Substring(0, maxChar / 2)} ... {textOriginal.Substring(answ.Length - maxChar / 2)}";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected void ToggleDetail(TaskListModel TaskRec)
|
|
{
|
|
if (DetailTaskId == null)
|
|
{
|
|
DetailTaskId = TaskRec;
|
|
}
|
|
else
|
|
{
|
|
DetailTaskId = (DetailTaskId.TaskId == TaskRec.TaskId) ? null : TaskRec;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int currPage = 1;
|
|
private TaskListModel? DetailTaskId = null;
|
|
private bool isLoading = false;
|
|
private List<TaskListModel> ListRecords = new List<TaskListModel>();
|
|
private int maxOrdinal = 999;
|
|
private int minOrdinal = 0;
|
|
private int numRecord = 5;
|
|
private int totalCount = 0;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private TaskListModel? currRecord { get; set; } = null;
|
|
|
|
private TaskListModel? detRecord { get; set; } = null;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string btnRunCss(DateTime dtNextExe)
|
|
{
|
|
DateTime adesso = DateTime.Now;
|
|
string answ = dtNextExe < adesso ? "btn-success" : "btn-warning";
|
|
return answ;
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
totalCount = AllRecords.Count;
|
|
var firstRec = AllRecords.OrderBy(x => x.Ordinal).FirstOrDefault();
|
|
minOrdinal = firstRec != null ? firstRec.Ordinal : 0;
|
|
var lastRec = AllRecords.OrderByDescending(x => x.Ordinal).FirstOrDefault();
|
|
maxOrdinal = lastRec != null ? lastRec.Ordinal : 9999;
|
|
ListRecords = AllRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |