MES.Service/bin/Debug/net8.0/MES.Service.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
MES.Service/bin/Debug/net8.0/MES.Service.pdb | 补丁 | 查看 | 原始文档 | blame | 历史 | |
MES.Service/service/PLM/PLMManager.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
MES.Service/service/PLM/WarehouseDownloadDoc.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
MESApplication/Controllers/PLM/PLMController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
MESApplication/bin/Debug/net8.0/MES.Service.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
MESApplication/bin/Debug/net8.0/MES.Service.pdb | 补丁 | 查看 | 原始文档 | blame | 历史 | |
MESApplication/bin/Debug/net8.0/MESApplication.dll | 补丁 | 查看 | 原始文档 | blame | 历史 | |
MESApplication/bin/Debug/net8.0/MESApplication.exe | 补丁 | 查看 | 原始文档 | blame | 历史 | |
MESApplication/bin/Debug/net8.0/MESApplication.pdb | 补丁 | 查看 | 原始文档 | blame | 历史 |
MES.Service/bin/Debug/net8.0/MES.Service.dllBinary files differ
MES.Service/bin/Debug/net8.0/MES.Service.pdbBinary files differ
MES.Service/service/PLM/PLMManager.cs
@@ -1,6 +1,6 @@ using Kingdee.CDP.WebApi.SDK; using MES.Service.Dto.webApi.PLM; using Newtonsoft.Json; using System.Text; namespace MES.Service.service.PLM; @@ -22,7 +22,7 @@ return stdDocuments; } #region 1.éè¿ç©æç¼ç ï¼éè¦å¯ä¸ï¼è·åç©æid public List<BaseObject> GetPlmCfgBase(string ItemNo) { //注æ 1ï¼æ¤å¤ä¸å使ç¨åæ°å½¢å¼ä¼ å ¥ç¨æ·ååå¯ç çææä¿¡æ¯ï¼æ¹ä¸ºå¨ç»å½é ç½®æä»¶ä¸è®¾ç½®ã @@ -69,7 +69,9 @@ return entity; }).ToList(); } #endregion #region 2.éè¿ç©æidè·åç¸å ³å¯¹è±¡ãä¸è½½éè¦çææ¡£ãçid public List<RelatedObject> GetPlmCfgRelatedObject(long? FRelatedObject) { //注æ 1ï¼æ¤å¤ä¸å使ç¨åæ°å½¢å¼ä¼ å ¥ç¨æ·ååå¯ç çææä¿¡æ¯ï¼æ¹ä¸ºå¨ç»å½é ç½®æä»¶ä¸è®¾ç½®ã @@ -116,7 +118,9 @@ return entity; }).ToList(); } #endregion #region 3.æ ¹æ®ææ¡£idè·åææ¡£ç©çæä»¶id public List<StdDocument> GetPlmStdDocument(List<RelatedObject> relatedObjects) { //注æ 1ï¼æ¤å¤ä¸å使ç¨åæ°å½¢å¼ä¼ å ¥ç¨æ·ååå¯ç çææä¿¡æ¯ï¼æ¹ä¸ºå¨ç»å½é ç½®æä»¶ä¸è®¾ç½®ã @@ -168,4 +172,5 @@ return entity; }).ToList(); } #endregion } MES.Service/service/PLM/WarehouseDownloadDoc.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,145 @@ using Newtonsoft.Json.Linq; using System.Net; using System.Text; namespace ConsoleApp1 { #region 1.æ ¹æ®ææ¡£ç©çæä»¶idè·åææ¡£æµæ°æ® public class WarehouseDownloadDoc() { private string _cloudUrl = "http://121.36.245.199/k3cloud"; private string _warehouse = "http://192.168.30.251/CloudPLMWarehouse"; #region ææ¡£æå¡å¨ä¸ä¸æ private string WarehouseCTX { get { string json = "{\"ap1\":{ \"AcctID\":\"" + "6722eada66becb" + "\",\"Username\":\"Administrator\",\"Password\":\"Yc123456@\",\"Lcid\":2052,\"AuthenticateType\":1,\"PasswordIsEncrypted\":\"false\",\"ClientInfo\":{\"ClientType\":8}}"; var resp = GetResponse("http://121.36.245.199/k3cloud/Kingdee.BOS.ServiceFacade.ServicesStub.User.UserService.ValidateLoginInfo.common.kdsvc", json, new Dictionary<string, string>()); string ret = (new StreamReader(resp.GetResponseStream(), Encoding.UTF8)).ReadToEnd(); var result = JObject.Parse(ret)["Context"]; string token = result["UserToken"].ToString(); var warehouseCtx = string.Format("LoginUrl={0}/&UserToken={1}", _cloudUrl, token); return Convert.ToBase64String(Encoding.UTF8.GetBytes(warehouseCtx)); } } #endregion #region ç©çæä»¶id private string GetFileId(string fileId) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(fileId)); } #endregion #region çµåä»è®¿é®åè¯ private string Token { get { var token = Guid.NewGuid().ToString(); return token; } } #endregion #region åéè¯·æ± public Stream SendRequest(string op, string fileId) { var header = new Dictionary<string, string>() { {"FileID" ,GetFileId(fileId) }, { "CTX",WarehouseCTX}, { "token", Token }, { "PLM_ACCESS_TYPE","pure" } }; return PostDataViaHttpWebRequest(RequestUrl(op), string.Empty, header, !op.Equals("Download")); } #endregion #region 请æ±çURL private string RequestUrl(string op) { return _warehouse + "/" + op; } #endregion #region è·åååº private HttpWebResponse GetResponse(string url, string bodyJson, Dictionary<string, string> header) { byte[] data = Encoding.UTF8.GetBytes(bodyJson); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = WebRequestMethods.Http.Post; request.ContentType = "application/json"; request.ContentLength = data.Length; if (header != null) { foreach (var p in header) { request.Headers.Add(p.Key, p.Value); } } using (Stream reqStream = request.GetRequestStream()) { reqStream.Write(data, 0, data.Length); reqStream.Close(); } HttpWebResponse resp = null; try { resp = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) { var res = ex.Response; if (res != null) { string statusBase64 = ((HttpWebResponse)ex.Response).StatusDescription;//base64ç¼ç åçæ¥éä¿¡æ¯ } } return resp; } #endregion #region ä¿åæä»¶å°æ¬å° /*private void PostDataViaHttpWebRequest(string url, string bodyJson, Dictionary<string, string> header, bool isGetContent) { var resp = GetResponse(url, bodyJson, header); var resultJson = string.Empty; Stream stream = File.Open("D://DownloadDocDemo.pdf", FileMode.OpenOrCreate); int packageSize = 1024 * 1024; byte[] buffer = new byte[packageSize]; using (stream) { using (Stream outputStream = resp.GetResponseStream()) { int readLength = 0; while ((readLength = outputStream.Read(buffer, 0, packageSize)) > 0) { stream.Write(buffer, 0, readLength); stream.Flush(); } outputStream.Close(); } stream.Close(); } }*/ #endregion #region è¿åæä»¶æµç»å端 private Stream PostDataViaHttpWebRequest(string url, string bodyJson, Dictionary<string, string> header, bool isGetContent) { var resp = GetResponse(url, bodyJson, header); return resp.GetResponseStream(); // ç´æ¥è¿åååºæµ } #endregion } #endregion } MESApplication/Controllers/PLM/PLMController.cs
@@ -1,7 +1,9 @@ using MES.Service.service.PLM; using ConsoleApp1; using MES.Service.service.PLM; using MES.Service.util; using Microsoft.AspNetCore.Mvc; using System.Dynamic; using System.IO; namespace MESApplication.Controllers.PLM; @@ -11,6 +13,7 @@ public class PLMController : ControllerBase { private readonly PLMManager m = new(); private readonly WarehouseDownloadDoc wdd = new(); //RetrieveDrawings è°åå¾çº¸ [HttpPost("RetrieveDrawings")] @@ -33,4 +36,25 @@ return ResponseResult.ResponseError(ex); } } //RetrieveDrawings è°åå¾çº¸ [HttpPost("OpenDrawings")] public IActionResult OpenDrawings(string fileId,string fName) { try { var resultInfos = wdd.SendRequest("Download", fileId); return File(resultInfos, "application/octet-stream", fName); } catch (Exception ex) { return StatusCode(500, new ResponseResult { status = 1, message = ex.Message, data = null }); } } } MESApplication/bin/Debug/net8.0/MES.Service.dllBinary files differ
MESApplication/bin/Debug/net8.0/MES.Service.pdbBinary files differ
MESApplication/bin/Debug/net8.0/MESApplication.dllBinary files differ
MESApplication/bin/Debug/net8.0/MESApplication.exeBinary files differ
MESApplication/bin/Debug/net8.0/MESApplication.pdbBinary files differ