|
|
|
|
@ -66,7 +66,7 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <summary>s
|
|
|
|
|
/// 获取到的JToken类型转换为实体类
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
@ -98,21 +98,25 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
{
|
|
|
|
|
FeedbackType = FeedbackType.WaitInvoke
|
|
|
|
|
};
|
|
|
|
|
if (MESHttpClient != null)
|
|
|
|
|
if (MESHttpClient == null)
|
|
|
|
|
{
|
|
|
|
|
if (!MESHttpClient.Online)
|
|
|
|
|
Console.WriteLine("MES客户端为空,重新初始化...");
|
|
|
|
|
await CreateWebApiClientAsync(m_IpHost);
|
|
|
|
|
}
|
|
|
|
|
else if (!MESHttpClient.Online)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("连接断开,尝试重连...");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("与MES客户端连接断开,尝试重新连接...");
|
|
|
|
|
await MESHttpClient.SetupAsync(new TouchSocketConfig()
|
|
|
|
|
.SetRemoteIPHost(m_IpHost)
|
|
|
|
|
);
|
|
|
|
|
Console.WriteLine("正在连接:" + m_IpHost);
|
|
|
|
|
await MESHttpClient.ConnectAsync();
|
|
|
|
|
Console.WriteLine("连接成功");
|
|
|
|
|
Console.WriteLine(m_IpHost + "连接成功");
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("重连失败,重新初始化客户端...");
|
|
|
|
|
await CreateWebApiClientAsync(m_IpHost);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var request = new WebApiRequest();
|
|
|
|
|
request.Method = HttpMethodType.Get;
|
|
|
|
|
request.Querys = new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("lineCode", lineCode), new KeyValuePair<string, string>("planDate", datetime) };
|
|
|
|
|
@ -120,7 +124,28 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//responseValue = await MESHttpClient.InvokeTAsync<string>("/ApiServer/get", invokeOption_30s, request);
|
|
|
|
|
responseValue = await MESHttpClient.InvokeTAsync<string>("/api/plan/get", invokeOption_30s, request);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
responseValue = await MESHttpClient.InvokeTAsync<string>("/api/plan/get", invokeOption_30s, request);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("调用失败,准备重连重试:" + ex.Message);
|
|
|
|
|
|
|
|
|
|
// 强制重连
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
await MESHttpClient.ConnectAsync();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
await CreateWebApiClientAsync(m_IpHost);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 再试一次
|
|
|
|
|
responseValue = await MESHttpClient.InvokeTAsync<string>("/api/plan/get", invokeOption_30s, request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (responseValue != null)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("MES接口返回:" + JsonSerializer.Serialize(responseValue));
|
|
|
|
|
@ -142,12 +167,12 @@ namespace SlnMesnac.TouchSocket
|
|
|
|
|
Log.Information(ex.Message);
|
|
|
|
|
return "202";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var responseValue = await MESHttpClient.InvokeTAsync<string>("/ApiServer/get", invokeOption_30s, request);
|
|
|
|
|
//JToken responseValue = await MESHttpClient.InvokeTAsync<JToken>("Get:/api/plan", null, requestValue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
|