1 string Url = System.Configuration.ConfigurationManager.AppSettings["CallPaperInvoiceURL"]; 2 Url = @"" + Url + "?id=" + PK_ECOrderHead + "&whse=" + Whse + ""; 3 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); 4 request.Method = "GET"; 5 request.ProtocolVersion = HttpVersion.Version10; 6 ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072; 7 HttpWebResponse res = (HttpWebResponse)request.GetResponse(); 8 StreamReader rd = new StreamReader(res.GetResponseStream()); 9 string theContent = rd.ReadToEnd();
1 string WHSE = Request["WHSE"].ToString(); 2 string transId = OrderData.GenerateTransId(18); 3 eStore2.App_Code.Data.OmsRoot.Root root = new eStore2.App_Code.Data.OmsRoot.Root(); 4 eStore2.App_Code.Data.OmsRoot.Head head = new eStore2.App_Code.Data.OmsRoot.Head(); 5 head.transId = transId; 6 head.transCode = "S1005"; 7 eStore2.App_Code.Data.OmsRoot.Body body = new eStore2.App_Code.Data.OmsRoot.Body(); 8 body.WHSE = WHSE; 9 root.head = head; 10 root.body = body; 11 Encoding encoding = Encoding.UTF8; 12 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(OrderData.Get_GetIMInventoryURL(System.Configuration.ConfigurationManager.AppSettings["GetIMInventory_KeyName"]).Rows[0]["KeyValue"].ToString()); 13 request.Method = "POST"; 14 request.Accept = "text/html, application/xhtml+xml, */*"; 15 request.ContentType = "application/json"; 16 byte[] buffer = encoding.GetBytes(JsonConvert.SerializeObject(root)); 17 request.ContentLength = buffer.Length; 18 request.GetRequestStream().Write(buffer, 0, buffer.Length); 19 HttpWebResponse response = (HttpWebResponse)request.GetResponse(); 20 using (StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8)) 21 { 22 string Result = reader.ReadToEnd(); 23 eStore2.App_Code.Data.OmsRoot.Root root_s = JsonConvert.DeserializeObject<eStore2.App_Code.Data.OmsRoot.Root>(Result); 24 List<eStore2.App_Code.Data.OmsRoot.DetailItem> detailItems = root_s.body.detail; 25 foreach (var item in detailItems) 26 { 27 OrderData.Insert_MDB_SYNC_LOG(item.PartNo, item.Qty); 28 } 29 } 30 ShowAlertMessage("库存获取完毕");
var rss = new JObject { {"Head",new JObject { {"TransCode","X1009" }, {"TransId",transid} } }, { "Body", new JObject { {"OrderSN", q.OrderSn }, {"WHSE",q.Whse}, {"SNs", SNs } } } }; //呼叫接口 HttpContent JSONContents = new StringContent(JsonConvert.SerializeObject(rss), Encoding.UTF8, "application/json"); using (var response = httpClient.PostAsync(Url, JSONContents).Result) { if (response.IsSuccessStatusCode) { string s = $"{response.Content.ReadAsStringAsync().Result}"; if (s == "Y") { using (var tran = _Database.Database.BeginTransaction()) { try { await _Database.OmsEcjsonlog.AddAsync(new OmsEcjsonlog { CreateDateTime = System.DateTime.UtcNow.AddHours(8), Fk = _HeadId, Json = JsonConvert.SerializeObject(rss), Msg = $"{q.OrderSn} Paper Invoice" }); await _Database.Log.AddAsync(GenerateECOrderLog($"成功")); await _Database.SaveChangesAsync(); tran.Commit(); } catch (Exception ex) { if (tran != null) tran.Rollback(); throw new Exception($"Failed,{ex.Message}"); } } } else throw new Exception($"服务系统:{s}"); } else { throw new Exception(response.StatusCode.ToString()); } }