Forráskód Böngészése

修改了DSN禁止check和read时候依旧进行操作的问题

chenjiangqun 2 éve
szülő
commit
2709134a54
1 módosított fájl, 61 hozzáadás és 57 törlés
  1. 61 57
      FactoryTool_CShare/Views/OperationPanel.cs

+ 61 - 57
FactoryTool_CShare/Views/OperationPanel.cs

@@ -88,10 +88,13 @@ namespace MOKA_Factory_Tools
 
         private void SetCheckboxStatusByConfig()
         {
+#if DEBUG
+
+#else
             // 非小米的抄写,不处理.需要保证其他工厂的配置不受影响;
             if (!FunctionSettingNow.MITVEnable && !FunctionSettingNow.IndiaMITVEnable)
                 return;
-
+#endif
             #region 默认根据config启用是否抄写;
             SetCheckboxStatus(WriteDID, cfg_writedone.DIDWrite_YesNo);
             SetCheckboxStatus(WriteMac, cfg_writedone.MacWrite_YesNo);
@@ -118,7 +121,7 @@ namespace MOKA_Factory_Tools
             SetCheckboxStatus(WriteDAK, cfg_writedone.DAKWrite_YesNo);
             SetCheckboxStatus(WriteFVP, cfg_writedone.FVPWrite_YesNo);
             SetCheckboxStatus(WriteKFP, cfg_writedone.KFPWrite_YesNo);
-            #endregion
+#endregion
         }
 
         public OperationPanel(Main form1, SQLiteConnection localDB, SQLiteConnection errorDB, MidAddress midAddress1, FunctionSetting functionSetting, Config_WriteCheck writeCheck1, Config_ReadCheck readCheck1, Config_WriteDone writeDone1, bool preload, MidList midList1, string order)
@@ -228,12 +231,12 @@ namespace MOKA_Factory_Tools
             BaudText.BackColor = Color.FromArgb(128, 255, 128);
             WritePSN.Checked = FunctionSettingNow.BarcodeWrite;
 
-            #region 串口重试机制;
+#region 串口重试机制;
             SerialCMD.EnableRetry = FunctionSettingNow.EnableRetry;
             SerialCMD.RetryCount = FunctionSettingNow.RetryCount;
-            #endregion
+#endregion
 
-            #region 设置WriteCheck复选框默认状态;
+#region 设置WriteCheck复选框默认状态;
             if (!cfg_writecheck.DIDCheckcheck)
                 SetspecificText(m_checkdid, LResource.Skip, Color.Yellow);
             if (!cfg_writecheck.MacCheckcheck)
@@ -280,8 +283,8 @@ namespace MOKA_Factory_Tools
                 SetspecificText(m_checkDAK, LResource.Skip, Color.Yellow);
             if (!cfg_writecheck.KFPCheckcheck)
                 SetspecificText(m_checkKFP, LResource.Skip, Color.Yellow);
-            #endregion
-            #region 设置ReadCheck复选框默认状态
+#endregion
+#region 设置ReadCheck复选框默认状态
             /////////////////////////////////////////////////////////////////
             if (!cfg_readcheck.PIDReadcheck)
                 SetspecificText(ProjectIDNote, LResource.SkipReadCheck, Color.Yellow);
@@ -341,8 +344,8 @@ namespace MOKA_Factory_Tools
                 SetspecificText(m_readDAK, LResource.SkipChecking, Color.Yellow);
             if (!cfg_readcheck.KFPReadcheck)
                 SetspecificText(m_readKFP, LResource.SkipChecking, Color.Yellow);
-            #endregion
-            #region 设置WriteDone复选框默认状态
+#endregion
+#region 设置WriteDone复选框默认状态
             /////////////////////////////////////////////////////////////////
             if (!cfg_writedone.PIDWrite_YesNo)
                 SetspecificText(ProjectIDNote, LResource.SkipCovering, Color.Yellow);
@@ -421,7 +424,7 @@ namespace MOKA_Factory_Tools
                 SHOPText.Text = LResource.Default;
                 SHOPText.BackColor = Color.Yellow;
             }
-            #endregion
+#endregion
             SetCheckboxStatusByConfig();
 
             if (midListNow.host != "LocalPC")
