Files
Mapo-IOB/SMGen/Components/FilesList.razor.cs
T
zaccaria.majid 7f1c430ea3 ordinamenti vari
2023-08-09 15:13:19 +02:00

128 lines
4.1 KiB
C#

using Microsoft.AspNetCore.Components;
using SMGen.Data;
using SMGen.Data.Data;
using SMGen.Data.Services;
namespace SMGen.Components
{
public partial class FilesList
{
[Parameter]
public bool calcEmptyState { get; set; } = false;
[Parameter]
public bool calcItSelf { get; set; } = false;
[Parameter]
public Core.Enum.ORDERTYPE orderType { get; set; } = Core.Enum.ORDERTYPE.stateEvent;
[Parameter]
public SelectSMIn2EvParams currFilter { get; set; } = null!;
//[Parameter]
//public Dictionary<string, bool> FilesStatus { get; set; } = new Dictionary<string, bool>();
public Dictionary<string, bool> FilesStatusTemp { get; set; } = new Dictionary<string, bool>();
[Parameter]
public bool hasBit { get; set; } = false;
//[Parameter]
//public Dictionary<string, string> Files2Download { get; set; } = new Dictionary<string, string>();
[Parameter]
public EventCallback<bool> PagerResetReq { get; set; }
[Parameter]
public EventCallback<int> updateRecordCount { get; set; }
protected string currFileName { get; set; } = "";
protected string currMsg { get; set; } = "";
protected Dictionary<string, FilesClass> Files { get; set; } = new Dictionary<string, FilesClass>();
protected Dictionary<string, FilesClass> FilesTemp { get; set; } = new Dictionary<string, FilesClass>();
[Inject]
protected SMGDataService SMGDService { get; set; } = null!;
[Parameter]
public int succFiles { get; set; } = 0;
private int _totalCount { get; set; } = 0;
private int currPage
{
get => currFilter.CurrPage;
set => currFilter.CurrPage = value;
}
private int numRecord
{
get => currFilter.NumRec;
set => currFilter.NumRec = value;
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
updateRecordCount.InvokeAsync(value);
}
}
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
protected async Task Read_rule_file_transitions()
{
SMGDService.events2Add.Clear();
Files = await SMGDService.FilesGetAll();
foreach (var item in Files.OrderBy(x => x.Value.origFileName))
{
item.Value.calcRunning = true;
await InvokeAsync(() => StateHasChanged());
await Task.Delay(1);
// chiamo esecuzione 1:1...
if (hasBit)
{
await SMGDService.EvalIn2EvRuleFile(item.Value, true);
}
else
{
await SMGDService.EvalIn2StateRuleFile(item.Value, false, calcItSelf, calcEmptyState, orderType);
}
item.Value.calcRunning = false;
if (item.Value.isOk)
{
succFiles = succFiles + 1;
}
await InvokeAsync(() => StateHasChanged());
}
await Task.Delay(5);
//await SMGDService.AnagEventinInsert(SMGDService.events2Add);
//SMGDService.events2Add.Clear();
}
protected async Task ReloadData()
{
SMGDService.events2Add.Clear();
await Task.Delay(1);
FilesTemp = await SMGDService.FilesGetAll();
totalCount = FilesTemp.Count;
Files = FilesTemp.Skip(numRecord * (currPage - 1)).Take(numRecord).OrderBy(x => x.Value.origFileName).ToDictionary(x => x.Key, y => y.Value);
await InvokeAsync(() => StateHasChanged());
}
protected async Task setCurrMsg(FilesClass currFile)
{
if (currFile.errorMsg != "")
{
currMsg = currFile.errorMsg;
}
currFileName = currFile.origFileName;
}
}
}