This commit is contained in:
2026-07-14 14:22:26 +02:00
parent 4e13db24f6
commit a81689bd56
4 changed files with 85 additions and 35 deletions
@@ -6,10 +6,12 @@
@using SteUp.Shared.Core.Interface.IntegryApi
@using SteUp.Shared.Core.Interface.LocalDb
@using SteUp.Shared.Core.Interface.System
@using Microsoft.Extensions.Logging
@inject IIspezioniService IspezioniService
@inject IIntegrySteupService IntegrySteupService
@inject IDialogService Dialog
@inject IFileManager FileManager
@inject IFileManager FileManager
@inject ILogger<SchedaCard> Logger
<div class="scheda-card">
<div class="scheda-body-section">
@@ -139,23 +141,34 @@
PersonaRif = Scheda.Responsabile,
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
Scandeza = (ScadenzaEnum)Scheda.Scadenza,
ParentActivityId = Scheda.Ispezione?.ActivityId
// Aggancia all'ispezione esistente sul server (evita di crearne una nuova a ogni invio).
ParentActivityId = SteupDataService.InspectionPageState.Ispezione.ActivityId
}
);
if (apiResponse != null)
if (apiResponse == null)
{
Scheda.ActivityId = apiResponse.ActivityIdScheda;
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
UserSession.User.Username, apiResponse.ActivityIdIspezione
);
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
await OnSchedaModified.InvokeAsync(Scheda);
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
return;
}
Scheda.ActivityId = apiResponse.ActivityIdScheda;
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
UserSession.User.Username, apiResponse.ActivityIdIspezione
);
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
// Notifica il genitore così il contatore "da inviare" del reparto si aggiorna.
await OnSchedaModified.InvokeAsync(Scheda);
Snackbar.Add("Scheda inviata", Severity.Success);
}
catch (Exception e)
{
Snackbar.Add("Invio non riuscito. La scheda resta sul dispositivo, riprova.", Severity.Error);
Logger.LogError(e, e.Message);
}
finally
{
@@ -176,12 +189,23 @@
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
.Where(x => x.ToUpload).ToList();
if (fileList == null) return;
if (fileList == null || fileList.Count == 0)
{
Snackbar.Add("Nessuna nuova foto da inviare", Severity.Info);
return;
}
foreach (var file in fileList)
{
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
}
Snackbar.Add(fileList.Count == 1 ? "Foto inviata" : $"{fileList.Count} foto inviate", Severity.Success);
}
catch (Exception e)
{
Snackbar.Add("Invio foto non riuscito, riprova.", Severity.Error);
Logger.LogError(e, e.Message);
}
finally
{