Browse Source

1、将DSN查重放在其他key抄写前面。
2、结果失败时,将服务器返回的描述提示给用户
3、变更FireTVDSN获取的接口。
4、针对DSN作条码限制。

sat23 4 years ago
parent
commit
5cbe0e7890

+ 14 - 34
SCBC Factory Tools/Business/CommonMethod.cs

@@ -1934,61 +1934,41 @@ namespace MOKA_Factory_Tools
             }
             }
         }
         }
 
 
-        public static bool GetFireTVDsn(string ordernum, string deviceCode, string FSN, string PSN, out string dsn,  out string error, SQLiteConnection errorDBNow)
+        public static bool GetFireTVDsn(string url, string ordernum, string deviceCode, string FSN, string PSN, out string dsn, out string error, SQLiteConnection errorDBNow)
         {
         {
             dsn = "";
             dsn = "";
             error = "";
             error = "";
             HttpHelper http = new HttpHelper();
             HttpHelper http = new HttpHelper();
             HttpItem item = new HttpItem()
             HttpItem item = new HttpItem()
             {
             {
-                Encoding = Encoding.Default,
+                Encoding = null,        // 编码格式(utf-8,gb2312,gbk)可选项 默认类会自动识别Encoding = Encoding.Default,
-                Method = "post",
+                Method = "GET",         // URL 可选项 默认为Get
-                ContentType = "application/json;charset=utf-8",
                 KeepAlive = false
                 KeepAlive = false
             };
             };
-            item.URL = TestMode.fireTVDsnUrl+ "getNewFiretvDsn.do?";
+
-            item.Postdata = JsonConvert.SerializeObject(new FireTVDsnInput { ordernum = ordernum, fsn = FSN, psn = PSN, mac = TestMode.MAC, deviceCode = deviceCode });
+            item.URL = string.Format("{0}/getFiretvDsn.do?ordernum={1}&fsn={2}&psn={3}&deviceCode={4}&mac={5}", url, ordernum, FSN, PSN, deviceCode, HttpUtility.UrlEncode(TestMode.MAC));
             HttpResult result = http.GetHtml(item);
             HttpResult result = http.GetHtml(item);
             if (result.StatusCode == System.Net.HttpStatusCode.OK)
             if (result.StatusCode == System.Net.HttpStatusCode.OK)
             {
             {
+                string code;
+                string desc;
                 Log.WriteGetKeyLog("\r\nGetFireTVDsn :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
                 Log.WriteGetKeyLog("\r\nGetFireTVDsn :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html);
-                try
+                if (Xmlconfig.GetDSNXml(result.Html, "response", out code, out desc, out dsn))
                 {
                 {
-                    JObject o = JObject.Parse(result.Html);
+                    Log.WriteGetKeyLog("\r\nDSN=" + dsn);
-                    if (o["code"].ToString() == "200")
+                    return true;
-                    {
-                        if (o["dsn"] != null)
-                        {
-                            dsn = o["dsn"].ToString();
-                            Log.WriteGetKeyLog("\r\nDSN=" + dsn);
-                            return true;
-                        }
-                        else
-                        {
-                            error = "error:dsn is null!";
-                            CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
-                            return false;
-                        }
-                    }
-                    else
-                    {
-                        error = o["message"].ToString();
-                        CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
-                        return false;
-                    }
                 }
                 }
-                catch(Exception ex)
+                else
                 {
                 {
-                    error = ex.Message;
+                    error = desc;
-                    Log.WriteErrorLog("\r\nParse FireTVDsn error :\r\n" + item.URL + "\r\n" + item.Postdata + "\r\n" + result.Html + "\r\n" + ex.Message);
+                    CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL, errorDBNow);
-                    CommonMethod.ReportErrormsg("Parse FireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
                     return false;
                     return false;
                 }
                 }
             }
             }
             else
             else
             {
             {
                 error = "Communication with server failed";
                 error = "Communication with server failed";
-                CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL + "\r\nPostdata: " + item.Postdata, errorDBNow);
+                CommonMethod.ReportErrormsg("GetFireTVDsn error", result.StatusDescription + "\r\n" + result.Html + "\r\nAddress: " + item.URL, errorDBNow);
                 return false;
                 return false;
             }
             }
         }
         }

+ 29 - 3
SCBC Factory Tools/Business/Countkey.cs

@@ -39,6 +39,24 @@ namespace MOKA_Factory_Tools
             { "playready", new Keyinfo{ keyType =0x10 }}
             { "playready", new Keyinfo{ keyType =0x10 }}
         };
         };
 
 
