Creato metodo per la rimozione delle ispezioni più vecchie di 60 giorni
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
@using System.Data.Common
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using Microsoft.Extensions.Logging
|
||||
@using SteUp.Shared.Components.Layout
|
||||
@using SteUp.Shared.Components.Layout.Overlay
|
||||
@using SteUp.Shared.Components.Layout.Spinner
|
||||
|
||||
@@ -17,6 +17,7 @@ public class SteupDataService(
|
||||
IDeviceService deviceService,
|
||||
IGenericSystemService genericSystemService,
|
||||
IIspezioniService ispezioniService,
|
||||
IFileManager fileManager,
|
||||
IDbInitializer dbInitializer) : ISteupDataService
|
||||
{
|
||||
public async Task Init()
|
||||
@@ -24,6 +25,7 @@ public class SteupDataService(
|
||||
await dbInitializer.InitializeAsync();
|
||||
await LoadDataAsync();
|
||||
await CheckAndUpdateStatus();
|
||||
await CleanOldClosedInspection();
|
||||
RegisterAppVersion();
|
||||
}
|
||||
|
||||
@@ -34,6 +36,21 @@ public class SteupDataService(
|
||||
);
|
||||
}
|
||||
|
||||
private async Task CleanOldClosedInspection()
|
||||
{
|
||||
var ispezioni = (await ispezioniService.GetAllIspezioniWithSchedeAsync())
|
||||
.Where(x =>
|
||||
x.Stato == StatusEnum.Completata &&
|
||||
x.Data < DateTime.Now.AddDays(-60)
|
||||
).ToList();
|
||||
|
||||
foreach (var ispezione in ispezioni)
|
||||
{
|
||||
fileManager.RemoveInspection(ispezione);
|
||||
await ispezioniService.DeleteIspezioneAsync(ispezione.CodMdep, ispezione.Data, ispezione.Rilevatore);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task CheckAndUpdateStatus()
|
||||
{
|
||||
var ispezioni = await ispezioniService.GetAllIspezioniWithSchedeAsync();
|
||||
|
||||
@@ -12,6 +12,7 @@ public interface IFileManager
|
||||
|
||||
string GetFileToUploadDir(Ispezione ispezione, string fileName);
|
||||
|
||||
bool RemoveInspection(Ispezione ispezione, bool removeAlsoFromFinal = true, bool removeAlsoFromToUpload = true);
|
||||
bool RemoveInspectionFile(Ispezione ispezione, string fileName, bool removeAlsoFromFinal = true,
|
||||
bool removeAlsoFromToUpload = true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user