You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using SlnMesnac.RfidUpload.Model;
using System;
using TouchSocket.Rpc.WebApi;
namespace SlnMesnac.RfidUpload.TouchSocket
{
public sealed class WebApiClientApp
{
#region 单例实现
private static readonly Lazy<WebApiClientApp> _lazy = new Lazy<WebApiClientApp>(() => new WebApiClientApp());
public static WebApiClientApp Instance
{
get
{
return _lazy.Value;
}
}
#endregion
private WebApiClientApp() { }
private WebApiClient CreateWebApiClient(string url)
{
WebApiClient client = new WebApiClient();
client.Setup(url);
client.Connect();
Console.WriteLine("连接成功");
return client;
}
public void Upload(string url)
{
try
{
var client = CreateWebApiClient(url);
var param = new ContainerInbound()
{
messageHeader = Guid.NewGuid().ToString(),
batchOpenQuery = "OK",
opOrgCode = Guid.NewGuid().ToString()
};
var sum2 = client.Invoke<ActionResult>("POST:/Server/ContainerInboundApi", null, param);
Console.WriteLine($"Post调用成功结果{sum2.Message}");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}