@@ -718,7 +721,7 @@ namespace MOKA_Factory_Tools
 
         private void OperationPanel_Load(object sender, EventArgs e)
         {
-            #region 研发账号
+#region 研发账号
             if (CommonMethod.GetLoginAccout().Equals("RD", StringComparison.OrdinalIgnoreCase))
             {
                 // 修改标题;
@@ -729,7 +732,7 @@ namespace MOKA_Factory_Tools
                 this.CaptionBackColorBottom = Color.Beige;
                 this.BackColor = Color.AliceBlue;
             }
-            #endregion
+#endregion
 
             if (midListNow.host == "LocalPC")
             {
@@ -838,10 +841,10 @@ namespace MOKA_Factory_Tools
                 SetInitialStatus();
                 SN = SNText.Text;
                 Log.WriteInfoLog(string.Format("Input SN={0}", SN));
-                #region 去除SN空格;
+#region 去除SN空格;
                 SN = SN.Trim();
                 Log.WriteInfoLog(string.Format("After Trim SN={0}", SN));
-                #endregion
+#endregion
                 SNText.Enabled = false;
                 if (FunctionSettingNow.BarcodeLimit)
                 {
@@ -867,7 +870,7 @@ namespace MOKA_Factory_Tools
                     }
                 }
 
-                #region 只有惠州工厂才启用G客户防呆措施;
+#region 只有惠州工厂才启用G客户防呆措施;
                 if (FunctionSettingNow.NTF)
                 {
                     StringBuilder strValue = new StringBuilder(256);
@@ -934,7 +937,7 @@ namespace MOKA_Factory_Tools
 
                     CommonMethod.WriteProfileString("MOKAFactoryTools", "LastSN", SN);
                 }
-                #endregion
+#endregion
 
 #if !SIMULATION && !OD_VER
                 if (FunctionSettingNow.EnableSanhuaMES)
@@ -966,7 +969,7 @@ namespace MOKA_Factory_Tools
                     }
                     else if (keyjson.Length > 0)
                     {
-                        #region 解决Json对象空导致的Bug.
+#region 解决Json对象空导致的Bug.
                         Func<JToken, string> GetJsonValue = (JsonObj) =>
                         {
                             if (JsonObj == null )
@@ -974,7 +977,7 @@ namespace MOKA_Factory_Tools
 
                             return JsonObj.Value<string>();
                         };
-                        #endregion
+#endregion
                         JObject jObject = JObject.Parse(keyjson);
                         keyInfo.DID.data = GetJsonValue(jObject["did"]);
                         keyInfo.Mac.data = GetJsonValue(jObject["mac"]);
@@ -1275,7 +1278,7 @@ namespace MOKA_Factory_Tools
             this.Refresh();
             SetCheckboxStatusByConfig();
             /////////////////////////////////////////////////////////////
-            #region  Set Write;
+#region  Set Write;
             if (m_writeci.Text != LResource.Skip)
             {
                 m_writeci.Text = "Null";
@@ -1401,9 +1404,9 @@ namespace MOKA_Factory_Tools
                 m_writeKFP.Text = "Null";
                 m_writeKFP.BackColor = Color.Transparent;
             }
-            #endregion
+#endregion
             /////////////////////////////////////////////////////////////
-            #region Write Check;
+#region Write Check;
             if (m_checkci.Text != LResource.Skip)
             {
                 m_checkci.Text = "Null";
@@ -1514,9 +1517,9 @@ namespace MOKA_Factory_Tools
                 m_checkKFP.Text = "Null";
                 m_checkKFP.BackColor = Color.Transparent;
             }
-            #endregion
+#endregion
             /////////////////////////////////////////////////////////////
-            #region  Read Check;
+#region  Read Check;
             if (m_readci.Text != LResource.Skip)
             {
                 m_readci.Text = "Null";
@@ -1647,7 +1650,7 @@ namespace MOKA_Factory_Tools
                 m_readKFP.Text = "Null";
                 m_readKFP.BackColor = Color.Transparent;
             }
-            #endregion
+#endregion
 
             ResultStatus.Text = "Wait";
             ResultStatus.BackColor = Color.Transparent;
@@ -1664,7 +1667,7 @@ namespace MOKA_Factory_Tools
         /// <returns></returns>
         public string GenerateReportInfo()
         {
-            #region 移除非IDM抄写的Key;
+#region 移除非IDM抄写的Key;
             if ((FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable) && _MiKey != null)
             {
                 // 配置要抄写的选项;
@@ -1680,9 +1683,9 @@ namespace MOKA_Factory_Tools
                 if (_MiKey.WIFIMAC != null)
                     SetCheckboxStatus(WriteWifiMac, false);
             }
-            #endregion
+#endregion
 
-            #region 生成IDMKey报文;
+#region 生成IDMKey报文;
             string reportdata = "";
             if (SN.Trim().Length > 0)
                 reportdata += "sn=" + SN + "&";
@@ -1765,7 +1768,7 @@ namespace MOKA_Factory_Tools
             reportdata += "toolVersion=" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "&";
 
             return reportdata;
-            #endregion
+#endregion
         }
 
         public bool ReportMIInfo(out string msg)
@@ -2415,7 +2418,7 @@ namespace MOKA_Factory_Tools
                         }
                     }
 
