添加项目文件。
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using JY.MES.Entity;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Script.Serialization;
|
||||
|
||||
namespace JY.MES
|
||||
{
|
||||
/// <summary>
|
||||
/// MES接口类
|
||||
/// </summary>
|
||||
public class MESApiHelper
|
||||
{
|
||||
public static string HttpPostJsonAPI(string url, string strJosnData, double MesRequestTime)
|
||||
{
|
||||
MesResponse mesResponse = new MesResponse();
|
||||
try
|
||||
{
|
||||
StringContent stringContent = new StringContent(strJosnData, Encoding.UTF8, "application/json");
|
||||
return new HttpClient()
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(MesRequestTime)
|
||||
}.PostAsync(url, (HttpContent)stringContent).Result.Content.ReadAsStringAsync().Result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mesResponse.success = false;
|
||||
mesResponse.message = $"massage:[{ex.InnerException}],mes: [MES反馈超时或无法访间MES服务器]";
|
||||
mesResponse.error = 99;
|
||||
return JsonConvert.SerializeObject(mesResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user