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.

76 lines
2.7 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 MaterialTraceability.Entity.DAO;
using Nancy;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Rpc;
using TouchSocket.Sockets;
using TouchSocket.WebApi;
namespace MaterialTraceabilityUI.ViewModel
{
public class MesHttpClient
{
public static WebApiClient _MeshttpClient;
public async void init()
{
try
{
_MeshttpClient = new WebApiClient();
await _MeshttpClient.SetupAsync(new TouchSocketConfig()
//.SetRemoteIPHost("10.150.144.83:5001")
.SetRemoteIPHost("127.0.0.1:9880")
.ConfigurePlugins(a =>
{
//a.Add<Myweb>
//a.UseWebApi();
//.ConfigureConverter(converter =>
//{
// //配置转换器
// //converter.Clear();//可以选择性的清空现有所有格式化器
// //添加Json格式化器可以自定义Json的一些设置
// converter.AddJsonSerializerFormatter(new Newtonsoft.Json.JsonSerializerSettings() { Formatting = Newtonsoft.Json.Formatting.None });
// //添加Xml格式化器
// converter.AddXmlSerializerFormatter();
//});
}));
await _MeshttpClient.ConnectAsync();
}
catch (Exception ex)
{
//FrmDisplayView.LogInfo.Fatal("MES接口连接异常: " + ex.Message);
}
}
public ApiResponse<SysUserInfo> LoadMESdata(string Resource)
{
try
{
IInvokeOption invokeOption = new InvokeOption();
var requestForPost = new WebApiRequest();
requestForPost.Method = HttpMethodType.Get;
requestForPost.Body = new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("Resource", Resource) };
//FrmDisplayView.LogInfo.Info(JsonSerializer.Serialize(requestForPost.Body));
//JToken responseValue = _MeshttpClient.InvokeT<JToken>("/autoread", null, requestForPost);
return _MeshttpClient.InvokeT<ApiResponse<SysUserInfo>>("/GetUserList", invokeOption, requestForPost);
}
catch (Exception ex)
{
//FrmDisplayView.LogInfo.Fatal("MES接口调用异常: " + ex.Message);
return null;
}
}
}
}