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

@@ -1,4 +1,5 @@
@page "/ispezione"
@using Microsoft.Extensions.Logging
@using SteUp.Shared.Components.Layout
@using SteUp.Shared.Components.Layout.Overlay
@using SteUp.Shared.Components.SingleElements.Card
@@ -15,7 +16,8 @@
@inject IIspezioniService IspezioniService
@inject IDialogService Dialog
@inject IIntegrySteupService IntegrySteupService
@inject IAttachedService AttachedService
@inject IFileManager FileManager
@inject ILogger<IspezionePage> Logger
@implements IDisposable
<HeaderLayout Title="Ispezione" BackTo="Indietro" Back="true"/>
@@ -150,7 +152,7 @@
if (scheda.ImageNames == null) continue;
var fileList = (await AttachedService.GetInspectionFiles(ispezione, scheda.ImageNames))?
var fileList = (await FileManager.GetInspectionFiles(ispezione, scheda.ImageNames))?
.Where(x => x.ToUpload).ToList();
if (fileList == null) continue;
@@ -187,7 +189,7 @@
StateHasChanged();
});
OnError(e.Message);
OnError(e, e.Message);
}
}
@@ -286,8 +288,9 @@
StateHasChanged();
}
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

@@ -1,4 +1,5 @@
@page "/login"
@using Microsoft.Extensions.Logging
@using SteUp.Shared.Components.Layout.Spinner
@using SteUp.Shared.Core.BarcodeReader.Contracts
@using SteUp.Shared.Core.Interface.System
@@ -7,6 +8,7 @@
@inject AppAuthenticationStateProvider AuthenticationStateProvider
@inject IGenericSystemService GenericSystemService
@inject IBarcodeManager BarcodeManager
@inject ILogger<LoginPage> Logger
@if (Spinner)
{
@@ -100,12 +102,13 @@ else
}
catch (Exception e)
{
ErrorMessage = e.Message;
Logger.LogError(e, ErrorMessage);
Console.WriteLine(e.Message);
Spinner = false;
StateHasChanged();
ErrorMessage = e.Message;
_attemptFailed = true;
Console.WriteLine(e);
}

View File

@@ -1,13 +1,19 @@
@page "/user"
@attribute [Authorize]
@using SteUp.Shared.Components.Layout
@using SteUp.Shared.Components.Layout.Overlay
@using SteUp.Shared.Components.SingleElements
@using SteUp.Shared.Core.Authorization.Enum
@using SteUp.Shared.Core.Interface.System.Network
@using SteUp.Shared.Core.Dto
@using SteUp.Shared.Core.Interface.IntegryApi
@using SteUp.Shared.Core.Interface.System
@using SteUp.Shared.Core.Services
@using SteUp.Shared.Core.Utility
@inject AppAuthenticationStateProvider AuthenticationStateProvider
@inject INetworkService NetworkService
@inject IGenericSystemService GenericSystemService
@inject IFileManager FileManager
@inject IIntegryApiService IntegryApiService
<HeaderLayout Title="Profilo"/>
@@ -62,19 +68,30 @@
</div>
</div>
</div>
<div class="container-button ripple-container mud-elevation-1">
<MudButton Class="button-settings red-icon"
FullWidth="true"
StartIcon="@Icons.Material.Rounded.UploadFile"
Size="Size.Medium"
OnClick="@ExportLog"
Variant="Variant.Outlined">
Esporta log
</MudButton>
</div>
<div class="container-button mud-elevation-1">
<div class="container-button ripple-container mud-elevation-1">
<MudButton Class="button-settings green-icon"
FullWidth="true"
StartIcon="@Icons.Material.Outlined.Sync"
Size="Size.Medium"
OnClick="@UpdateDb"
Variant="Variant.Outlined">
Sincronizza ispezioni
Sincronizza ispezioni esportate
</MudButton>
</div>
<div class="container-button mud-elevation-1">
<div class="container-button ripple-container mud-elevation-1">
<MudButton Class="button-settings exit"
FullWidth="true"
Color="Color.Error"
@@ -89,8 +106,11 @@
</div>
}
<SpinnerOverlay VisibleOverlay="VisibleOverlay"/>
@code {
private bool IsLoggedIn { get; set; }
private bool VisibleOverlay { get; set; }
private string? CodHash { get; set; } = "";
protected override async Task OnInitializedAsync()
@@ -100,8 +120,41 @@
StateHasChanged();
}
private void UpdateDb()
private async Task ExportLog()
{
VisibleOverlay = true;
StateHasChanged();
var profiloAzienda = LocalStorage.GetString("codHash");
var email = new SendEmailDto
{
FromName = "Integry Log",
To = "developer@integry.it",
Subject = $"SteUP - Log del {DateTime.Today:d} di {UserSession.User.Username}",
IsHtml = true,
MsgText = $"Username: <b>{UserSession.User.Username}</b><br/>" +
$"Profilo azienda: <b>{profiloAzienda}</b><br/>" +
$"ProfileDb: <b>{UserSession.ProfileDb}</b><br/>" +
$"Versione app: <b>{GenericSystemService.GetCurrentAppVersion()}</b>",
Attachments = FileManager.GetFileForExport()
};
await IntegryApiService.SendEmail(email);
VisibleOverlay = false;
StateHasChanged();
}
private async Task UpdateDb()
{
VisibleOverlay = true;
StateHasChanged();
await SteupDataService.CheckAndUpdateStatus();
VisibleOverlay = false;
StateHasChanged();
}
private async Task Logout()