1 changed files with 54 additions and 0 deletions
@ -0,0 +1,54 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Headers; |
|||
using AMESCoreStudio.CommonTools.Result; |
|||
|
|||
namespace AMESCoreStudio.WebApi.Controllers.QASRV |
|||
{ |
|||
[Route("api/[controller]")]
|
|||
[ApiController] |
|||
public class GetPLMDataController : ControllerBase |
|||
{ |
|||
/// <summary>
|
|||
/// GetPLM ECN
|
|||
/// </summary>
|
|||
/// <param name="ItemNo">料號</param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("Get_PLM_ECN")] |
|||
public IResultModel GetPlmEcn(string ItemNo) |
|||
{ |
|||
ResultModel<string> resultModel = new ResultModel<string> { Success = false }; |
|||
var client = new HttpClient(); |
|||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml")); |
|||
//
|
|||
client.Timeout = TimeSpan.FromHours(1);//1小時
|
|||
try |
|||
{ |
|||
var apiUrl = $"http://plm935fs01:50786/RMA_GetLocation/QueryLastReleaseECN?item={ItemNo}"; |
|||
HttpResponseMessage response = client.GetAsync(apiUrl).Result; |
|||
|
|||
if (response.IsSuccessStatusCode) |
|||
{ |
|||
var jsonString = response.Content.ReadAsStringAsync(); |
|||
jsonString.Wait(); |
|||
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument(); |
|||
xdoc.LoadXml(jsonString.Result); |
|||
resultModel.Msg = xdoc.DocumentElement.LastChild.Value; |
|||
resultModel.Success = true; |
|||
return resultModel; |
|||
} |
|||
resultModel.Msg = "error"; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
resultModel.Msg = ex.Message; |
|||
} |
|||
|
|||
return resultModel; |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue