Esportazione immagini anche con ispezione completata

This commit is contained in:
2026-03-03 12:50:17 +01:00
parent e1e0c91db5
commit 3760e38c8d
2 changed files with 82 additions and 12 deletions

View File

@@ -5,9 +5,11 @@
@using SteUp.Shared.Core.Enum
@using SteUp.Shared.Core.Interface.IntegryApi
@using SteUp.Shared.Core.Interface.LocalDb
@using SteUp.Shared.Core.Interface.System
@inject IIspezioniService IspezioniService
@inject IIntegrySteupService IntegrySteupService
@inject IDialogService Dialog
@inject IAttachedService AttachedService
<div class="scheda-card">
<div class="scheda-body-section">
@@ -27,7 +29,7 @@
</div>
<div class="scheda-card-action">
@if (Stato != StatusEnum.Completata)
@if (Ispezione.Stato != StatusEnum.Completata)
{
if (NetworkService.IsNetworkAvailable())
{
@@ -56,6 +58,11 @@
Color="Color.Info" Size="Size.Small" OnClick="@ViewScheda">
Visualizza
</MudButton>
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.CloudSync"
Color="Color.Success" Size="Size.Small" OnClick="@ExportImg">
Esporta immagini
</MudButton>
}
</div>
</div>
@@ -66,9 +73,7 @@
Message="Confermi la cancellazione della scheda corrente?"/>
@code{
[Parameter] public string CodMdep { get; set; } = string.Empty;
[Parameter] public DateTime Data { get; set; }
[Parameter] public StatusEnum Stato { get; set; }
[Parameter] public Ispezione Ispezione { get; set; } = new();
[Parameter] public required Scheda Scheda { get; set; }
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
@@ -79,7 +84,7 @@
private async Task UpdateScheda()
{
var modal = await Dialog.OpenFormScheda(CodMdep, Data, false, Scheda);
var modal = await Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda);
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
}
@@ -95,6 +100,14 @@
if (Scheda.ActivityId != null)
await IntegrySteupService.DeleteScheda(Scheda.ActivityId);
if (Scheda.ImageNames != null)
{
foreach (var fileName in Scheda.ImageNames)
{
AttachedService.RemoveInspectionFile(Ispezione, fileName);
}
}
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
@@ -104,7 +117,7 @@
}
private void ViewScheda() =>
_ = Dialog.OpenFormScheda(CodMdep, Data, false, Scheda, true);
_ = Dialog.OpenFormScheda(Ispezione.CodMdep, Ispezione.Data, false, Scheda, true);
private async Task ExportScheda()
{
@@ -117,8 +130,8 @@
LocalIdScheda = Scheda.Id,
ActivityTypeId = Scheda.ActivityTypeId,
CodJfas = Scheda.CodJfas,
CodMdep = CodMdep,
DataCreazione = Data,
CodMdep = Ispezione.CodMdep,
DataCreazione = Ispezione.Data,
Note = Scheda.Note,
PersonaRif = Scheda.Responsabile,
Barcodes = Scheda.Articoli.ConvertAll(x => x.Barcode),
@@ -132,7 +145,7 @@
Scheda.ActivityId = apiResponse.ActivityIdScheda;
SteupDataService.InspectionPageState.Ispezione.ActivityId = apiResponse.ActivityIdIspezione;
await IspezioniService.UpdateActivityIdIspezioneAsync(CodMdep, Data,
await IspezioniService.UpdateActivityIdIspezioneAsync(Ispezione.CodMdep, Ispezione.Data,
UserSession.User.Username, apiResponse.ActivityIdIspezione
);
await IspezioniService.UpdateActivityIdSchedaAsync(Scheda.Id, Scheda.ActivityId);
@@ -142,4 +155,18 @@
StateHasChanged();
}
private async Task ExportImg()
{
if (Scheda.ImageNames == null) return;
var fileList = (await AttachedService.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
.Where(x => x.ToUpload).ToList();
if (fileList == null) return;
foreach (var file in fileList)
{
await IntegrySteupService.UploadFile(Scheda.ActivityId!, file.FileBytes!, file.Name!);
}
}
}