diff --git a/GWMS.UI/Components/LoadingData.razor b/GWMS.UI/Components/LoadingData.razor index 2ffebab..d3228ba 100644 --- a/GWMS.UI/Components/LoadingData.razor +++ b/GWMS.UI/Components/LoadingData.razor @@ -1,4 +1,4 @@ -
+

loading data

diff --git a/GWMS.UI/Components/OrderAdminEditor.razor b/GWMS.UI/Components/OrderAdminEditor.razor new file mode 100644 index 0000000..0101f83 --- /dev/null +++ b/GWMS.UI/Components/OrderAdminEditor.razor @@ -0,0 +1,161 @@ +@using GWMS.UI.Components +@using GWMS.Data.DatabaseModels +@using System.Security.Claims +@using Microsoft.AspNetCore.Components.Authorization +@using GWMS.UI.Data +@using Microsoft.Extensions.Configuration + +@inject MessageService AppMService +@inject GWMSDataService DataService +@inject IConfiguration Configuration + +
+
+ Modifica +
+
+ + +
+
+ +
+
+
+
+
+
+ + + +
+ + @foreach (var item in suppList) + { + + } + +
+
+
+ @*
+
+ + + +
+ +
*@ +
+
+
+
+ + + +
+ +
+ + Note + +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +@code { + + private List suppList; + + protected OrderModel _currItem = new OrderModel(); + protected int _supplierId { get; set; } = 0; + + [Parameter] + public OrderModel currItem + { + get + { + return _currItem = null; + } + set + { + _currItem = value; + } + } + + [Parameter] + public EventCallback DataReset { get; set; } + [Parameter] + public EventCallback DataUpdated { get; set; } + [Parameter] + public int SupplierId + { + get + { + return _supplierId; + } + set + { + _supplierId = value; + // condiziono visualizzazione... + var pUpd = Task.Run(async () => await ReloadAllData()); + pUpd.Wait(); + } + } + + private async Task saveUpdate() + { + if (_currItem != null) + { + DataService.OrderUpdate(_currItem, AppMService.Order_Filter); + await DataUpdated.InvokeAsync(1); + } + else + { + Console.WriteLine("Order null!"); + } + } + + private async Task cancelUpdate() + { + await DataReset.InvokeAsync(0); + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task ReloadAllData() + { + suppList = await DataService.SuppliersGetAll(); + } + + /// + /// Restituisce URL immagine QRCode + /// + /// Parametro da renderizzare con QRCode + /// + protected string getImgUrl(object QrValue) + { + string baseUrl = $"{Configuration["matrixUrl"]}/HOME/QR_site/JSON?val="; + string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}"; + string answ = $"{baseUrl}{payload}"; + return answ; + } + +} \ No newline at end of file diff --git a/GWMS.UI/Components/OrderEditor.razor b/GWMS.UI/Components/OrderEditor.razor deleted file mode 100644 index 790b02c..0000000 --- a/GWMS.UI/Components/OrderEditor.razor +++ /dev/null @@ -1,131 +0,0 @@ -@using GWMS.UI.Components -@using GWMS.Data.DatabaseModels -@using System.Security.Claims -@using Microsoft.AspNetCore.Components.Authorization -@using GWMS.UI.Data - -@inject MessageService AppMessages -@inject GWMSDataService DataService - -
-
- Modifica -
-
- - - -
-
- - mettere QRCODE da https://qrcode.steamware.net/ -
-
-
-
- - - @foreach (var item in transpList) - { - - } - -
-
- - -
-
-
- - -
-
-
-
-
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-
- -@code { - - private List transpList; - - protected OrderModel _currItem = new OrderModel(); - protected int _supplierId { get; set; } = 0; - - [Parameter] - public OrderModel currItem - { - get - { - return _currItem = null; - } - set - { - _currItem = value; - } - } - - [Parameter] - public EventCallback DataReset { get; set; } - [Parameter] - public EventCallback DataUpdated { get; set; } - [Parameter] - public int SupplierId - { - get - { - return _supplierId; - } - set - { - _supplierId = value; - // condiziono visualizzazione... - var pUpd = Task.Run(async () => await ReloadAllData()); - pUpd.Wait(); - } - } - - private async Task saveUpdate() - { - if (_currItem != null) - { - DataService.OrderUpdate(_currItem); - await DataUpdated.InvokeAsync(1); - } - else - { - Console.WriteLine("Order null!"); - } - } - - private async Task cancelUpdate() - { - await DataReset.InvokeAsync(0); - } - - protected override async Task OnInitializedAsync() - { - await ReloadAllData(); - } - - protected async Task ReloadAllData() - { - transpList = await DataService.TransportersGetFilt(SupplierId); - } -} \ No newline at end of file diff --git a/GWMS.UI/Components/OrderSupplierEditor.razor b/GWMS.UI/Components/OrderSupplierEditor.razor new file mode 100644 index 0000000..888eb7c --- /dev/null +++ b/GWMS.UI/Components/OrderSupplierEditor.razor @@ -0,0 +1,161 @@ +@using GWMS.UI.Components +@using GWMS.Data.DatabaseModels +@using System.Security.Claims +@using Microsoft.AspNetCore.Components.Authorization +@using GWMS.UI.Data +@using Microsoft.Extensions.Configuration + +@inject MessageService AppMService +@inject GWMSDataService DataService +@inject IConfiguration Configuration + +
+
+ Modifica +
+
+ + +
+
+ +
+
+
+
+
+
+ + + +
+ + @foreach (var item in transpList) + { + + } + +
+
+
+
+
+ + + +
+ +
+
+
+
+
+ + + +
+ +
+ + Note + +
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +@code { + + private List transpList; + + protected OrderModel _currItem = new OrderModel(); + protected int _supplierId { get; set; } = 0; + + [Parameter] + public OrderModel currItem + { + get + { + return _currItem = null; + } + set + { + _currItem = value; + } + } + + [Parameter] + public EventCallback DataReset { get; set; } + [Parameter] + public EventCallback DataUpdated { get; set; } + [Parameter] + public int SupplierId + { + get + { + return _supplierId; + } + set + { + _supplierId = value; + // condiziono visualizzazione... + var pUpd = Task.Run(async () => await ReloadAllData()); + pUpd.Wait(); + } + } + + private async Task saveUpdate() + { + if (_currItem != null) + { + DataService.OrderUpdate(_currItem, AppMService.Order_Filter); + await DataUpdated.InvokeAsync(1); + } + else + { + Console.WriteLine("Order null!"); + } + } + + private async Task cancelUpdate() + { + await DataReset.InvokeAsync(0); + } + + protected override async Task OnInitializedAsync() + { + await ReloadAllData(); + } + + protected async Task ReloadAllData() + { + transpList = await DataService.TransportersGetFilt(SupplierId); + } + + /// + /// Restituisce URL immagine QRCode + /// + /// Parametro da renderizzare con QRCode + /// + protected string getImgUrl(object QrValue) + { + string baseUrl = $"{Configuration["matrixUrl"]}/HOME/QR_site/JSON?val="; + string payload = "{'baseUrl':'{0}','parameters':['" + $"{QrValue}" + "']}"; + string answ = $"{baseUrl}{payload}"; + return answ; + } + +} \ No newline at end of file diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 213129f..a57e363 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -31,13 +31,13 @@ namespace GWMS.UI.Data /// /// Durata assoluta massima della cache IN SECONDI /// - private int chAbsExp = 60; + private int chAbsExp = 60 * 5; /// /// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire rimossa /// NON estende oltre il tempo massimo di validità della cache (chAbsExp) /// - private int chSliExp = 5; + private int chSliExp = 60 * 1; #endregion Private Fields @@ -159,30 +159,18 @@ namespace GWMS.UI.Data public async Task> OrdersGetFilt(SelectOrderData CurrFilter) { List dbResult = new List(); - string cacheKey = getCacheKey("GWMS:DATA:ORDERS", CurrFilter); - string rawData; - var redisDataList = await distributedCache.GetAsync(cacheKey); - if (redisDataList != null) - { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject>(rawData); - } - else - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId, CurrFilter.DateStart, CurrFilter.DateEnd); - rawData = JsonConvert.SerializeObject(dbResult); - redisDataList = Encoding.UTF8.GetBytes(rawData); - await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(true)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Info($"Effettuata lettura da DB + caching per OrdersGetFilt: {ts.TotalMilliseconds} ms"); - } + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + dbResult = dbController.GetOrdersFilt(CurrFilter.PlantId, CurrFilter.SupplierId, CurrFilter.DateStart, CurrFilter.DateEnd); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Info($"Effettuata lettura da DB per OrdersGetFilt: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(dbResult); } - public void OrderUpdate(OrderModel currItem) + public void OrderUpdate(OrderModel currItem, SelectOrderData CurrFilter) { try { diff --git a/GWMS.UI/Pages/Orders.razor b/GWMS.UI/Pages/Orders.razor index f6b8dad..88da5b9 100644 --- a/GWMS.UI/Pages/Orders.razor +++ b/GWMS.UI/Pages/Orders.razor @@ -7,7 +7,7 @@
- Ordini + Elenco Ordini
@@ -69,7 +69,11 @@
-
+
+ @if (currRecord != null) + { + + } @if (ListRecords == null) { @@ -85,6 +89,7 @@ + @@ -96,6 +101,7 @@ @foreach (var record in ListRecords) { +
Impianto Data Ordine Ordine
@record.Plant.PlantCode
@record.Plant.PlantDesc
diff --git a/GWMS.UI/Pages/Orders.razor.cs b/GWMS.UI/Pages/Orders.razor.cs index 2b293b3..577f56d 100644 --- a/GWMS.UI/Pages/Orders.razor.cs +++ b/GWMS.UI/Pages/Orders.razor.cs @@ -64,17 +64,17 @@ namespace GWMS.UI.Pages get { int answ = 0; - if (MessageService.Order_Filter != null) + if (AppMService.Order_Filter != null) { - answ = MessageService.Order_Filter.PlantId; + answ = AppMService.Order_Filter.PlantId; } return answ; } set { - if (!MessageService.Order_Filter.PlantId.Equals(value)) + if (!AppMService.Order_Filter.PlantId.Equals(value)) { - MessageService.Order_Filter.PlantId = value; + AppMService.Order_Filter.PlantId = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } @@ -86,17 +86,17 @@ namespace GWMS.UI.Pages get { int answ = 0; - if (MessageService.Order_Filter != null) + if (AppMService.Order_Filter != null) { - answ = MessageService.Order_Filter.SupplierId; + answ = AppMService.Order_Filter.SupplierId; } return answ; } set { - if (!MessageService.Order_Filter.SupplierId.Equals(value)) + if (!AppMService.Order_Filter.SupplierId.Equals(value)) { - MessageService.Order_Filter.SupplierId = value; + AppMService.Order_Filter.SupplierId = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } @@ -109,6 +109,9 @@ namespace GWMS.UI.Pages #region Protected Properties + [Inject] + protected MessageService AppMService { get; set; } + [Inject] protected GWMSDataService DataService { get; set; } @@ -117,17 +120,17 @@ namespace GWMS.UI.Pages get { DateTime answ = DateTime.Today.AddDays(1); - if (MessageService.Order_Filter != null) + if (AppMService.Order_Filter != null) { - answ = MessageService.Order_Filter.DateEnd; + answ = AppMService.Order_Filter.DateEnd; } return answ; } set { - if (!MessageService.Order_Filter.DateEnd.Equals(value)) + if (!AppMService.Order_Filter.DateEnd.Equals(value)) { - MessageService.Order_Filter.DateEnd = value; + AppMService.Order_Filter.DateEnd = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } @@ -139,17 +142,17 @@ namespace GWMS.UI.Pages get { DateTime answ = DateTime.Today.AddDays(-1); - if (MessageService.Order_Filter != null) + if (AppMService.Order_Filter != null) { - answ = MessageService.Order_Filter.DateStart; + answ = AppMService.Order_Filter.DateStart; } return answ; } set { - if (!MessageService.Order_Filter.DateStart.Equals(value)) + if (!AppMService.Order_Filter.DateStart.Equals(value)) { - MessageService.Order_Filter.DateStart = value; + AppMService.Order_Filter.DateStart = value; var pUpd = Task.Run(async () => await ReloadData()); pUpd.Wait(); } @@ -159,9 +162,6 @@ namespace GWMS.UI.Pages [Inject] protected IJSRuntime JSRuntime { get; set; } - [Inject] - protected MessageService MessageService { get; set; } - [Inject] protected NavigationManager NavManager { get; set; } @@ -195,7 +195,7 @@ namespace GWMS.UI.Pages private async Task ReloadData() { isLoading = true; - SearchRecords = await DataService.OrdersGetFilt(MessageService.Order_Filter); + SearchRecords = await DataService.OrdersGetFilt(AppMService.Order_Filter); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); isLoading = false; } @@ -204,6 +204,11 @@ namespace GWMS.UI.Pages #region Protected Methods + protected void Edit(OrderModel selRecord) + { + currRecord = selRecord; + } + protected void ForceReload(int newNum) { numRecord = newNum; @@ -216,10 +221,10 @@ namespace GWMS.UI.Pages protected override async Task OnInitializedAsync() { - MessageService.ShowSearch = false; - MessageService.PageName = "Ordini"; - MessageService.PageIcon = "fas fa-file-invoice pr-2"; - MessageService.EA_SearchUpdated += OnSeachUpdated; + AppMService.ShowSearch = false; + AppMService.PageName = "Ordini"; + AppMService.PageIcon = "fas fa-file-invoice pr-2"; + AppMService.EA_SearchUpdated += OnSeachUpdated; await ReloadAllData(); } @@ -230,12 +235,18 @@ namespace GWMS.UI.Pages await ReloadData(); } + protected void ResetData() + { + DataService.rollBackEdit(currRecord); + currRecord = null; + } + protected async Task ResetFilter(SelectOrderData newFilter) { currRecord = null; SearchRecords = null; ListRecords = null; - MessageService.Order_Filter = SelectOrderData.Init(5, 7); + AppMService.Order_Filter = SelectOrderData.Init(5, 7); await ReloadAllData(); } @@ -272,7 +283,7 @@ namespace GWMS.UI.Pages public void Dispose() { - MessageService.EA_SearchUpdated -= OnSeachUpdated; + AppMService.EA_SearchUpdated -= OnSeachUpdated; } public async void OnSeachUpdated() diff --git a/GWMS.UI/Pages/Suppliers.razor b/GWMS.UI/Pages/Suppliers.razor index e525ff7..ddcf199 100644 --- a/GWMS.UI/Pages/Suppliers.razor +++ b/GWMS.UI/Pages/Suppliers.razor @@ -7,7 +7,7 @@
- Elenco Ordini Fornitore + Ordini Fornitore
@@ -54,7 +54,6 @@