+        /// <summary>
+        /// 字节数组转16进制字符串
+        /// </summary>
+        /// <param name="bytes"></param>
+        /// <returns></returns>
+        private static string byteToHexStr(byte[] bytes)
+        {
+            string returnStr = "";
+            if (bytes != null)
+            {
+                for (int i = 0; i < bytes.Length; i++)
+                {
+                    returnStr += bytes[i].ToString("X2");
+                }
+            }
+            return returnStr;
+        }
+
         public static bool Countfile(string path, string Type, out string result, out int num)
         public static bool Countfile(string path, string Type, out string result, out int num)
         {
         {
             result = null;
             result = null;
@@ -131,7 +149,12 @@ namespace MOKA_Factory_Tools
                         if (item.Key.Equals("mac"))
                         if (item.Key.Equals("mac"))
                             Keydict[item.Key].keyValue = item.Value.Replace("-", "");
                             Keydict[item.Key].keyValue = item.Value.Replace("-", "");
                         else
                         else
-                            Keydict[item.Key].keyValue = item.Value;
+                        {
+                            if ( item.Key.Equals("did"))
+                                Keydict[item.Key].keyValue = byteToHexStr(Encoding.ASCII.GetBytes(item.Value));
+                            else
+                                Keydict[item.Key].keyValue = item.Value;
+                        }
 
 
                         if (item.Value.Length > 0)
                         if (item.Value.Length > 0)
                         {
                         {
@@ -161,8 +184,11 @@ namespace MOKA_Factory_Tools
 
 
             if (Keydict.ContainsKey("widi") && Keydict.ContainsKey("hdcp22"))
             if (Keydict.ContainsKey("widi") && Keydict.ContainsKey("hdcp22"))
             {
             {
-                error = "Key包里面同时包含HDCP22和WiDikey,请检查!";
+                if (Keydict["widi"].keyValue.Length > 0 && Keydict["widi"].keyValue.Length > 0)
-                return false;
+                {
+                    error = "Key包里面同时包含HDCP22和WiDikey,请检查!";
+                    return false;
+                }
             }
             }
 
 
             try
             try

+ 25 - 1
SCBC Factory Tools/Http/Xmlconfig.cs

@@ -130,7 +130,6 @@ public class Xmlconfig
 
 
     }
     }
 
 
-
     public static bool GetOthersKeyXml(string str, string node, string node2, out string code, out string desc, out string value)
     public static bool GetOthersKeyXml(string str, string node, string node2, out string code, out string desc, out string value)
     {
     {
         code = "";
         code = "";
@@ -259,6 +258,31 @@ public class Xmlconfig
         }
         }
 
 
     }
     }
+
+    public static bool GetDSNXml(string str, string node, out string code, out string desc, out string value)
+    {
+        code = "";
+        value = "";
+        try
+        {
+            XmlDocument xml = new XmlDocument();
+            xml.LoadXml(str);
+            code = xml.SelectSingleNode(node).Attributes.GetNamedItem("code").InnerText;
+            desc = xml.SelectSingleNode(node).Attributes.GetNamedItem("desc").InnerText;
+            if (code == "200")
+            {
+                value = xml.SelectSingleNode(node + "//" + "firetvDsn").Attributes.GetNamedItem("dsn").InnerText;
+                return true;
+            }
+            return false;
+
+        }
+        catch (Exception ex)
+        {
+            desc = ex.Message;
+            return false;
+        }
+    }
 }
 }
 
 
 
 

+ 2 - 6
SCBC Factory Tools/Licence.txt

@@ -3,11 +3,7 @@ moka tools
 //////////////////////////////////////
 //////////////////////////////////////
 //         Upgrade content:         // 
 //         Upgrade content:         // 
 //////////////////////////////////////
 //////////////////////////////////////
-33:9 2021/06/01 Ver=3.0.5.8
+Ver=3.0.5.9
-1.日本项目导出ACASID和SN,在Config.json文件中添加:
+1.由于FiretvDSN业务接口由scbc-server迁移至IDManage,针对更新对应的GetFireTvDSN接口。
-	"ExportSNACASID": true,
-即开启导出功能,导出目录为SN-ACAS, 文件名是以订单号命令,如0528TEST001.txt
-2.修复Eeprom生成缺少PlayreadyKey的问题.
-3.G客户获取dsn时,新增参数psn用于防重。
 
 
 
 

