Browse Source

新增接口isSmt,psnSmt参数,新增配置文件IsSmt选项

chenjiangqun 2 năm trước cách đây
mục cha
commit
5067e8f467

+ 38 - 5
FactoryTool_CShare/Business/V2Method.cs

@@ -19,6 +19,8 @@ namespace MOKA_Factory_Tools
 {
     internal class V2Method
     {
+        
+
         private static string url_getDSNFromSmes = "http://smes-app-prod.tclking.com:9006/api/xm/GetXMTVParts?TVSN=";
         public static MidList midList { get; set; }
 
@@ -152,6 +154,8 @@ namespace MOKA_Factory_Tools
                 mid.host = jObject["host"].Value<string>();
                 mid.whiteType = jObject["whiteType"].Value<string>();
                 string aesEncrypt = jObject["aesEncrypt"] == null ? null : jObject["aesEncrypt"].Value<string>();
+                mid.isSmt = jObject["isSmt"] == null ? null : jObject["isSmt"].Value<string>();    
+                
                 if (aesEncrypt != null)
                     mid.aesEncrypt = aesEncrypt.Equals("yes", StringComparison.OrdinalIgnoreCase);
                 object a = jObject["rokuCustomer"];
@@ -159,11 +163,29 @@ namespace MOKA_Factory_Tools
                 {
                     mid.rokuCustomer = GetRokuInfo(jObject["rokuCustomer"].ToString());
                 }
-
-                mid.keytype = new Dictionary<string, string>();
-                foreach (var ss in jObject["obj"])  //查找某个字段与值
+                //如果服务器返回的是整机抄写订单,配置文件配置了1,提示整机抄写订单,不可用来抄写板卡              
+                //if (mid.isSmt == "0" && Main.Is_Smt == "1")
+                //{
+                //    MessageBox.Show("整机抄写订单,不可用来抄写板卡(配置文件IsSmt = 1)");
+                //    return false;
+                //}
+                mid.keytype = new Dictionary<string, string>();               
+                //根据配置文件选择要抄写的类型
+                if (Main.Is_Smt == "1")
                 {
-                    mid.keytype.Add(ss["name"].Value<string>(), ss["type"].Value<string>());
+                    //板卡抄写
+                    foreach (var ss in jObject["obj_smt"])  //查找isSmt某个字段与值
+                    {
+                        mid.keytype.Add(ss["name"].Value<string>(), ss["type"].Value<string>());
+                    }
+                }                            
+                else
+                {
+                    //整机抄写
+                    foreach (var ss in jObject["obj"])  //查找某个字段与值
+                    {
+                        mid.keytype.Add(ss["name"].Value<string>(), ss["type"].Value<string>());
+                    }
                 }
 
                 if (mid.code == "1000")
@@ -203,7 +225,7 @@ namespace MOKA_Factory_Tools
             watch.Start();
 
             item.URL = url + "/bind/order";        
-            item.Postdata = string.Format("{{\"orderNum\":\"{0}\",\"sn\":\"{1}\",\"psn\":\"{2}\",\"orderCode\":\"{3}\",\"clientType\":\"{4}\",\"skipKey\":{5}}}", order, sn, psn, firetv_device_code, midList.clienttype, key2Write == null ? "[]" : JsonConvert.SerializeObject(key2Write).ToString());
+            item.Postdata = string.Format("{{\"orderNum\":\"{0}\",\"sn\":\"{1}\",\"psn\":\"{2}\",\"orderCode\":\"{3}\",\"clientType\":\"{4}\",\"isSmt\":\"{5}\",\"skipKey\":{6}}}", order, sn, psn, firetv_device_code, midList.clienttype,Main.Is_Smt , key2Write == null ? "[]" : JsonConvert.SerializeObject(key2Write).ToString());
             HttpResult httpResult = http.GetHtml(item);
             if (httpResult.StatusCode == System.Net.HttpStatusCode.OK)
             {
@@ -580,6 +602,17 @@ namespace MOKA_Factory_Tools
                 AddJsonItem("sversionid", swVer, postJson);
                 AddJsonItem("projectid", pid, postJson);
 
+                //当配置文件中的isSmt=0  ---》整机抄写  ---》上报时增加smtpsn 字段
+                if(Main.Is_Smt == "0")
+                {
+                    //读取PSN               
+                    AddJsonItem("smtPsn",OperationPanel.smtPsn,postJson);
+                }
+                else
+                {
+                    AddJsonItem("smtPsn", sn, postJson);
+                }
+
                 if (keyinfo != null)
                 {
                     AddKeyJson2(keyinfo.DID, postJson, "deviceid");

+ 10 - 1
FactoryTool_CShare/Models/StructList.cs

@@ -30,7 +30,10 @@ namespace MOKA_Factory_Tools
         public string whiteType { get; set; }
         public RokuCustomer rokuCustomer { get; set; }
         public Dictionary <string,string> keytype { get; set; }
-        public bool aesEncrypt { get; set; } = false;    
+        public bool aesEncrypt { get; set; } = false;
+        //新增是否整机抄写字段
+        public string isSmt { get; set; }
+        public string obj_smt { get; set; }
     }
 
     public class RokuData
@@ -279,6 +282,12 @@ namespace MOKA_Factory_Tools
         /// 后台上传IDM的在线数据;
         /// </summary>
         public bool BackgroudReportData { get; set; } = false;
+
+        ///
+        ///整机还是板卡抄写
+        ///
+        public string IsSmt { get; set; } = "0";//默认整机
+
     }
 
     public enum KEY_FROM

+ 3 - 1
FactoryTool_CShare/Views/Main.cs

@@ -23,6 +23,7 @@ namespace MOKA_Factory_Tools
     public delegate void KeyDownHandler(ArrayList formlocationmsg, IntPtr intPtr);
     public partial class Main : Skin_Color
     {
+        public static string Is_Smt { get; set; }
         MidList midList1 = new MidList();
         UpgradeMsgList UpgradeMsgList1 = new UpgradeMsgList();
         MidAddress midAddress1 = new MidAddress();
@@ -968,7 +969,8 @@ namespace MOKA_Factory_Tools
                 #region 是否整机抄写
                 if (jObject["IsSmt"] != null)
                 {
-                    functionSetting1.IsSmt = jObject["IsSmt"].Value<string>();                 
+                    functionSetting1.IsSmt = jObject["IsSmt"].Value<string>();
+                    Is_Smt = functionSetting1.IsSmt;
                 }
                 else
                 {

+ 43 - 8
FactoryTool_CShare/Views/OperationPanel.cs

@@ -49,6 +49,9 @@ namespace MOKA_Factory_Tools
         Thread SNTextFocus;
         bool FocusMark = false;
         Thread WritekeyThread;
+
+        //整机抄写的
+        public static string smtPsn { get; set; } = "";
         // 当前窗口抄写线程只能开一个;
         private readonly object MyLock;
         private bool IsThreadRunning { get; set; } = false;
@@ -90,12 +93,10 @@ namespace MOKA_Factory_Tools
 
         private void SetCheckboxStatusByConfig()
         {
-
             // 非小米的抄写,不处理.需要保证其他工厂的配置不受影响;
             if (!FunctionSettingNow.MITVEnable && !FunctionSettingNow.IndiaMITVEnable)
                 return;
-
-            #region 默认根据config启用是否抄写;
+#region 默认根据config启用是否抄写;
             SetCheckboxStatus(WriteDID, cfg_writedone.DIDWrite_YesNo);
             SetCheckboxStatus(WriteMac, cfg_writedone.MacWrite_YesNo);
             SetCheckboxStatus(WriteHDCP, cfg_writedone.HDCPWrite_YesNo);
@@ -135,7 +136,7 @@ namespace MOKA_Factory_Tools
             localDBNow = localDB;
             errorDBNow = errorDB;
             preloadNow = preload;
-            midListNow = midList1;
+            midListNow = midList1;          
             orderNow = order;
             if (reportDBNow == null)
             {
@@ -150,6 +151,14 @@ namespace MOKA_Factory_Tools
                 ProductMsg_Text.Text = "Roku:";
             if (functionSetting.NTF)
                 ntfBLL = new NTFBLL(functionSetting.Mexican_NTF);
+                          
+            //修改界面颜色
+            if (functionSetting.IsSmt == "1")
+            {
+                this.CaptionBackColorTop = Color.Red;
+                this.CaptionBackColorBottom = Color.Gold;
+            }
+
             MyLock = new object();
         }
 
@@ -240,7 +249,7 @@ namespace MOKA_Factory_Tools
             SerialCMD.EnableRetry = FunctionSettingNow.EnableRetry;
             SerialCMD.RetryCount = FunctionSettingNow.RetryCount;
 #endregion
-
+          
 #region 设置WriteCheck复选框默认状态;
             if (!cfg_writecheck.DIDCheckcheck)
                 SetspecificText(m_checkdid, LResource.Skip, Color.Yellow);
@@ -429,6 +438,8 @@ namespace MOKA_Factory_Tools
                 SHOPText.Text = LResource.Default;
                 SHOPText.BackColor = Color.Yellow;
             }
+
+
 #endregion
             SetCheckboxStatusByConfig();
 
@@ -771,7 +782,7 @@ namespace MOKA_Factory_Tools
             SNTextFocus.Start();
             SNText.Focus();
         }
-
+       
         /// <summary>
         /// 强制聚焦扫描框
         /// </summary>
@@ -1278,8 +1289,17 @@ namespace MOKA_Factory_Tools
         /// </summary>
         public void SetInitialStatus()
         {
-            this.CaptionBackColorTop = Color.RoyalBlue;
-            this.CaptionBackColorBottom = Color.Cyan;
+            if(FunctionSettingNow.IsSmt == "1")
+            {
+                this.CaptionBackColorTop = Color.Red;
+                this.CaptionBackColorBottom = Color.Red;
+            }
+            else
+            {
+                this.CaptionBackColorTop = Color.RoyalBlue;
+                this.CaptionBackColorBottom = Color.Cyan;
+            }
+           
             this.Refresh();
             SetCheckboxStatusByConfig();
             /////////////////////////////////////////////////////////////
@@ -5071,6 +5091,21 @@ namespace MOKA_Factory_Tools
             }
             else
             {// 在线抄写;
+                if(FunctionSettingNow.IsSmt == "0")
+                {
+                    //读取PSN 并且上报
+                    if (SerialCMD.ReadFireTVPSN(TVPort, out result, out data, out error, SerailDelay))
+                    {
+                        smtPsn = Encoding.ASCII.GetString(data);
+                    }
+                    else
+                    {
+                        ErrMsg = string.Format("读取PSN失败 {0}", error);
+                        Log.WriteErrorLog(ErrMsg);
+                        goto end;
+                    }
+
+                }
                 if (WriteDID.Checked)
                 {
                     string postjson = V2Method.GetReportJson(orderNow, SN, isNodid: false, midListNow.clienttype, midListNow.version, ProjectIDText.Text, ref keyInfo, FunctionSettingNow.MITVEnable || FunctionSettingNow.IndiaMITVEnable, ref _MiKey);