Merge branch 'release/FixIn2Ev01'
This commit is contained in:
@@ -1 +1 @@
|
||||
0.9.2408.1918
|
||||
0.9.2409.1719
|
||||
|
||||
@@ -38,8 +38,11 @@ namespace SMGen.Data
|
||||
return clonedData;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (!(obj is SelectFamIngParams item))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -38,8 +38,11 @@ namespace SMGen.Data
|
||||
return clonedData;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (!(obj is SelectFamStatiParams item))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -38,8 +38,11 @@ namespace SMGen.Data
|
||||
return clonedData;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (!(obj is SelectRulFixParams item))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -38,8 +38,11 @@ namespace SMGen.Data
|
||||
return clonedData;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (!(obj is SelectSMIn2EvParams item))
|
||||
return false;
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ namespace SMGen.Data
|
||||
{
|
||||
public partial class SMGDataContext : DbContext
|
||||
{
|
||||
public SMGDataContext()
|
||||
{ }
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
@@ -368,6 +368,142 @@ namespace SMGen.Data.Services
|
||||
private Dictionary<string, int> Events_to_send { get; set; } = new Dictionary<string, int>();
|
||||
private List<string> States { get; set; } = new List<string>();
|
||||
private List<TransizioneIngressiModelTemp> TranInList2add { get; set; } = new List<TransizioneIngressiModelTemp>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Verifica su DB eventi e stati
|
||||
/// </summary>
|
||||
/// <param name="currFile"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<FileLinesClass> DoCheckUnusedEv(FilesClass currFile)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
States.Clear();
|
||||
Bits.Clear();
|
||||
Events_to_send.Clear();
|
||||
Rules.Clear();
|
||||
eventsAll.Clear();
|
||||
evOk.Clear();
|
||||
StatesAll.Clear();
|
||||
string lineOk = "";
|
||||
// recupero nome file x partire
|
||||
string filePath = currFile.tempFileName;
|
||||
FileLinesClass answ = new FileLinesClass();
|
||||
string[] lines = File.ReadAllLines(filePath, Encoding.UTF8);
|
||||
try
|
||||
{
|
||||
foreach (var line in lines)
|
||||
{
|
||||
lineOk = line.Trim();
|
||||
if (!lineOk.StartsWith("#") && !string.IsNullOrEmpty(lineOk) && lineOk.Length >= 3)
|
||||
{
|
||||
if (lineOk.Contains("#"))
|
||||
{
|
||||
var lineSplit = lineOk.Split("#");
|
||||
lineOk = lineSplit[0];
|
||||
}
|
||||
|
||||
var sz_tokens = lineOk.Split(":");
|
||||
|
||||
var sz_temp = sz_tokens[0].Trim();
|
||||
switch (sz_temp)
|
||||
{
|
||||
case "$DEFINITIONS":
|
||||
b_rules_definition = false;
|
||||
break;
|
||||
|
||||
case "$NAME":
|
||||
break;
|
||||
|
||||
case "$IDX":
|
||||
break;
|
||||
|
||||
case "$STATE":
|
||||
if (!StatesAll.ContainsKey(sz_tokens[2].Trim().ToUpper()))
|
||||
{
|
||||
StatesAll.Add(sz_tokens[2].Trim().ToUpper(), int.Parse(sz_tokens[1].Trim().ToUpper()));
|
||||
}
|
||||
break;
|
||||
|
||||
case "$EVENT":
|
||||
if (!Events_to_send.ContainsValue(int.Parse(sz_tokens[1].Trim().ToUpper())))
|
||||
{
|
||||
Events_to_send.Add(sz_tokens[2].Trim().ToUpper(), int.Parse(sz_tokens[1].Trim().ToUpper()));
|
||||
}
|
||||
var newEvent = new AnagEventiModelTemp()
|
||||
{
|
||||
IdxTipo = int.Parse(sz_tokens[1].Trim().ToUpper()),
|
||||
Nome = sz_tokens[2].Trim().ToUpper()
|
||||
};
|
||||
break;
|
||||
|
||||
case "$RULES":
|
||||
b_rules_definition = true;
|
||||
break;
|
||||
case "$DO":
|
||||
b_rules_definition = false;
|
||||
|
||||
break;
|
||||
default:
|
||||
if (b_rules_definition)
|
||||
{
|
||||
var state = sz_temp.Trim().ToUpper();
|
||||
var event_to_send = sz_tokens[1].Trim().ToUpper();
|
||||
var next_state = sz_tokens[2].Trim().ToUpper();
|
||||
|
||||
var temp_rule = new RuleClass()
|
||||
{
|
||||
state = state,
|
||||
event_to_send = event_to_send,
|
||||
next_state = next_state
|
||||
};
|
||||
Rules.Add(temp_rule);
|
||||
States2Rules.Add(next_state);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//linesChecked.Add(line, true);
|
||||
}
|
||||
}
|
||||
foreach (var item in States2Rules)
|
||||
{
|
||||
if (!StatesAll2.ContainsKey(item))
|
||||
{
|
||||
StatesAll2.Add(item, StatesAll[item]);
|
||||
}
|
||||
}
|
||||
foreach (var ev in Events_to_send)
|
||||
{
|
||||
var rule2Ev = Rules.FirstOrDefault(x => x.event_to_send == ev.Key);
|
||||
if (rule2Ev != null)
|
||||
{
|
||||
if (!evOk.ContainsKey(ev.Key) && !evOk.ContainsValue(ev.Value))
|
||||
{
|
||||
evOk.Add(ev.Key, ev.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"{exc}{Environment.NewLine}");
|
||||
}
|
||||
|
||||
answ.file = currFile.tempFileName;
|
||||
answ.statesOK = StatesAll2;
|
||||
answ.eventsOK = evOk;
|
||||
answ.lines = lines.ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica su DB eventi e stati
|
||||
/// </summary>
|
||||
/// <param name="currFile"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<FileLinesClass> DoCheckUnusedEvSt(FilesClass currFile)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
@@ -492,17 +628,15 @@ namespace SMGen.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Valuta un file di ruoles x ingressi 2 eventi e restituisce esito
|
||||
/// </summary>
|
||||
/// <param name="currFile">Path file *.rul da processare</param>
|
||||
/// <param name="saveToDb">Indica se salvare sul DB</param>
|
||||
/// <param name="doProcState">Indica se processare parte state (x state machine stati)</param>
|
||||
/// <returns></returns>
|
||||
///
|
||||
public async Task<FilesClass> EvalIn2EvRuleFile(FilesClass currFile, bool saveToDb)
|
||||
public async Task<FilesClass> EvalIn2EvRuleFile(FilesClass currFile, bool saveToDb, bool doProcState)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
Dictionary<string, string> evSt2Change = new Dictionary<string, string>();
|
||||
@@ -542,7 +676,7 @@ namespace SMGen.Data.Services
|
||||
|
||||
var sz_tokens = line.Split(":");
|
||||
|
||||
var sz_temp = sz_tokens[0].Trim();
|
||||
var sz_temp = sz_tokens[0].Trim().ToUpper();
|
||||
switch (sz_temp)
|
||||
{
|
||||
case "$DEFINITIONS":
|
||||
@@ -637,7 +771,7 @@ namespace SMGen.Data.Services
|
||||
}
|
||||
}
|
||||
|
||||
evSt2Change = await modFile(currFile, false);
|
||||
evSt2Change = await modFile(currFile, false, doProcState);
|
||||
|
||||
if (evSt2Change.Count() == 0)
|
||||
{
|
||||
@@ -708,8 +842,14 @@ namespace SMGen.Data.Services
|
||||
return currFile;
|
||||
}
|
||||
|
||||
|
||||
public async Task<Dictionary<string, string>> modFile(FilesClass file, bool doProc)
|
||||
/// <summary>
|
||||
/// Modifica il file in oggetto
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="doProc"></param>
|
||||
/// <param name="doProcState">Necessaria modifica stati (x state machine stati)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<Dictionary<string, string>> modFile(FilesClass file, bool doProc, bool doProcState)
|
||||
{
|
||||
Dictionary<string, string> evSt2Change = new Dictionary<string, string>();
|
||||
|
||||
@@ -727,19 +867,22 @@ namespace SMGen.Data.Services
|
||||
{
|
||||
if (!line.StartsWith("$EVENT") && !line.StartsWith("#") && line.StartsWith("$STATE"))
|
||||
{
|
||||
var lineSplit = line.Split(":");
|
||||
if (lineSplit.Count() >= 3)
|
||||
if (doProcState)
|
||||
{
|
||||
if (!statesFromDb.ContainsKey(int.Parse(lineSplit[1].Trim())))
|
||||
var lineSplit = line.Split(":");
|
||||
if (lineSplit.Count() >= 3)
|
||||
{
|
||||
errMsg = $"Lo stato {lineSplit[1].Trim()}: {lineSplit[2].Trim()} non è presente in AnagraficaStati sul DB";
|
||||
file.errorMsgs.Add(errMsg);
|
||||
file.isOk = false;
|
||||
}
|
||||
else if (statesFromDb[int.Parse(lineSplit[1].Trim())] != lineSplit[2].Trim())
|
||||
{
|
||||
fileTxt = fileTxt.Replace(lineSplit[2].Trim(), statesFromDb[int.Parse(lineSplit[1].Trim())]);
|
||||
evSt2Change.Add(lineSplit[2].Trim(), lineSplit[0].Trim());
|
||||
if (!statesFromDb.ContainsKey(int.Parse(lineSplit[1].Trim())))
|
||||
{
|
||||
errMsg = $"Lo stato {lineSplit[1].Trim()}: {lineSplit[2].Trim()} non è presente in AnagraficaStati sul DB";
|
||||
file.errorMsgs.Add(errMsg);
|
||||
file.isOk = false;
|
||||
}
|
||||
else if (statesFromDb[int.Parse(lineSplit[1].Trim())] != lineSplit[2].Trim())
|
||||
{
|
||||
fileTxt = fileTxt.Replace(lineSplit[2].Trim(), statesFromDb[int.Parse(lineSplit[1].Trim())]);
|
||||
evSt2Change.Add(lineSplit[2].Trim(), lineSplit[0].Trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -793,8 +936,12 @@ namespace SMGen.Data.Services
|
||||
/// </summary>
|
||||
/// <param name="currFile">Path file *.rul da processare</param>
|
||||
/// <param name="saveToDb">Indica se salvare sul DB</param>
|
||||
/// <param name="calcItself"></param>
|
||||
/// <param name="calcEmptyState"></param>
|
||||
/// <param name="orderType"></param>
|
||||
/// <param name="doProcState">Indica se processare parte state (x state machine stati)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<FilesClass> EvalIn2StateRuleFile(FilesClass currFile, bool saveToDb, bool calcItself, bool calcEmptyState, Core.Enum.ORDERTYPE orderType)
|
||||
public async Task<FilesClass> EvalIn2StateRuleFile(FilesClass currFile, bool saveToDb, bool calcItself, bool calcEmptyState, Core.Enum.ORDERTYPE orderType, bool doProcState)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
Dictionary<string, string> evSt2Change = new Dictionary<string, string>();
|
||||
@@ -940,7 +1087,7 @@ namespace SMGen.Data.Services
|
||||
Log.Error($"Eccezione durante la lettura del file {currFile.origFileName} alla riga {line}: {exc}{Environment.NewLine}");
|
||||
}
|
||||
|
||||
evSt2Change = await modFile(currFile, false);
|
||||
evSt2Change = await modFile(currFile, false, doProcState);
|
||||
|
||||
if (evSt2Change.Count() == 0)
|
||||
{
|
||||
@@ -1060,7 +1207,9 @@ namespace SMGen.Data.Services
|
||||
{
|
||||
for (var i = 0; i <= n_states - 1; i++)
|
||||
{
|
||||
sz_actual_state = Events_to_send.FirstOrDefault(x => x.Value == i).Key;
|
||||
// verificare qui: non dovrebbe essere vente_to_send ma stati!!!!
|
||||
//sz_actual_state = Events_to_send.FirstOrDefault(x => x.Value == i).Key;
|
||||
sz_actual_state = StatesAll.FirstOrDefault(x => x.Value == i).Key;
|
||||
|
||||
//ciclo negli ingressi
|
||||
for (n_input = 0; n_input <= (Math.Pow(2, n_bits) - 1); n_input++)
|
||||
|
||||
@@ -21,87 +21,96 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Files)
|
||||
@if (Files == null || Files.Count == 0)
|
||||
{
|
||||
<tr>
|
||||
<td scope="row">@item.Key</td>
|
||||
@if (item.Value.isOk)
|
||||
{
|
||||
<td class="text-success"><i class="fa-solid fa-circle-check"></i></td>
|
||||
<td>
|
||||
<a href="Download?fileName=@item.Value.DLoadFileName" target="_blank" class="btn btn-sm bg-success"><i class="fa-solid fa-download"></i></a>
|
||||
</td>
|
||||
<td colspan="5">
|
||||
<div class="alert alert-warning fs-4">Nessun file trovato</div>
|
||||
</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in Files)
|
||||
{
|
||||
<tr>
|
||||
<td scope="row">@item.Key</td>
|
||||
@if (item.Value.isOk)
|
||||
{
|
||||
<td class="text-success"><i class="fa-solid fa-circle-check"></i></td>
|
||||
<td>
|
||||
<a href="Download?fileName=@item.Value.DLoadFileName" target="_blank" class="btn btn-sm bg-success"><i class="fa-solid fa-download"></i></a>
|
||||
</td>
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
<td class="text-danger">
|
||||
<i class="fa-solid fa-circle-xmark"></i>
|
||||
</td>
|
||||
<td>
|
||||
@if (item.Value.calcRunning)
|
||||
{
|
||||
<LoadingData DisplaySize="LoadingData.CtrlSize.Small" DisplayMode="LoadingData.SpinMode.BounceLine"></LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="btn btn-sm text-decoration-none" disabled><i class="fa-solid fa-download text-secondary"></i></a>
|
||||
}
|
||||
</td>
|
||||
@if (!hasBit)
|
||||
{
|
||||
<td>
|
||||
@*<i class="@showDanger(item.Value)"></i>*@
|
||||
<button class="btn btn-sm btn-info" @onclick="()=>doProc(item.Value)"><i class="fa-solid fa-code-compare"></i></button>
|
||||
</td>
|
||||
}
|
||||
@if (item.Value.errorMsgs.Count > 0)
|
||||
{
|
||||
<td>
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#exampleModal" @onclick="()=>setCurrMsg(item.Value)"><i class="fa-solid fa-circle-exclamation"></i></button>
|
||||
</td>
|
||||
}
|
||||
else
|
||||
{ }
|
||||
}
|
||||
</tr>
|
||||
@if (FileLines != null && FileLines.statesOK.Count > 0 && FileLines.eventsOK.Count > 0 && FileLines.lines.Count > 0 && item.Value.tempFileName == FileLines.file)
|
||||
{
|
||||
<div class="d-flex justify-content-between p-3">
|
||||
<div class="card shadow-lg rounded mb-2">
|
||||
<div class="card-header">
|
||||
<h4>STATI</h4>
|
||||
</div>
|
||||
<div class="card-body overflow-auto" style="max-height: 50rem">
|
||||
@foreach (var line in FileLines.lines)
|
||||
{
|
||||
<td class="text-danger">
|
||||
<i class="fa-solid fa-circle-xmark"></i>
|
||||
</td>
|
||||
<td>
|
||||
@if (item.Value.calcRunning)
|
||||
{
|
||||
@if (line.StartsWith("$STATE"))
|
||||
{
|
||||
<span class="@lineCssState(line.Split(":")[2].ToUpper().Trim())">@line</span>
|
||||
<br />
|
||||
}
|
||||
<LoadingData DisplaySize="LoadingData.CtrlSize.Small" DisplayMode="LoadingData.SpinMode.BounceLine"></LoadingData>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow-lg rounded mb-2">
|
||||
<div class="card-header">
|
||||
<h4>EVENTI</h4>
|
||||
</div>
|
||||
<div class="card-body overflow-auto" style="max-height: 50rem">
|
||||
@foreach (var line in FileLines.lines)
|
||||
else
|
||||
{
|
||||
@if (line.StartsWith("$EVENT"))
|
||||
<a class="btn btn-sm text-decoration-none" disabled><i class="fa-solid fa-download text-secondary"></i></a>
|
||||
}
|
||||
</td>
|
||||
@if (!hasBit)
|
||||
{
|
||||
<td>
|
||||
@*<i class="@showDanger(item.Value)"></i>*@
|
||||
<button class="btn btn-sm btn-info" @onclick="()=>doProc(item.Value)"><i class="fa-solid fa-code-compare"></i></button>
|
||||
</td>
|
||||
}
|
||||
@if (item.Value.errorMsgs.Count > 0)
|
||||
{
|
||||
<td>
|
||||
<button class="btn btn-sm btn-danger" data-bs-toggle="modal" data-bs-target="#exampleModal" @onclick="()=>setCurrMsg(item.Value)"><i class="fa-solid fa-circle-exclamation"></i></button>
|
||||
</td>
|
||||
}
|
||||
else
|
||||
{ }
|
||||
}
|
||||
</tr>
|
||||
@if (FileLines != null && FileLines.statesOK.Count > 0 && FileLines.eventsOK.Count > 0 && FileLines.lines.Count > 0 && item.Value.tempFileName == FileLines.file)
|
||||
{
|
||||
<div class="d-flex justify-content-between p-3">
|
||||
<div class="card shadow-lg rounded mb-2">
|
||||
<div class="card-header">
|
||||
<h4>STATI</h4>
|
||||
</div>
|
||||
<div class="card-body overflow-auto" style="max-height: 50rem">
|
||||
@foreach (var line in FileLines.lines)
|
||||
{
|
||||
<div>
|
||||
|
||||
<span class="@lineCssEvent(line.Split(":")[2].ToUpper().Trim())">@line</span>
|
||||
@if (line.StartsWith("$STATE"))
|
||||
{
|
||||
<span class="@lineCssState(line.Split(":")[2].ToUpper().Trim())">@line</span>
|
||||
<br />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card shadow-lg rounded mb-2">
|
||||
<div class="card-header">
|
||||
<h4>EVENTI</h4>
|
||||
</div>
|
||||
<div class="card-body overflow-auto" style="max-height: 50rem">
|
||||
@foreach (var line in FileLines.lines)
|
||||
{
|
||||
@if (line.StartsWith("$EVENT"))
|
||||
{
|
||||
<div>
|
||||
|
||||
<span class="@lineCssEvent(line.Split(":")[2].ToUpper().Trim())">@line</span>
|
||||
<br />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
@@ -117,9 +126,9 @@
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@if(currMsgs != null)
|
||||
@if (currMsgs != null)
|
||||
{
|
||||
foreach(var msg in currMsgs.Distinct())
|
||||
foreach (var msg in currMsgs.Distinct())
|
||||
{
|
||||
<div class="mb-1">
|
||||
<span>• @msg</span>
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace SMGen.Components
|
||||
{
|
||||
protected FileLinesClass FileLines = new FileLinesClass();
|
||||
|
||||
[Parameter]
|
||||
public bool doProcState { get; set; } = true;
|
||||
|
||||
[Parameter]
|
||||
public bool calcEmptyState { get; set; } = false;
|
||||
|
||||
@@ -118,7 +121,16 @@ namespace SMGen.Components
|
||||
await Task.Delay(1);
|
||||
if (FileLines.statesOK.Count <= 0 && FileLines.eventsOK.Count <= 0 && FileLines.lines.Count <= 0)
|
||||
{
|
||||
FileLines = await SMGDService.DoCheckUnusedEvSt(currFile);
|
||||
FileLines = await SMGDService.DoCheckUnusedEvSt(currFile);
|
||||
#if false
|
||||
if (doProcState)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
FileLines = await SMGDService.DoCheckUnusedEv(currFile);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -141,15 +153,15 @@ namespace SMGen.Components
|
||||
// chiamo esecuzione 1:1...
|
||||
if (hasBit)
|
||||
{
|
||||
await SMGDService.EvalIn2EvRuleFile(item.Value, true);
|
||||
await SMGDService.EvalIn2EvRuleFile(item.Value, true, doProcState);
|
||||
}
|
||||
else if (is2Chk)
|
||||
{
|
||||
await SMGDService.modFile(item.Value, true);
|
||||
await SMGDService.modFile(item.Value, true, doProcState);
|
||||
}
|
||||
else
|
||||
{
|
||||
await SMGDService.EvalIn2StateRuleFile(item.Value, false, calcItSelf, calcEmptyState, orderType);
|
||||
await SMGDService.EvalIn2StateRuleFile(item.Value, false, calcItSelf, calcEmptyState, orderType, doProcState);
|
||||
}
|
||||
item.Value.calcRunning = false;
|
||||
if (item.Value.isOk)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
@page "/FileFixIngr"
|
||||
|
||||
<div class="text-center">
|
||||
<span class="fs-1"><i class="fa-solid fa-wave-square"></i> Fix <b>Ingressi</b> *.rul files</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="w-100 shadow-lg p-3 rounded mb-2">
|
||||
|
||||
<div class="d-flex justify-content-between w-100">
|
||||
<div class="mb-2">
|
||||
<InputFile OnChange="@LoadFiles" multiple />
|
||||
</div>
|
||||
</div>
|
||||
<FilesList PagerResetReq="pgResetReq" updateRecordCount="UpdateTotCount" currFilter="@currFilter" hasBit="false" is2Chk="true" succFiles="@resetSucc" doProcState="false"></FilesList>
|
||||
</div>
|
||||
@@ -0,0 +1,196 @@
|
||||
using EgwCoreLib.Razor;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NLog;
|
||||
using SMGen.Data.Data;
|
||||
using SMGen.Data.Services;
|
||||
using SMGen.Data;
|
||||
|
||||
namespace SMGen.Pages
|
||||
{
|
||||
public partial class FileFixIngr
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
protected SelectSMIn2EvParams currFilter = new SelectSMIn2EvParams();
|
||||
protected Dictionary<int, string> eventsFromDb = new Dictionary<int, string>();
|
||||
protected DataPager? pagerRulFix = null!;
|
||||
protected Dictionary<int, string> statesFromDb = new Dictionary<int, string>();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected Dictionary<string, FilesClass> Files { get; set; } = new Dictionary<string, FilesClass>();
|
||||
|
||||
protected int maxAllowedFiles { get; set; } = 100;
|
||||
|
||||
protected string pathDir { get; set; } = "";
|
||||
|
||||
protected string pathFile { get; set; } = "";
|
||||
|
||||
protected int resetSucc { get; set; } = 0;
|
||||
|
||||
[Inject]
|
||||
protected SMGDataService SMGDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
}
|
||||
|
||||
protected void ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
// path cartella root (development)
|
||||
pathDir = Path.Combine("Temp", "unsafe_uploads");
|
||||
// se la cartella non esistesse la creo
|
||||
if (!Directory.Exists(pathDir))
|
||||
{
|
||||
Directory.CreateDirectory(pathDir);
|
||||
Log.Info($"Creato directory {pathDir}");
|
||||
}
|
||||
|
||||
// svuoto cartella prima di partire
|
||||
deleteOldFiles(pathDir);
|
||||
await Task.Delay(1);
|
||||
await SMGDService.ExecFlushRedisPattern(Core.Constants.FILES_TO_PROC);
|
||||
}
|
||||
|
||||
protected async Task pgResetReq(bool doReset)
|
||||
{
|
||||
if (doReset)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
if (pagerRulFix != null)
|
||||
{
|
||||
pagerRulFix.resetCurrPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
Files = await SMGDService.FilesGetAll();
|
||||
}
|
||||
|
||||
protected void UpdateTotCount(int newTotCount)
|
||||
{
|
||||
totalCount = newTotCount;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private int currPage
|
||||
{
|
||||
get => currFilter.CurrPage;
|
||||
set => currFilter.CurrPage = value;
|
||||
}
|
||||
|
||||
private int numRecord
|
||||
{
|
||||
get => currFilter.NumRec;
|
||||
set => currFilter.NumRec = value;
|
||||
}
|
||||
|
||||
private int totalCount
|
||||
{
|
||||
get => currFilter.TotCount;
|
||||
set => currFilter.TotCount = value;
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Procedee a bonificare la cartella di upload dei files + vecchi di 3 mesi
|
||||
/// </summary>
|
||||
private void deleteOldFiles(string dirPath)
|
||||
{
|
||||
// elenco files nella directory
|
||||
string[] files = Directory.GetFiles(dirPath);
|
||||
// li guardo tutti e se vecchi li elimino...
|
||||
foreach (string file in files)
|
||||
{
|
||||
FileInfo fi = new FileInfo(file);
|
||||
if (fi.LastAccessTime < DateTime.Now.AddMinutes(-10))
|
||||
{
|
||||
fi.Delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadFiles(InputFileChangeEventArgs e)
|
||||
{
|
||||
List<IBrowserFile> loadedFiles = new();
|
||||
long maxFileSize = 1024 * 1024;
|
||||
loadedFiles.Clear();
|
||||
Files.Clear();
|
||||
|
||||
// svuoto cartella prima di partire
|
||||
deleteOldFiles(pathDir);
|
||||
|
||||
foreach (var file in e.GetMultipleFiles(maxAllowedFiles))
|
||||
{
|
||||
try
|
||||
{
|
||||
loadedFiles.Add(file);
|
||||
|
||||
//assegno un nome file randomico x sicurezza
|
||||
var trustedFileNameForFileStorage = Path.GetRandomFileName();
|
||||
|
||||
//path del file da scrivere
|
||||
pathFile = Path.Combine(pathDir, trustedFileNameForFileStorage);
|
||||
|
||||
// creo file
|
||||
using (FileStream fs = new(pathFile, FileMode.Create))
|
||||
{
|
||||
// copio il contenuto del file
|
||||
await file.OpenReadStream(maxFileSize).CopyToAsync(fs);
|
||||
// scrivo log
|
||||
Log.Info($"Salvato file temp {pathFile}");
|
||||
}
|
||||
|
||||
if (file.Name.Contains(".rul"))
|
||||
{
|
||||
var newFIle = new FilesClass()
|
||||
{
|
||||
tempFileName = pathFile,
|
||||
isOk = false,
|
||||
origFileName = file.Name,
|
||||
calcRunning = false,
|
||||
DLoadFileName = ""
|
||||
};
|
||||
|
||||
Files.Add(file.Name, newFIle);
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore durante salvataggio file temp {file.Name}: {exc}{Environment.NewLine}");
|
||||
}
|
||||
}
|
||||
if (Files != null && Files.Count > 0)
|
||||
{
|
||||
await SMGDService.FilesLoadRedis(Files);
|
||||
}
|
||||
resetSucc = 0;
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
@page "/FilesFix"
|
||||
|
||||
<div class="text-center">
|
||||
<span class="fs-1 fw-bold">Files Fix</span>
|
||||
<span class="fs-1"><i class="fa-solid fa-bullseye"></i> Fix <b>Stati</b> *.rul files</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@page "/SMEvent2State"
|
||||
<div class="text-center">
|
||||
<span class="fs-1 fw-bold">Stati</span>
|
||||
<span class="fs-1"><i class="fa-solid fa-bullseye"></i> <b>Stati</b> rul → csv</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@page "/SMIn2Event"
|
||||
|
||||
<div class="text-center">
|
||||
<span class="fs-1 fw-bold">Ingressi</span>
|
||||
<span class="fs-1"><i class="fa-solid fa-wave-square"></i> <b>Ingressi</b> rul → csv</span>
|
||||
</div>
|
||||
|
||||
<div class="w-100 shadow-lg p-3 rounded mb-2">
|
||||
@@ -11,7 +11,7 @@
|
||||
<InputFile OnChange="@LoadFiles" multiple />
|
||||
</div>
|
||||
</div>
|
||||
<FilesList PagerResetReq="pgResetReq" updateRecordCount="UpdateTotCount" currFilter="@currFilter" hasBit="true" succFiles="@resetSucc"></FilesList>
|
||||
<FilesList PagerResetReq="pgResetReq" updateRecordCount="UpdateTotCount" currFilter="@currFilter" hasBit="true" succFiles="@resetSucc" doProcState="false"></FilesList>
|
||||
</div>
|
||||
|
||||
<div class="w-100 shadow-lg p-3 bg-body rounded mb-2">
|
||||
|
||||
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<History>True|2023-07-24T14:24:14.2770302Z;True|2023-07-24T16:23:20.6455643+02:00;True|2023-05-22T15:35:59.9735292+02:00;False|2023-05-22T15:33:39.4808724+02:00;True|2023-05-11T17:36:48.1468628+02:00;</History>
|
||||
<History>True|2024-09-17T17:25:38.1089716Z||;True|2024-09-17T17:30:03.3866876+02:00||;True|2023-07-24T16:24:14.2770302+02:00||;True|2023-07-24T16:23:20.6455643+02:00||;True|2023-05-22T15:35:59.9735292+02:00||;False|2023-05-22T15:33:39.4808724+02:00||;True|2023-05-11T17:36:48.1468628+02:00||;</History>
|
||||
<LastFailureDetails />
|
||||
<TimeStampOfAssociatedLegacyPublishXmlFile />
|
||||
<EncryptedPassword>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAHBJL+AjnSkKKQcJBrmvYDwAAAAACAAAAAAADZgAAwAAAABAAAABqHjtCI4r9HP4to5TPRtU/AAAAAASAAACgAAAAEAAAAGWTrj6ykvtUZnIZTp5COsMYAAAAHkol9Zhdo3QCFNYyIvyJViyIyNSW1oNCFAAAAEvXT2wDdsDBGFpVXvR5NVA172tk</EncryptedPassword>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Description>State Machine Generator</Description>
|
||||
<Version>0.9.2408.1918</Version>
|
||||
<Version>0.9.2409.1719</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -16,27 +16,32 @@
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link p-2" href="FamIngressi">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Anag Fam.Ingressi
|
||||
<span class="fa-solid fa-table-list pe-2" aria-hidden="true"></span> Anag Fam.Ingressi
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link p-2" href="FamMacchine">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> Anag Fam.Macchine
|
||||
<span class="fa-solid fa-table-list pe-2" aria-hidden="true"></span> Anag Fam.Macchine
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link p-2" href="SMIn2Event">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Gen. SM Ingressi
|
||||
<span class="fa-solid fa-wave-square pe-2" aria-hidden="true"></span> Gen. SM Ingressi
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link p-2" href="SMEvent2State">
|
||||
<span class="oi oi-plus" aria-hidden="true"></span> Gen. SM Stati
|
||||
<span class="fa-solid fa-bullseye pe-2" aria-hidden="true"></span> Gen. SM Stati
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link p-2" href="FilesFix">
|
||||
<span class="oi oi-file" aria-hidden="true"></span> Fix files
|
||||
<NavLink class="nav-link text-warning p-2" href="FileFixIngr">
|
||||
<span class="fa-solid fa-wave-square pe-2" aria-hidden="true"></span> Fix Ingressi.rul
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link text-warning p-2" href="FilesFix">
|
||||
<span class="fa-solid fa-bullseye pe-2" aria-hidden="true"></span> Fix Stati.rul
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
|
||||
Reference in New Issue
Block a user