| | |
| | | using MES.Service.DB; |
| | | using AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models; |
| | | using AlibabaCloud.TeaUtil.Models; |
| | | using MES.Service.DB; |
| | | using MES.Service.Dto.webApi; |
| | | using MES.Service.Dto.webApi.DeliveryNote; |
| | | using MES.Service.Modes; |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using Tea; |
| | | |
| | | public class ProductionOrderManager : Repository<ProductionOrders> |
| | | { |
| | | |
| | | public static AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client CreateClient1() |
| | | { |
| | | AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config(); |
| | | config.Protocol = "https"; |
| | | config.RegionId = "central"; |
| | | return new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client(config); |
| | | } |
| | | |
| | | /** |
| | | * 获取钉钉的 Access Token |
| | | * @return string 返回获取到的 Access Token |
| | | */ |
| | | public string GetToken() |
| | | { |
| | | AlibabaCloud.SDK.Dingtalkoauth2_1_0.Client client = CreateClient1(); |
| | | AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models.GetAccessTokenRequest getAccessTokenRequest = new AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models.GetAccessTokenRequest |
| | | { |
| | | AppKey = "dingyzos0r1bizj7g6lr", |
| | | AppSecret = "-HP4RvK2OUbqhG3iBUpd_TPe5MZRj8cfLc0b8Skt8rhC3I38kVLY9SS8P3kLWFcH", |
| | | }; |
| | | |
| | | try |
| | | { |
| | | var response = client.GetAccessToken(getAccessTokenRequest); |
| | | return response.Body.AccessToken; // 返回获取到的 Access Token |
| | | } |
| | | catch (TeaException err) |
| | | { |
| | | Console.WriteLine($"TeaException: Code={err.Code}, Message={err.Message}"); |
| | | return null; |
| | | } |
| | | catch (Exception _err) |
| | | { |
| | | Console.WriteLine($"Exception: {_err.Message}"); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | public static AlibabaCloud.SDK.Dingtalkyida_1_0.Client CreateClient() |
| | | { |
| | | AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config(); |
| | | config.Protocol = "https"; |
| | | config.RegionId = "central"; |
| | | return new AlibabaCloud.SDK.Dingtalkyida_1_0.Client(config); |
| | | } |
| | | |
| | | public string GetFileUrl() |
| | | { |
| | | |
| | | string accessToken = GetToken(); |
| | | if (string.IsNullOrEmpty(accessToken)) |
| | | { |
| | | return "获取 Access Token 失败"; |
| | | } |
| | | AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient(); |
| | | AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlHeaders getOpenUrlHeaders = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlHeaders(); |
| | | getOpenUrlHeaders.XAcsDingtalkAccessToken = accessToken; |
| | | AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlRequest getOpenUrlRequest = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetOpenUrlRequest |
| | | { |
| | | SystemToken = "54A66HC1YDSSO9DP61Y93CWQ2W9B36IZZOY6MC81", |
| | | UserId = "923188102", |
| | | Language = "zh_CN", |
| | | FileUrl = "https://cfw1x5.aliwork.com/inst/filePreview?appType=APP_Q7PLYKXMKFUJ5HY6DMWR&fileName=APP_Q7PLYKXMKFUJ5HY6DMWR_MDcxODM5NTEyMDMyNjgzODgzX09WOTY2V0ExN1lUVFRDS0Q3WjFYTTlQNUw5MVIzTTNaQ1hHOE1SOQ$$.xls", |
| | | Timeout = 3600000, |
| | | }; |
| | | try |
| | | { |
| | | |
| | | var response = client.GetOpenUrlWithOptions("APP_Q7PLYKXMKFUJ5HY6DMWR", getOpenUrlRequest, getOpenUrlHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions()); |
| | | return (Newtonsoft.Json.JsonConvert.SerializeObject(response.Body)); |
| | | } |
| | | catch (TeaException err) |
| | | { |
| | | return $"TeaException: Code={err.Code}, Message={err.Message}"; |
| | | } |
| | | catch (Exception _err) |
| | | { |
| | | return $"Exception: {_err.Message}"; |
| | | } |
| | | } |
| | | |
| | | |
| | | public dynamic Save(ErpProductionOrder erpProductionOrder) |
| | | { |
| | | //var erpProductionOrder = productionOrder.erpProductionOrder; |