| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using UAS_MES_NEW.DataOperate;
- namespace UAS_MES_NEW.PublicMethod
- {
- public class BindItem
- {
- [JsonProperty("bindKey")]
- public string BindKey { get; set; }
- [JsonProperty("bindValue")]
- public string BindValue { get; set; }
- [JsonProperty("keyType")]
- public string KeyType { get; set; }
- [JsonProperty("keyValue")]
- public string KeyValue { get; set; }
- [JsonProperty("hashType")]
- public string HashType { get; set; }
- [JsonProperty("hashKey")]
- public string HashKey { get; set; }
- }
- public class RootObject
- {
- [JsonProperty("productModuleType")]
- public string ProductModuleType { get; set; }
- [JsonProperty("productMainClass")]
- public string ProductMainClass { get; set; }
- [JsonProperty("productMediumClass")]
- public string ProductMediumClass { get; set; }
- [JsonProperty("productSubClass")]
- public string ProductSubClass { get; set; }
- [JsonProperty("task")]
- public string Task { get; set; }
- [JsonProperty("processType")]
- public string ProcessType { get; set; }
- [JsonProperty("userId")]
- public string UserId { get; set; }
- [JsonProperty("bindList")]
- public List<BindItem> BindList { get; set; }
- }
- class HttpServer
- {
- static DataHelper dh = new DataHelper();
- static string ComputeSha256Hash(string input)
- {
- using (SHA256 sha256 = SHA256.Create())
- {
- byte[] bytes = Encoding.UTF8.GetBytes(input);
- byte[] hashBytes = sha256.ComputeHash(bytes);
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < hashBytes.Length; i++)
- {
- builder.Append(hashBytes[i].ToString("x2"));
- }
- return builder.ToString().ToUpper();
- }
- }
- public static void SendBoxData(string iBox)
- {
- string sn = dh.getFieldDataByCondition("", "", "").ToString();
- var root = new RootObject
- {
- ProductModuleType = "整机",
- ProductMainClass = "固网_CPE",
- ProductMediumClass = "CPE",
- ProductSubClass = "ZXSLC SC50L",
- Task = "2025070006",
- ProcessType = "生产过程",
- UserId = "邓帝森",
- BindList = new List<BindItem>()
- };
- root.BindList.Add(new BindItem
- {
- BindKey = "cartonSn",
- BindValue = "4Y12R93C0001",
- KeyType = "macbox",
- KeyValue = sn,
- HashType = "SHA256",
- HashKey = ComputeSha256Hash(sn)
- }); ;
- string json = JsonConvert.SerializeObject(root, Formatting.Indented);
- }
- }
- }
|