-                    #region EDID屏抄写是从MID中获取值;
+#region EDID屏抄写是从MID中获取值;
                     if (WriteEDIDPID.Checked)
                     {
                         keyInfo.EDIDPid.data = midListNow.keytype["edid_pid"];
@@ -2424,7 +2427,7 @@ namespace MOKA_Factory_Tools
                     {
                         keyInfo.EDIDModelName.data = midListNow.keytype["edid_model_name"];
                     }
-                    #endregion
+#endregion
                     watch.Stop();
                     Log.WriteInfoLog(string.Format("Get All Keys Elapsed={0}", watch.Elapsed.TotalMilliseconds));
                 }
@@ -3784,7 +3787,7 @@ namespace MOKA_Factory_Tools
                     keyInfo.KFP.result = true;
                 }
 
-                #region FVP激活-放在Hash key抄写之后,应用于所有FireTV项目-已通过郁沛确认;
+#region FVP激活-放在Hash key抄写之后,应用于所有FireTV项目-已通过郁沛确认;
                 if (WriteFVP.Checked)
                 {
                     keyInfo.FVP.data = "FAIL"; //默认失败;
@@ -3820,7 +3823,7 @@ namespace MOKA_Factory_Tools
                         goto end;
                     }
                 }
-                #endregion
+#endregion
 
                 // Dolby Key抄写;
                 if (cfg_writecheck.DolbyCheckcheck)
@@ -4733,23 +4736,38 @@ namespace MOKA_Factory_Tools
                             ErrMsg = string.Format("DSN format error!\r\n{0}", keyInfo.DSN.data);
                             Log.WriteErrorLog(ErrMsg);
                             goto end;
-                        }
-                        byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN.data);
+                        }                       
+                        byte[] DSNData = System.Text.Encoding.ASCII.GetBytes((keyInfo.DSN.data));
                         Log.WriteInfoLog("Write DSN...");
                         if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
                         {
                             SetsuccessStatus(m_writeDSN);
-                            Log.WriteInfoLog("Check DSN...");
-                            if (cfg_writecheck.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
+                            Log.WriteInfoLog("Check DSN...");                   
+                            if(cfg_writecheck.DSNCheckcheck ? !SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : false)
                             {
-                                SetsuccessStatus(m_checkDSN);
-                                Log.WriteInfoLog("Read DSN...");
-                                if (cfg_readcheck.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
+                                //失败
+                                SetfailStatus(m_checkDSN);
+                                ErrMsg = string.Format("{0}  check DSN fail!", SN);
+                                Log.WriteErrorLog(ErrMsg);
+                                goto end;
+                            }
+                            
+                            SetsuccessStatus(m_checkDSN);
+                            if (cfg_readcheck.DSNReadcheck ?  !SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay):false)
+                            {
+                                SetfailStatus(m_readDSN);
+                                ErrMsg = string.Format("{0}  read DSN fail!", SN);
+                                Log.WriteErrorLog(ErrMsg);
+                                goto end;
+                            }
+                            else
+                            {
+                                if(cfg_readcheck.DSNReadcheck)
                                 {
                                     if (SerialInit.BytesCompare_Base64(data, DSNData))
                                     {
                                         SetsuccessStatus(m_readDSN);
-                                        //DSN读取别对成功
+                                        //DSN读取对成功
                                     }
                                     else
                                     {
@@ -4759,21 +4777,7 @@ namespace MOKA_Factory_Tools
                                         goto end;
                                     }
                                 }
-                                else
-                                {
-                                    SetfailStatus(m_readDSN);
-                                    ErrMsg = string.Format("{0}  read DSN fail!", SN);
-                                    Log.WriteErrorLog(ErrMsg);
-                                    goto end;
-                                }
-                            }
-                            else
-                            {
-                                SetfailStatus(m_checkDSN);
-                                ErrMsg = string.Format("{0}  check DSN fail!", SN);
-                                Log.WriteErrorLog(ErrMsg);
-                                goto end;
-                            }
+                            }                      
                         }
                         else
                         {
@@ -4979,8 +4983,8 @@ namespace MOKA_Factory_Tools
 #endregion
 #endregion
 #endif
-            //数据上传
-            if (midListNow.host == "LocalPC" && !preloadNow)
+                    //数据上传
+                    if (midListNow.host == "LocalPC" && !preloadNow)
             {// 离线抄写
                 if (GetLocalKeyCount.DeleteLocalKeys(keypath, keyStream, keyReader))
                 {