From 10e3004977bb80cfc0db6756ba72cdb24a231847 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 20 Oct 2023 12:06:29 +0200 Subject: [PATCH] Update con cancellazione pdf oltre 6 mesi --- LPA/MainForm.cs | 2 +- LPA/reportPrinter.cs | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/LPA/MainForm.cs b/LPA/MainForm.cs index 195b5b8..db1c6d5 100644 --- a/LPA/MainForm.cs +++ b/LPA/MainForm.cs @@ -642,7 +642,7 @@ namespace LPA { // parto da template base template = item.template; - //se non c'è uso quello della cosa... + //se non c'è uso quello della coda... if (string.IsNullOrEmpty(template)) { template = confCoda.template; diff --git a/LPA/reportPrinter.cs b/LPA/reportPrinter.cs index eaec7b9..2d4b2c9 100644 --- a/LPA/reportPrinter.cs +++ b/LPA/reportPrinter.cs @@ -319,7 +319,34 @@ namespace LPA // salvo il log degli update if (eliminati > 0) { - Log.Instance.Info($"Eliminati {eliminati} files temporanei da area temp"); + Log.Instance.Info($"Eliminati {eliminati} files EMF temporanei da area temp"); + } + + // verifica file pdf vecchi (oltre 5 mesi...) + currPath = $"{baseDir}{localPdfPath}"; + eliminati = 0; + // ottengo elenco files *.emf + fileMover.obj.setDirectory(currPath); + _fis = Directory.GetFiles(currPath, "*.pdf", SearchOption.AllDirectories); + fatto = false; + foreach (var _fileName in _fis) + { + FileInfo file = new FileInfo(_fileName); + if (file.CreationTime < DateTime.Now.AddMonths(-5)) // elimino files vecchi... + { + fatto = fileMover.obj.eliminaFile(file); + if (fatto) + { + Log.Instance.Info($"Eliminato file {file.Name}"); + eliminati++; + } + } + } + + // salvo il log degli update + if (eliminati > 0) + { + Log.Instance.Info($"Eliminati {eliminati} files EMF temporanei da area temp"); } } catch (Exception exc)