浏览代码

1、在线获取Key接口变量;2、配置项与在线订单key类型比较。3、删除无用的widi key。

JeffWang 3 年之前
父节点
当前提交
85410e6dd1

+ 193 - 2
FactoryTool_CShare/Business/CommonMethod.cs

@@ -296,6 +296,197 @@ namespace MOKA_Factory_Tools
 
         }
 
+        public static bool CheckKeyType(Dictionary<string, string> keyTypes, Config_WriteDone cfg_write, out List<KeyType> resultKeyType)
+        {
+            resultKeyType = new List<KeyType>();
+
+            Func<string, List <KeyType> ,bool > check_key_type = (keyname, listType) => 
+            {
+                if (!keyTypes.ContainsKey(keyname)) {
+                    Log.WriteErrorLog(string.Format("{0} is not included in the available key type of the order", keyname));
+                    return false;
+                }
+
+                KeyType keyType = new KeyType();
+                keyType.name = keyname;
+                keyType.type = keyTypes[keyname];
+                listType.Add(keyType);
+                return true; 
+            };
+
+            if (cfg_write.DIDWrite_YesNo)
+            {
+                if (!check_key_type("DeviceID", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.MacWrite_YesNo)
+            {
+                if (!check_key_type("MAC", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.HDCPWrite_YesNo)
+            {
+                if (!check_key_type("HDCP_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.HDCP22Write_YesNo)
+            {
+                if (!check_key_type("HDCP2.2_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.ESNWrite_YesNo)
+            {
+                if (!check_key_type("NETFILX_ESN", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.WidevineWrite_YesNo)
+            {
+                if (!check_key_type("Widevine_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.CI_plusWrite_YesNo)
+            {
+                if (!check_key_type("CI_PLUS_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.AttestationWrite_YesNo)
+            {
+                if (!check_key_type("Attestation_key", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.MGKWrite_YesNo)
+            {
+                if (!check_key_type("MGK_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.FairplayWrite_YesNo)
+            {
+                if (!check_key_type("Fairplay_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.ECPWrite_YesNo)
+            {
+                if (!check_key_type("ECP_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.WifiMacWrite_YesNo)
+            {
+                if (!check_key_type("WiFi_MAC", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.BTMacWrite_YesNo)
+            {
+                if (!check_key_type("BT_MAC", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.LEKWrite_YesNo)
+            {
+                if (!check_key_type("LEK", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.PEKWrite_YesNo)
+            {
+                if (!check_key_type("PEK", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.PlayreadyWrite_YesNo)
+            {
+                if (!check_key_type("PlayReady_key", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.HashWrite_YesNo)
+            {
+                if (!check_key_type("Hashkey", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.DSNWrite_YesNo)
+            {
+                if (!check_key_type("DSN", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.YouTubeWrite_YesNo)
+            {
+                if (!check_key_type("YouTube_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.ACASKeyWrite_YesNo)
+            {
+                if (!check_key_type("ACAS_KEY", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            if (cfg_write.DAKWrite_YesNo)
+            {
+                if (!check_key_type("DAK", resultKeyType))
+                {
+                    return false;
+                }
+            }
+
+            Log.WriteInfoLog("key type of order need to copy="+resultKeyType.ToString());
+
+            return true;
+        }
+
         /// <summary>
         /// 获取预绑定模式下的key包地址
         /// </summary>
@@ -488,7 +679,7 @@ namespace MOKA_Factory_Tools
         /// <param name="error"></param>
         /// <param name="md5"></param>
         /// <returns></returns>
-        public static bool GetIDMKeys(string url, string sn, string order, string psn, string firetv_device_code, SQLiteConnection connection, out KeyInfo keys, out string msg)
+        public static bool GetIDMKeys(string url, string sn, string order, string psn, string firetv_device_code, List<KeyType> key2Write, SQLiteConnection connection, out KeyInfo keys, out string msg)
         {
             msg = "";
             keys = new KeyInfo();
@@ -509,7 +700,7 @@ namespace MOKA_Factory_Tools
             watch.Start();
 
             item.URL = url + "/v1/bind/order";
-            item.Postdata = string.Format("{{\"orderNum\":\"{0}\",\"sn\":\"{1}\",\"psn\":\"{2}\",\"orderCode\":\"{3}\"}}", order, sn, psn, firetv_device_code);
+            item.Postdata = string.Format("{{\"orderNum\":\"{0}\",\"sn\":\"{1}\",\"psn\":\"{2}\",\"orderCode\":\"{3}\",\"skipKey\":{4}}}", order, sn, psn, firetv_device_code, key2Write == null ? "[]" : JsonConvert.SerializeObject(key2Write).ToString());
             HttpResult httpResult = http.GetHtml(item);
             if (httpResult.StatusCode == System.Net.HttpStatusCode.OK)
             {

+ 15 - 7
FactoryTool_CShare/Models/StructList.cs

@@ -398,12 +398,16 @@ namespace MOKA_Factory_Tools
         public bool SHOPWrite_YesNo { get; set; }
         public bool ClientTypeCheck_YesNo { get; set; }
         public bool SoftwareVersionCheck_YesNo { get; set; }
+        public bool EDIDPIDWrite_YesNo { get; set; }
+        public bool EDIDModeNameWrite_YesNo { get; set; }
+        public bool FVPWrite_YesNo { get; set; }
+
+        #region getmessage接口对应需要在线获取的key类型;
         public bool DIDWrite_YesNo { get; set; }
         public bool MacWrite_YesNo { get; set; }
         public bool HDCPWrite_YesNo { get; set; }
         public bool HDCP22Write_YesNo { get; set; }
-        public bool ESNWrite_YesNo { get; set; }
-        public bool WiDiWrite_YesNo { get; set; }
+        public bool ESNWrite_YesNo { get; set; }        
         public bool WidevineWrite_YesNo { get; set; }
         public bool CI_plusWrite_YesNo { get; set; }
         public bool AttestationWrite_YesNo { get; set; }
@@ -417,12 +421,10 @@ namespace MOKA_Factory_Tools
         public bool PlayreadyWrite_YesNo { get; set; }
         public bool HashWrite_YesNo { get; set; }
         public bool DSNWrite_YesNo { get; set; }
-        public bool YouTubeWrite_YesNo { get; set; }
-        public bool EDIDPIDWrite_YesNo { get; set; }
-        public bool EDIDModeNameWrite_YesNo { get; set; }
+        public bool YouTubeWrite_YesNo { get; set; }       
         public bool ACASKeyWrite_YesNo { get; set; }
-        public bool FVPWrite_YesNo { get; set; }
         public bool DAKWrite_YesNo { get; set; }
+        #endregion
     }
 
     public class ErrorInfo
@@ -640,5 +642,11 @@ namespace MOKA_Factory_Tools
         public string HDCP14 { set; get; } = "";
         public string HDCP22 { set; get; } = "";
     }
-#endregion
+    #endregion
+
+    public class KeyType
+    {
+        public string name { get; set; } = "";
+        public string type { get; set; } = "";
+    }
 }

+ 9 - 1
FactoryTool_CShare/Views/Main.cs

@@ -34,6 +34,7 @@ namespace MOKA_Factory_Tools
 
         Dictionary<string, string> ChannelMapList = new Dictionary<string, string>();
         Dictionary<string, string> LanguageMapList = new Dictionary<string, string>();
+        List<KeyType> key2Write = null;
         string Custom_ProjectID = "";
         ArrayList formlocationmsg = new ArrayList();
         string ErrorDBPath = AppDomain.CurrentDomain.BaseDirectory + "\\Error.db";
@@ -252,6 +253,7 @@ namespace MOKA_Factory_Tools
                     }
                     else
                     {
+                        // 预绑定模式下:没有db数据库时需要下载json包;
                         if (CommonMethod.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, "", "", ErrorDB, out midList1))
                         {
                             if (CommonMethod.GetMidAddress2(midList1, OrderText.Text.Trim(), ErrorDB, out List<MidAddress> midAddress2))
@@ -428,6 +430,13 @@ namespace MOKA_Factory_Tools
                 {
                     if (CommonMethod.GetMidInfo(TestMode.serverurl, OrderText.Text.Trim(), TestMode.MAC, "", "", ErrorDB, out midList1))
                     {
+                        if ( !CommonMethod.CheckKeyType(midList1.keytype, cfg_writedone, out key2Write) )
+                        {
+                            MessageBox.Show("The key type to be copied in the configuration item does not match the order");
+                            return;
+                        }
+                        OperationPanel.key2Write = key2Write;
+
                         //CommonMethod.UpgradeCheck(UpgradeUrl.Officialurl, midList1.factoryNum, ErrorDB, out UpgradeMsgList1);
                         if (UsinglocalIDCheck.Checked)
                         {
@@ -949,7 +958,6 @@ namespace MOKA_Factory_Tools
                 cfg_writedone.MacWrite_YesNo = jObject["WriteDone"]["MAC"].Value<bool>();
                 cfg_writedone.HDCPWrite_YesNo = jObject["WriteDone"]["HDCP"].Value<bool>();
                 cfg_writedone.HDCP22Write_YesNo = jObject["WriteDone"]["HDCP22"].Value<bool>();
-                cfg_writedone.WiDiWrite_YesNo = jObject["WriteDone"]["WIDI"].Value<bool>();
                 cfg_writedone.WidevineWrite_YesNo = jObject["WriteDone"]["WIDEVINE"].Value<bool>();
                 cfg_writedone.ESNWrite_YesNo = jObject["WriteDone"]["ESN"].Value<bool>();
                 cfg_writedone.CI_plusWrite_YesNo = jObject["WriteDone"]["CI"].Value<bool>();

+ 2 - 9
FactoryTool_CShare/Views/OperationPanel.cs

@@ -50,6 +50,7 @@ namespace MOKA_Factory_Tools
         // 只有NTF才用该变量, 0试产, 1=量产;
         int nOrderType = -1;
         MIKey _MiKey = null;
+        public static List<KeyType> key2Write = null;
 
         //删除界面指针委托
         public delegate void DisplayUpdateDelegate(IntPtr intPtr);
@@ -317,8 +318,6 @@ namespace MOKA_Factory_Tools
                 SetspecificText(m_writehdcp, LResource.Skip, Color.Yellow);
             if (!cfg_writedone.HDCP22Write_YesNo)
                 SetspecificText(m_writehdcp22, LResource.Skip, Color.Yellow);
-            if (!cfg_writedone.WiDiWrite_YesNo)
-                SetspecificText(m_writewidi, LResource.Skip, Color.Yellow);
             if (!cfg_writedone.WidevineWrite_YesNo)
                 SetspecificText(m_writewidevine, LResource.Skip, Color.Yellow);
             if (!cfg_writedone.ESNWrite_YesNo)
@@ -2195,7 +2194,7 @@ namespace MOKA_Factory_Tools
                 // 部分订单无key,只有Roku信息;
                 if (midListNow.keytype.Count() != 0)
                 {
-                    if (!CommonMethod.GetIDMKeys(midListNow.host, SN, orderNow, psn, devicecode, errorDBNow, out keyInfo, out error))
+                    if (!CommonMethod.GetIDMKeys(midListNow.host, SN, orderNow, psn, devicecode, key2Write, errorDBNow, out keyInfo, out error))
                     {
                         ErrMsg = string.Format("{0} GetIDMKeys Failed!\r\n{1}", SN, error);
                         Log.WriteErrorLog(ErrMsg);
@@ -5006,12 +5005,6 @@ namespace MOKA_Factory_Tools
                     SetCheckboxStatus(WriteCiplus, true);
                 UpdateKeyCountOnline("CI_PLUS_KEY", keys["CI_PLUS_KEY"], autokey);
             }
-            if (keys.ContainsKey("WiDi"))
-            {
-                if (cfg_writedone.WiDiWrite_YesNo)
-                    SetCheckboxStatus(WriteWiDi, true);
-                UpdateKeyCountOnline("WiDi", keys["WiDi"], autokey);
-            }
             if (keys.ContainsKey("Widevine_KEY"))
             {
                 if (cfg_writedone.WidevineWrite_YesNo)