Inizio modifiche controller API x check risorse
This commit is contained in:
@@ -147,5 +147,81 @@ namespace MagMan.UI.Controllers
|
||||
answ = fatto ? "OK" : "NO";
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Processa una chiamata POST per la verifica di un oggetto di TRACKING risorse progetto (RestPayload.Resources)
|
||||
/// PUT: api/Resources/check/00000000-0000-0000-0000-000000000000
|
||||
/// </summary>
|
||||
/// <param name="id">token comunicazione</param>
|
||||
/// <returns>restituisce diversi valori secondo esito: ND/EQUAL/CHANGED, dove
|
||||
/// | ND = non definito / non calcolato
|
||||
/// | EQUAL = il set inviato èidentico all'ultimo registrato (in termini di numero barre impiegate complessivo e per singolo tipo, check da CloudId barre)
|
||||
/// | CHANGED = il set inviato è differente (per tipo/numero/mix di barre)
|
||||
/// </returns>
|
||||
[HttpPost("check/{id}")]
|
||||
public async Task<string> check(string id, [FromBody] RestPayload.Resources projectData)
|
||||
{
|
||||
string answ = "ND";
|
||||
bool isEqual = false;
|
||||
// verifico ci sia valore
|
||||
if (!string.IsNullOrEmpty(id) && projectData != null)
|
||||
{
|
||||
// in primis recupero codice chiave da token...
|
||||
int nKey = await MTAdmService.MainKeyByToken(id);
|
||||
if (nKey > 0)
|
||||
{
|
||||
/// TBD!!!! fare verifica equality
|
||||
#if false
|
||||
// nel projData ho le info x gestire aggiornamento PER INTERO
|
||||
int ProjCloudId = projectData.ProjCloudId;
|
||||
// proseguo solo se ho un Id valido
|
||||
if (ProjCloudId > 0)
|
||||
{
|
||||
// recupero info del progetto con cui registrare le note
|
||||
var projRec = await TService.ProjectGetById(nKey, ProjCloudId);
|
||||
|
||||
// in primis registro il record RequestPlan...
|
||||
var recPlan = new RequestPlanModel()
|
||||
{
|
||||
DtRequest = projectData.DtReq,
|
||||
IsActive = true,
|
||||
ReqState = projectData.ReqState,
|
||||
ProjDbId = ProjCloudId
|
||||
};
|
||||
|
||||
// registro richiesta prima dei movimenti...
|
||||
int RequestPlanId = await TService.ReqPlanUpdate(nKey, recPlan);
|
||||
|
||||
// per ogni riga risorsa registro le info relative...
|
||||
if (projectData.ResourceList != null)
|
||||
{
|
||||
List<ResourceModel> listRes = projectData.ResourceList.Select(x => TService.ResourceFromDto(x, RequestPlanId)).ToList();
|
||||
try
|
||||
{
|
||||
string prDesc = $"K{nKey}";
|
||||
if (projRec != null)
|
||||
{
|
||||
prDesc += $" | P.{ProjCloudId} | {projRec.ProjDescription} ({projRec.Machine})";
|
||||
}
|
||||
// rivedere SIA consumi che gestione stime...
|
||||
await TService.ResourceUpdate(nKey, RequestPlanId, projectData.ResourceList, projectData.ReqState, prDesc);
|
||||
isEqual = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"ResourceController.upsert | Errore in fase salvataggio ResourceDto{Environment.NewLine}{exc}");
|
||||
isEqual = false;
|
||||
}
|
||||
}
|
||||
// resetto cache redis
|
||||
await MTAdmService.FlushRedisCache();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
answ = isEqual ? "EQUAL" : "CHANGED";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user