+ 1 - 1
SCBC Factory Tools/Packagescript/setup without net40.nsi

@@ -4,7 +4,7 @@ ${StrRep}
 
 
 ; °²×°³ÌÐò³õʼ¶¨Òå³£Á¿
 ; °²×°³ÌÐò³õʼ¶¨Òå³£Á¿
 !define PRODUCT_NAME "MOKA Factory Tools"
 !define PRODUCT_NAME "MOKA Factory Tools"
-!define PRODUCT_VERSION "3.0.5.8"
+!define PRODUCT_VERSION "3.0.5.9"
 !define PRODUCT_PUBLISHER "MOKA"
 !define PRODUCT_PUBLISHER "MOKA"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MOKA Factory Tools.exe"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MOKA Factory Tools.exe"
 !define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"
 !define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall"

+ 1 - 1
SCBC Factory Tools/Packagescript/setup.nsi

@@ -4,7 +4,7 @@ ${StrRep}
 
 
 ; °²×°³ÌÐò³õʼ¶¨Òå³£Á¿
 ; °²×°³ÌÐò³õʼ¶¨Òå³£Á¿
 !define PRODUCT_NAME "MOKA Factory Tools"
 !define PRODUCT_NAME "MOKA Factory Tools"
-!define PRODUCT_VERSION "3.0.5.8"
+!define PRODUCT_VERSION "3.0.5.9"
 !define PRODUCT_PUBLISHER "MOKA"
 !define PRODUCT_PUBLISHER "MOKA"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MOKA Factory Tools.exe"
 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\MOKA Factory Tools.exe"
 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"

+ 1 - 1
SCBC Factory Tools/Properties/AssemblyInfo.cs

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
 //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
 //通过使用 "*",如下所示:
 //通过使用 "*",如下所示:
 // [assembly: AssemblyVersion("1.0.*")]
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("3.0.5.8")]
+[assembly: AssemblyVersion("3.0.5.9")]
 [assembly: AssemblyFileVersion("1.0.0.1")]
 [assembly: AssemblyFileVersion("1.0.0.1")]

+ 15 - 0
SCBC Factory Tools/Upgradelog/Licence3.0.5.5.txt

@@ -0,0 +1,15 @@
+scbc tools
+
+//////////////////////////////////////
+//         Upgrade content:         // 
+//////////////////////////////////////
+Version 3.0.5.5
+1.更新widevine和attestation获取key数量接口;
+2.更新widevine和attestation获取key数据接口;
+3.根据公司要求,变更程序名称:MOKA Factory Tools;
+4.修复抄Key时,不同电脑由于性能问题,在读取串口数据未等待足够时间导致的读取数据缺失的问题;
+
+
+
+
+

+ 12 - 0
SCBC Factory Tools/Upgradelog/Licence3.0.5.6.txt

@@ -0,0 +1,12 @@
+scbc tools
+
+//////////////////////////////////////
+//         Upgrade content:         // 
+//////////////////////////////////////
+Version 3.0.5.6
+1.G客户抄写防呆处理:在Config.Json中,添加"UsingGFoolProofing": true,表示开启G客户抄写防呆措施;
+
+
+
+
+

+ 12 - 0
SCBC Factory Tools/Upgradelog/Licence3.0.5.7.txt

@@ -0,0 +1,12 @@
+scbc tools
+
+//////////////////////////////////////
+//         Upgrade content:         // 
+//////////////////////////////////////
+Version 3.0.5.6
+1.G客户在获取DSN前进行防呆处理,先读取PSN。
+
+
+
+
+

+ 12 - 0
SCBC Factory Tools/Upgradelog/Licence3.0.5.8.txt

@@ -0,0 +1,12 @@
+scbc tools
+
+//////////////////////////////////////
+//         Upgrade content:         // 
+//////////////////////////////////////
+Version 3.0.5.6
+1.修复Eeprom生成时,缺少PlayreadKey的问题;
+
+
+
+
+

+ 9 - 0
SCBC Factory Tools/Upgradelog/Licence3.0.5.9.txt

@@ -0,0 +1,9 @@
+moka tools
+
+//////////////////////////////////////
+//         Upgrade content:         // 
+//////////////////////////////////////
+Ver=3.0.5.9
+1.由于FiretvDSN业务接口由scbc-server迁移至IDManage,针对更新对应的GetFireTvDSN接口。
+
+

