[성현모] CPMeta , Netstandard 오류 수정

This commit is contained in:
SHM
2026-02-06 11:15:55 +09:00
parent 40c509ba89
commit 4bfcf64720
5 changed files with 123 additions and 79 deletions

View File

@ -12,6 +12,20 @@ namespace CPMeta
public class CPMeta
{
public static int Port { get; set; } = 9000;
public static int TimeOut { get; set; } = 3000;
public CPMeta()
{
RestAPI.TimeOut = TimeOut;
}
public static async Task<string> HealthCheck(string host)
{
string url = $"https://{host}:{Port}/CPMeta/Health/health";
var res = await RestAPI.GetAsync<string>(url);
return res;
}
public static async Task<Response_SetWbmsMeta> SetWbmsMetaAsync(string host, Request_SetWbmsMeta request)
{

View File

@ -4,21 +4,24 @@ using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace CPMeta
{
public class RestAPI
{
{
private static HttpClient RequestClient = new HttpClient();
private static HttpClient ResponseClient = new HttpClient();
public static int TimeOut { get; set; } = 3000;
static RestAPI()
{
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
RequestClient.Timeout = TimeSpan.FromMilliseconds(10000);
ResponseClient.Timeout = TimeSpan.FromMilliseconds(10000);
RequestClient.Timeout = TimeSpan.FromMilliseconds(TimeOut);
}
public static async Task<RESPONSE> PostAsync<REQUEST,RESPONSE>(string Url, REQUEST body) where REQUEST : class where RESPONSE : class
@ -27,9 +30,12 @@ namespace CPMeta
{
if (body != null)
{
var jsonBody = JsonConvert.SerializeObject(body);
var contents = new StringContent(jsonBody, Encoding.UTF8, "application/json");
Console.WriteLine($"PostAsync:{Url},{JsonConvert.SerializeObject(body, Formatting.Indented)}");
var jsonBody = JsonConvert.SerializeObject(body);
var contents = new StringContent(jsonBody, Encoding.UTF8, "application/json");
//RequestClient.Timeout = TimeSpan.FromMilliseconds(TimeOut);
var response = await RequestClient.PostAsync(Url, contents);
var resContentStr = await response.Content.ReadAsStringAsync();
@ -38,6 +44,7 @@ namespace CPMeta
}
catch (Exception e)
{
Console.WriteLine($"TimeOut: {ResponseClient.Timeout}");
Console.WriteLine("PostAsync Error");
Console.WriteLine(e.Message);
}
@ -49,6 +56,9 @@ namespace CPMeta
{
try
{
Console.WriteLine($"GetAsync:{Url}");
//ResponseClient.Timeout = TimeSpan.FromMilliseconds(TimeOut);
var response = await ResponseClient.GetAsync(Url);
var resContentStr = await response.Content.ReadAsStringAsync();
@ -57,6 +67,7 @@ namespace CPMeta
}
catch(Exception e)
{
Console.WriteLine($"TimeOut: {ResponseClient.Timeout}");
Console.WriteLine("GetAsync Error");
Console.WriteLine(e.Message);
}