diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs index 8b69b7a0..80e3371f 100644 --- a/MP.SPEC/Components/ListPODL.razor.cs +++ b/MP.SPEC/Components/ListPODL.razor.cs @@ -2,6 +2,7 @@ using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.SPEC.Data; +using MP.SPEC.Services; namespace MP.SPEC.Components { @@ -47,6 +48,9 @@ namespace MP.SPEC.Components [Inject] protected MpDataService MDService { get; set; } = null!; + [Inject] + protected IOApiService MpIoApiCall { get; set; } + [Inject] protected MessageService MsgService { get; set; } = null!; @@ -91,6 +95,7 @@ namespace MP.SPEC.Components return; await Task.Delay(1); var done = await MDService.PODLDeleteRecord(selRec); + await callSyncDb(selRec); currRecord = null; await reloadData(); await Task.Delay(1); @@ -152,6 +157,7 @@ namespace MP.SPEC.Components private List? ListRecords; private List? ListStati; + private List? SearchRecords; #endregion Private Fields @@ -189,6 +195,19 @@ namespace MP.SPEC.Components #region Private Methods + /// + /// Chiama metodo x chiedere sync DB + /// + /// + /// + private async Task callSyncDb(PODLModel selRec) + { + // chiamo aggiunta task SyncDb... + string idxMacc = selRec.IdxMacchina; + string restUrl = $"IOB/addTask2Exe/{idxMacc}?taskName=syncDbData&taskVal="; + var response = await MpIoApiCall.callMpIoUrlGet(restUrl); + } + private async void MessageService_EA_PageUpdated() { await reloadData(); diff --git a/MP.SPEC/Pages/PODL.razor.cs b/MP.SPEC/Pages/PODL.razor.cs index ef65f1e7..964dc448 100644 --- a/MP.SPEC/Pages/PODL.razor.cs +++ b/MP.SPEC/Pages/PODL.razor.cs @@ -3,6 +3,7 @@ using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.SPEC.Components; using MP.SPEC.Data; +using MP.SPEC.Services; namespace MP.SPEC.Pages { @@ -24,6 +25,9 @@ namespace MP.SPEC.Pages [Inject] protected MpDataService MDService { get; set; } + [Inject] + protected IOApiService MpIoApiCall { get; set; } + [Inject] protected MessageService MsgService { get; set; } @@ -150,6 +154,7 @@ namespace MP.SPEC.Pages return; await Task.Delay(1); var done = await MDService.POdlUpdateRecord(selRec); + await callSyncDb(selRec); currRecord = null; await reloadData(); await Task.Delay(1); @@ -165,10 +170,15 @@ namespace MP.SPEC.Pages #region Private Fields private PODLModel? _currRecord = null; + private List? ListArticoli; + private List? ListAziende; + private List? ListGruppiFase; + private List? ListMacchine; + private List? ListStati; #endregion Private Fields @@ -176,6 +186,7 @@ namespace MP.SPEC.Pages #region Private Properties private string _artSearch { get; set; } = ""; + private string _currAzienda { get; set; } = "*"; private bool addEnabled @@ -206,6 +217,7 @@ namespace MP.SPEC.Pages } private List? configData { get; set; } = null; + private string currArticolo { get; set; } = ""; private string currAzienda @@ -265,6 +277,19 @@ namespace MP.SPEC.Pages #region Private Methods + /// + /// Chiama metodo x chiedere sync DB + /// + /// + /// + private async Task callSyncDb(PODLModel selRec) + { + // chiamo aggiunta task SyncDb... + string idxMacc = selRec.IdxMacchina; + string restUrl = $"IOB/addTask2Exe/{idxMacc}?taskName=syncDbData&taskVal="; + var response = await MpIoApiCall.callMpIoUrlGet(restUrl); + } + private async Task reloadData() { isLoading = true; diff --git a/MP.SPEC/Program.cs b/MP.SPEC/Program.cs index fae8d42a..75d78ad3 100644 --- a/MP.SPEC/Program.cs +++ b/MP.SPEC/Program.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using MP.SPEC.Components; using MP.SPEC.Data; +using MP.SPEC.Services; using StackExchange.Redis; var builder = WebApplication.CreateBuilder(args); @@ -38,6 +39,9 @@ builder.Services.AddSingleton(redisMultiplexer); builder.Services.AddSingleton(); builder.Services.AddScoped(); +builder.Services.AddHttpClient(); +builder.Services.AddSingleton(); + var app = builder.Build(); // Configure the HTTP request pipeline. diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 1c8e2a90..81eaf43f 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1,5 @@ +<<<<<<< HEAD 6.16.2210.1016 +======= +6.16.2210.1011 +>>>>>>> 91174a2f6752f9d3cf06484367ebf4b92a2b8d69 diff --git a/MP.SPEC/Services/IOApiService.cs b/MP.SPEC/Services/IOApiService.cs new file mode 100644 index 00000000..9267abcd --- /dev/null +++ b/MP.SPEC/Services/IOApiService.cs @@ -0,0 +1,56 @@ +using Microsoft.Extensions.Configuration; +using MP.SPEC.Data; +using System.Text.Json; + +namespace MP.SPEC.Services +{ + /// + /// Classe per chiamare metodi da MP-IO + /// + /// rif: + /// https://www.ezzylearning.net/tutorial/making-http-requests-in-blazor-server-apps + /// https://wellsb.com/csharp/aspnet/blazor-httpclientfactory-and-web-api/ + /// + public class IOApiService + { + private readonly IHttpClientFactory _clientFactory; + private static ILogger _logger = null!; + private static IConfiguration _configuration = null!; + + + private static string MpIoBaseUrl = ""; + + public IOApiService(IHttpClientFactory clientFactory, IConfiguration configuration, ILogger logger) + { + _logger = logger; + _logger.LogInformation("Starting IOApiService INIT"); + _configuration = configuration; + _clientFactory = clientFactory; + // conf url x chiamate REST + MpIoBaseUrl = _configuration.GetValue("ServerConf:MpIoBaseUrl"); + } + /// + /// Effettua chiamata ad MP-IO + /// + /// URL metodo relativo alla base path di MP-IO + /// + public async Task callMpIoUrlGet(string relUrl) + { + string result = ""; + var request = new HttpRequestMessage(HttpMethod.Get, $"{MpIoBaseUrl}{relUrl}"); + request.Headers.Add("Accept", "application/vnd.github.v3+json"); + var client = _clientFactory.CreateClient(); + var response = await client.SendAsync(request); + if (response.IsSuccessStatusCode) + { + var stringResponse = await response.Content.ReadAsStringAsync(); + result = stringResponse; + } + else + { + result = "NO"; + } + return result; + } + } +} diff --git a/MP.SPEC/appsettings.Production.json b/MP.SPEC/appsettings.Production.json index a5197b52..bd32e3ce 100644 --- a/MP.SPEC/appsettings.Production.json +++ b/MP.SPEC/appsettings.Production.json @@ -12,5 +12,11 @@ "ConnectionStrings": { "Mp.Data": "Server=localhost\\SQLEXPRESS;Database=MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=Blazor.ServerApp;", "Redis": "localhost:6379,DefaultDatabase=13,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false" + }, + "ServerConf": { + "maxAge": "2000", + "cacheCheckArtUsato": 2, + "redisLongTimeCache": 15, + "MpIoBaseUrl": "http://localhost/MP/IO/" } } diff --git a/MP.SPEC/appsettings.json b/MP.SPEC/appsettings.json index f4116e61..098b7be2 100644 --- a/MP.SPEC/appsettings.json +++ b/MP.SPEC/appsettings.json @@ -15,6 +15,7 @@ "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": 2, - "redisLongTimeCache": 15 + "redisLongTimeCache": 15, + "MpIoBaseUrl": "http://localhost:20967/" } }