Ver código fonte

添加小米FireTV相关的HTTP接口实现。

sat23 3 anos atrás
pai
commit
8a2f2712c9

+ 116 - 1
FactoryTool_CShare/Business/CommonMethod.cs

@@ -2367,7 +2367,122 @@ namespace MOKA_Factory_Tools
 
             return false;
         }
-#endregion
+        #endregion
+
+        #region 小米FireTV功能模块相关接口;
+        public static bool GetMIKey(string sn, out MIKey mikey, out string msg)
+        {
+            msg = "";
+            mikey = null;
+            string strPost = String.Format("{{\"TVSN\":\"{0}\"}}", sn);
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.UTF8,
+                Method = "post",
+                ContentType = "application/json",
+                KeepAlive = false
+            };
+
+            // 测试地址;
+            item.URL = "http://smes-app-prod.tclking.com:9006/api/SMESCustomer/GetXMCard";
+            item.Postdata = strPost;
+            HttpResult hResult = http.GetHtml(item);
+            if (hResult.StatusCode == System.Net.HttpStatusCode.OK)
+            {
+                try
+                {
+                    using (JsonTextReader reader = new JsonTextReader(new StringReader(hResult.Html)))
+                    {
+                        JObject jObject = (JObject)JToken.ReadFrom(reader);
+                        reader.Close();
+
+                        bool bResult = jObject["Result"].Value<bool>();
+                        msg = jObject["Error"].Value<string>();
+                        JArray jAry = (JArray)JsonConvert.DeserializeObject(jObject["Data"].ToString());
+                        if ( jAry.Count > 0 )
+                        {
+                            mikey = JsonConvert.DeserializeObject<MIKey>(jAry[0].ToString());
+                        }
+
+                        if (bResult)
+                        {
+                            return true;
+                        }
+
+                        Log.WriteInfoLog("GetMIKey error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                    }
+                }
+                catch (Exception e)
+                {
+                    msg = e.Message;
+                    Log.WriteErrorLog("GetMIKey Json-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                }
+            }
+            else
+            {
+                msg = hResult.StatusDescription;
+                Log.WriteInfoLog("GetMIKey Http-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+            }
+
+            return false;
+        }
+
+        public static bool ReportMIKey(ReportMIKey mikey, out string msg)
+        {
+            msg = "";
+            string strPost = String.Format("{{\"TVSN\":\"{0}\",\"TVMN\":\"{1}\",\"DSN\":\"{2}\",\"ChipSN\":\"{3}\",\"ChipMN\":\"{4}\",\"EthernetMAC\":\"{5}\",\"BTMAC\":\"{6}\",\"HDCP14\":\"{7}\",\"HDCP22\":\"{8}\"}}",
+                mikey.TVSN, mikey.TVMN, mikey.DSN, mikey.ChipSN, mikey.ChipMN, mikey.EthernetMAC, mikey.BTMAC, mikey.HDCP14, mikey.HDCP22);
+            HttpHelper http = new HttpHelper();
+            HttpItem item = new HttpItem()
+            {
+                Encoding = Encoding.UTF8,
+                Method = "post",
+                ContentType = "application/json",
+                KeepAlive = false
+            };
+
+            // 测试地址;
+            item.URL = "http://smes-app-prod.tclking.com:9006/api/SMESCustomer/UploadXMDataControl";
+            item.Postdata = strPost;
+            HttpResult hResult = http.GetHtml(item);
+            if (hResult.StatusCode == System.Net.HttpStatusCode.OK)
+            {
+                try
+                {
+                    using (JsonTextReader reader = new JsonTextReader(new StringReader(hResult.Html)))
+                    {
+                        JObject jObject = (JObject)JToken.ReadFrom(reader);
+                        reader.Close();
+
+                        bool bResult = jObject["Result"].Value<bool>();
+                        msg = jObject["Error"].Value<string>();
+                        string data = jObject["Data"].ToString();
+
+                        if (bResult && data.StartsWith("成功"))
+                        {
+                            return true;
+                        }
+
+                        Log.WriteInfoLog("ReportMIKey error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                    }
+                }
+                catch (Exception e)
+                {
+                    msg = e.Message;
+                    Log.WriteErrorLog("ReportMIKey Json-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+                }
+            }
+            else
+            {
+                msg = hResult.StatusDescription;
+                Log.WriteInfoLog("ReportMIKey Http-error:" + hResult.StatusDescription + "\r\n" + hResult.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata);
+            }
+
+            return false;
+        }
+
+        #endregion
     }
 
     /// <summary>

+ 36 - 0
FactoryTool_CShare/Models/StructList.cs

@@ -534,4 +534,40 @@ namespace MOKA_Factory_Tools
         public string Model;
     }
     #endregion
+
+    #region 小米FireTVKey;
+    public class MIKey
+    {
+        public string Batchnum;
+        public string TVSN;
+        public string TVMN;
+        public string EthernetMac;
+        public string FWVersion;
+        public string Model;
+        public string UpdateUser;
+        public string UpdateTime;
+        public string BTMac;
+        public string EAN;
+        public string IsPrint;
+        public string SKU;
+        public string DeviceID;
+        public string OPName;
+        public string OPSN;
+        public string FWVersion_2;
+        public string DSN;
+    }
+
+    public class ReportMIKey
+    {
+        public string DSN { set; get; } = "";
+        public string TVSN { set; get; } = "";
+        public string TVMN { set; get; } = "";
+        public string ChipSN { set; get; } = "";
+        public string ChipMN { set; get; } = "";
+        public string EthernetMAC { set; get; } = "";
+        public string BTMAC { set; get; } = "";
+        public string HDCP14 { set; get; } = "";
+        public string HDCP22 { set; get; } = "";
+    }
+    #endregion
 }