Files
WorkFlowCheck/src/WorkFlowCheck.Web/Helpers/SystemHelper.cs
T
2026-01-21 13:01:06 +01:00

45 lines
1.4 KiB
C#

using Serilog;
using System.Net.Http;
using WorkFlowCheck.Common.DTO;
namespace WorkFlowCheck.Web.Helpers
{
public static class SystemHelper
{
public static string DatabaseName = "";
public static string ProgramVersion = "v1.1.031";
public async static Task GetAPIInfoAsync(IConfiguration configuration)
{
using (var httpClient = new HttpClient())
{
var apiBaseUrl = configuration["ApiBaseUrl"]; // API-cím elérése a konfigurációból
httpClient.BaseAddress = new Uri(apiBaseUrl);
var apiKey = configuration["ApiKey"];
httpClient.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
string endpoint = $"{httpClient.BaseAddress}api/System/GetDatabaseAndVersionInfo";
var retVal = new RoleDTO();
try
{
var response = await httpClient.GetFromJsonAsync<ApiResponseDTO<string>>(endpoint);
if (response != null)
{
if (response.IsSuccess)
{
DatabaseName = response.Data;
}
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
}
}
}
}