ok controllo stati/eventi mancanti su db
This commit is contained in:
@@ -9,7 +9,7 @@ namespace SMGen.Data.Controllers
|
||||
{
|
||||
public class SMGenController : IDisposable
|
||||
{
|
||||
private static IConfiguration _configuration;
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
using NLog.LayoutRenderers.Wrappers;
|
||||
|
||||
namespace SMGen.Data
|
||||
{
|
||||
public class SelectRulFixParams
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public SelectRulFixParams()
|
||||
{ }
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
|
||||
public int CurrPage { get; set; } = 1;
|
||||
|
||||
public int MaxRecord { get; set; } = 100;
|
||||
|
||||
public int NumRec { get; set; } = 10;
|
||||
|
||||
public int TotCount { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public SelectRulFixParams clone()
|
||||
{
|
||||
SelectRulFixParams clonedData = new SelectRulFixParams()
|
||||
{
|
||||
CurrPage = this.CurrPage,
|
||||
MaxRecord = this.MaxRecord,
|
||||
NumRec = this.NumRec,
|
||||
TotCount = this.TotCount
|
||||
};
|
||||
return clonedData;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (!(obj is SelectRulFixParams item))
|
||||
return false;
|
||||
|
||||
if (MaxRecord != item.MaxRecord)
|
||||
return false;
|
||||
|
||||
if (NumRec != item.NumRec)
|
||||
return false;
|
||||
|
||||
if (TotCount != item.TotCount)
|
||||
return false;
|
||||
|
||||
if (CurrPage != item.CurrPage)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -282,8 +282,8 @@ namespace SMGen.Data.Services
|
||||
var rawData = await redisDb.HashGetAllAsync(currKey);
|
||||
foreach (var item in rawData)
|
||||
{
|
||||
var desVal = JsonConvert.DeserializeObject<FilesClass>(item.Value);
|
||||
dbResult.Add($"{item.Name}", desVal);
|
||||
var desVal = JsonConvert.DeserializeObject<FilesClass>(item.Value!);
|
||||
dbResult.Add($"{item.Name}", desVal!);
|
||||
}
|
||||
|
||||
return dbResult;
|
||||
@@ -370,6 +370,7 @@ namespace SMGen.Data.Services
|
||||
private List<TransizioneIngressiModelTemp> TranInList2add { get; set; } = new List<TransizioneIngressiModelTemp>();
|
||||
public async Task<FileLinesClass> DoCheckUnusedEvSt(FilesClass currFile)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
States.Clear();
|
||||
Bits.Clear();
|
||||
Events_to_send.Clear();
|
||||
@@ -568,7 +569,7 @@ namespace SMGen.Data.Services
|
||||
break;
|
||||
|
||||
case "$STATE":
|
||||
|
||||
|
||||
//States.Add(sz_tokens[2].Trim().ToUpper());
|
||||
if (!StatesAll.ContainsKey(sz_tokens[2].Trim().ToUpper()))
|
||||
{
|
||||
@@ -694,9 +695,9 @@ namespace SMGen.Data.Services
|
||||
string filePath = file.tempFileName;
|
||||
var lines = File.ReadLines(filePath);
|
||||
var fileTxt = File.ReadAllText(filePath);
|
||||
string errMsg = "";
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var txt = "";
|
||||
if (line != "" && line.Contains(":"))
|
||||
{
|
||||
if (!line.StartsWith("$EVENT") && !line.StartsWith("#") && line.StartsWith("$STATE"))
|
||||
@@ -704,7 +705,13 @@ namespace SMGen.Data.Services
|
||||
var lineSplit = line.Split(":");
|
||||
if (lineSplit.Count() >= 3)
|
||||
{
|
||||
if (statesFromDb[int.Parse(lineSplit[1].Trim())] != lineSplit[2].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())]);
|
||||
}
|
||||
@@ -715,22 +722,35 @@ namespace SMGen.Data.Services
|
||||
var lineSplit = line.Split(":");
|
||||
if (lineSplit.Count() >= 3)
|
||||
{
|
||||
if (eventsFromDb[int.Parse(lineSplit[1].Trim())] != lineSplit[2].Trim())
|
||||
if (!eventsFromDb.ContainsKey(int.Parse(lineSplit[1].Trim())))
|
||||
{
|
||||
errMsg = $"L'evento {lineSplit[1].Trim()}: {lineSplit[2].Trim()} non è presente in AnagraficaEventi sul DB";
|
||||
file.errorMsgs.Add(errMsg);
|
||||
file.isOk = false;
|
||||
}
|
||||
else if (eventsFromDb[int.Parse(lineSplit[1].Trim())] != lineSplit[2].Trim())
|
||||
{
|
||||
fileTxt = fileTxt.Replace(lineSplit[2].Trim(), eventsFromDb[int.Parse(lineSplit[1].Trim())]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var fileName = $"{file.origFileName.Split(".")[0]}.rul";
|
||||
file.DLoadFileName = $"{Path.Combine(procRootDir, bitCsvPath, fileName)}";
|
||||
|
||||
await FileUpdate(file.origFileName, file);
|
||||
using (StreamWriter sw = new StreamWriter(file.DLoadFileName))
|
||||
if (file.errorMsgs.Count() == 0)
|
||||
{
|
||||
sw.Write(fileTxt);
|
||||
var fileName = $"{file.origFileName.Split(".")[0]}.rul";
|
||||
file.DLoadFileName = $"{Path.Combine(procRootDir, bitCsvPath, fileName)}";
|
||||
file.isOk = true;
|
||||
await FileUpdate(file.origFileName, file);
|
||||
using (StreamWriter sw = new StreamWriter(file.DLoadFileName))
|
||||
{
|
||||
sw.Write(fileTxt);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await FileUpdate(file.origFileName, file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,24 +96,6 @@
|
||||
|
||||
<span class="@lineCssEvent(line.Split(":")[2].ToUpper().Trim())">@line</span>
|
||||
<br />
|
||||
@*@if (FileLines.eventsOK.ContainsKey(line.Split(":")[2].ToUpper().Trim()))
|
||||
{
|
||||
<span class="text-success">@line</span>
|
||||
<br />
|
||||
}
|
||||
else if (line.Contains("#"))
|
||||
{
|
||||
if (FileLines.eventsOK.ContainsKey(line.Split(":")[2].Split("#")[0].ToUpper().Trim()))
|
||||
{
|
||||
<span class="text-success">@line</span>
|
||||
<br />
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="text-danger">@line</span>
|
||||
<br />
|
||||
}*@
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ namespace SMGen.Components
|
||||
|
||||
[Parameter]
|
||||
public bool hasBit { get; set; } = false;
|
||||
[Parameter]
|
||||
public bool is2Chk { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public Core.Enum.ORDERTYPE orderType { get; set; } = Core.Enum.ORDERTYPE.stateEvent;
|
||||
@@ -139,6 +141,10 @@ namespace SMGen.Components
|
||||
{
|
||||
await SMGDService.EvalIn2EvRuleFile(item.Value, true);
|
||||
}
|
||||
else if (is2Chk)
|
||||
{
|
||||
await SMGDService.modFile(item.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
await SMGDService.EvalIn2StateRuleFile(item.Value, false, calcItSelf, calcEmptyState, orderType);
|
||||
|
||||
@@ -8,16 +8,5 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button @onclick="()=>doProc()">PROC</button>
|
||||
@foreach (var item in Files)
|
||||
{
|
||||
<div>
|
||||
<span>
|
||||
@item.Key
|
||||
</span>
|
||||
@if(item.Value.DLoadFileName != "")
|
||||
{
|
||||
<span>@item.Value.DLoadFileName</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<FilesList PagerResetReq="pgResetReq" updateRecordCount="UpdateTotCount" currFilter="@currFilter" hasBit="false" is2Chk="true" succFiles="@resetSucc"></FilesList>
|
||||
|
||||
@@ -1,29 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using SMGen;
|
||||
using SMGen.Shared;
|
||||
using SMGen.Components;
|
||||
using EgwCoreLib.Razor;
|
||||
using EgwCoreLib.Razor.Data;
|
||||
using SMGen.Data;
|
||||
using SMGen.Core;
|
||||
using SMGen.Data.DbModels;
|
||||
using SMGen.Data.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.VisualBasic;
|
||||
using System.Text;
|
||||
using NLog.Fluent;
|
||||
using SMGen.Core;
|
||||
using SMGen.Data;
|
||||
using SMGen.Data.Data;
|
||||
using SMGen.Data.Services;
|
||||
|
||||
namespace SMGen.Pages
|
||||
{
|
||||
@@ -36,7 +19,6 @@ namespace SMGen.Pages
|
||||
protected SMGDataService SMGDService { get; set; } = null!;
|
||||
|
||||
protected Dictionary<string, FilesClass> Files { get; set; } = new Dictionary<string, FilesClass>();
|
||||
|
||||
|
||||
protected int maxAllowedFiles { get; set; } = 100;
|
||||
protected string pathDir { get; set; } = "";
|
||||
@@ -111,19 +93,66 @@ namespace SMGen.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
eventsFromDb = await SMGDService.AnagEventiGetAll();
|
||||
statesFromDb = await SMGDService.AnagStatiGetAll();
|
||||
await SMGDService.ExecFlushRedisPattern(Core.Constants.FILES_TO_PROC);
|
||||
}
|
||||
|
||||
protected async Task doProc()
|
||||
#region Protected Methods
|
||||
|
||||
protected void ForceReload(int newNum)
|
||||
{
|
||||
foreach (var item in Files.OrderBy(x => x.Value.origFileName))
|
||||
numRecord = newNum;
|
||||
}
|
||||
|
||||
protected void ForceReloadPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
}
|
||||
|
||||
protected SelectSMIn2EvParams currFilter = new SelectSMIn2EvParams();
|
||||
|
||||
protected DataPager? pagerRulFix = null!;
|
||||
|
||||
protected async Task pgResetReq(bool doReset)
|
||||
{
|
||||
if (doReset)
|
||||
{
|
||||
await Task.Delay(1);
|
||||
await SMGDService.modFile(item.Value);
|
||||
if (pagerRulFix != null)
|
||||
{
|
||||
pagerRulFix.resetCurrPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
Files = await SMGDService.FilesGetAll();
|
||||
|
||||
@@ -46,6 +46,7 @@ $STATE : 34 : Riscaldamento
|
||||
$STATE : 35 : Anomalia_Macchina
|
||||
$STATE : 49 : Manca_Attrezzatura
|
||||
$STATE : 50 : Usura_Utensile
|
||||
$STATE : 52 : Formazione_Personale
|
||||
|
||||
#definizione eventi : obbligatorio iniziare da 0 --> select * from AnagraficaEventi
|
||||
# NOTE
|
||||
|
||||
Reference in New Issue
Block a user