From ea08fb4b7818fd0ceb7a9acf7e4eb4457e0dffc9 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 May 2021 13:18:15 +0200 Subject: [PATCH] Aggiunta lettura RAW dati scarti --- MP-STATS/Data/MpStatsService.cs | 72 +++++++++ MP-STATS/Pages/Controlli.razor | 14 +- MP-STATS/Pages/Index.razor | 10 +- MP-STATS/Pages/Scarti.razor | 60 ++++++- MP-STATS/Pages/Scarti.razor.cs | 146 ++++++++++++++++++ MP-STATS/Shared/NavMenu.razor | 14 +- MP-STATS/Startup.cs | 49 ++++-- MP-STATS/appsettings.json | 6 +- MpDataLayer/Controllers/MpStatsController.cs | 85 ++++++++++ .../{VRc.cs => ResControlli.cs} | 14 +- .../DatabaseModels/{VR.cs => ResScarti.cs} | 20 ++- .../{VUl.cs => UserActionLog.cs} | 18 ++- MpDataLayer/MoonPro_STATSContext.cs | 90 +++++++---- MpDataLayer/MpDataLayer.csproj | 23 ++- 14 files changed, 526 insertions(+), 95 deletions(-) create mode 100644 MP-STATS/Data/MpStatsService.cs create mode 100644 MP-STATS/Pages/Scarti.razor.cs create mode 100644 MpDataLayer/Controllers/MpStatsController.cs rename MpDataLayer/DatabaseModels/{VRc.cs => ResControlli.cs} (80%) rename MpDataLayer/DatabaseModels/{VR.cs => ResScarti.cs} (85%) rename MpDataLayer/DatabaseModels/{VUl.cs => UserActionLog.cs} (83%) diff --git a/MP-STATS/Data/MpStatsService.cs b/MP-STATS/Data/MpStatsService.cs new file mode 100644 index 00000000..df8ce951 --- /dev/null +++ b/MP-STATS/Data/MpStatsService.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Configuration; +using System.Text; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using MpDataLayer; + +namespace MP_STATS.Data +{ + public class MpStatsService + { + #region Private Fields + + private static IConfiguration _configuration; + private static ILogger _logger; + + #endregion Private Fields + + #region Protected Fields + + protected static string connStringBBM = ""; + protected static string connStringFatt = ""; + + #endregion Protected Fields + + #region Public Fields + + public static MpDataLayer.Controllers.MpStatsController dbController; + + #endregion Public Fields + + #region Public Constructors + + public MpStatsService(IConfiguration configuration, ILogger logger) + { + _logger = logger; + _configuration = configuration; + string connStr = _configuration.GetConnectionString("Mp.Stats"); + if (string.IsNullOrEmpty(connStr)) + { + _logger.LogError("ConnString empty!"); + } + else + { + dbController = new MpDataLayer.Controllers.MpStatsController(configuration); + StringBuilder sb = new StringBuilder(); + sb.AppendLine($"DbController OK"); + //sb.AppendLine($"CST: {dbController.CustomersCount()} | CNT: {dbController.CountersCount()} | BSK: {dbController.BasketsCount()} | NGT: {dbController.NegotiationsCount()} | DOC: {dbController.DocsCount()} | ITM: {dbController.ItemsCount()} | RES: {dbController.ResourcesCount()}"); + _logger.LogInformation(sb.ToString()); + } + } + + #endregion Public Constructors + + #region Public Methods + + public void rollBackEdit(object item) + { + dbController.rollBackEntity(item); + } + + public Task ScartiGetAll(int numRecord, string searchVal = "") + { + return Task.FromResult(dbController.ScartiGetAll(numRecord, searchVal).ToArray()); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP-STATS/Pages/Controlli.razor b/MP-STATS/Pages/Controlli.razor index 80019b0d..854bc248 100644 --- a/MP-STATS/Pages/Controlli.razor +++ b/MP-STATS/Pages/Controlli.razor @@ -1,5 +1,15 @@ -

Controlli

+@page "/controlli" + +@using MP_STATS.Components +@using MP_STATS.Data + +
+
Controlli
+
+ elenco controlli +
+
@code { -} +} \ No newline at end of file diff --git a/MP-STATS/Pages/Index.razor b/MP-STATS/Pages/Index.razor index 2762d330..7e53c4fd 100644 --- a/MP-STATS/Pages/Index.razor +++ b/MP-STATS/Pages/Index.razor @@ -13,7 +13,7 @@
- | | | | | | + | | |
@@ -24,13 +24,7 @@
@Anno
-
-
- -
-
-
- + @**@ diff --git a/MP-STATS/Pages/Scarti.razor b/MP-STATS/Pages/Scarti.razor index 31e1f24d..8ce0c777 100644 --- a/MP-STATS/Pages/Scarti.razor +++ b/MP-STATS/Pages/Scarti.razor @@ -1,5 +1,59 @@ -

Scarti

+@page "/scarti" -@code { +@using MP_STATS.Components +@using MP_STATS.Data -} +
+
Scarti
+
+ @if (currRecord != null) + { + @**@ + } + @if (ListRecords == null) + { +

Loading...

+ } + else + { + + + + @**@ + + + + + + + + + + + @foreach (var record in ListRecords) + { + + @**@ + + + + + + + + + } + +
MacchinaDataODL/CommessaArticoloDescrizioneQtaOperatore
 @record.IdxMacchina@record.DataOra@record.IdxOdl | @record.KeyRichiesta@record.CodArticolo@record.Descrizione@record.CodArticolo@record.MatrOpr
+ } +
+ +
\ No newline at end of file diff --git a/MP-STATS/Pages/Scarti.razor.cs b/MP-STATS/Pages/Scarti.razor.cs new file mode 100644 index 00000000..8a10dc37 --- /dev/null +++ b/MP-STATS/Pages/Scarti.razor.cs @@ -0,0 +1,146 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP_STATS.Data; +using System; +using System.Threading.Tasks; + +namespace MP_STATS.Pages +{ + public partial class Scarti : ComponentBase, IDisposable + { + #region Private Fields + + private MpDataLayer.DatabaseModels.ResScarti currRecord = null; + + private MpDataLayer.DatabaseModels.ResScarti[] ListRecords; + + #endregion Private Fields + + #region Private Properties + + private int numRecord { get; set; } = 10; + + #endregion Private Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected MessageService MessageService { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + [Inject] + protected MpStatsService StatService { get; set; } + + #endregion Protected Properties + + #region Protected Methods + + protected async Task ForceReload(int newNum) + { + numRecord = newNum; + ListRecords = await StatService.ScartiGetAll(numRecord, MessageService.SearchVal); + } + + protected override async Task OnInitializedAsync() + { + MessageService.ShowSearch = true; + MessageService.EA_SearchUpdated += OnSeachUpdated; + ListRecords = await StatService.ScartiGetAll(numRecord, MessageService.SearchVal); + } + + protected void ResetData() + { + StatService.rollBackEdit(currRecord); + currRecord = null; + } + + protected async Task UpdateData() + { + currRecord = null; + ListRecords = await StatService.ScartiGetAll(numRecord, MessageService.SearchVal); + } + + #endregion Protected Methods + + #region Public Methods + + public string checkSelect(DateTime DataOra, string IdxMacchina, string Causale) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.DataOra == DataOra && currRecord.IdxMacchina == IdxMacchina && currRecord.Causale == Causale) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + MessageService.EA_SearchUpdated -= OnSeachUpdated; + } + + public void OnSeachUpdated() + { + InvokeAsync(() => + { + UpdateData(); + StateHasChanged(); + }); + } + + #endregion Public Methods + +#if false + [Inject] + protected BBM_SelectData SelectData { get; set; } + + protected void CreateNew() + { + // recupero counter + string newCode = BBMService.CounterGetNext("EGW.B", 6); + DatabaseModels.BasketsModel newRecord = new DatabaseModels.BasketsModel() + { + CodBasket = newCode, + DataIns = DateTime.Now, + CustomerId = 1, + Descript = "New Basket" + }; + currBasket = newRecord; + } + + protected async Task Delete(SHERPA.BBM.DatabaseModels.BasketsModel currRecord) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare il Basket '{currRecord.CodBasket}'?")) + return; + + BBMService.BasketsDelete(currRecord); + await UpdateData(); + } + + protected void Edit(SHERPA.BBM.DatabaseModels.BasketsModel currRecord) + { + currBasket = currRecord; + } + + protected void ShowDocs(SHERPA.BBM.DatabaseModels.BasketsModel currRecord) + { + // salvo + SelectData.BasketId = currRecord.BasketId; + SelectData.NegotiationId = 0; + // rimando... + NavManager.NavigateTo("docs"); + } + +#endif + } +} \ No newline at end of file diff --git a/MP-STATS/Shared/NavMenu.razor b/MP-STATS/Shared/NavMenu.razor index c7710983..68368d26 100644 --- a/MP-STATS/Shared/NavMenu.razor +++ b/MP-STATS/Shared/NavMenu.razor @@ -12,19 +12,14 @@ Home - @**@ + @*