From 55e8aada24dde6bb1a751e37c396b7e350f8ecf9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 12 Apr 2023 17:46:29 +0200 Subject: [PATCH] Ok processing settimane consumo passate... --- IOB-WIN-NEXT/IobGeneric.cs | 42 +++++++++++++++++++++++++++----------- IOB-WIN-NEXT/IobSimula.cs | 8 +++++--- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/IOB-WIN-NEXT/IobGeneric.cs b/IOB-WIN-NEXT/IobGeneric.cs index c605733a..8c01e1bb 100644 --- a/IOB-WIN-NEXT/IobGeneric.cs +++ b/IOB-WIN-NEXT/IobGeneric.cs @@ -6057,8 +6057,8 @@ namespace IOB_WIN_NEXT // ora cerca nella folder locale e processa i files... bool okCheck = RecipeDoCheckFileProc(tempPath, archBasePath); - // verifica se sia da creare/inviare il record settimanale di consumo - bool okSent = RecipeDoProcCons(archBasePath, "W"); + // verifica se sia da creare/inviare il record settimanale di consumo (dopo la mezzanotte del lunedì inizio settimana) + bool okSent = RecipeDoProcCons(); } return answ; } @@ -6141,8 +6141,6 @@ namespace IOB_WIN_NEXT protected virtual bool RecipeDoCheckFileProc(string localPath, string archBasePath) { bool answ = false; - DateTime adesso = DateTime.Now; - Calendar cal = new CultureInfo("it-IT").Calendar; List weekProcNew = new List(); // recupero elenco files... @@ -6191,8 +6189,10 @@ namespace IOB_WIN_NEXT // salvo in redis... string fullKey = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:WeekStats"); var okHashDict = redisMan.redSaveHashDict(fullKey, redHashWeek); +#if false // manda a MP-IO update delle settimane processate (+ azioni) - var currStats = redisMan.redGetHashDict(fullKey); + Dictionary currStats = redisMan.redGetHashDict(fullKey); +#endif // invio ANCHE in MP-IO l'update delle info... string remUrl = urlSetHashDict; string dictPayload = JsonConvert.SerializeObject(redHashWeek); @@ -6208,16 +6208,34 @@ namespace IOB_WIN_NEXT /// /// Verifica se si debba registrare/inviare il report periodico di consumo indicato /// - /// - /// Report di consumo: D/W/M (day, week, month...) /// - protected bool RecipeDoProcCons(string archBasePath, string repType) + protected bool RecipeDoProcCons() { bool answ = false; - // NB: invio AS400 inKG, 2 decimali (N2) - - // implementare d Dict task da eseguire, x ogni settimana PASSATA effettua SendArch.... - + // calcolo quale sia la settimana corrente... + int week = 0; + DateTime adesso = DateTime.Now; + Calendar cal = new CultureInfo("it-IT").Calendar; + // calcolo week da data-ora file... + week = cal.GetWeekOfYear(adesso, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday); + // verifico se ci sia la settimana indicata in elenco... + string currWeek = $"{adesso:yyyy}-{week:00}"; + // recupero elenco delle settimane da processare da redis/WeekStats + string fullKey = redisMan.redHash($"IOB:Status:{cIobConf.codIOB}:WeekStats"); + Dictionary currStats = redisMan.redGetHashDict(fullKey); + if (currStats != null && currStats.Count > 0) + { + // definisco il DICT delle settimane da processare (= settimane passate, NON la corrente...) + foreach (var weekData in currStats) + { + if (weekData.Key != currWeek) + { + // ...x ogni settimana PASSATA effettua SendArch... --> lancia un task! + processOtherInfo(weekData.Key, "SendArch"); + } + } + answ = true; + } return answ; } diff --git a/IOB-WIN-NEXT/IobSimula.cs b/IOB-WIN-NEXT/IobSimula.cs index 6c99a71c..b1101aa9 100644 --- a/IOB-WIN-NEXT/IobSimula.cs +++ b/IOB-WIN-NEXT/IobSimula.cs @@ -129,9 +129,11 @@ namespace IOB_WIN_NEXT // effettua process ritorno ricette processRecipeFileRet(); - // eseguo test x ricette CABLATO... - processOtherInfo("2023-05", "SendArch"); - //processOtherInfo("2023-05", "Arch"); + // eseguo verifica/lancio ricette + RecipeDoProcCons(); + //// eseguo test x ricette CABLATO... + //processOtherInfo("2023-05", "SendArch"); + ////processOtherInfo("2023-05", "Arch"); } }