Files
Mapo-IOB/SMGen/Components/FilesList.razor.cs
T
2023-08-10 11:09:35 +02:00

140 lines
4.6 KiB
C#

using Microsoft.AspNetCore.Components;
using SMGen.Data;
using SMGen.Data.Data;
using SMGen.Data.Services;
namespace SMGen.Components
{
public partial class FilesList
{
protected FileLinesClass k = new FileLinesClass();
[Parameter]
public bool calcEmptyState { get; set; } = false;
[Parameter]
public bool calcItSelf { get; set; } = false;
[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 Core.Enum.ORDERTYPE orderType { get; set; } = Core.Enum.ORDERTYPE.stateEvent;
//[Parameter]
//public Dictionary<string, string> Files2Download { get; set; } = new Dictionary<string, string>();
[Parameter]
public int succFiles { get; set; } = 0;
[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!;
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 async Task doProc(FilesClass currFile)
{
await Task.Delay(1);
if (k.statesOK.Count <= 0 && k.eventsOK.Count <= 0 && k.lines.Count <= 0)
{
k = await SMGDService.DoCheckUnusedEvSt(currFile);
}
else
{
k = new FileLinesClass();
}
}
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;
}
}
}