From 6ca41ed7204fe59e844bf42f6b2adfbff5c4c1c5 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 26 Oct 2024 12:51:10 +0200 Subject: [PATCH] MP.TaskMan +MP. STATS - eliminazione riferimenti codice escluso da compilazione - pulizia codice da componenti non impiegati NON ancora 100% ok pulizia --- Egw.Core/Utils.cs | 32 ++ MP-STATS.sln | 12 + MP.AppAuth/MP.AppAuth.csproj | 2 +- MP.Data/Controllers/MpLandController.cs | 376 +--------------------- MP.Data/Controllers/MpStatsController.cs | 320 ------------------- MP.Data/MgModels/RecipeModel.cs | 7 - MP.Data/MoonProContext.cs | 8 - MP.Data/MoonPro_STATSContext.cs | 5 - MP.Data/Objects/Enums.cs | 80 ----- MP.Data/Services/RestCallService.cs | 115 ------- MP.Data/Services/TaskService.cs | 370 ---------------------- MP.Data/Utils.cs | 20 -- MP.Land/Components/SearchMod.razor | 5 +- MP.Land/MP.Land.csproj | 4 +- MP.Land/Pages/Index.razor | 2 +- MP.Land/Pages/TaskScheduler.razor | 190 +----------- MP.Land/Pages/TaskScheduler.razor.cs | 380 +---------------------- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- MP.Land/Shared/NavMenu.razor.cs | 1 - MP.Stats/Data/MpStatsService.cs | 12 +- MP.Stats/MP.Stats.csproj | 18 +- MP.Stats/Pages/Controlli.razor.cs | 2 +- MP.Stats/Pages/Diario.razor.cs | 2 +- MP.Stats/Pages/Energy.razor.cs | 2 +- MP.Stats/Pages/Oee.razor.cs | 2 +- MP.Stats/Pages/ReportODL.razor.cs | 2 +- MP.Stats/Pages/Scarti.razor.cs | 2 +- MP.Stats/Pages/TaskScheduler.razor | 2 +- MP.Stats/Pages/TaskScheduler.razor.cs | 11 +- MP.Stats/Pages/UserLog.razor.cs | 2 +- MP.Stats/Resources/ChangeLog.html | 2 +- MP.Stats/Resources/VersNum.txt | 2 +- MP.Stats/Resources/manifest.xml | 2 +- MP.Stats/_Imports.razor | 2 + MP.TaskMan/MP.TaskMan.csproj | 8 + MP.TaskMan/TaskList.razor | 190 ++++++++++++ MP.TaskMan/TaskList.razor.cs | 363 ++++++++++++++++++++++ MP.TaskMan/_Imports.razor | 4 +- 40 files changed, 666 insertions(+), 1899 deletions(-) create mode 100644 Egw.Core/Utils.cs delete mode 100644 MP.Data/Services/RestCallService.cs delete mode 100644 MP.Data/Services/TaskService.cs create mode 100644 MP.TaskMan/TaskList.razor create mode 100644 MP.TaskMan/TaskList.razor.cs diff --git a/Egw.Core/Utils.cs b/Egw.Core/Utils.cs new file mode 100644 index 00000000..91376768 --- /dev/null +++ b/Egw.Core/Utils.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Egw.Core +{ + public class Utils + { + /// + /// Effettua salvataggio in file di un generico oggetto in formato CSV + /// + /// + /// + /// + /// Separatore da impiegare + /// + public static async Task SaveToCsv(List reportData, string path, char separator) + { + var lines = new List(); + IEnumerable props = TypeDescriptor.GetProperties(typeof(T)).OfType(); + var header = string.Join(";", props.ToList().Select(x => x.Name)); + lines.Add(header); + var valueLines = reportData.Select(row => string.Join(separator, header.Split(separator).Select(a => row.GetType().GetProperty(a).GetValue(row, null)))); + //var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null)))); + lines.AddRange(valueLines); + await Task.Run(() => File.WriteAllLines(path, lines.ToArray())); + } + } +} diff --git a/MP-STATS.sln b/MP-STATS.sln index 16ba2c74..30bbf192 100644 --- a/MP-STATS.sln +++ b/MP-STATS.sln @@ -7,6 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Stats", "MP.Stats\MP.Sta EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.Data", "MP.Data\MP.Data.csproj", "{10BA8450-301D-49C7-8E1E-21B7469C225C}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MP.TaskMan", "MP.TaskMan\MP.TaskMan.csproj", "{D334DE4B-1F54-4F30-899B-9ECB79C9F527}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Egw.Core", "Egw.Core\Egw.Core.csproj", "{BC94E319-A622-497C-BEE1-BB3D77170A6D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +25,14 @@ Global {10BA8450-301D-49C7-8E1E-21B7469C225C}.Debug|Any CPU.Build.0 = Debug|Any CPU {10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.ActiveCfg = Release|Any CPU {10BA8450-301D-49C7-8E1E-21B7469C225C}.Release|Any CPU.Build.0 = Release|Any CPU + {D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D334DE4B-1F54-4F30-899B-9ECB79C9F527}.Release|Any CPU.Build.0 = Release|Any CPU + {BC94E319-A622-497C-BEE1-BB3D77170A6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC94E319-A622-497C-BEE1-BB3D77170A6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC94E319-A622-497C-BEE1-BB3D77170A6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC94E319-A622-497C-BEE1-BB3D77170A6D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MP.AppAuth/MP.AppAuth.csproj b/MP.AppAuth/MP.AppAuth.csproj index 95ecb38c..f5648765 100644 --- a/MP.AppAuth/MP.AppAuth.csproj +++ b/MP.AppAuth/MP.AppAuth.csproj @@ -18,7 +18,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/MP.Data/Controllers/MpLandController.cs b/MP.Data/Controllers/MpLandController.cs index 289a88e7..92f56963 100644 --- a/MP.Data/Controllers/MpLandController.cs +++ b/MP.Data/Controllers/MpLandController.cs @@ -14,8 +14,7 @@ using static MP.Data.Objects.Enums; namespace MP.Data.Controllers { /// - /// Controller specifico x LAND - /// FixMe ToDo !!! è ancora necessario con obj task estratti?!?!? + /// Controller specifico x LAND FixMe ToDo !!! è ancora necessario con obj task estratti?!?!? /// public class MpLandController : IDisposable { @@ -31,60 +30,6 @@ namespace MP.Data.Controllers #region Public Methods -#if false - public DateTime CalcNextExe(TaskListModel taskRec) - { - DateTime dtNext = DateTime.Today; - try - { - // calcolo next exec da tipo... - switch (taskRec.Freq) - { - case TaskFreqType.ND: - dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad); - break; - - case TaskFreqType.Sec: - dtNext = taskRec.DtLastExec.AddSeconds(taskRec.Cad); - break; - - case TaskFreqType.Min: - dtNext = taskRec.DtLastExec.AddMinutes(taskRec.Cad); - break; - - case TaskFreqType.Hour: - dtNext = taskRec.DtLastExec.AddHours(taskRec.Cad); - break; - - case TaskFreqType.Day: - dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad); - break; - - case TaskFreqType.Week: - dtNext = taskRec.DtLastExec.AddDays(7 * taskRec.Cad); - break; - - case TaskFreqType.Month: - dtNext = taskRec.DtLastExec.AddMonths(taskRec.Cad); - break; - - case TaskFreqType.Year: - dtNext = taskRec.DtLastExec.AddYears(taskRec.Cad); - break; - - default: - dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad); - break; - } - } - catch (Exception exc) - { - Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}"); - } - return dtNext; - } -#endif - /// /// Elenco da tabella Config /// @@ -127,83 +72,6 @@ namespace MP.Data.Controllers return dbResult; } -#if false - /// - /// Chiamata esecuzione di un singolo task programmato - /// - /// - /// Se true rischedula successiva chiamata - /// - public TaskResultModel ExecuteSqlTask(int TaskId, bool SchedNext) - { - TaskResultModel callRes = new TaskResultModel(); - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - // imposto timeout a 5 min - //var currTimeout = dbCtx.Database.GetCommandTimeout(); - dbCtx.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); - try - { - DateTime dtStart = DateTime.Now; - // recupero i dati da richiamare... - var currRec = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == TaskId) - .FirstOrDefault(); - if (currRec != null) - { - // recupero comando - string sqlCommand = currRec.Command; - string rawParams = currRec.Args; - callRes = dbCtx - .DbSetTaskResult - .FromSqlRaw($"EXEC {sqlCommand} {rawParams}") - .AsNoTracking() - .AsEnumerable() - .FirstOrDefault(); - DateTime dtEnd = DateTime.Now; - - // preparo record esecuzione... - TaskExecModel resRec = new TaskExecModel() - { - TaskId = TaskId, - DtStart = dtStart, - DtEnd = dtEnd, - IsError = callRes.ExecResult < 0, - Result = callRes.TextResult - }; - dbCtx - .DbSetTaskExe - .Add(resRec); - - // aggiorno record chiamata... - currRec.DtLastExec = dtStart; - currRec.LastResult = resRec.Result; - currRec.LastIsError = resRec.IsError; - currRec.LastDuration = dtEnd.Subtract(dtStart).TotalSeconds; - // solo se richiesto rischedulazione ricalcola chiamata - if (SchedNext) - { - // calcolo prossima esecuzione... - currRec.DtNextExec = CalcNextExe(currRec); - } - // segno modificato - dbCtx.Entry(currRec).State = EntityState.Modified; - - // salvo modifiche! - dbCtx.SaveChanges(); - } - } - catch (Exception exc) - { - Log.Error($"Eccezione in ExecuteSqlCommand{Environment.NewLine}{exc}"); - } - } - return callRes; - } - -#endif - /// /// Annulla modifiche su una specifica entity (cancel update) /// @@ -229,248 +97,6 @@ namespace MP.Data.Controllers return answ; } -#if false - /// - /// Ricerca task dato tipo + num max (desc) - /// - /// TaskId da cui deriva - /// - public List TaskExecGetFilt(int TaskId, int maxRec) - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetTaskExe - .Include(x => x.TaskListNav) - .Where(x => (x.TaskId == TaskId)) - .OrderByDescending(x => x.DtStart) - .Take(maxRec) - .ToList(); - } - return dbResult; - } - - /// - /// Upsert record TaskExec - /// - /// Record da aggiornare/inserire - /// - public bool TaskExecUpsert(TaskExecModel rec2upd) - { - bool done = false; - using (var dbCtx = new MoonProContext(_configuration)) - { - try - { - var currData = dbCtx - .DbSetTaskExe - .Where(x => x.TaskExecId == rec2upd.TaskExecId) - .FirstOrDefault(); - if (currData != null) - { - currData.TaskId = rec2upd.TaskId; - currData.DtStart = rec2upd.DtStart; - currData.DtEnd = rec2upd.DtEnd; - currData.IsError = rec2upd.IsError; - currData.Result = rec2upd.Result; - dbCtx.Entry(currData).State = EntityState.Modified; - } - else - { - dbCtx - .DbSetTaskExe - .Add(rec2upd); - } - dbCtx.SaveChanges(); - done = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskExecUpsert{Environment.NewLine}{exc}"); - } - } - return done; - } - - /// - /// Ricerca task dato tipo e - /// - /// - /// - public List TaskListGetAll(Task2ExeType TType) - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetTaskList - .Where(x => (TType == Task2ExeType.ND || x.TType == TType)) - .OrderBy(x => x.Ordinal) - .ToList(); - } - return dbResult; - } - - - /// - /// Esegue registrazione di un Task generico (NON SQL) - /// - /// - /// Se true rischedula successiva chiamata - /// Record esecuzione task esterno - /// - public TaskResultModel TaskExecSaveExecuted(int TaskId, bool SchedNext, TaskExecModel ResRec) - { - TaskResultModel callRes = new TaskResultModel(); - using (var dbCtx = new MoonProContext(_configuration)) - { - try - { - // recupero i dati da richiamare... - var currRec = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == TaskId) - .FirstOrDefault(); - if (currRec != null) - { - // registro task ricevuto - dbCtx - .DbSetTaskExe - .Add(ResRec); - - // aggiorno record chiamata... - currRec.DtLastExec = ResRec.DtStart; - currRec.LastResult = ResRec.Result; - currRec.LastIsError = ResRec.IsError; - currRec.LastDuration = ResRec.DtEnd.Subtract(ResRec.DtStart).TotalSeconds; - // solo se richiesto rischedulazione ricalcola chiamata - if (SchedNext) - { - // calcolo prossima esecuzione... - currRec.DtNextExec = CalcNextExe(currRec); - } - // segno modificato - dbCtx.Entry(currRec).State = EntityState.Modified; - - // salvo modifiche! - dbCtx.SaveChanges(); - } - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskExecSaveExecuted{Environment.NewLine}{exc}"); - } - } - return callRes; - } - /// - /// Update ordinamento task - /// - /// Record da spostare x priorità - /// - public bool TaskListMove(TaskListModel rec2upd, bool moveUp) - { - bool done = false; - using (var dbCtx = new MoonProContext(_configuration)) - { - try - { - var currData = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == rec2upd.TaskId) - .FirstOrDefault(); - if (currData != null) - { - int actOrdinal = currData.Ordinal; - TaskListModel? otherRec = null; - // cerco, secondo richiesta, precedente o successivo - if (moveUp) - { - otherRec = dbCtx - .DbSetTaskList - .Where(x => x.Ordinal < currData.Ordinal) - .OrderByDescending(x => x.Ordinal) - .FirstOrDefault(); - } - else - { - otherRec = dbCtx - .DbSetTaskList - .Where(x => x.Ordinal > currData.Ordinal) - .OrderBy(x => x.Ordinal) - .FirstOrDefault(); - } - // inverto ordinale SE ho record - if (otherRec != null) - { - currData.Ordinal = otherRec.Ordinal; - otherRec.Ordinal = actOrdinal; - dbCtx.Entry(currData).State = EntityState.Modified; - dbCtx.Entry(otherRec).State = EntityState.Modified; - } - } - //salvo - dbCtx.SaveChanges(); - done = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}"); - } - } - return done; - } - - /// - /// Upsert record TaskList - /// - /// Record da aggiornare/inserire - /// - public bool TaskListUpsert(TaskListModel rec2upd) - { - bool done = false; - using (var dbCtx = new MoonProContext(_configuration)) - { - try - { - var currData = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == rec2upd.TaskId && rec2upd.TaskId > 0) - .FirstOrDefault(); - if (currData != null) - { - currData.Ordinal = rec2upd.Ordinal; - currData.Name = rec2upd.Name; - currData.Descript = rec2upd.Descript; - currData.Command = rec2upd.Command; - currData.Args = rec2upd.Args; - currData.Freq = rec2upd.Freq; - currData.Cad = rec2upd.Cad; - currData.DtLastExec = rec2upd.DtLastExec; - currData.DtNextExec = rec2upd.DtNextExec; - currData.LastDuration = rec2upd.LastDuration; - currData.LastResult = rec2upd.LastResult; - dbCtx.Entry(currData).State = EntityState.Modified; - } - else - { - dbCtx - .DbSetTaskList - .Add(rec2upd); - } - dbCtx.SaveChanges(); - done = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}"); - } - } - return done; - } -#endif - #endregion Public Methods #region Private Fields diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 21c42d08..0ca54481 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -63,60 +63,6 @@ namespace MP.Data.Controllers return dbResult; } -#if false - public DateTime CalcNextExe(TaskListModel taskRec) - { - DateTime dtNext = DateTime.Today; - try - { - // calcolo next exec da tipo... - switch (taskRec.Freq) - { - case TaskFreqType.ND: - dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad); - break; - - case TaskFreqType.Sec: - dtNext = taskRec.DtLastExec.AddSeconds(taskRec.Cad); - break; - - case TaskFreqType.Min: - dtNext = taskRec.DtLastExec.AddMinutes(taskRec.Cad); - break; - - case TaskFreqType.Hour: - dtNext = taskRec.DtLastExec.AddHours(taskRec.Cad); - break; - - case TaskFreqType.Day: - dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad); - break; - - case TaskFreqType.Week: - dtNext = taskRec.DtLastExec.AddDays(7 * taskRec.Cad); - break; - - case TaskFreqType.Month: - dtNext = taskRec.DtLastExec.AddMonths(taskRec.Cad); - break; - - case TaskFreqType.Year: - dtNext = taskRec.DtLastExec.AddYears(taskRec.Cad); - break; - - default: - dtNext = taskRec.DtLastExec.AddDays(taskRec.Cad); - break; - } - } - catch (Exception exc) - { - Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}"); - } - return dtNext; - } -#endif - /// /// Elenco tabella Articoli da filtro /// @@ -142,82 +88,6 @@ namespace MP.Data.Controllers { } -#if false - /// - /// Chiamata esecuzione di un singolo task programmato - /// - /// - /// Se true rischedula successiva chiamata - /// - public TaskResultModel ExecuteTask(int TaskId, bool SchedNext) - { - TaskResultModel callRes = new TaskResultModel(); - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - // imposto timeout a 5 min - //var currTimeout = dbCtx.Database.GetCommandTimeout(); - dbCtx.Database.SetCommandTimeout(TimeSpan.FromMinutes(5)); - try - { - DateTime dtStart = DateTime.Now; - // recupero i dati da richiamare... - var currRec = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == TaskId) - .FirstOrDefault(); - if (currRec != null) - { - // recupero comando - string sqlCommand = currRec.Command; - string rawParams = currRec.Args; - callRes = dbCtx - .DbSetTaskResult - .FromSqlRaw($"EXEC {sqlCommand} {rawParams}") - .AsNoTracking() - .AsEnumerable() - .FirstOrDefault(); - DateTime dtEnd = DateTime.Now; - - // preparo record esecuzione... - TaskExecModel resRec = new TaskExecModel() - { - TaskId = TaskId, - DtStart = dtStart, - DtEnd = dtEnd, - IsError = callRes.ExecResult < 0, - Result = callRes.TextResult - }; - dbCtx - .DbSetTaskExe - .Add(resRec); - - // aggiorno record chiamata... - currRec.DtLastExec = dtStart; - currRec.LastResult = resRec.Result; - currRec.LastIsError = resRec.IsError; - currRec.LastDuration = dtEnd.Subtract(dtStart).TotalSeconds; - // solo se richiesto rischedulazione ricalcola chiamata - if (SchedNext) - { - // calcolo prossima esecuzione... - currRec.DtNextExec = CalcNextExe(currRec); - } - // segno modificato - dbCtx.Entry(currRec).State = EntityState.Modified; - - // salvo modifiche! - dbCtx.SaveChanges(); - } - } - catch (Exception exc) - { - Log.Error($"Eccezione in ExecuteSqlCommand{Environment.NewLine}{exc}"); - } - } - return callRes; - } -#endif - /// /// Elenco da tabella Macchine /// @@ -481,196 +351,6 @@ namespace MP.Data.Controllers return dbResult; } -#if false - /// - /// Ricerca task dato tipo + num max (desc) - /// - /// TaskId da cui deriva - /// - public List TaskExecGetFilt(int TaskId, int maxRec) - { - List dbResult = new List(); - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - dbResult = dbCtx - .DbSetTaskExe - .Include(x => x.TaskListNav) - .Where(x => (x.TaskId == TaskId)) - .OrderByDescending(x => x.DtStart) - .Take(maxRec) - .ToList(); - } - return dbResult; - } - - /// - /// Upsert record TaskExec - /// - /// Record da aggiornare/inserire - /// - public bool TaskExecUpsert(TaskExecModel rec2upd) - { - bool done = false; - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - try - { - var currData = dbCtx - .DbSetTaskExe - .Where(x => x.TaskExecId == rec2upd.TaskExecId) - .FirstOrDefault(); - if (currData != null) - { - currData.TaskId = rec2upd.TaskId; - currData.DtStart = rec2upd.DtStart; - currData.DtEnd = rec2upd.DtEnd; - currData.IsError = rec2upd.IsError; - currData.Result = rec2upd.Result; - dbCtx.Entry(currData).State = EntityState.Modified; - } - else - { - dbCtx - .DbSetTaskExe - .Add(rec2upd); - } - dbCtx.SaveChanges(); - done = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskExecUpsert{Environment.NewLine}{exc}"); - } - } - return done; - } - - /// - /// Ricerca task dato tipo - /// - /// - /// - public List TaskListGetAll(Task2ExeType TType) - { - List dbResult = new List(); - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - dbResult = dbCtx - .DbSetTaskList - .Where(x => (TType == Task2ExeType.ND || x.TType == TType)) - .OrderBy(x => x.Ordinal) - .ToList(); - } - return dbResult; - } - - /// - /// Update ordinamento task - /// - /// Record da spostare x priorità - /// - public bool TaskListMove(TaskListModel rec2upd, bool moveUp) - { - bool done = false; - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - try - { - var currData = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == rec2upd.TaskId) - .FirstOrDefault(); - if (currData != null) - { - int actOrdinal = currData.Ordinal; - TaskListModel? otherRec = null; - // cerco, secondo richiesta, precedente o successivo - if (moveUp) - { - otherRec = dbCtx - .DbSetTaskList - .Where(x => x.Ordinal < currData.Ordinal) - .OrderByDescending(x => x.Ordinal) - .FirstOrDefault(); - } - else - { - otherRec = dbCtx - .DbSetTaskList - .Where(x => x.Ordinal > currData.Ordinal) - .OrderBy(x => x.Ordinal) - .FirstOrDefault(); - } - // inverto ordinale SE ho record - if (otherRec != null) - { - currData.Ordinal = otherRec.Ordinal; - otherRec.Ordinal = actOrdinal; - dbCtx.Entry(currData).State = EntityState.Modified; - dbCtx.Entry(otherRec).State = EntityState.Modified; - } - } - //salvo - dbCtx.SaveChanges(); - done = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}"); - } - } - return done; - } - - /// - /// Upsert record TaskList - /// - /// Record da aggiornare/inserire - /// - public bool TaskListUpsert(TaskListModel rec2upd) - { - bool done = false; - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - try - { - var currData = dbCtx - .DbSetTaskList - .Where(x => x.TaskId == rec2upd.TaskId) - .FirstOrDefault(); - if (currData != null) - { - currData.Ordinal = rec2upd.Ordinal; - currData.Name = rec2upd.Name; - currData.Descript = rec2upd.Descript; - currData.Command = rec2upd.Command; - currData.Args = rec2upd.Args; - currData.Freq = rec2upd.Freq; - currData.Cad = rec2upd.Cad; - currData.DtLastExec = rec2upd.DtLastExec; - currData.DtNextExec = rec2upd.DtNextExec; - currData.LastDuration = rec2upd.LastDuration; - currData.LastResult = rec2upd.LastResult; - dbCtx.Entry(currData).State = EntityState.Modified; - } - else - { - dbCtx - .DbSetTaskList - .Add(rec2upd); - } - dbCtx.SaveChanges(); - done = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in TaskListUpsert{Environment.NewLine}{exc}"); - } - } - return done; - } -#endif - #endregion Public Methods #region Private Fields diff --git a/MP.Data/MgModels/RecipeModel.cs b/MP.Data/MgModels/RecipeModel.cs index 1e64f17d..e8730f70 100644 --- a/MP.Data/MgModels/RecipeModel.cs +++ b/MP.Data/MgModels/RecipeModel.cs @@ -58,13 +58,6 @@ namespace MP.Data.MgModels #region Public Properties -#if false - /// - /// Ricetta in formato calcolato (string) - /// - public string CalcRecipe { get; set; } = ""; -#endif - /// /// Configurazione ricetta x header /// diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 36eef4b3..6d12f3a9 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -98,14 +98,6 @@ namespace MP.Data public virtual DbSet DbSetVSCS { get; set; } public virtual DbSet DbSetParetoFluxLog { get; set; } - -#if false - public virtual DbSet DbSetTaskList { get; set; } - public virtual DbSet DbSetTaskExe { get; set; } - public virtual DbSet DbSetTaskResult { get; set; } -#endif - - #endregion Public Properties #region Private Methods diff --git a/MP.Data/MoonPro_STATSContext.cs b/MP.Data/MoonPro_STATSContext.cs index 5c67297c..4af88c94 100644 --- a/MP.Data/MoonPro_STATSContext.cs +++ b/MP.Data/MoonPro_STATSContext.cs @@ -46,11 +46,6 @@ namespace MP.Data public virtual DbSet DbSetTurniOee { get; set; } public virtual DbSet DbSetUserLog { get; set; } public virtual DbSet DbSetOdlEnergy { get; set; } -#if false - public virtual DbSet DbSetTaskList { get; set; } - public virtual DbSet DbSetTaskExe { get; set; } - public virtual DbSet DbSetTaskResult { get; set; } -#endif #endregion Public Properties diff --git a/MP.Data/Objects/Enums.cs b/MP.Data/Objects/Enums.cs index d7f74a82..7e9428af 100644 --- a/MP.Data/Objects/Enums.cs +++ b/MP.Data/Objects/Enums.cs @@ -250,86 +250,6 @@ namespace MP.Data.Objects SS } -#if false - //[JsonConverter(typeof(StringEnumConverter))] - public enum Task2ExeType - { - /// - /// Tipo indefinito / ALL - /// - ND, - - /// - /// Chiamata exe esterno - /// - Exe, - - /// - /// Chiamata a SQL Command - /// - SqlCommand, - - /// - /// Chiamata a SQL Stored Procedure - /// - SqlStored, - - /// - /// Chiamata REST tipo Get - /// - RestCallGet, - - ///// - ///// Chiamata REST tipo Post - ///// - //RestCallPost - } - - //[JsonConverter(typeof(StringEnumConverter))] - public enum TaskFreqType - { - /// - /// Tipo indefinito / ALL - /// - ND, - - /// - /// Secondi - /// - Sec, - - /// - /// Minuti - /// - Min, - - /// - /// Ore - /// - Hour, - - /// - /// Giorni - /// - Day, - - /// - /// Settimane - /// - Week, - - /// - /// Mesi - /// - Month, - - /// - /// Anni - /// - Year - } -#endif - /// /// Elenco task ammessi (x IOB-WIN da eseguire...) /// diff --git a/MP.Data/Services/RestCallService.cs b/MP.Data/Services/RestCallService.cs deleted file mode 100644 index 0d116441..00000000 --- a/MP.Data/Services/RestCallService.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Newtonsoft.Json; -using NLog; -using RestSharp; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Web; -using static System.Net.Mime.MediaTypeNames; - -namespace MP.AppAuth.Services -{ - /// - /// Servizio gestione chaimate REST xTaskMan - /// FixMe ToDo !!! è ancora necessario con obj task estratti?!?!? - /// - public class RestCallService - { - #region Public Constructors - - /// - /// Init classe - /// - /// - public RestCallService(IConfiguration configuration) - { - _configuration = configuration; - // verifico la url base - apiUrl = _configuration.GetValue("ServerConf:Prog.ApiUrl"); - // fix opzioni base del RestClient - restOptStd = new RestClientOptions - { - Timeout = TimeSpan.FromSeconds(60), - BaseUrl = new Uri(apiUrl) - }; - } - - private string apiUrl = ""; - - #endregion Public Constructors - - #region Public Methods - - /// - /// Stato server da chiamare x verifiche preliminari stato API REST - /// - /// - /// - public async Task CheckServer() - { - string answ = "ND"; - // cerco online - using (RestClient client = new RestClient(restOptStd)) - { - var request = new RestRequest($"api/health", Method.Get); - var response = await client.GetAsync(request); - // controllo risposta - if (response.StatusCode == System.Net.HttpStatusCode.OK) - { - // verifico risposta - if (response.Content != null) - { - answ = response.Content.Replace("\"", ""); - } - } - } - return answ; - } - - /// - /// Effettua una generica chiamata ApiRest - /// - /// URL Api di base - /// Richiesta completa - /// - public async Task CallRestGet(string ApiUrl, string ApiRequest) - { - RestResponse response; - // cerco online - using (RestClient client = new RestClient(ApiUrl)) - { - var request = new RestRequest(ApiRequest, Method.Get); - response = await client.GetAsync(request); - } - return response; - } - - #endregion Public Methods - - #region Private Fields - - private static IConfiguration? _configuration; - - /// - /// Classe logger - /// - private static Logger Log = LogManager.GetCurrentClassLogger(); - - #endregion Private Fields - - #region Private Properties - - /// - /// Conf client RestSharp standard: - /// - base URI al sito - /// - timeout 1 min - /// - private RestClientOptions restOptStd { get; set; } = new RestClientOptions(); - - #endregion Private Properties - } -} \ No newline at end of file diff --git a/MP.Data/Services/TaskService.cs b/MP.Data/Services/TaskService.cs deleted file mode 100644 index 6e866e4a..00000000 --- a/MP.Data/Services/TaskService.cs +++ /dev/null @@ -1,370 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Options; -using MP.AppAuth.Services; -using MP.Data.Controllers; -using MP.Data.DatabaseModels; -using Newtonsoft.Json; -using NLog; -using StackExchange.Redis; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static MP.Data.Objects.Enums; - -namespace MP.Data.Services -{ - public class TaskService : BaseServ, IDisposable - { - #region Public Constructors - - /// - /// Init servizio TAB - /// - /// - public TaskService(IConfiguration configuration) - { - _configuration = configuration; - - // setup compoenti REDIS - redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis")); - redisDb = redisConn.GetDatabase(); - - // conf DB - ConnStr = _configuration.GetConnectionString("MP.All"); - if (string.IsNullOrEmpty(ConnStr)) - { - Log.Error("ConnString empty!"); - } - else - { - StringBuilder sb = new StringBuilder(); - MLController = new MpLandController(configuration); - sb.AppendLine($"TaskService | MpLandController OK"); - Log.Info(sb.ToString()); - // sistemo i parametri x redHas... - CodModulo = _configuration.GetValue("ServerConf:CodModulo"); - var cstringArray = ConnStr.Split(";"); - foreach (var item in cstringArray) - { - var cData = item.Trim().Split("="); - if (cData.Length == 2) - { - if (!connStrParams.ContainsKey(cData[0])) - { - connStrParams.Add(cData[0], cData[1]); - } - } - } - // sistemo - DataSource = connStrParams["Server"]; - DataBase = connStrParams["Database"]; - } - - // conf rest call service - RCallService = new RestCallService(_configuration); - } - - #endregion Public Constructors - - #region Public Events - - /// - /// Evento richiesta rilettura dati pagina (x refresh pagine aperte) - /// - public event EventHandler ReloadRequest = delegate { }; - - #endregion Public Events - - #region Public Methods - - public void Dispose() - { - // Clear database controller - MLController.Dispose(); - // redis dispose - redisConn = null; - redisDb = null; - } - - /// - /// Chiamata esecuzione di un singolo task programmato - /// - /// Task richiesto - /// Se true rischedula successiva chiamata - /// - public async Task ExecuteTask(TaskListModel TaskRec, bool SchedNext) - { - TaskResultModel answ = new TaskResultModel() - { - Task = $"TaskId: {TaskRec.TaskId} | {TaskRec.TType}", - ExecResult = -1, - TextResult = "Task Not recognized" - }; - // verifico tipo di task ed eseguo di conseguenza... - switch (TaskRec.TType) - { - //case Task2ExeType.ND: - // break; - //case Task2ExeType.Exe: - // break; - //case Task2ExeType.SqlCommand: - // break; - case Task2ExeType.SqlStored: - answ = MLController.ExecuteSqlTask(TaskRec.TaskId, SchedNext); - break; - case Task2ExeType.RestCallGet: - DateTime dtStart = DateTime.Now; - // in primis testo la chiamata al servizio Health - string rAnsw = await RCallService.CheckServer(); - // se ok effettuo vera chiamata... - if (rAnsw.ToUpper() == "OK") - { - var callResp = await RCallService.CallRestGet(TaskRec.Command, TaskRec.Args); - DateTime dtEnd = DateTime.Now; - TaskExecModel tExeMod = new TaskExecModel() - { - DtEnd = dtEnd, - DtStart = dtStart, - IsError = callResp.StatusCode != System.Net.HttpStatusCode.OK, - TaskId = TaskRec.TaskId, - Result = $"{callResp.Content}".Replace("\"", ""), - }; - // salvo su DB - answ = MLController.TaskExecSaveExecuted(TaskRec.TaskId, SchedNext, tExeMod); - } - break; - default: - break; - } - // svuoto cache! - await FlushCache("Task"); - return answ; - } - - /// - /// Pulizia cache Redis (tutta) - /// - /// - public async Task FlushCache() - { - RedisValue pattern = new RedisValue($"{redisBaseKey}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - return answ; - } - - /// - /// Pulizia cache Redis per chiave specifica (da redisBaseKey...) - /// - /// - public async Task FlushCache(string KeyReq) - { - RedisValue pattern = new RedisValue($"{redisBaseKey}:{KeyReq}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - return answ; - } - - /// - /// Invio notifica rilettura (con parametro) - /// - /// - public void NotifyReloadRequest(string message) - { - if (ReloadRequest != null) - { - // messaggio - ReloadEventArgs rea = new ReloadEventArgs(message); - ReloadRequest.Invoke(this, rea); - } - } - - public void rollBackEdit(object item) - { - MLController.RollBackEntity(item); - } - - /// - /// Ricerca task dato tipo + num max (desc) - /// - /// TaskId da cui deriva - /// - public async Task> TaskExecGetFilt(int TaskId, int maxRec, string searchVal) - { - // setup parametri costanti - string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - List result = new List(); - // cerco in redis... - DateTime adesso = DateTime.Now; - string currKey = $"{redisBaseKey}:Task:ExecList:{TaskId}:{adesso:yyMMdd}:{adesso:HHmm}:{maxRec}"; - RedisValue rawData = await redisDb.StringGetAsync(currKey); - if (rawData.HasValue) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - source = "REDIS"; - } - else - { - result = MLController.TaskExecGetFilt(TaskId, maxRec); - // serializzp e salvo... - rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(currKey, rawData, FastCache); - } - if (result == null) - { - result = new List(); - } - sw.Stop(); - Log.Debug($"TaskExecGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); - return result; - } - - /// - /// Elenco TaskList gestiti - /// - /// - /// - /// - public async Task> TaskListAll(Task2ExeType TType, string searchVal = "") - { - // setup parametri costanti - string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - List result = new List(); - // cerco in redis... - DateTime adesso = DateTime.Now; - string currKey = $"{redisBaseKey}:Task:List:{TType}"; - RedisValue rawData = await redisDb.StringGetAsync(currKey); - if (rawData.HasValue) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - source = "REDIS"; - } - else - { - result = MLController.TaskListGetAll(TType); - // serializzp e salvo... - rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(currKey, rawData, FastCache); - } - if (result == null) - { - result = new List(); - } - // se necessario filtro.. - if (!string.IsNullOrEmpty(searchVal)) - { - result = result - .Where(x => x.Name.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase) - || x.Descript.Contains(searchVal, StringComparison.InvariantCultureIgnoreCase)) - .ToList(); - } - sw.Stop(); - Log.Debug($"TaskListAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); - return result; - } - - /// - /// Update ordinamento task - /// - /// Record da spostare x priorità - /// - public async Task TaskListMove(TaskListModel rec2upd, bool moveUp) - { - bool dbResult = MLController.TaskListMove(rec2upd, moveUp); - // svuoto cache! - await FlushCache("Task"); - return await Task.FromResult(dbResult); - } - - /// - /// Update/Insert record TaskList - /// - /// - /// - public async Task TaskListUpsert(TaskListModel rec2upd) - { - bool dbResult = MLController.TaskListUpsert(rec2upd); - // svuoto cache! - await FlushCache("Task"); - return dbResult; - } - - #endregion Public Methods - - #region Protected Fields - - /// - /// Oggetto per connessione a REDIS - /// - protected ConnectionMultiplexer redisConn = null!; - - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - protected IDatabase redisDb = null!; - - #endregion Protected Fields - - #region Private Fields - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - private string CodModulo = ""; - - private string ConnStr = ""; - - private Dictionary connStrParams = new Dictionary(); - - private string DataBase = ""; - - private string DataSource = ""; - - private string redisBaseKey = "MP:TASK"; - - #endregion Private Fields - - #region Private Properties - - private static MpLandController MLController { get; set; } = null!; - private RestCallService RCallService { get; set; } = null!; - - #endregion Private Properties - - #region Private Methods - - /// - /// Esegue flush memoria redis dato pattern - /// - /// - /// - private async Task ExecFlushRedisPattern(RedisValue pattern) - { - bool answ = false; - var listEndpoints = redisConn.GetEndPoints(); - foreach (var endPoint in listEndpoints) - { - //var server = redisConnAdmin.GetServer(listEndpoints[0]); - var server = redisConn.GetServer(endPoint); - if (server != null) - { - var keyList = server.Keys(redisDb.Database, pattern); - foreach (var item in keyList) - { - await redisDb.KeyDeleteAsync(item); - } - answ = true; - } - } - // notifico update ai client in ascolto x reset cache - NotifyReloadRequest($"FlushRedisCache | {pattern}"); - return answ; - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs index a0960900..778a8906 100644 --- a/MP.Data/Utils.cs +++ b/MP.Data/Utils.cs @@ -127,26 +127,6 @@ namespace MP.Data return (RedisValue)$"{redisBaseAddr}{keyName}"; } - /// - /// Effettua salvataggio in file di un generico oggetto in formato CSV - /// - /// - /// - /// - /// Separatore da impiegare - /// - public static async Task SaveToCsv(List reportData, string path, char separator) - { - var lines = new List(); - IEnumerable props = TypeDescriptor.GetProperties(typeof(T)).OfType(); - var header = string.Join(";", props.ToList().Select(x => x.Name)); - lines.Add(header); - var valueLines = reportData.Select(row => string.Join(separator, header.Split(separator).Select(a => row.GetType().GetProperty(a).GetValue(row, null)))); - //var valueLines = reportData.Select(row => string.Join(";", header.Split(';').Select(a => row.GetType().GetProperty(a).GetValue(row, null)))); - lines.AddRange(valueLines); - await Task.Run(() => File.WriteAllLines(path, lines.ToArray())); - } - #endregion Public Methods #region Public Classes diff --git a/MP.Land/Components/SearchMod.razor b/MP.Land/Components/SearchMod.razor index 1eba65ea..80d87327 100644 --- a/MP.Land/Components/SearchMod.razor +++ b/MP.Land/Components/SearchMod.razor @@ -6,10 +6,7 @@
- -
- -
+
@code { diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 7c10aff5..68981098 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.16.2410.2611 + 6.16.2410.2612 Debug;Release;Debug_LiManDebug @@ -16,7 +16,6 @@ - @@ -28,7 +27,6 @@ - diff --git a/MP.Land/Pages/Index.razor b/MP.Land/Pages/Index.razor index 5e17189a..baa68c22 100644 --- a/MP.Land/Pages/Index.razor +++ b/MP.Land/Pages/Index.razor @@ -39,7 +39,7 @@
@foreach (var item in ListRecords) { -
+
} diff --git a/MP.Land/Pages/TaskScheduler.razor b/MP.Land/Pages/TaskScheduler.razor index 4cb01b87..26339b36 100644 --- a/MP.Land/Pages/TaskScheduler.razor +++ b/MP.Land/Pages/TaskScheduler.razor @@ -1,191 +1,3 @@ @page "/TaskScheduler" -
-
-
-
-
-
- TaskList -
-
-
- @if (TypeSel != MP.TaskMan.Objects.Enums.Task2ExeType.ND) - { - @if (currRecord == null) - { - - } - else - { - - } - } - else - { - - } - -
-
-
- -
-
- @if (isLoading) - { - - - } - else if (ListRecords == null) - { - - } - else if (totalCount == 0) - { -
Nessun record trovato
- } - else - { -
-
- - - - - - - - @if (detRecord == null) - { - - } - - @if (detRecord == null) - { - - - - - } - - - - @foreach (var record in ListRecords) - { - - - - - - @if (detRecord == null) - { - - } - - @if (detRecord == null) - { - - - - - } - - @if (DetailTaskId != null && DetailTaskId.TaskId == record.TaskId) - { - - - - } - } - -
- - OrdTaskTipoCommandSched.LastNextResult - -
- - @if (detRecord == null) - { - @if (currRecord == null) - { - - - } - else - { - - } - } - - @if (detRecord == null) - { - @if (record.Ordinal == minOrdinal) - { - - } - else - { - - } - } - @record.Ordinal - @if (detRecord == null) - { - @if (record.Ordinal == maxOrdinal) - { - - } - else - { - - } - } - -
@record.Name
-
@record.Descript
-
- @record.TType - -
@TextReduce(record.Command, 32)
-
@TextReduce(record.Args, 40)
-
@record.Freq × @record.Cad -
@($"{record.DtLastExec:yyyy-MM-dd}")
-
@($"{record.DtLastExec:ddd HH:mm:ss}")
-
-
@($"{record.DtNextExec:yyyy-MM-dd}")
-
@($"{record.DtNextExec:ddd HH:mm:ss}")
-
- @($"{record.LastDuration:N3}") sec - - -
-
-
-
@record.LastResult
-
-
-
-
-
- } -
- -
-
- @if (detRecord != null && !isLoading) - { -
- -
- } -
\ No newline at end of file + \ No newline at end of file diff --git a/MP.Land/Pages/TaskScheduler.razor.cs b/MP.Land/Pages/TaskScheduler.razor.cs index b88e123b..dff3c10a 100644 --- a/MP.Land/Pages/TaskScheduler.razor.cs +++ b/MP.Land/Pages/TaskScheduler.razor.cs @@ -14,392 +14,24 @@ using MP.TaskMan.Services; namespace MP.Land.Pages { - public partial class TaskScheduler : ComponentBase, IDisposable + public partial class TaskScheduler : ComponentBase { - #region Public Methods - - public string checkSelect(int TaskId) - { - string answ = ""; - if (currRecord != null) - { - try - { - answ = (currRecord.TaskId == TaskId) ? "table-info" : ""; - } - catch - { } - } - else if (detRecord != null) - { - answ = (detRecord.TaskId == TaskId) ? "table-info" : ""; - } - return answ; - } - - public void Dispose() - { - MessageService.EA_SearchUpdated -= OnSeachUpdated; - } - - public async void OnSeachUpdated() - { - await InvokeAsync(() => - { - Task task = ReloadData(); - StateHasChanged(); - }); - } - - #endregion Public Methods - - #region Protected Fields - - protected string fileName = "TaskList.csv"; - - #endregion Protected Fields - #region Protected Properties [Inject] - protected IJSRuntime JSRuntime { get; set; } - - protected string mainCss - { - get => detRecord == null ? "col-12" : "col-6"; - } - - protected int maxOrdinal { get; set; } = 999; - - [Inject] - protected Data.MessageService MessageService { get; set; } - - protected int minOrdinal { get; set; } = 0; - - [Inject] - protected NavigationManager NavManager { get; set; } - - protected int totalCount { get; set; } = 0; - - [Inject] - protected TaskService TService { get; set; } - - protected Task2ExeType TypeSel - { - get => typeSel; - set - { - if (typeSel != value) - { - typeSel = value; - var pUpd = Task.Run(async () => - { - await ReloadData(); - }); - pUpd.Wait(); - } - } - } + protected Data.MessageService MServ { get; set; } = null!; #endregion Protected Properties #region Protected Methods - protected async Task addNew() + protected override void OnInitialized() { - currRecord = new TaskListModel() - { - Name = "Nuovo Task", - TType = TypeSel, - Descript = "Descrizione Task", - DtLastExec = DateTime.Today, - DtNextExec = DateTime.Today.AddDays(1) - }; - await ReloadData(); - } - - /// - /// Gestione display avanzamento step - /// - /// - protected async Task advStep(int currStep) - { - currVal = currStep; - nextVal = currVal + 1; - await InvokeAsync(StateHasChanged); - } - - protected string alCss(TaskListModel TaskRec) - { - return TaskRec.LastIsError ? "alert-danger" : "alert-success"; - } - - protected string btnCss(TaskListModel TaskRec) - { - string answ = DetailTaskId != null && DetailTaskId.TaskId == TaskRec.TaskId ? "btn-" : "btn-outline-"; - answ += TaskRec.LastIsError ? "danger" : "success"; - return answ; - } - - protected async Task doCancel() - { - currRecord = null; - detRecord = null; - await ReloadData(); - } - - protected async Task doClone(TaskListModel selRec) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler duplicare il record selezionato?")) - return; - currRecord = new TaskListModel() - { - Args = selRec.Args, - Name = $"Copia di {selRec.Name}", - Cad = selRec.Cad, - Command = selRec.Command, - Descript = $"Copia di {selRec.Descript}", - DtNextExec = DateTime.Today.AddDays(1), - DtLastExec = DateTime.Today.AddYears(-10), - Freq = selRec.Freq, - LastDuration = 0, - LastIsError = false, - LastResult = "", - TType = selRec.TType, - Ordinal = SearchRecords.Count + 1, - }; - await ReloadData(); - } - - protected async Task doEdit(TaskListModel selRec) - { - currRecord = selRec; - await ReloadData(); - } - - protected async Task doMove(TaskListModel currRec, bool goUp) - { - await TService.TaskListMove(currRec, goUp); - detRecord = null; - currRecord = null; - await ReloadData(); - } - - protected async Task doReset() - { - detRecord = null; - currRecord = null; - await TService.FlushCache(); - await ReloadData(); - } - - protected async Task doRun(TaskListModel selRec) - { - // SE non è ancora scaduto chiedo conferma - if (selRec.DtNextExec > DateTime.Now) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi esecuzione forzata task non scaduto?{Environment.NewLine}[{selRec.TaskId}]: {selRec.Name} - {selRec.Descript}{Environment.NewLine}Prossima schedulazione: {selRec.DtNextExec:yyyy-MM-dd HH:mm:ss}")) - return; - } - - // imposto tempo atteso esecuzione da ultimo... - isLoading = true; - MaxVal = 4; - int currStep = 0; - await advStep(currStep); - expTimeMsec = (int)(1000 * selRec.LastDuration) / 4; - detRecord = null; - await advStep(currStep++); - await Task.Delay(100); - await advStep(currStep++); - // chiama esecuzione task - var result = await TService.ExecuteTask(selRec, false); - await advStep(currStep++); - isLoading = false; - await Task.Delay(100); - await advStep(currStep++); - await ReloadData(); - } - - protected async Task doSelect(TaskListModel selRec) - { - detRecord = null; - currRecord = null; - DetailTaskId = null; - isLoading = true; - detRecord = selRec; - await ReloadData(); - isLoading = false; - } - - protected async Task forceAll() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi esecuzione forzata di tutti i task?")) - return; - - isLoading = true; - detRecord = null; - await Task.Delay(100); - foreach (var taskRec in SearchRecords) - { - var result = await TService.ExecuteTask(taskRec, false); - } - isLoading = false; - await Task.Delay(100); - await ReloadData(); - } - - protected async Task ForceReload(int newNum) - { - numRecord = newNum; - await ReloadData(); - } - - protected async Task ForceReloadPage(int newNum) - { - currPage = newNum; - await ReloadData(); - } - - protected async Task forceUpdate(bool doForce) - { - currRecord = null; - await ReloadData(); - } - - protected string iconCss(TaskListModel TaskRec) - { - return TaskRec.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up"; - } - - protected override async Task OnInitializedAsync() - { - clearFile(); - numRecord = 10; - MessageService.ShowSearch = false; - MessageService.PageName = "Task Scheduler"; - MessageService.PageIcon = "oi oi-clock"; - MessageService.EA_SearchUpdated += OnSeachUpdated; - await ReloadData(); - } - - protected void ResetData() - { - clearFile(); - TService.rollBackEdit(currRecord); - currRecord = null; - } - - protected async Task ResetFilter(SelectData newFilter) - { - clearFile(); - detRecord = null; - currRecord = null; - SearchRecords = null; - ListRecords = null; - await ReloadData(); - } - - protected double righDiv(double num, double den) - { - if (den == 0) - { - den = 1; - } - double answ = num / den; - return answ; - } - - protected string TextReduce(string textOriginal, int maxChar) - { - string answ = textOriginal; - if (answ.Length > maxChar) - { - answ = $"{textOriginal.Substring(0, maxChar / 2)} ... {textOriginal.Substring(answ.Length - maxChar / 2)}"; - } - return answ; - } - - protected void ToggleDetail(TaskListModel TaskRec) - { - if (DetailTaskId == null) - { - DetailTaskId = TaskRec; - } - else - { - DetailTaskId = (DetailTaskId.TaskId == TaskRec.TaskId) ? null : TaskRec; - } + MServ.ShowSearch = true; + MServ.PageName = "Task Scheduler"; + MServ.PageIcon = "oi oi-clock"; } #endregion Protected Methods - - #region Private Fields - - private double currVal = 0; - private TaskListModel? DetailTaskId = null; - private List ListRecords; - private int MaxVal = 10; - private double nextVal = 0; - private List SearchRecords; - - #endregion Private Fields - - #region Private Properties - - private int currPage { get; set; } = 1; - - private TaskListModel currRecord { get; set; } = null; - - private TaskListModel detRecord { get; set; } = null; - - private int expTimeMsec { get; set; } = 30000; - - private string fullPath - { - get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}"; - } - - private bool isLoading { get; set; } = false; - private int numRecord { get; set; } = 10; - - private Task2ExeType typeSel { get; set; } = Task2ExeType.ND; - - #endregion Private Properties - - #region Private Methods - - private string btnRunCss(DateTime dtNextExe) - { - DateTime adesso = DateTime.Now; - string answ = dtNextExe < adesso ? "btn-success" : "btn-warning"; - return answ; - } - - private async void clearFile() - { - await Task.Run(() => File.Delete(fullPath)); - } - - private async Task ExportCsv() - { - isLoading = true; - // salvo davvero! - await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';'); - isLoading = false; - } - - private async Task ReloadData() - { - SearchRecords = await TService.TaskListAll(TypeSel, ""); - totalCount = SearchRecords.Count; - var firstRec = SearchRecords.OrderBy(x => x.Ordinal).FirstOrDefault(); - minOrdinal = firstRec != null ? firstRec.Ordinal : 0; - var lastRec = SearchRecords.OrderByDescending(x => x.Ordinal).FirstOrDefault(); - maxOrdinal = lastRec != null ? lastRec.Ordinal : 9999; - ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - } - - #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index 97dbacdb..f1632ace 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo Tablet MAPO - DotNet6 -

Versione: 6.16.2410.2611

+

Versione: 6.16.2410.2612


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index f52a95aa..e9c2ab4a 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2410.2611 +6.16.2410.2612 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index bbab1a7a..5f1e8470 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2410.2611 + 6.16.2410.2612 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false diff --git a/MP.Land/Shared/NavMenu.razor.cs b/MP.Land/Shared/NavMenu.razor.cs index b8f7574c..7485ff52 100644 --- a/MP.Land/Shared/NavMenu.razor.cs +++ b/MP.Land/Shared/NavMenu.razor.cs @@ -111,7 +111,6 @@ namespace MP.Land.Shared private async Task ReloadData() { isLoading = true; - await Task.Delay(1); // sistemo elenco pagine safe... SafePages = ConfMan.GetValue("Application:SafePages").ToLower(); var authState = await AuthStateProvider.GetAuthenticationStateAsync(); diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index 36bbd02f..ba7a00f0 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -127,6 +127,7 @@ namespace MP.Stats.Data return Task.FromResult(answ); } +#if false /// /// Aggiorna record calcolando prossima scadenza dato ultima esecuzione /// @@ -140,7 +141,8 @@ namespace MP.Stats.Data dtNext = dbController.CalcNextExe(taskRec); } return dtNext; - } + } +#endif public Task> CommesseGetSearch(int numRecord, string searchVal = "") { @@ -162,6 +164,7 @@ namespace MP.Stats.Data redisDb = null; } +#if false /// /// Chiamata esecuzione di un singolo task programmato /// @@ -174,7 +177,8 @@ namespace MP.Stats.Data // svuoto cache! await FlushCache("Task"); return await Task.FromResult(dbResult); - } + } +#endif /// /// Pulizia cache Redis (tutta) @@ -559,6 +563,7 @@ namespace MP.Stats.Data return result; } +#if false /// /// Ricerca task dato tipo + num max (desc) /// @@ -666,7 +671,8 @@ namespace MP.Stats.Data // svuoto cache! await FlushCache("Task"); return await Task.FromResult(dbResult); - } + } +#endif #endregion Public Methods diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index b25a603b..9957de5d 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,18 +4,25 @@ net6.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 6.16.2410.2318 - 6.16.2410.2318 + 6.16.2410.2612 + 6.16.2410.2612 true $(NoWarn);1591 + + + + + + + @@ -32,6 +39,7 @@ + @@ -188,7 +196,7 @@ - + @@ -216,6 +224,10 @@ Always + + + + diff --git a/MP.Stats/Pages/Controlli.razor.cs b/MP.Stats/Pages/Controlli.razor.cs index 6a3927a2..a364f41c 100644 --- a/MP.Stats/Pages/Controlli.razor.cs +++ b/MP.Stats/Pages/Controlli.razor.cs @@ -123,7 +123,7 @@ namespace MP.Stats.Pages { isLoading = true; // salvo davvero! - await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';'); + await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';'); isLoading = false; } diff --git a/MP.Stats/Pages/Diario.razor.cs b/MP.Stats/Pages/Diario.razor.cs index cc3babc7..d4979afc 100644 --- a/MP.Stats/Pages/Diario.razor.cs +++ b/MP.Stats/Pages/Diario.razor.cs @@ -100,7 +100,7 @@ namespace MP.Stats.Pages // recupero TUTTI i dati var allRecords = await StatService.StatDdbGetAllExport(currFilter, MessageService.SearchVal); // salvo davvero! - await MP.Data.Utils.SaveToCsv(allRecords, fullPath, ';'); + await Egw.Core.Utils.SaveToCsv(allRecords, fullPath, ';'); isLoading = false; } diff --git a/MP.Stats/Pages/Energy.razor.cs b/MP.Stats/Pages/Energy.razor.cs index 9e5fa476..0f4d58a2 100644 --- a/MP.Stats/Pages/Energy.razor.cs +++ b/MP.Stats/Pages/Energy.razor.cs @@ -92,7 +92,7 @@ namespace MP.Stats.Pages { isLoading = true; // salvo davvero! - await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';'); + await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';'); isLoading = false; } diff --git a/MP.Stats/Pages/Oee.razor.cs b/MP.Stats/Pages/Oee.razor.cs index 7c898ea4..ce05045e 100644 --- a/MP.Stats/Pages/Oee.razor.cs +++ b/MP.Stats/Pages/Oee.razor.cs @@ -124,7 +124,7 @@ namespace MP.Stats.Pages isLoading = true; // calcolo nome file // salvo davvero! - await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';'); + await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';'); isLoading = false; } diff --git a/MP.Stats/Pages/ReportODL.razor.cs b/MP.Stats/Pages/ReportODL.razor.cs index 0d6db954..606d216e 100644 --- a/MP.Stats/Pages/ReportODL.razor.cs +++ b/MP.Stats/Pages/ReportODL.razor.cs @@ -92,7 +92,7 @@ namespace MP.Stats.Pages { isLoading = true; // salvo davvero! - await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';'); + await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';'); isLoading = false; } diff --git a/MP.Stats/Pages/Scarti.razor.cs b/MP.Stats/Pages/Scarti.razor.cs index ac7dd0e0..d41f90b8 100644 --- a/MP.Stats/Pages/Scarti.razor.cs +++ b/MP.Stats/Pages/Scarti.razor.cs @@ -123,7 +123,7 @@ namespace MP.Stats.Pages { isLoading = true; // salvo davvero! - await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';'); + await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';'); isLoading = false; } diff --git a/MP.Stats/Pages/TaskScheduler.razor b/MP.Stats/Pages/TaskScheduler.razor index 14f307a3..be6d4b0a 100644 --- a/MP.Stats/Pages/TaskScheduler.razor +++ b/MP.Stats/Pages/TaskScheduler.razor @@ -19,7 +19,7 @@ } + @foreach (var option in Enum.GetValues(typeof(MP.TaskMan.Objects.Enums.Task2ExeType))) + { + + } + +
+
+ + + +
+ @if (isLoading) + { + + + } + else if (ListRecords == null) + { + + } + else if (totalCount == 0) + { +
Nessun record trovato
+ } + else + { +
+
+ + + + + + + + @if (detRecord == null) + { + + } + + @if (detRecord == null) + { + + + + + } + + + + @foreach (var record in ListRecords) + { + + + + + + @if (detRecord == null) + { + + } + + @if (detRecord == null) + { + + + + + } + + @if (DetailTaskId != null && DetailTaskId.TaskId == record.TaskId) + { + + + + } + } + +
+ + OrdTaskTipoCommandSched.LastNextResult + +
+ + @if (detRecord == null) + { + @if (currRecord == null) + { + + + } + else + { + + } + } + + @if (detRecord == null) + { + @if (record.Ordinal == minOrdinal) + { + + } + else + { + + } + } + @record.Ordinal + @if (detRecord == null) + { + @if (record.Ordinal == maxOrdinal) + { + + } + else + { + + } + } + +
@record.Name
+
@record.Descript
+
+ @record.TType + +
@TextReduce(record.Command, 32)
+
@TextReduce(record.Args, 40)
+
@record.Freq × @record.Cad +
@($"{record.DtLastExec:yyyy-MM-dd}")
+
@($"{record.DtLastExec:ddd HH:mm:ss}")
+
+
@($"{record.DtNextExec:yyyy-MM-dd}")
+
@($"{record.DtNextExec:ddd HH:mm:ss}")
+
+ @($"{record.LastDuration:N3}") sec + + +
+
+
+
@record.LastResult
+
+
+
+
+
+ } +
+ + + + @if (detRecord != null && !isLoading) + { +
+ +
+ } + + diff --git a/MP.TaskMan/TaskList.razor.cs b/MP.TaskMan/TaskList.razor.cs new file mode 100644 index 00000000..44cfa91e --- /dev/null +++ b/MP.TaskMan/TaskList.razor.cs @@ -0,0 +1,363 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.TaskMan.Models; +using MP.TaskMan.Services; +using static MP.TaskMan.Objects.Enums; + +namespace MP.TaskMan +{ + public partial class TaskList : ComponentBase + { + #region Public Methods + + public string checkSelect(int TaskId) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.TaskId == TaskId) ? "table-info" : ""; + } + catch + { } + } + else if (detRecord != null) + { + answ = (detRecord.TaskId == TaskId) ? "table-info" : ""; + } + return answ; + } + + #endregion Public Methods + + #region Protected Fields + + protected string fileName = "TaskList.csv"; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected string mainCss + { + get => detRecord == null ? "col-12" : "col-6"; + } + + protected int maxOrdinal { get; set; } = 999; + protected int minOrdinal { get; set; } = 0; + protected int totalCount { get; set; } = 0; + + [Inject] + protected TaskService TService { get; set; } = null!; + + protected Task2ExeType TypeSel + { + get => typeSel; + set + { + if (typeSel != value) + { + typeSel = value; + var pUpd = Task.Run(async () => + { + await ReloadData(); + }); + pUpd.Wait(); + } + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected async Task addNew() + { + currRecord = new TaskListModel() + { + Name = "Nuovo Task", + TType = TypeSel, + Descript = "Descrizione Task", + DtLastExec = DateTime.Today, + DtNextExec = DateTime.Today.AddDays(1) + }; + await ReloadData(); + } + + /// + /// Gestione display avanzamento step + /// + /// + protected async Task advStep(int currStep) + { + currVal = currStep; + nextVal = currVal + 1; + await InvokeAsync(StateHasChanged); + } + + protected string alCss(TaskListModel TaskRec) + { + return TaskRec.LastIsError ? "alert-danger" : "alert-success"; + } + + protected string btnCss(TaskListModel TaskRec) + { + string answ = DetailTaskId != null && DetailTaskId.TaskId == TaskRec.TaskId ? "btn-" : "btn-outline-"; + answ += TaskRec.LastIsError ? "danger" : "success"; + return answ; + } + + protected async Task doCancel() + { + currRecord = null; + detRecord = null; + await ReloadData(); + } + + protected async Task doClone(TaskListModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler duplicare il record selezionato?")) + return; + currRecord = new TaskListModel() + { + Args = selRec.Args, + Name = $"Copia di {selRec.Name}", + Cad = selRec.Cad, + Command = selRec.Command, + Descript = $"Copia di {selRec.Descript}", + DtNextExec = DateTime.Today.AddDays(1), + DtLastExec = DateTime.Today.AddYears(-10), + Freq = selRec.Freq, + LastDuration = 0, + LastIsError = false, + LastResult = "", + TType = selRec.TType, + Ordinal = SearchRecords.Count + 1, + }; + await ReloadData(); + } + + protected async Task doEdit(TaskListModel selRec) + { + currRecord = selRec; + await ReloadData(); + } + + protected async Task doMove(TaskListModel currRec, bool goUp) + { + await TService.TaskListMove(currRec, goUp); + detRecord = null; + currRecord = null; + await ReloadData(); + } + + protected async Task doReset() + { + detRecord = null; + currRecord = null; + await TService.FlushCache(); + await ReloadData(); + } + + protected async Task doRun(TaskListModel selRec) + { + // SE non è ancora scaduto chiedo conferma + if (selRec.DtNextExec > DateTime.Now) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi esecuzione forzata task non scaduto?{Environment.NewLine}[{selRec.TaskId}]: {selRec.Name} - {selRec.Descript}{Environment.NewLine}Prossima schedulazione: {selRec.DtNextExec:yyyy-MM-dd HH:mm:ss}")) + return; + } + + // imposto tempo atteso esecuzione da ultimo... + isLoading = true; + MaxVal = 4; + int currStep = 0; + await advStep(currStep); + expTimeMsec = (int)(1000 * selRec.LastDuration) / 4; + detRecord = null; + await advStep(currStep++); + await Task.Delay(100); + await advStep(currStep++); + // chiama esecuzione task + var result = await TService.ExecuteTask(selRec, false); + await advStep(currStep++); + isLoading = false; + await Task.Delay(100); + await advStep(currStep++); + await ReloadData(); + } + + protected async Task doSelect(TaskListModel selRec) + { + detRecord = null; + currRecord = null; + DetailTaskId = null; + isLoading = true; + detRecord = selRec; + await ReloadData(); + isLoading = false; + } + + protected async Task forceAll() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi esecuzione forzata di tutti i task?")) + return; + + isLoading = true; + detRecord = null; + await Task.Delay(100); + foreach (var taskRec in SearchRecords) + { + var result = await TService.ExecuteTask(taskRec, false); + } + isLoading = false; + await Task.Delay(100); + await ReloadData(); + } + + protected async Task ForceReload(int newNum) + { + numRecord = newNum; + await ReloadData(); + } + + protected async Task ForceReloadPage(int newNum) + { + currPage = newNum; + await ReloadData(); + } + + protected async Task forceUpdate(bool doForce) + { + currRecord = null; + await ReloadData(); + } + + protected string iconCss(TaskListModel TaskRec) + { + return TaskRec.LastIsError ? "fa-thumbs-down" : "fa-thumbs-up"; + } + + protected override async Task OnInitializedAsync() + { + isLoading = true; + MaxVal = 2; + clearFile(); + await advStep(1); + numRecord = 10; + await ReloadData(); + await advStep(2); + isLoading = false; + } + + protected void ResetData() + { + clearFile(); + TService.rollBackEdit(currRecord); + currRecord = null; + } + + protected double righDiv(double num, double den) + { + if (den == 0) + { + den = 1; + } + double answ = num / den; + return answ; + } + + protected string TextReduce(string textOriginal, int maxChar) + { + string answ = textOriginal; + if (answ.Length > maxChar) + { + answ = $"{textOriginal.Substring(0, maxChar / 2)} ... {textOriginal.Substring(answ.Length - maxChar / 2)}"; + } + return answ; + } + + protected void ToggleDetail(TaskListModel TaskRec) + { + if (DetailTaskId == null) + { + DetailTaskId = TaskRec; + } + else + { + DetailTaskId = (DetailTaskId.TaskId == TaskRec.TaskId) ? null : TaskRec; + } + } + + #endregion Protected Methods + + #region Private Fields + + private double currVal = 0; + private TaskListModel? DetailTaskId = null; + private List ListRecords = new List(); + private int MaxVal = 10; + private double nextVal = 0; + private List SearchRecords = new List(); + + #endregion Private Fields + + #region Private Properties + + private int currPage { get; set; } = 1; + private TaskListModel? currRecord { get; set; } = null; + private TaskListModel? detRecord { get; set; } = null; + private int expTimeMsec { get; set; } = 30000; + + private string fullPath + { + get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}"; + } + + private bool isLoading { get; set; } = false; + private int numRecord { get; set; } = 10; + private string SearchVal { get; set; } = ""; + private Task2ExeType typeSel { get; set; } = Task2ExeType.ND; + + #endregion Private Properties + + #region Private Methods + + private string btnRunCss(DateTime dtNextExe) + { + DateTime adesso = DateTime.Now; + string answ = dtNextExe < adesso ? "btn-success" : "btn-warning"; + return answ; + } + + private async void clearFile() + { + await Task.Run(() => File.Delete(fullPath)); + } + + private async Task ExportCsv() + { + isLoading = true; + // salvo davvero! + await Egw.Core.Utils.SaveToCsv(SearchRecords, fullPath, ';'); + isLoading = false; + } + + private async Task ReloadData() + { + SearchRecords = await TService.TaskListAll(TypeSel, SearchVal); + totalCount = SearchRecords.Count; + var firstRec = SearchRecords.OrderBy(x => x.Ordinal).FirstOrDefault(); + minOrdinal = firstRec != null ? firstRec.Ordinal : 0; + var lastRec = SearchRecords.OrderByDescending(x => x.Ordinal).FirstOrDefault(); + maxOrdinal = lastRec != null ? lastRec.Ordinal : 9999; + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.TaskMan/_Imports.razor b/MP.TaskMan/_Imports.razor index a97860ca..c52cb18e 100644 --- a/MP.TaskMan/_Imports.razor +++ b/MP.TaskMan/_Imports.razor @@ -1,2 +1,4 @@ @using Microsoft.AspNetCore.Components.Web -@using MP.TaskMan.Models \ No newline at end of file +@using MP.TaskMan.Models +@using EgwCoreLib.Razor +@using EgwCoreLib.Utils \ No newline at end of file