¶Ô±ÈÐÂÎļþ |
| | |
| | | using StackExchange.Profiling.Internal; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Net.Http.Headers; |
| | | using System.Net.Http.Json; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | | { |
| | | public class MESAPIInvoke |
| | | { |
| | | // 使ç¨éæHttpClientå®ä¾ |
| | | private static readonly HttpClient _client = new HttpClient |
| | | { |
| | | BaseAddress = new Uri("http://192.168.12.212:9003/api/WMS/"), |
| | | DefaultRequestHeaders = |
| | | { |
| | | Accept = { new MediaTypeWithQualityHeaderValue("application/json") }, |
| | | UserAgent = { new ProductInfoHeaderValue("MESClient", "1.0") } |
| | | } |
| | | }; |
| | | |
| | | /// <summary> |
| | | /// çç®±ç©æç»å® |
| | | /// </summary> |
| | | /// <param name="Devid"></param> |
| | | /// <param name="Materials"></param> |
| | | /// <returns></returns> |
| | | public static MESback BakingFeedingBinding(string devId, List<BakingClass> materials) |
| | | { |
| | | var request = new BakingFeedingClass |
| | | { |
| | | Devid = devId, |
| | | Materials = materials |
| | | }; |
| | | |
| | | var response = _client.PostAsJsonAsync("BakingFeedingBinding", request).Result; |
| | | response.EnsureSuccessStatusCode(); |
| | | return response.Content.ReadFromJsonAsync<MESback>().Result; |
| | | |
| | | //using (HttpClient client = new HttpClient()) |
| | | |
| | | //{ |
| | | // client.BaseAddress = new Uri("http://192.168.12.212:9003/api/WMS/BakingFeedingBinding"); |
| | | // client.DefaultRequestHeaders.Accept.Clear(); |
| | | // client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); |
| | | // client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); |
| | | |
| | | // HttpResponseMessage response = client.PostAsJsonAsync("BakingFeedingBinding", req).Result; |
| | | // if (response.IsSuccessStatusCode) |
| | | // { |
| | | // MESback back = response.Content.ReadAsStringAsync().Result.FromJson<MESback>(); |
| | | // return back; |
| | | // } |
| | | // else |
| | | // { |
| | | // throw new Exception("è°ç¨MESAPI失败ï¼"); |
| | | // } |
| | | //} |
| | | } |
| | | } |
| | | |
| | | public class MESback |
| | | { |
| | | /// <summary> |
| | | /// 0:æåï¼å¤§äº0ï¼å¤±è´¥ |
| | | /// </summary> |
| | | public int Code { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åé¦ä¿¡æ¯ |
| | | /// </summary> |
| | | public string Message { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©æç±»å |
| | | /// </summary> |
| | | public string MaterialType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç©ææ¹å·ï¼åå
¥PLC |
| | | /// </summary> |
| | | public string BarCode { get; set; } |
| | | |
| | | public string ProcessName { get; set; } |
| | | } |
| | | } |