Fix gestione allegati e creato metodo di esportazione log

This commit is contained in:
2026-03-04 11:51:42 +01:00
parent 3760e38c8d
commit 2d938fb210
26 changed files with 986 additions and 384 deletions

View File

@@ -9,7 +9,7 @@
@inject IIspezioniService IspezioniService
@inject IIntegrySteupService IntegrySteupService
@inject IDialogService Dialog
@inject IAttachedService AttachedService
@inject IFileManager FileManager
<div class="scheda-card">
<div class="scheda-body-section">
@@ -104,7 +104,7 @@
{
foreach (var fileName in Scheda.ImageNames)
{
AttachedService.RemoveInspectionFile(Ispezione, fileName);
FileManager.RemoveInspectionFile(Ispezione, fileName);
}
}
@@ -159,7 +159,7 @@
{
if (Scheda.ImageNames == null) return;
var fileList = (await AttachedService.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
var fileList = (await FileManager.GetInspectionFiles(Ispezione, Scheda.ImageNames))?
.Where(x => x.ToUpload).ToList();
if (fileList == null) return;

View File

@@ -1,4 +1,7 @@
<div class="container container-modal">
@using Microsoft.Extensions.Logging
@inject ILogger<ExceptionModal> Logger
<div class="container container-modal">
<div class="c-modal">
<div class="exception-header mb-2">
<i class="ri-emotion-unhappy-line"></i>
@@ -43,6 +46,8 @@
{
Message = Exception.Message;
}
Logger.LogError(Exception, "Errore nel componente Blazor: {Message}", Message);
StateHasChanged();
}

View File

@@ -1,4 +1,6 @@
@using SteUp.Shared.Components.Layout
@using System.Data.Common
@using Microsoft.Extensions.Logging
@using SteUp.Shared.Components.Layout
@using SteUp.Shared.Components.Layout.Overlay
@using SteUp.Shared.Components.Layout.Spinner
@using SteUp.Shared.Components.SingleElements.Card.ModalForm
@@ -13,10 +15,11 @@
@inject INetworkService NetworkService
@inject IDialogService Dialog
@inject IIntegryApiService IntegryApiService
@inject IAttachedService AttachedService
@inject IFileManager FileManager
@inject IIspezioniService IspezioniService
@inject IIntegrySteupService IntegrySteupService
@inject OnScannerService OnScannerService
@inject ILogger<ModalFormScheda> Logger
<MudDialog Class="customDialog-form">
<DialogContent>
@@ -75,7 +78,7 @@
}
<MudCardContent Class="image_card">
<MudText Typo="Typo.subtitle1"><b>@item.p.Name</b></MudText>
@if (IsNew)
@if (item.p.ToUpload)
{
<MudIconButton Variant="Variant.Outlined"
Icon="@Icons.Material.Rounded.Close"
@@ -236,7 +239,7 @@
Task.Run(async () =>
{
var fileList = await AttachedService.GetInspectionFiles(
var fileList = await FileManager.GetInspectionFiles(
new Ispezione
{
CodMdep = CodMdep,
@@ -285,17 +288,19 @@
}
catch (Exception e)
{
Console.WriteLine(e.Message);
var message = e.Message;
await Dialog.ShowError(e.Message);
Logger.LogError(e, message);
Console.WriteLine(message);
await Dialog.ShowError(message);
}
if (IsNew) await NewSave(apiResponse);
else await Update(apiResponse);
if (Scheda.ActivityId.IsValorized()) await UploadFile(Scheda.ActivityId!);
if (Scheda.ActivityId.IsValorized()) await UploadFile(Scheda);
await AttachedService.CleanTempStorageAsync();
await FileManager.CleanTempStorageAsync();
SuccessAnimation = true;
StateHasChanged();
@@ -311,7 +316,7 @@
{
foreach (var attached in AttachedList!)
{
var fileNameAdded = await AttachedService.SaveInspectionFile(
var fileNameAdded = await FileManager.SaveInspectionFile(
new Ispezione
{
CodMdep = CodMdep,
@@ -354,7 +359,7 @@
if (!attached.ToRemove)
{
var fileNameAdded = await AttachedService.SaveInspectionFile(
var fileNameAdded = await FileManager.SaveInspectionFile(
ispezione,
attached.FileBytes!,
attached.Name!
@@ -365,7 +370,7 @@
Scheda.ImageNames.Add(fileNameAdded);
}
else
_ = AttachedService.RemoveInspectionFile(ispezione, attached.Name!);
_ = FileManager.RemoveInspectionFile(ispezione, attached.Name!);
}
}
@@ -378,7 +383,7 @@
);
}
private async Task UploadFile(string activityId)
private async Task UploadFile(Scheda scheda)
{
if (AttachedList.IsNullOrEmpty()) return;
@@ -393,16 +398,23 @@
{
if (file.FileBytes == null || file.Name == null) continue;
await IntegrySteupService.UploadFile(activityId, file.FileBytes, file.Name);
await AttachedService.MoveInspectionFileFromToUploadToFinal(ispezione, file.Name);
await IntegrySteupService.UploadFile(scheda.ActivityId!, file.FileBytes, file.Name);
var newPath = await FileManager.MoveInspectionFileFromToUploadToFinal(ispezione, file.Name);
if (newPath == null) continue;
var filePathToRemove = FileManager.GetFileToUploadDir(ispezione, file.Name);
scheda.ImageNames!.Remove(filePathToRemove);
scheda.ImageNames.Add(newPath);
}
await IspezioniService.UpdateFileListSchedaAsync(scheda.Id, scheda.ImageNames);
}
private async Task Cancel()
{
if (await CheckSavePreAction())
{
await AttachedService.CleanTempStorageAsync();
await FileManager.CleanTempStorageAsync();
DisposeMessage();
MudDialog.Cancel();
}
@@ -500,7 +512,7 @@
var a = attachedList[i];
if (a.FileBytes is null || a.Name is null) continue;
var (origUrl, thumbUrl) = await AttachedService.SaveAndCreateThumbAsync(a.FileBytes, a.Name);
var (origUrl, thumbUrl) = await FileManager.SaveAndCreateThumbAsync(a.FileBytes, a.Name);
await InvokeAsync(() =>
{
@@ -557,7 +569,7 @@
TextLoading = null;
StateHasChanged();
OnError(e.Message);
OnError(e, e.Message);
});
return;
@@ -670,7 +682,7 @@
}
else
{
OnError("Nessun articolo trovato");
OnError(null, "Nessun articolo trovato");
}
});
}
@@ -684,18 +696,19 @@
StateHasChanged();
});
OnError(e.Message);
OnError(e, e.Message);
}
}
private void OnErrorScan(string? value) => OnError(value);
private void OnErrorScan(string? value) => OnError(new Exception(value), value);
#endregion
private void OnError(string? errorMessage)
private void OnError(Exception? e, string? errorMessage)
{
if (e != null) Logger.LogError(e, errorMessage);
if (errorMessage == null) return;
_ = Dialog.ShowError(errorMessage);
}

View File

@@ -8,7 +8,7 @@
<div class="shop-header">
<div class="shop-title">
<MudText Typo="Typo.h5"><b>Seleziona il negozio</b></MudText>
<MudIconButton Icon="@Icons.Material.Rounded.Close" Size="Size.Small" OnClick="@Cancel"/>
</div>
@@ -67,19 +67,20 @@
if (FilterText.IsNullOrEmpty())
{
FilteredList = SteupDataService.PuntiVenditaList;
StateHasChanged();
return;
}
else
{
FilteredList = SteupDataService.PuntiVenditaList.FindAll(x =>
(x.Indirizzo != null && x.Indirizzo.ContainsIgnoreCase(FilterText!)) ||
(x.Descrizione != null && x.Descrizione.ContainsIgnoreCase(FilterText!)) ||
(x.CodMdep != null && x.CodMdep.ContainsIgnoreCase(FilterText!)) ||
(x.Citta != null && x.Citta.ContainsIgnoreCase(FilterText!)) ||
(x.Cap != null && x.Cap.ContainsIgnoreCase(FilterText!)) ||
(x.Provincia != null && x.Provincia.ContainsIgnoreCase(FilterText!))
);
}
FilteredList = SteupDataService.PuntiVenditaList.FindAll(x =>
(x.Indirizzo != null && x.Indirizzo.ContainsIgnoreCase(FilterText!)) ||
(x.Descrizione != null && x.Descrizione.ContainsIgnoreCase(FilterText!)) ||
(x.CodMdep != null && x.CodMdep.ContainsIgnoreCase(FilterText!)) ||
(x.Citta != null && x.Citta.ContainsIgnoreCase(FilterText!)) ||
(x.Cap != null && x.Cap.ContainsIgnoreCase(FilterText!)) ||
(x.Provincia != null && x.Provincia.ContainsIgnoreCase(FilterText!))
);
FilteredList = FilteredList.OrderBy(x => x.CodMdep).ToList();
StateHasChanged();
}