From cd7c9e15bc51e65be0b456129d7d380667b9351e Mon Sep 17 00:00:00 2001
From: yantian yue <306727702@qq.com>
Date: 星期五, 29 十二月 2023 12:47:39 +0800
Subject: [PATCH] 更新

---
 YX/wt/Frmwt.cs |  132 +++++++++++++++++++++-----------------------
 1 files changed, 63 insertions(+), 69 deletions(-)

diff --git a/YX/wt/Frmwt.cs b/YX/wt/Frmwt.cs
index df916b6..31a0d79 100644
--- a/YX/wt/Frmwt.cs
+++ b/YX/wt/Frmwt.cs
@@ -17,7 +17,7 @@
 using System.IO.Ports;
 using System.Net.NetworkInformation;
 
-namespace YX.wt
+namespace YX
 {
     public partial class Frmwt : WindowParent
     {
@@ -34,6 +34,7 @@
         public string PSN = "";
         public string PSN2 = "";
         public string PSN3 = "";
+        public bool t = true;
         public Frmwt(string ParentId)
         {
             InitializeComponent();
@@ -48,7 +49,7 @@
             {
                 Console.WriteLine($"鍙戠敓閿欒锛歿ex}");
             }
-            dataGridView1.DataSource = System_Bll.GetSystemLog(FrmLogin.LocalIP);
+            dataGridView1.DataSource = System_Bll.GetSystemLog(FrmLogin.LocalIP, "鍥涚爜鍚堜竴");
             macBox.Text = GetMacByNetworkInterface();
 
         }
@@ -58,16 +59,13 @@
             while (true)
             {
                 ProcessDelegate showProcess = new ProcessDelegate(LabelShow);
-                //string str = "1\n2\n3\n";
-                //str = str.Replace("\n", string.Empty); // 灏� \n 鏇挎崲涓虹┖瀛楃涓�
                 string str = ModbusTCPRead(5, 1).Trim("\n".ToCharArray());
                 if (ModbusTCPRead(5, 1).Trim("\n".ToCharArray()) == "1")
                 {
 
                     try
                     {
-                        //PSN = ModbusTCPRead(5, 20).Replace("\n", string.Empty);
-                        PSN = ModbusTCPReadString(25, 30).Replace("\0", string.Empty);
+                        PSN = ModbusTCPReadString(25, 30).Replace("\0", string.Empty); //灏哱0鏇挎崲涓虹┖瀛楃涓�
                         PSN2 = ModbusTCPReadString(45, 20).Replace("\0", string.Empty);
                         PSN3 = ModbusTCPReadString(65, 20).Replace("\0", string.Empty);
                         label1.Invoke(showProcess);
@@ -224,9 +222,8 @@
 
         private void LabelShow()
         {
-            //string[] aaa = PSN.Split(',');
-            //string bbbb = aaa[0];
-            PSNBox.Text = PSN;
+            string[] b_str = PSN.Split(',');
+            PSNBox.Text = b_str[1];
 
             JObject jo = WI6027();
             if (jo == null)
@@ -237,7 +234,7 @@
                     CreateUserName = FrmLogin.loginUserName,
                     LocalIP = FrmLogin.LocalIP,
                     LogMessage = "WI6027璋冪敤澶辫触锛�",
-                    Type = "绉伴噸",
+                    Type = "鍥涚爜鍚堜竴",
                     ClassName = typeof(FrmLogin).ToString()
                 });
                 return;
@@ -254,7 +251,7 @@
                 JObject jo1032 = WI1032(PSNBox.Text, SNMBox.Text, KPNMBox.Text, KPValueBox.Text);
                 if (jo1032 != null)
                 {
-                    if (WI6041(PSNBox.Text, SNMBox.Text, KPNMBox.Text, jo1032))
+                    if (WI6041(PSNBox.Text, SNMBox.Text, KPNMBox.Text, b_str[0]))
                     {
                         System_Bll.WriteLogToDB(new Entity.Base_Log
                         {
@@ -268,7 +265,7 @@
                     }
                 }
             }
-            dataGridView1.DataSource = System_Bll.GetSystemLog(FrmLogin.LocalIP);
+            dataGridView1.DataSource = System_Bll.GetSystemLog(FrmLogin.LocalIP, "鍥涚爜鍚堜竴");
             Refresh();
         }
 
@@ -309,9 +306,7 @@
 
         public JObject WI6027()
         {
-            //string WI6027 = "{ \"user\":\"sys\",\"password\":\"sysuser\",\"method\":\"MES_BA_WI6027\",\"servername\":\"TEST_WTMES_Customer\",\"methodparameter\":{ \"mac\":\"6A:15:63:C3:CC:EA\",\"hostName\":\"liuxingliang-PC\"} }";
-            string a = "D0:8E:79:02:CF:91";
-
+            string a = "a0:36:9F:6c:0e:95";
             string WI6027 = "{";
             WI6027 += "\"user\":\"sys\",";
             WI6027 += "\"password\":\"sysuser\",";
@@ -319,17 +314,16 @@
             WI6027 += "\"servername\":\"London\",";
             WI6027 += "\"methodparameter\":{";
             WI6027 += "\"mac\":\"" + a + "\",";
-            WI6027 += "\"hostName\":\"PC-20230103TQKE\"";
+            WI6027 += "\"hostName\":\"DESKTOP-UV8I1I0\"";
             WI6027 += "}}";
 
-            JObject jo = MES_Interface(WI6027, encryptionKey);
-            return jo;
+            return MES_Interface(WI6027, encryptionKey);
         }
 
         public bool WI601K(string BarCode)
         {
             //string WI601K = "{\"user\":\"sys\",聽\"password\":\"sysuser\",\"method\":\"MES_BA_WI601K\",\"servername\":\"TEST_WTMES_Customer\",聽\"methodparameter\":{\"BarCode\":\"123456789\",聽\"HostName\":\"liuxingliang-PC\",聽\"Mac\":\"6A:15:63:C3:CC:EA\"聽}}\n";
-
+            string a = "a0:36:9F:6c:0e:95";
             string WI601K = "{";
             WI601K += "\"user\":\"sys\",";
             WI601K += "\"password\":\"sysuser\",";
@@ -337,21 +331,23 @@
             WI601K += "\"servername\":\"London\",";
             WI601K += "\"methodparameter\":{";
             WI601K += "\"BarCode\":\"" + BarCode + "\",";
-            WI601K += "\"HostName\":\"liuxingliang-PC\",";
-            WI601K += "\"Mac\":\"6A:15:63:C3:CC:EA\"";
+            WI601K += "\"HostName\":\"DESKTOP-UV8I1I0\",";
+            WI601K += "\"Mac\":\"" + a + "\"";
             WI601K += "}";
             WI601K += "}";
 
             JObject jo = MES_Interface(WI601K, encryptionKey);
             if (jo["state"].ToString() == "false")
             {
+                t = false;
                 System_Bll.WriteLogToDB(new Entity.Base_Log
+
                 {
                     CreateUserID = FrmLogin.LoginUserID,
                     CreateUserName = FrmLogin.loginUserName,
                     LocalIP = FrmLogin.LocalIP,
-                    LogMessage = "MES鎺ュ彛WI601K,鏉$爜姣斿澶辫触锛�",
-                    Type = "鍖呰绾�",
+                    LogMessage = "WI601K鎺ュ彛璋冪敤澶辫触锛�" + jo["content"].ToString(),
+                    Type = "鍥涚爜鍚堜竴",
                     ClassName = typeof(FrmLogin).ToString()
                 });
                 return false;
@@ -375,13 +371,14 @@
             JObject jo = MES_Interface(WI1032, encryptionKey);
             if (jo["state"].ToString() == "false")
             {
+                t = false;
                 System_Bll.WriteLogToDB(new Entity.Base_Log
                 {
                     CreateUserID = FrmLogin.LoginUserID,
                     CreateUserName = FrmLogin.loginUserName,
                     LocalIP = FrmLogin.LocalIP,
-                    LogMessage = "MES鎺ュ彛WI1032鏉$爜閭﹀畾澶辫触",
-                    Type = "鍖呰绾�",
+                    LogMessage = "WI1032鎺ュ彛璋冪敤澶辫触锛�" + jo["content"].ToString(),
+                    Type = "鍥涚爜鍚堜竴",
                     ClassName = typeof(FrmLogin).ToString()
                 });
                 return null;
@@ -389,61 +386,58 @@
             return jo;
         }
 
-        public bool WI6041(string Line, string Station, string StationID, JObject outWI1032)
+        public bool WI6041(string Line, string Station, string StationID, string PSN)
         {
-            var contents = outWI1032["content"];
-
-            string WI6041 = "{ " +
-                "\n\"user\":\"sys\", " +
-                "\n\"password\":\"sysuser\", " +
-                "\n\"method\":\"MES_BA_WI6041\", " +
-                "\n\"servername\":\"London\", " +
-                "\n\"methodparameter\":{ " +
-                "\n\"content\":{ " +
-                "\n\"snresult\":{ " +
-                "\n}, " +
-                "\n\"testresult\":{ " +
-                "\n\"psn\":\"" + (string)contents["PSN"] + "\", " +
-                "\n\"workordernumber\":\"100000236815\", " +
-                "\n\"testStationId\":\"" + StationID + "\", " +
-                "\n\"testStationName\":\"" + Station + "\", " +
-                "\n\"linename\":\"" + Line + "\", " +
-                "\n\"hostname\":\"admin-PC-0930\", " +
-                "\n\"testTime\":\"" + string.Format("{0:yyyy-MM-dd HH:mm:ss.fff}", DateTime.Now) + "\", " +
-                "\n\"testModel\":\"S87567GB002_BLK1\", " +
-                "\n\"testWorkID\":\"\", " +
-                "\n\"Fixture\":\"\", " +
-                "\n\"FixtureSN\":\"\", " +
-                "\n\"Powersupply\":\"\", " +
-                "\n\"PowersupplySN\":\"\", " +
-                "\n\"Instrument\":\"\", " +
-                "\n\"InstrumentSN\":\"\", " +
-                "\n\"Operator\":\"\", " +
-                "\n\"testVersion\":\"V1.0.1\" " +
-                "\n}, " +
-                "\n\"itemresult\":[ " +
-                "\n]," +
-                "\n\"specialitem\":[ " +
-                "\n] " +
-                "\n}, " +
-                "\n\"state\":\"pass\", " +
-                "\n\"errcode\":\"\", " +
-                "\n\"errmessage\":\"\"} " +
-                "\n}";
+            string WI6041 = "{ ";
+            WI6041 += "\n\"user\":\"sys\", ";
+            WI6041 += "\n\"password\":\"sysuser\", ";
+            WI6041 += "\n\"method\":\"MES_BA_WI6041\", ";
+            WI6041 += "\n\"servername\":\"London\", ";
+            WI6041 += "\n\"methodparameter\":{ ";
+            WI6041 += "\n\"content\":{ ";
+            WI6041 += "\n\"snresult\":{ ";
+            WI6041 += "\n}, ";
+            WI6041 += "\n\"testresult\":{ ";
+            WI6041 += "\n\"psn\":\"" + PSN + "\", ";
+            WI6041 += "\n\"workordernumber\":\"100000236815\", ";
+            WI6041 += "\n\"testStationId\":\"" + StationID + "\", ";
+            WI6041 += "\n\"testStationName\":\"" + Station + "\", ";
+            WI6041 += "\n\"linename\":\"" + Line + "\", ";
+            WI6041 += "\n\"hostname\":\"admin-PC-0930\", ";
+            WI6041 += "\n\"testTime\":\"" + string.Format("{0:yyyy-MM-dd HH:mm:ss.fff}", DateTime.Now) + "\", ";
+            WI6041 += "\n\"testModel\":\"S87567GB002_BLK1\", ";
+            WI6041 += "\n\"testWorkID\":\"\", ";
+            WI6041 += "\n\"Fixture\":\"\", ";
+            WI6041 += "\n\"FixtureSN\":\"\", ";
+            WI6041 += "\n\"Powersupply\":\"\", ";
+            WI6041 += "\n\"PowersupplySN\":\"\", ";
+            WI6041 += "\n\"Instrument\":\"\", ";
+            WI6041 += "\n\"InstrumentSN\":\"\", ";
+            WI6041 += "\n\"Operator\":\"\", ";
+            WI6041 += "\n\"testVersion\":\"V1.0.1\" ";
+            WI6041 += "\n}, ";
+            WI6041 += "\n\"itemresult\":[ ";
+            WI6041 += "\n],";
+            WI6041 += "\n\"specialitem\":[ ";
+            WI6041 += "\n] ";
+            WI6041 += "\n}, ";
+            WI6041 += "\n\"state\":\"pass\", ";
+            WI6041 += "\n\"errcode\":\"\", ";
+            WI6041 += "\n\"errmessage\":\"\"} ";
+            WI6041 += "\n}";
             JObject jo = MES_Interface(WI6041, encryptionKey);
             if (jo["state"].ToString() == "false")
             {
+                t = false;
                 System_Bll.WriteLogToDB(new Entity.Base_Log
                 {
                     CreateUserID = FrmLogin.LoginUserID,
                     CreateUserName = FrmLogin.loginUserName,
                     LocalIP = FrmLogin.LocalIP,
-                    LogMessage = "MES鎺ュ彛WI6041鏁版嵁鎻愪氦澶辫触",
-                    Type = "鍖呰绾�",
+                    LogMessage = "WI6041鎺ュ彛璋冪敤澶辫触锛�" + jo["content"].ToString(),
+                    Type = "鍥涚爜鍚堜竴",
                     ClassName = typeof(FrmLogin).ToString()
                 });
-
-                string a = string.Format("{0:yyyy-MM-dd HH:mm:ss.fff}", DateTime.Now);
                 return false;
             }
             return true;

--
Gitblit v1.9.3