From ffec555e85bea9fcbd0c04303b2535031f737282 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 26 Oct 2024 11:02:26 +0200 Subject: [PATCH] MP.TaskMan: - Completato aggiunta progetto - porting classi servizi/controlli/db a progetto - compilazione OK - manca gestione connString ottimizzata x il DB di origine CORRETTO (LAND/PROG/STATS) --- MP.Data/Controllers/MpLandController.cs | 14 +- MP.Data/Controllers/MpStatsController.cs | 12 +- MP.Data/MP.Data.csproj | 5 + MP.Data/MoonProContext.cs | 4 +- MP.Data/MoonPro_STATSContext.cs | 4 +- MP.Data/Objects/Enums.cs | 4 +- MP.Data/Services/ReloadEventArgs.cs | 4 + MP.Data/Services/RestCallService.cs | 4 + MP.Land/Components/TaskEdit.razor | 101 ----- MP.Land/Components/TaskEdit.razor.cs | 47 --- MP.Land/Components/TaskExeList.razor | 100 ----- MP.Land/Components/TaskExeList.razor.cs | 136 ------- MP.Land/MP.Land.csproj | 9 +- MP.Land/Pages/TaskScheduler.razor | 6 +- MP.Land/Pages/TaskScheduler.razor.cs | 5 +- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- MP.Land/Shared/NavMenu.razor.cs | 2 +- MP.Land/Startup.cs | 1 + MP.Land/_Imports.razor | 1 + MP.TaskMan/Controllers/MpTaskController.cs | 438 +++++++++++++++++++++ MP.TaskMan/MP.TaskMan.csproj | 20 +- MP.TaskMan/Models/ConfigModel.cs | 22 ++ MP.TaskMan/Services/ReloadEventArgs.cs | 26 ++ MP.TaskMan/Services/RestCallService.cs | 111 ++++++ MP.TaskMan/Services/TaskService.cs | 9 +- MP.TaskMan/TaskContext.cs | 116 ++++++ MP.TaskMan/TaskEdit.razor.cs | 3 +- MP.TaskMan/TaskExeList.razor.cs | 8 +- 30 files changed, 797 insertions(+), 421 deletions(-) delete mode 100644 MP.Land/Components/TaskEdit.razor delete mode 100644 MP.Land/Components/TaskEdit.razor.cs delete mode 100644 MP.Land/Components/TaskExeList.razor delete mode 100644 MP.Land/Components/TaskExeList.razor.cs create mode 100644 MP.TaskMan/Controllers/MpTaskController.cs create mode 100644 MP.TaskMan/Models/ConfigModel.cs create mode 100644 MP.TaskMan/Services/ReloadEventArgs.cs create mode 100644 MP.TaskMan/Services/RestCallService.cs create mode 100644 MP.TaskMan/TaskContext.cs diff --git a/MP.Data/Controllers/MpLandController.cs b/MP.Data/Controllers/MpLandController.cs index e4998388..289a88e7 100644 --- a/MP.Data/Controllers/MpLandController.cs +++ b/MP.Data/Controllers/MpLandController.cs @@ -13,6 +13,10 @@ using static MP.Data.Objects.Enums; namespace MP.Data.Controllers { + /// + /// Controller specifico x LAND + /// FixMe ToDo !!! è ancora necessario con obj task estratti?!?!? + /// public class MpLandController : IDisposable { #region Public Constructors @@ -27,6 +31,7 @@ namespace MP.Data.Controllers #region Public Methods +#if false public DateTime CalcNextExe(TaskListModel taskRec) { DateTime dtNext = DateTime.Today; @@ -77,7 +82,8 @@ namespace MP.Data.Controllers Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}"); } return dtNext; - } + } +#endif /// /// Elenco da tabella Config @@ -121,6 +127,7 @@ namespace MP.Data.Controllers return dbResult; } +#if false /// /// Chiamata esecuzione di un singolo task programmato /// @@ -195,6 +202,7 @@ namespace MP.Data.Controllers return callRes; } +#endif /// /// Annulla modifiche su una specifica entity (cancel update) @@ -221,6 +229,7 @@ namespace MP.Data.Controllers return answ; } +#if false /// /// Ricerca task dato tipo + num max (desc) /// @@ -459,7 +468,8 @@ namespace MP.Data.Controllers } } return done; - } + } +#endif #endregion Public Methods diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 8dadbbb8..21c42d08 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -63,6 +63,7 @@ namespace MP.Data.Controllers return dbResult; } +#if false public DateTime CalcNextExe(TaskListModel taskRec) { DateTime dtNext = DateTime.Today; @@ -113,7 +114,8 @@ namespace MP.Data.Controllers Log.Error($"Eccezione in CalcNextExe{Environment.NewLine}{exc}"); } return dtNext; - } + } +#endif /// /// Elenco tabella Articoli da filtro @@ -140,6 +142,7 @@ namespace MP.Data.Controllers { } +#if false /// /// Chiamata esecuzione di un singolo task programmato /// @@ -212,7 +215,8 @@ namespace MP.Data.Controllers } } return callRes; - } + } +#endif /// /// Elenco da tabella Macchine @@ -477,6 +481,7 @@ namespace MP.Data.Controllers return dbResult; } +#if false /// /// Ricerca task dato tipo + num max (desc) /// @@ -663,7 +668,8 @@ namespace MP.Data.Controllers } } return done; - } + } +#endif #endregion Public Methods diff --git a/MP.Data/MP.Data.csproj b/MP.Data/MP.Data.csproj index fb544465..540549d6 100644 --- a/MP.Data/MP.Data.csproj +++ b/MP.Data/MP.Data.csproj @@ -7,10 +7,15 @@ + + + + + diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 99e1199b..36eef4b3 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -99,9 +99,11 @@ namespace MP.Data 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; } + public virtual DbSet DbSetTaskResult { get; set; } +#endif #endregion Public Properties diff --git a/MP.Data/MoonPro_STATSContext.cs b/MP.Data/MoonPro_STATSContext.cs index f84c7f2f..5c67297c 100644 --- a/MP.Data/MoonPro_STATSContext.cs +++ b/MP.Data/MoonPro_STATSContext.cs @@ -46,9 +46,11 @@ 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; } + 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 91506d00..d7f74a82 100644 --- a/MP.Data/Objects/Enums.cs +++ b/MP.Data/Objects/Enums.cs @@ -250,6 +250,7 @@ namespace MP.Data.Objects SS } +#if false //[JsonConverter(typeof(StringEnumConverter))] public enum Task2ExeType { @@ -326,7 +327,8 @@ namespace MP.Data.Objects /// Anni /// Year - } + } +#endif /// /// Elenco task ammessi (x IOB-WIN da eseguire...) diff --git a/MP.Data/Services/ReloadEventArgs.cs b/MP.Data/Services/ReloadEventArgs.cs index debc8e62..51b77d7e 100644 --- a/MP.Data/Services/ReloadEventArgs.cs +++ b/MP.Data/Services/ReloadEventArgs.cs @@ -6,6 +6,10 @@ using System.Threading.Tasks; namespace MP.Data.Services { + /// + /// Gestione eventi reload da forzare via mesaggio + /// FixMe ToDo !!! è ancora necessario con obj task estratti?!?!? + /// public class ReloadEventArgs : EventArgs { #region Public Constructors diff --git a/MP.Data/Services/RestCallService.cs b/MP.Data/Services/RestCallService.cs index 8173f3fc..0d116441 100644 --- a/MP.Data/Services/RestCallService.cs +++ b/MP.Data/Services/RestCallService.cs @@ -13,6 +13,10 @@ 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 diff --git a/MP.Land/Components/TaskEdit.razor b/MP.Land/Components/TaskEdit.razor deleted file mode 100644 index 69d6674a..00000000 --- a/MP.Land/Components/TaskEdit.razor +++ /dev/null @@ -1,101 +0,0 @@ -@if (CurrRecord != null) -{ -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- @*
-
- - -
-
-
-
- - -
-
*@ -
-
-
-
- - -
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
- -
-
-} - diff --git a/MP.Land/Components/TaskEdit.razor.cs b/MP.Land/Components/TaskEdit.razor.cs deleted file mode 100644 index da8867a9..00000000 --- a/MP.Land/Components/TaskEdit.razor.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Microsoft.AspNetCore.Components; -using MP.Data.DatabaseModels; -using MP.Data.Services; -using System.Threading.Tasks; - -namespace MP.Land.Components -{ - public partial class TaskEdit - { - #region Public Properties - - [Parameter] - public TaskListModel? CurrRecord { get; set; } = null; - - [Parameter] - public EventCallback EC_update { get; set; } - - #endregion Public Properties - - #region Protected Properties - - [Inject] - protected TaskService TService { get; set; } - - #endregion Protected Properties - - #region Protected Methods - - protected async Task doCancel() - { - await EC_update.InvokeAsync(false); - } - - protected async Task doSave() - { - bool fatto = false; - await Task.Delay(1); - if (CurrRecord != null) - { - fatto = await TService.TaskListUpsert(CurrRecord); - } - await EC_update.InvokeAsync(fatto); - } - - #endregion Protected Methods - } -} \ No newline at end of file diff --git a/MP.Land/Components/TaskExeList.razor b/MP.Land/Components/TaskExeList.razor deleted file mode 100644 index 99220f54..00000000 --- a/MP.Land/Components/TaskExeList.razor +++ /dev/null @@ -1,100 +0,0 @@ - -
-
-
-
-
- History -
-
- @if (CurrRecord != null) - { -
@TextReduce(CurrRecord.Command, 40)
-
@TextReduce(CurrRecord.Args, 60)
- } -
-
-
-
- -
-
-
-
-
- @if (ListRecords == null) - { - - } - else if (totalCount == 0) - { -
Nessun record trovato
- } - else - { -
-
- - - - - - - - - - - @foreach (var record in ListRecords) - { - - - - - - - - - - } - -
#InizioFineEsito
- @record.TaskExecId - - @($"{record.DtStart:HH:mm:ss.fff}") -
@($"{record.DtStart:yyyy-MM.dd ddd}")
-
- @($"{record.DtEnd:HH:mm:ss.fff}") -
@($"{record.DtEnd:yyyy-MM.dd ddd}")
-
-
-
- @if (@record.IsError) - { - - } - else - { - - } -
-
- @($"{record.Duration:N3}") sec -
-
-
-
-
@record.Result
-
-
-
-
- } -
- -
\ No newline at end of file diff --git a/MP.Land/Components/TaskExeList.razor.cs b/MP.Land/Components/TaskExeList.razor.cs deleted file mode 100644 index 67658db4..00000000 --- a/MP.Land/Components/TaskExeList.razor.cs +++ /dev/null @@ -1,136 +0,0 @@ -using MailKit; -using Microsoft.AspNetCore.Components; -using MongoDB.Bson; -using MP.Data.DatabaseModels; -using MP.Data.Services; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NLog; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace MP.Land.Components -{ - public partial class TaskExeList - { - #region Public Properties - - [Parameter] - public TaskListModel? CurrRecord { get; set; } = null; - - #endregion Public Properties - - #region Protected Fields - - protected bool isLoading = false; - - #endregion Protected Fields - - #region Protected Properties - - [Inject] - protected NavigationManager NavManager { get; set; } - - /// - /// Show error mode: 0 = tutti 1 = solo errori 2 = solo ok - /// - protected int ShowErrorMode - { - get => showErrorMode; - set - { - if (showErrorMode != value) - { - showErrorMode = value; - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); - } - } - } - - protected int totalCount { get; set; } = 0; - - [Inject] - protected TaskService TService { get; set; } - - #endregion Protected Properties - - #region Protected Methods - - protected string alCss(TaskExecModel TaskRec) - { - return TaskRec.IsError ? "alert-danger" : "alert-success"; - } - - protected async Task ForceReload(int newNum) - { - numRecord = newNum; - await ReloadData(); - } - - protected async Task ForceReloadPage(int newNum) - { - currPage = newNum; - await ReloadData(); - } - - protected override async Task OnInitializedAsync() - { - await ReloadData(); - } - - 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; - } - - #endregion Protected Methods - - #region Private Fields - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - private List ListRecords; - private List SearchRecords; - - #endregion Private Fields - - #region Private Properties - - private int currPage { get; set; } = 1; - private int numRecord { get; set; } = 10; - private int showErrorMode { get; set; } = 0; - - #endregion Private Properties - - #region Private Methods - - private async Task ReloadData() - { - SearchRecords = await TService.TaskExecGetFilt(CurrRecord.TaskId, 1000, ""); - // se non tutti filtro... - if (ShowErrorMode != 0) - { - if (ShowErrorMode == 1) - { - SearchRecords = SearchRecords.FindAll(x => x.IsError); - } - else if (ShowErrorMode == 2) - { - SearchRecords = SearchRecords.FindAll(x => !x.IsError); - } - } - totalCount = SearchRecords.Count; - ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 0a170296..7c10aff5 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.16.2410.2519 + 6.16.2410.2611 Debug;Release;Debug_LiManDebug @@ -11,9 +11,12 @@ + + + @@ -21,8 +24,11 @@ + + + @@ -63,6 +69,7 @@ + diff --git a/MP.Land/Pages/TaskScheduler.razor b/MP.Land/Pages/TaskScheduler.razor index accc34b3..4cb01b87 100644 --- a/MP.Land/Pages/TaskScheduler.razor +++ b/MP.Land/Pages/TaskScheduler.razor @@ -10,7 +10,7 @@
- @if (TypeSel != MP.Data.Objects.Enums.Task2ExeType.ND) + @if (TypeSel != MP.TaskMan.Objects.Enums.Task2ExeType.ND) { @if (currRecord == null) { @@ -26,7 +26,7 @@ }