|
@@ -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>
|