diff --git a/Projects/NetStandard/CPMeta/CPMeta.cs b/Projects/NetStandard/CPMeta/CPMeta.cs index 8db69b4..54d9d10 100644 --- a/Projects/NetStandard/CPMeta/CPMeta.cs +++ b/Projects/NetStandard/CPMeta/CPMeta.cs @@ -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 HealthCheck(string host) + { + string url = $"https://{host}:{Port}/CPMeta/Health/health"; + + var res = await RestAPI.GetAsync(url); + return res; + } public static async Task SetWbmsMetaAsync(string host, Request_SetWbmsMeta request) { diff --git a/Projects/NetStandard/CPMeta/RestAPI.cs b/Projects/NetStandard/CPMeta/RestAPI.cs index aec4a5d..776f06a 100644 --- a/Projects/NetStandard/CPMeta/RestAPI.cs +++ b/Projects/NetStandard/CPMeta/RestAPI.cs @@ -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 PostAsync(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); } diff --git a/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj b/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj index 479b481..10dc7ea 100644 --- a/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj +++ b/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj @@ -33,9 +33,6 @@ 4 - - .\CPMeta.dll - ..\packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll @@ -57,6 +54,10 @@ + + {0bdb3e8c-2f57-4780-8b6f-3ae3f426a6c3} + CPMeta + {73824acb-4fb9-4e11-9a86-e05471b3c979} KmsProxy diff --git a/Projects/NetStandard/PlayGround.NetFramework/Program.cs b/Projects/NetStandard/PlayGround.NetFramework/Program.cs index 4496ec4..c55c979 100644 --- a/Projects/NetStandard/PlayGround.NetFramework/Program.cs +++ b/Projects/NetStandard/PlayGround.NetFramework/Program.cs @@ -12,80 +12,98 @@ namespace PlayGround.NetFramework //global set string host = "192.168.0.43"; + //random value + string ProductId = "00010032-87a4-45ca-b627-b975d41e35df"; + // string Mac1 = Guid.NewGuid().ToString(); + // string Mac2 = Guid.NewGuid().ToString(); + + //Get Task.Run(async () => { - //1. ecuid - var resEcuid = await KmsProxy.KmsProxy.EcuID_SupplierEcuID(host, new KmsProxy.Models.EcuID.Request_SupplierEcuID - { - EcuID = "" - }); - Console.WriteLine(JsonConvert.SerializeObject(resEcuid, Formatting.Indented)); - - //2. master ecu key - var resMasterKeyProvisioning = await KmsProxy.KmsProxy.MasterEcuKey_SupplierKeyProvisioning(host, new KmsProxy.Models.MasterEcuKey.Request_SupplierKeyProvisioning - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(resMasterKeyProvisioning, Formatting.Indented)); - - var resMasterKeyProvisioningResult = await KmsProxy.KmsProxy.MasterEcuKey_SupplierKeyProvisioningResult(host, new KmsProxy.Models.MasterEcuKey.Request_SupplierKeyProvisioning_Result - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(resMasterKeyProvisioningResult, Formatting.Indented)); - - //3. SupplierSymmKey - var symmKeyProvisioning = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeyProvisioning(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeyProvisioning - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(symmKeyProvisioning, Formatting.Indented)); - - var symmKeyProvisioningResult = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeyProvisioningResult(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeyProvisioning_Result - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(symmKeyProvisioningResult, Formatting.Indented)); - - var symmKeySync = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeySyncValue(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeySyncValue - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(symmKeySync, Formatting.Indented)); - - var symmKeySyncResult = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeySyncValueResult(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeySyncValue_Result - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(symmKeySyncResult, Formatting.Indented)); - - //4. SecOCKey - var secOcKeyProvisioning = await KmsProxy.KmsProxy.SecOCKey_SupplierKeyProvisioning(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeyProvisioning - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(secOcKeyProvisioning, Formatting.Indented)); - - var secOcKeyProvisioningResult = await KmsProxy.KmsProxy.SecOCKey_SupplierKeyProvisioningResult(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeyProvisioning_Result - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(secOcKeyProvisioningResult, Formatting.Indented)); - - var secOcKeySync = await KmsProxy.KmsProxy.SecOCKey_SupplierKeySyncValue(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeySyncValue - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(secOcKeySync, Formatting.Indented)); - - var secOcKeySyncResult = await KmsProxy.KmsProxy.SecOCKey_SupplierKeySyncValueResult(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeySyncValue_Result - { - EcuID="" - }); - Console.WriteLine(JsonConvert.SerializeObject(secOcKeySyncResult, Formatting.Indented)); + var res2 = await CPMeta.CPMeta.GetWbmsMetaByProductId(host, ProductId); + // var res3 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac1); + // var res4 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac2); + }).Wait(); - }).Wait(); + return; + ////global set + //string host = "192.168.0.43"; + + //Task.Run(async () => + //{ + // //1. ecuid + // var resEcuid = await KmsProxy.KmsProxy.EcuID_SupplierEcuID(host, new KmsProxy.Models.EcuID.Request_SupplierEcuID + // { + // EcuID = "" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(resEcuid, Formatting.Indented)); + + // //2. master ecu key + // var resMasterKeyProvisioning = await KmsProxy.KmsProxy.MasterEcuKey_SupplierKeyProvisioning(host, new KmsProxy.Models.MasterEcuKey.Request_SupplierKeyProvisioning + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(resMasterKeyProvisioning, Formatting.Indented)); + + // var resMasterKeyProvisioningResult = await KmsProxy.KmsProxy.MasterEcuKey_SupplierKeyProvisioningResult(host, new KmsProxy.Models.MasterEcuKey.Request_SupplierKeyProvisioning_Result + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(resMasterKeyProvisioningResult, Formatting.Indented)); + + // //3. SupplierSymmKey + // var symmKeyProvisioning = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeyProvisioning(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeyProvisioning + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(symmKeyProvisioning, Formatting.Indented)); + + // var symmKeyProvisioningResult = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeyProvisioningResult(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeyProvisioning_Result + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(symmKeyProvisioningResult, Formatting.Indented)); + + // var symmKeySync = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeySyncValue(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeySyncValue + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(symmKeySync, Formatting.Indented)); + + // var symmKeySyncResult = await KmsProxy.KmsProxy.SupplierSymmKey_SupplierKeySyncValueResult(host, new KmsProxy.Models.SupplierSymmKey.Request_SupplierKeySyncValue_Result + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(symmKeySyncResult, Formatting.Indented)); + + // //4. SecOCKey + // var secOcKeyProvisioning = await KmsProxy.KmsProxy.SecOCKey_SupplierKeyProvisioning(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeyProvisioning + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(secOcKeyProvisioning, Formatting.Indented)); + + // var secOcKeyProvisioningResult = await KmsProxy.KmsProxy.SecOCKey_SupplierKeyProvisioningResult(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeyProvisioning_Result + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(secOcKeyProvisioningResult, Formatting.Indented)); + + // var secOcKeySync = await KmsProxy.KmsProxy.SecOCKey_SupplierKeySyncValue(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeySyncValue + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(secOcKeySync, Formatting.Indented)); + + // var secOcKeySyncResult = await KmsProxy.KmsProxy.SecOCKey_SupplierKeySyncValueResult(host, new KmsProxy.Models.SecOCKey.Request_SupplierKeySyncValue_Result + // { + // EcuID="" + // }); + // Console.WriteLine(JsonConvert.SerializeObject(secOcKeySyncResult, Formatting.Indented)); + + + // }).Wait(); } } } diff --git a/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor b/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor index 078967a..4464138 100644 --- a/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor +++ b/Projects/WebClient/Web.Operation/Components/Layout/MainLayout.razor @@ -15,7 +15,7 @@ - + @* *@