Merge branch 'LoopTest'

This commit is contained in:
SHM
2025-11-10 09:15:03 +09:00
2 changed files with 49 additions and 23 deletions

View File

@ -17,8 +17,8 @@ namespace CPMeta
{ {
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
RequestClient.Timeout = TimeSpan.FromMilliseconds(3000); RequestClient.Timeout = TimeSpan.FromMilliseconds(10000);
ResponseClient.Timeout = TimeSpan.FromMilliseconds(3000); ResponseClient.Timeout = TimeSpan.FromMilliseconds(10000);
} }
public static async Task<RESPONSE> PostAsync<REQUEST,RESPONSE>(string Url, REQUEST body) where REQUEST : class where RESPONSE : class public static async Task<RESPONSE> PostAsync<REQUEST,RESPONSE>(string Url, REQUEST body) where REQUEST : class where RESPONSE : class

View File

@ -1,9 +1,11 @@
using CPMeta; using CPMeta;
using CPMeta.Models; using CPMeta.Models;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace PlayGround.NetFramework namespace PlayGround.NetFramework
@ -12,33 +14,57 @@ namespace PlayGround.NetFramework
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
//global set
string host = "192.168.0.126";
//CpMetaSet //CpMetaSet
CPMeta.CPMeta.Port = 9000; //CPMeta.CPMeta.Port = 9000;
string ProductId = Guid.NewGuid().ToString(); //DateTime start = DateTime.Now;
string Mac1 = Guid.NewGuid().ToString(); //Task.Run(async () =>
string Mac2 = Guid.NewGuid().ToString(); //{
// var rese2 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress("192.168.0.126", "4594095f-01d0-4192-bc4a-0913ae496e25");
// //var rese2 = await CPMeta.CPMeta.GetWbmsMetaByProductId(host, "cf35eeee-39ff-43e8-a7a9-0fd0baf6df2b");
// Console.WriteLine(JsonConvert.SerializeObject(rese2, Formatting.Indented));
// int c = 0;
//}).Wait();
//Set //Console.WriteLine((DateTime.Now - start).TotalSeconds + " sec");
Task.Run(async() =>
for (int i = 0; i < 1000000; i++)
{ {
Request_SetWbmsMeta req = new Request_SetWbmsMeta(); string ProductId = Guid.NewGuid().ToString();
req.ProductID = ProductId; string Mac1 = Guid.NewGuid().ToString();
req.MacAddress1 = Mac1; string Mac2 = Guid.NewGuid().ToString();
req.MacAddress2 = Mac2;
var res = await CPMeta.CPMeta.SetWbmsMetaAsync("127.0.0.1", req); //Set
}).Wait(); Task.Run(async () =>
{
//Get Request_SetWbmsMeta req = new Request_SetWbmsMeta();
Task.Run(async() => req.ProductID = ProductId;
{ req.MacAddress1 = Mac1;
var rese2 = await CPMeta.CPMeta.GetWbmsMetaByProductId("127.0.0.1", ProductId); req.MacAddress2 = Mac2;
var rese3 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress("127.0.0.1", Mac1); if (i % 2 == 0)
var rese4 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress("127.0.0.1", Mac2); req.Type = "CMU";
int b = 0; else
}).Wait();; req.Type = "BMU";
req.ProductNo = "X";
var res = await CPMeta.CPMeta.SetWbmsMetaAsync(host, req);
}).Wait();
//Get
//Task.Run(async () =>
//{
// var rese2 = await CPMeta.CPMeta.GetWbmsMetaByProductId(host, ProductId);
// var rese3 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac1);
// var rese4 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress("192.168.0.126", Mac2);
//}).Wait();
Thread.Sleep(100);
}
int a = 0; int a = 0;
} }