This commit is contained in:
zaccaria.majid
2022-10-10 17:14:39 +02:00
7 changed files with 116 additions and 1 deletions
+19
View File
@@ -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<PODLModel>? ListRecords;
private List<ListValues>? ListStati;
private List<PODLModel>? SearchRecords;
#endregion Private Fields
@@ -189,6 +195,19 @@ namespace MP.SPEC.Components
#region Private Methods
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
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();
+25
View File
@@ -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<AnagArticoli>? ListArticoli;
private List<AnagGruppi>? ListAziende;
private List<AnagGruppi>? ListGruppiFase;
private List<Macchine>? ListMacchine;
private List<ListValues>? 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<ConfigModel>? configData { get; set; } = null;
private string currArticolo { get; set; } = "";
private string currAzienda
@@ -265,6 +277,19 @@ namespace MP.SPEC.Pages
#region Private Methods
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
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;
+4
View File
@@ -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<IConnectionMultiplexer>(redisMultiplexer);
builder.Services.AddSingleton<MpDataService>();
builder.Services.AddScoped<MessageService>();
builder.Services.AddHttpClient();
builder.Services.AddSingleton<IOApiService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
+4
View File
@@ -1 +1,5 @@
<<<<<<< HEAD
6.16.2210.1016
=======
6.16.2210.1011
>>>>>>> 91174a2f6752f9d3cf06484367ebf4b92a2b8d69
+56
View File
@@ -0,0 +1,56 @@
using Microsoft.Extensions.Configuration;
using MP.SPEC.Data;
using System.Text.Json;
namespace MP.SPEC.Services
{
/// <summary>
/// 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/
/// </summary>
public class IOApiService
{
private readonly IHttpClientFactory _clientFactory;
private static ILogger<MpDataService> _logger = null!;
private static IConfiguration _configuration = null!;
private static string MpIoBaseUrl = "";
public IOApiService(IHttpClientFactory clientFactory, IConfiguration configuration, ILogger<MpDataService> logger)
{
_logger = logger;
_logger.LogInformation("Starting IOApiService INIT");
_configuration = configuration;
_clientFactory = clientFactory;
// conf url x chiamate REST
MpIoBaseUrl = _configuration.GetValue<string>("ServerConf:MpIoBaseUrl");
}
/// <summary>
/// Effettua chiamata ad MP-IO
/// </summary>
/// <param name="relUrl">URL metodo relativo alla base path di MP-IO</param>
/// <returns></returns>
public async Task<string> 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;
}
}
}
+6
View File
@@ -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/"
}
}
+2 -1
View File
@@ -15,6 +15,7 @@
"ServerConf": {
"maxAge": "2000",
"cacheCheckArtUsato": 2,
"redisLongTimeCache": 15
"redisLongTimeCache": 15,
"MpIoBaseUrl": "http://localhost:20967/"
}
}