+ 17 - 0
SCBC Factory Tools/Views/Main.cs

@@ -79,6 +79,16 @@ namespace MOKA_Factory_Tools
             }
             }
         }
         }
 
 
+        private void SetDSNLimit()
+        {
+            // 设置条码限制默认打上勾;
+            if ( midList1.keytype.ContainsKey("DSN") )
+            {
+                BarcodeLimit.Checked = true;
+                BarCodeKeyCodeText.Text = OrderText.Text;
+            }
+        }
+
         private void OrderSubmit_Click(object sender, EventArgs e)
         private void OrderSubmit_Click(object sender, EventArgs e)
         {
         {
             SQLiteHelper.DeleteOldData(ErrorDB);//删除30天以前已经上报的数据
             SQLiteHelper.DeleteOldData(ErrorDB);//删除30天以前已经上报的数据
@@ -226,6 +236,8 @@ namespace MOKA_Factory_Tools
                                 Log.WriteErrorLog(ex.Message);
                                 Log.WriteErrorLog(ex.Message);
                             }
                             }
 
 
+                            // 是否有dsn要抄写;
+                            SetDSNLimit();
                         }
                         }
                     }
                     }
                     else
                     else
@@ -396,6 +408,9 @@ namespace MOKA_Factory_Tools
                         {
                         {
                             MessageBox.Show(LResource.GetMidInfoerror);
                             MessageBox.Show(LResource.GetMidInfoerror);
                         }
                         }
+
+                        // 是否有dsn要抄写;
+                        SetDSNLimit();
                     }
                     }
                 }
                 }
                 else
                 else
@@ -451,6 +466,8 @@ namespace MOKA_Factory_Tools
                             Log.WriteErrorLog(ex.Message);
                             Log.WriteErrorLog(ex.Message);
                         }
                         }
 
 
+                        // 是否有dsn要抄写;
+                        SetDSNLimit();
                     }
                     }
                     else
                     else
                     {
                     {

+ 16 - 2
SCBC Factory Tools/Views/OperationPanel.cs

@@ -15,6 +15,7 @@ using System.Windows.Forms;
 using System.Net;
 using System.Net;
 using System.Net.Sockets;
 using System.Net.Sockets;
 using System.Linq;
 using System.Linq;
+using System.Text.RegularExpressions;
 
 
 namespace MOKA_Factory_Tools
 namespace MOKA_Factory_Tools
 {
 {
@@ -706,7 +707,20 @@ namespace MOKA_Factory_Tools
                         SNText.Enabled = true;
                         SNText.Enabled = true;
                         SNText.Text = "";                      
                         SNText.Text = "";                      
                         return;
                         return;
-                    }                                            
+                    }
+
+                    if ( midListNow.keytype.ContainsKey("DSN") )
+                    {
+                        // 如果不是全大写字母+数字,返回;
+                        Regex r = new Regex(@"^[A-Z0-9]+$");
+                        if (!r.Match(SN).Success)
+                        {
+                            MessageBox.Show(LResource.WrongBarcode + "\r\n" + SN);
+                            SNText.Enabled = true;
+                            SNText.Text = "";
+                            return;
+                        }
+                    }
                 }
                 }
 
 
                 // 是否启用G客户防呆措施;
                 // 是否启用G客户防呆措施;
@@ -1492,7 +1506,7 @@ namespace MOKA_Factory_Tools
                     if (SerialCMD.ReadFireTVPSN(TVPort, out result_psn, out data_psn, out error_psn, SerailDelay))
                     if (SerialCMD.ReadFireTVPSN(TVPort, out result_psn, out data_psn, out error_psn, SerailDelay))
                     {
                     {
                         string psn = Encoding.ASCII.GetString(data_psn);
                         string psn = Encoding.ASCII.GetString(data_psn);
-                        if (CommonMethod.GetFireTVDsn(orderNow, Encoding.ASCII.GetString(data), SN, psn, out string dsn, out error_psn, errorDBNow))
+                        if (CommonMethod.GetFireTVDsn(midListNow.host, orderNow, Encoding.ASCII.GetString(data), SN, psn, out string dsn, out error_psn, errorDBNow))
                         {
                         {
                             keyInfo.DSN = dsn;
                             keyInfo.DSN = dsn;
                             if (!CommonMethod.IsNumberAndWord(keyInfo.DSN))
                             if (!CommonMethod.IsNumberAndWord(keyInfo.DSN))