Aggiunto blocco per ispezioni non completate più vecchie di 20 giorni

This commit is contained in:
2026-03-02 12:30:24 +01:00
parent ab9578a45f
commit 63368748ab
13 changed files with 232 additions and 142 deletions

View File

@@ -6,6 +6,7 @@ namespace SteUp.Shared.Core.Data.Contracts;
public interface ISteupDataService
{
Task Init();
Task<bool> CanOpenNewInspection();
void RegisterAppVersion();
List<PuntoVenditaDto> PuntiVenditaList { get; }

View File

@@ -3,11 +3,11 @@ using IntegryApiClient.Core.Domain.Abstraction.Contracts.Device;
using SteUp.Shared.Core.Data.Contracts;
using SteUp.Shared.Core.Dto;
using SteUp.Shared.Core.Dto.PageState;
using SteUp.Shared.Core.Enum;
using SteUp.Shared.Core.Helpers;
using SteUp.Shared.Core.Interface.IntegryApi;
using SteUp.Shared.Core.Interface.LocalDb;
using SteUp.Shared.Core.Interface.System;
using SteUp.Shared.Core.Interface.System.Network;
namespace SteUp.Shared.Core.Data;
@@ -76,6 +76,20 @@ public class SteupDataService(
}
}
public async Task<bool> CanOpenNewInspection()
{
var completedInspection = await ispezioniService.GetAllIspezioni();
if (completedInspection.IsNullOrEmpty()) return true;
//Controllo se sono presenti attività più vecchie di 20 giorni non chiuse
//Se presenti non si possono aprire nuove ispezioni
return !completedInspection.Any(x =>
x.Stato != StatusEnum.Completata &&
x.Data < DateTime.Now.AddDays(-20)
);
}
private async Task LoadDataAsync()
{
if (!await userSession.IsLoggedIn()) return;

View File

@@ -6,129 +6,154 @@ using SteUp.Shared.Core.Entities;
namespace SteUp.Shared.Core.Helpers;
public abstract class ModalHelper
public static class ModalHelper
{
public static async Task<DialogResult?> OpenSelectShop(IDialogService dialog)
extension(IDialogService dialog)
{
var modal = await dialog.ShowAsync<ModalSelectShop>(
"ModalSelectShop",
new DialogParameters(),
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true
}
);
public async Task<DialogResult?> OpenSelectShop()
{
var modal = await dialog.ShowAsync<ModalSelectShop>(
"ModalSelectShop",
new DialogParameters(),
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true
}
);
return await modal.Result;
}
return await modal.Result;
}
public static async Task<DialogResult?> OpenFormScheda(IDialogService dialog, string codMdep, DateTime data,
bool isNew = false, Scheda? scheda = null)
{
scheda = isNew && scheda == null ? new Scheda() : scheda;
public async Task<DialogResult?> OpenFormScheda(string codMdep, DateTime data,
bool isNew = false, Scheda? scheda = null)
{
scheda = isNew && scheda == null ? new Scheda() : scheda;
var modal = await dialog.ShowAsync<ModalFormScheda>(
"ModalFormScheda",
new DialogParameters<ModalFormScheda>
{
{ x => x.CodMdep, codMdep },
{ x => x.Data, data },
{ x => x.IsNew, isNew },
{ x => x.Scheda, scheda }
},
new DialogOptions
{
FullScreen = true,
CloseButton = false,
NoHeader = true
}
);
var modal = await dialog.ShowAsync<ModalFormScheda>(
"ModalFormScheda",
new DialogParameters<ModalFormScheda>
{
{ x => x.CodMdep, codMdep },
{ x => x.Data, data },
{ x => x.IsNew, isNew },
{ x => x.Scheda, scheda }
},
new DialogOptions
{
FullScreen = true,
CloseButton = false,
NoHeader = true
}
);
return await modal.Result;
}
return await modal.Result;
}
public static async Task<DialogResult?> OpenAddAttached(IDialogService dialog)
{
var modal = await dialog.ShowAsync<ModalAddAttached>(
"Add attached",
new DialogParameters(),
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = false
}
);
public async Task<DialogResult?> OpenAddAttached()
{
var modal = await dialog.ShowAsync<ModalAddAttached>(
"Add attached",
new DialogParameters(),
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = false
}
);
return await modal.Result;
}
return await modal.Result;
}
public static async Task<DialogResult?> OpenSuggestActivityDescription(IDialogService dialog,
List<StbActivityTyperDto>? activityTypers)
{
var modal = await dialog.ShowAsync<ModalSuggestDescription>(
"Suggest activity description",
new DialogParameters<ModalSuggestDescription>
{
{ x => x.ActivityTypers, activityTypers }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true
}
);
public async Task<DialogResult?> OpenSuggestActivityDescription(List<StbActivityTyperDto>? activityTypers)
{
var modal = await dialog.ShowAsync<ModalSuggestDescription>(
"Suggest activity description",
new DialogParameters<ModalSuggestDescription>
{
{ x => x.ActivityTypers, activityTypers }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true
}
);
return await modal.Result;
}
return await modal.Result;
}
public static async Task<DialogResult?> OpenSelectArt(IDialogService dialog, List<ArticoliInGrigliaDto>? articoli)
{
var modal = await dialog.ShowAsync<ModalSelectArt>(
"ModalSelectArt",
new DialogParameters<ModalSelectArt>
{
{ x => x.Articoli, articoli }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
public async Task<DialogResult?> OpenSelectArt(List<ArticoliInGrigliaDto>? articoli)
{
var modal = await dialog.ShowAsync<ModalSelectArt>(
"ModalSelectArt",
new DialogParameters<ModalSelectArt>
{
{ x => x.Articoli, articoli }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
return await modal.Result;
}
return await modal.Result;
}
public static async Task ShowError(IDialogService dialog, string message)
{
var modal = await dialog.ShowAsync<ModalError>(
"ModalError",
new DialogParameters<ModalError>
{
{ x => x.ErrorMessage, message }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
public async Task ShowError(string message)
{
var modal = await dialog.ShowAsync<ModalError>(
"ModalError",
new DialogParameters<ModalError>
{
{ x => x.ErrorMessage, message }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
await modal.Result;
await modal.Result;
}
public async Task ShowWarning(string message)
{
var modal = await dialog.ShowAsync<ModalError>(
"ModalError",
new DialogParameters<ModalError>
{
{ x => x.ErrorMessage, message },
{ x => x.IsWarning, true }
},
new DialogOptions
{
FullScreen = false,
CloseButton = false,
NoHeader = true,
BackdropClick = true,
FullWidth = true,
MaxWidth = MaxWidth.ExtraLarge
}
);
await modal.Result;
}
}
}

View File

@@ -17,4 +17,6 @@ public interface IIntegrySteupService
Task<SaveSchedaResponseDto?> SaveMultipleSchede(List<SaveRequestDto> request);
Task CompleteInspection(string activityId);
Task UploadFile(string activityId, byte[] file, string fileName);
Task DeleteScheda(string activityId);
}

View File

@@ -1,4 +1,5 @@
using SteUp.Shared.Core.Entities;
using System.Linq.Expressions;
using SteUp.Shared.Core.Entities;
using SteUp.Shared.Core.Enum;
namespace SteUp.Shared.Core.Interface.LocalDb;
@@ -7,6 +8,7 @@ public interface IIspezioniService
{
// ISPEZIONI
Task<Ispezione?> GetIspezioneAsync(string codMdep, DateTime data, string rilevatore);
Task<List<Ispezione>> GetAllIspezioni();
Task<List<Ispezione>> GetAllIspezioniWithSchedeAsync();
Task AddIspezioneAsync(Ispezione ispezione);
Task<Ispezione> GetOrCreateIspezioneAsync(string codMdep, DateTime data, string rilevatore);

View File

@@ -67,4 +67,13 @@ public class IntegrySteupService(IIntegryApiRestClient integryApiRestClient) : I
return integryApiRestClient.Post<object>($"{BaseRequest}/uploadAttachment", content, queryParams!);
}
public Task DeleteScheda(string activityId) =>
integryApiRestClient.AuthorizedGet<object>(
$"{BaseRequest}/deleteScheda",
new Dictionary<string, object>
{
{ "activityId", activityId }
}
);
}