Fix errore lettura idxFase vuoto

This commit is contained in:
Samuele Locatelli
2022-01-13 14:47:09 +01:00
parent 9ba06b5734
commit 702a09deca
2 changed files with 42 additions and 16 deletions
@@ -230,15 +230,34 @@ namespace GPW_Admin.WebUserControls
// solo se ha diritti scrittura controllo
if (idxObj != null)
{
int trovati = 0;
int idxCli = 0;
_ = int.TryParse(idxObj.ToString(), out idxCli);
trovati = DataProxy.DP.taAP.getByIdxCli(idxCli, true, true).Rows.Count;
// controllo se ci sono record correlati...
if (trovati > 0)
{
answ = false;
}
_ = int.TryParse($"{idxObj}", out idxCli);
answ = !hasChildObj(idxCli);
}
return answ;
}
/// <summary>
/// Determina se abbia child obj --> NON eliminabile
/// </summary>
/// <param name="idxCli"></param>
/// <returns></returns>
public bool hasChildObj(int idxCli)
{
bool answ = false;
string redKey = memLayer.ML.redHash($"clienteHasChildObj:{idxCli}");
// cerco inc ache redis...
string rawData = memLayer.ML.getRSV(redKey);
if (rawData == null)
{
int trovati = DataProxy.DP.taAP.getByIdxCli(idxCli, true, false).Rows.Count;
answ = (trovati > 0);
memLayer.ML.setRSV(redKey, $"{answ}", 60 * 5);
}
else
{
bool.TryParse(rawData, out answ);
}
return answ;
}
@@ -557,18 +557,25 @@ namespace GPW_Admin.WebUserControls
public bool hasChildObj(int idxFase)
{
bool answ = false;
string redKey = memLayer.ML.redHash($"faseHasChildObj:{idxFase}");
// cerco inc ache redis...
string rawData = memLayer.ML.getRSV(redKey);
if (rawData == null)
if (idxFase > 0)
{
int trovati = DataProxy.DP.taRA.getByFase(this.idxFase).Count;
answ = (trovati > 0);
memLayer.ML.setRSV(redKey, $"{answ}", 60 * 5);
string redKey = memLayer.ML.redHash($"faseHasChildObj:{idxFase}");
// cerco inc ache redis...
string rawData = memLayer.ML.getRSV(redKey);
if (rawData == null)
{
int trovati = DataProxy.DP.taRA.getByFase(this.idxFase).Count;
answ = (trovati > 0);
memLayer.ML.setRSV(redKey, $"{answ}", 60 * 5);
}
else
{
bool.TryParse(rawData, out answ);
}
}
else
{
bool.TryParse(rawData, out answ);
answ = true;
}
return answ;
}