fix minore clear lista

This commit is contained in:
zaccaria.majid
2023-08-10 15:27:31 +02:00
parent 5958e300f4
commit ff8271d7d6
+151 -164
View File
@@ -65,6 +65,51 @@ namespace SMGen.Data.Services
#region Public Methods
public async Task<Dictionary<int, string>> AnagEventiGetAll()
{
string source = "DB";
Dictionary<int, string> dbResult = new Dictionary<int, string>();
try
{
// cerco da cache
string currKey = $"{Constants.rKeyEventi}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<Dictionary<int, string>>(rawData);
if (tempResult == null)
{
dbResult = new Dictionary<int, string>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.AnagEventiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new Dictionary<int, string>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AnagEventiGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Exception during AnagEventiGetAll: {exc}{Environment.NewLine}");
}
return dbResult;
}
public async Task<bool> AnagEventinInsert(List<AnagEventiModelTemp> newEvList)
{
var dbResult = await dbController.AnagEventinInsert(newEvList);
@@ -96,6 +141,96 @@ namespace SMGen.Data.Services
return answ;
}
public async Task<List<FamIngressiViewModel>> FamIngressiGetAll()
{
string source = "DB";
List<FamIngressiViewModel> dbResult = new List<FamIngressiViewModel>();
try
{
// cerco da cache
string currKey = $"{Constants.rKeyFamIng}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<FamIngressiViewModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<FamIngressiViewModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.FamIngressiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<FamIngressiViewModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"FamIngressiGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Exception during FamIngressiGetAll: {exc}{Environment.NewLine}");
}
return dbResult;
}
public async Task<List<FamStatiViewModel>> FamStatiGetAll()
{
string source = "DB";
List<FamStatiViewModel> dbResult = new List<FamStatiViewModel>();
try
{
// cerco da cache
string currKey = $"{Constants.rKeyFamStati}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<FamStatiViewModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<FamStatiViewModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.FamStatiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<FamStatiViewModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"FamStatiGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Exception during FamStatiGetAll: {exc}{Environment.NewLine}");
}
return dbResult;
}
public async Task<Dictionary<string, FilesClass>> FilesGetAll()
{
Dictionary<string, FilesClass> dbResult = new Dictionary<string, FilesClass>();
@@ -141,143 +276,6 @@ namespace SMGen.Data.Services
return fatto;
}
public async Task<List<FamStatiViewModel>> FamStatiGetAll()
{
string source = "DB";
List<FamStatiViewModel> dbResult = new List<FamStatiViewModel>();
try
{
// cerco da cache
string currKey = $"{Constants.rKeyFamStati}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<FamStatiViewModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<FamStatiViewModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.FamStatiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<FamStatiViewModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"FamStatiGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Exception during FamStatiGetAll: {exc}{Environment.NewLine}");
}
return dbResult;
}
public async Task<List<FamIngressiViewModel>> FamIngressiGetAll()
{
string source = "DB";
List<FamIngressiViewModel> dbResult = new List<FamIngressiViewModel>();
try
{
// cerco da cache
string currKey = $"{Constants.rKeyFamIng}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<List<FamIngressiViewModel>>(rawData);
if (tempResult == null)
{
dbResult = new List<FamIngressiViewModel>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.FamIngressiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new List<FamIngressiViewModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"FamIngressiGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Exception during FamIngressiGetAll: {exc}{Environment.NewLine}");
}
return dbResult;
}
public async Task<Dictionary<int, string>> AnagEventiGetAll()
{
string source = "DB";
Dictionary<int, string> dbResult = new Dictionary<int, string>();
try
{
// cerco da cache
string currKey = $"{Constants.rKeyEventi}";
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string? rawData = await redisDb.StringGetAsync(currKey);
if (!string.IsNullOrEmpty(rawData))
{
source = "REDIS";
var tempResult = JsonConvert.DeserializeObject<Dictionary<int, string>>(rawData);
if (tempResult == null)
{
dbResult = new Dictionary<int, string>();
}
else
{
dbResult = tempResult;
}
}
else
{
dbResult = dbController.AnagEventiGetAll();
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
}
if (dbResult == null)
{
dbResult = new Dictionary<int, string>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AnagEventiGetAll | {source} in: {ts.TotalMilliseconds} ms");
}
catch (Exception exc)
{
Log.Error($"Exception during AnagEventiGetAll: {exc}{Environment.NewLine}");
}
return dbResult;
}
public async Task<bool> TranInInsert(List<TransizioneIngressiModelTemp> newTIList, int currIdxFamiglia)
{
var dbResult = await dbController.TranInInsert(newTIList, currIdxFamiglia);
@@ -286,28 +284,23 @@ namespace SMGen.Data.Services
#endregion Public Methods
public Dictionary<int, string> eventsFromDb = new Dictionary<int, string>();
private bool b_rules_definition = false;
List<CsvClass> csvLines = new List<CsvClass>();
List<string> linesList = new List<string>();
private int n_bits = 0;
private string n_state_machine_index = "";
private int n_states = 0;
private string sz_state_machine_name = "";
public List<AnagEventiModelTemp> events2Add { get; set; } = new List<AnagEventiModelTemp>();
public List<AnagEventiModelTemp> eventsAll { get; set; } = new List<AnagEventiModelTemp>();
protected string bitCsvPath
{
get => _configuration.GetValue<string>("ServerConf:BitCsvPath");
}
#if false
protected bool calcEmptyState
{
get => _configuration.GetValue<bool>("SetupOptions:DoCalcEmptyState");
}
protected bool calcItself
{
get => _configuration.GetValue<bool>("SetupOptions:DoCalcItself");
}
#endif
protected string procRootDir
{
get => _configuration.GetValue<string>("ServerConf:ProcCsvRootPath");
@@ -321,19 +314,17 @@ namespace SMGen.Data.Services
get => _configuration.GetValue<string>("ServerConf:StatiCsvPath");
}
private List<string> actStates2Chk { get; set; } = new List<string>();
private List<string> Bits { get; set; } = new List<string>();
private Dictionary<string, int> Events_to_send { get; set; } = new Dictionary<string, int>();
private Dictionary<string, int> evOk { get; set; } = new Dictionary<string, int>();
public List<AnagEventiModelTemp> events2Add { get; set; } = new List<AnagEventiModelTemp>();
public List<AnagEventiModelTemp> eventsAll { get; set; } = new List<AnagEventiModelTemp>();
private List<RuleClass> Rules { get; set; } = new List<RuleClass>();
private List<string> States { get; set; } = new List<string>();
private List<TransizioneIngressiModelTemp> TranInList2add { get; set; } = new List<TransizioneIngressiModelTemp>();
public Dictionary<int, string> eventsFromDb = new Dictionary<int, string>();
//private Dictionary<string, bool> linesChecked { get; set; } = new Dictionary<string, bool>();
private FileLinesClass linesChecked { get; set; } = new FileLinesClass();
private List<string> nextStates2Chk { get; set; } = new List<string>();
private List<RuleClass> Rules { get; set; } = new List<RuleClass>();
private List<string> States { get; set; } = new List<string>();
private List<TransizioneIngressiModelTemp> TranInList2add { get; set; } = new List<TransizioneIngressiModelTemp>();
public async Task<FileLinesClass> DoCheckUnusedEvSt(FilesClass currFile)
{
States.Clear();
@@ -342,6 +333,7 @@ namespace SMGen.Data.Services
Rules.Clear();
eventsAll.Clear();
evOk.Clear();
StatesAll.Clear();
string lineOk = "";
// recupero nome file x partire
string filePath = currFile.tempFileName;
@@ -477,6 +469,7 @@ namespace SMGen.Data.Services
Rules.Clear();
eventsAll.Clear();
evOk.Clear();
StatesAll.Clear();
string line = "";
// recupero nome file x partire
string filePath = currFile.tempFileName;
@@ -530,6 +523,7 @@ namespace SMGen.Data.Services
break;
case "$STATE":
//States.Add(sz_tokens[2].Trim().ToUpper());
if (!StatesAll.ContainsKey(sz_tokens[2].Trim().ToUpper()))
{
@@ -665,6 +659,7 @@ namespace SMGen.Data.Services
Bits.Clear();
Events_to_send.Clear();
Rules.Clear();
StatesAll.Clear();
// recupero nome file x partire
string filePath = currFile.tempFileName;
string line = "";
@@ -843,10 +838,6 @@ namespace SMGen.Data.Services
return currFile;
}
private List<string> actStates2Chk { get; set; } = new List<string>();
private List<string> nextStates2Chk { get; set; } = new List<string>();
/// <summary>
/// Valutazione schema macchina a stati x Ingressi --> Eventi
/// </summary>
@@ -984,10 +975,6 @@ namespace SMGen.Data.Services
}
return currFile;
}
List<string> linesList = new List<string>();
List<CsvClass> csvLines = new List<CsvClass>();
/// <summary>
/// Valutazione schema macchina a stati x Ingressi --> stati
/// </summary>