Completata prima bozza gestioen calcolo progetti "sforati"
This commit is contained in:
@@ -28,14 +28,62 @@ namespace GPW.CORE.Api.Controllers
|
||||
public async Task<string> Get()
|
||||
{
|
||||
string answ = "ND";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
StringBuilder sbLog = new StringBuilder();
|
||||
StringBuilder sbActions = new StringBuilder();
|
||||
|
||||
// recupero progetti attivi...
|
||||
var currProj = await dataService.AnagProjActiv();
|
||||
sb.Append($"Found {currProj.Count} Active Projects");
|
||||
sbLog.AppendLine("-----------------------");
|
||||
sbLog.AppendLine($"Found {currProj.Count} Active Projects");
|
||||
|
||||
// leggo fasi attive
|
||||
var currFasiAct = await dataService.AnagFasiActiv();
|
||||
sbLog.AppendLine($"Found {currFasiAct.Count} Active Phases");
|
||||
|
||||
answ = sb.ToString();
|
||||
sbLog.AppendLine("-----------------------");
|
||||
// ciclo elenco fasi ancestor di ognuno...
|
||||
foreach (var itemProj in currProj)
|
||||
{
|
||||
// cerco le sue fasi PARENT...
|
||||
var subsetFasi = currFasiAct
|
||||
.Where(x => x.IdxProgetto == itemProj.IdxProgetto && x.IdxFaseAncest == 0)
|
||||
.ToList();
|
||||
sbLog.AppendLine("----------");
|
||||
string projData = $"[{itemProj.IdxProgetto}] {itemProj.ClienteNav.RagSociale} - {itemProj.NomeProj} | Found {subsetFasi.Count} Phases";
|
||||
sbLog.AppendLine(projData);
|
||||
|
||||
// ciclo x ogni fase Parent
|
||||
foreach (var parentFase in subsetFasi)
|
||||
{
|
||||
// cerco la prima child del parent...
|
||||
var firstChild = currFasiAct
|
||||
.Where(x => x.IdxFaseAncest == parentFase.IdxFase)
|
||||
.FirstOrDefault();
|
||||
if (firstChild != null)
|
||||
{
|
||||
// se ne trovo valuto le ore impiegate...
|
||||
var statoFase = await dataService.CalcOreFase(parentFase.IdxFase);
|
||||
|
||||
// se ore usate > (ore budget x %) --> CHIUDO!
|
||||
if (statoFase != null && statoFase.percUsed >= (decimal)statoFase.percOpen)
|
||||
{
|
||||
// x ora LOG... poi chiudo...
|
||||
string currAction = $"!!! [{parentFase.IdxFase}] Budget exhausted for Phase {parentFase.NomeFase} {statoFase.totOre:N2}h used, {statoFase.percUsed:P1} vs {statoFase.percOpen:P1}";
|
||||
sbLog.AppendLine(currAction);
|
||||
sbActions.AppendLine("----------");
|
||||
sbActions.AppendLine(projData);
|
||||
sbActions.AppendLine(currAction);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LOG esteso locale
|
||||
_logger.LogInformation(sbLog.ToString());
|
||||
|
||||
// ritorno solo LOG azioni
|
||||
answ = sbActions.ToString();
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,10 @@ namespace GPW.CORE.Api.Data
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string rKeyProjAct = "Cache:ProjAct";
|
||||
protected const string rKeyProjAct = "Check:ProjAct";
|
||||
protected const string rKeyFasiAct = "Check:FasiAct";
|
||||
protected const string rKeyCalcOreFase = "Check:OreFasi";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// TTL da 1 min x cache Redis
|
||||
@@ -141,7 +144,7 @@ namespace GPW.CORE.Api.Data
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco progetti (tutti)
|
||||
/// Recupera l'elenco progetti (ATTIVI)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagProgettiModel>> AnagProjActiv()
|
||||
@@ -159,16 +162,78 @@ namespace GPW.CORE.Api.Data
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagProjAll(true);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, Formatting.None, new JsonSerializerSettings(){ ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
||||
rawData = JsonConvert.SerializeObject(dbResult, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
||||
await setRSV(cacheKey, rawData, shortTTL);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AttivazioniByLic: {ts.TotalMilliseconds} ms");
|
||||
Log.Trace($"Effettuata lettura da DB per AnagProjActiv: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco fasi (ATTIVE)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagFasiModel>> AnagFasiActiv()
|
||||
{
|
||||
List<AnagFasiModel> dbResult = new List<AnagFasiModel>();
|
||||
string cacheKey = $"{rKeyFasiAct}";
|
||||
trackCache(cacheKey);
|
||||
string rawData = await getRSV(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
dbResult = JsonConvert.DeserializeObject<List<AnagFasiModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagFasiAll(true);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
||||
await setRSV(cacheKey, rawData, shortTTL);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per AnagFasiActiv: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Vista dati per FASE (tipicamente master...) con totalizzaizone ore budget/real e stato fase
|
||||
/// </summary>
|
||||
/// <param name="idxFase"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<CalcOreFasiModel> CalcOreFase(int idxFase)
|
||||
{
|
||||
CalcOreFasiModel? dbResult = new CalcOreFasiModel();
|
||||
string cacheKey = $"{rKeyCalcOreFase}:{idxFase}";
|
||||
trackCache(cacheKey);
|
||||
string rawData = await getRSV(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
dbResult = JsonConvert.DeserializeObject<CalcOreFasiModel>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.CalcOreFase(idxFase);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, Formatting.None, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
|
||||
await setRSV(cacheKey, rawData, shortTTL);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB per CalcOreFase: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new CalcOreFasiModel();
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// invalida tutta la cache in caso di update
|
||||
/// </summary>
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace GPW.CORE.Data.Controllers
|
||||
/// Recupera l'elenco delle fasi (tutte)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagFasiModel> AnagFasiAll()
|
||||
public List<AnagFasiModel> AnagFasiAll(bool onlyActive)
|
||||
{
|
||||
// init dati necessari
|
||||
List<AnagFasiModel> dbResult = new List<AnagFasiModel>();
|
||||
@@ -70,6 +70,7 @@ namespace GPW.CORE.Data.Controllers
|
||||
// recupero intero set...
|
||||
dbResult = localDbCtx
|
||||
.DbSetAnagFasi
|
||||
.Where(x => ((bool)x.Attivo == true && onlyActive == true) || !onlyActive)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace GPW.CORE.Data.DbModels
|
||||
public bool? Attivo { get; set; }
|
||||
public decimal budgetTime { get; set; } = 0;
|
||||
public decimal budgetMoney { get; set; } = 0;
|
||||
public double percOpen { get; set; } = 1;
|
||||
public string CodClasse { get; set; } = "";
|
||||
public string CodExt { get; set; } = "";
|
||||
public decimal totOre { get; set; } = 0;
|
||||
|
||||
@@ -233,7 +233,7 @@ namespace GPW.CORE.UI.Data
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.AnagFasiAll();
|
||||
dbResult = dbController.AnagFasiAll(false);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true));
|
||||
@@ -358,7 +358,7 @@ namespace GPW.CORE.UI.Data
|
||||
public async Task<CalcOreFasiModel> CalcOreFase(int idxFase)
|
||||
{
|
||||
CalcOreFasiModel? dbResult = new CalcOreFasiModel();
|
||||
string currKey = $"{rKeyCalcOreProj}:{idxFase}";
|
||||
string currKey = $"{rKeyCalcOreFase}:{idxFase}";
|
||||
trackCache(currKey);
|
||||
|
||||
string rawData;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>3.0.2201.2517</Version>
|
||||
<Version>3.0.2201.2519</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>GPW - Gestione Presenze Web</i>
|
||||
<h4>Versione: 3.0.2201.2517</h4>
|
||||
<h4>Versione: 3.0.2201.2519</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.0.2201.2517
|
||||
3.0.2201.2519
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>3.0.2201.2517</version>
|
||||
<version>3.0.2201.2519</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user