Browse Source

自动过站解析器修改

Hcsy 6 years ago
parent
commit
766cb4a127
1 changed files with 37 additions and 32 deletions
  1. 37 32
      UAS_AutoPass/AutoAnalysisXml.cs

+ 37 - 32
UAS_AutoPass/AutoAnalysisXml.cs

@@ -13,7 +13,7 @@ using System.Text;
 namespace UAS_AutoPass
 {
     public partial class AutoAnalysisXml : Form
-    {         
+    {
 
         DataHelper dh;
 
@@ -31,7 +31,7 @@ namespace UAS_AutoPass
         /// </summary>
         string isource;
 
-        Tip tipform ;
+        Tip tipform;
 
         Thread InitDB;
         /// <summary>
@@ -78,7 +78,7 @@ namespace UAS_AutoPass
 
         private void Form1_Load(object sender, EventArgs e)
         {
-            tipform.Show(); 
+            tipform.Show();
             CheckForIllegalCrossThreadCalls = false;
             FormBorderStyle = FormBorderStyle.FixedSingle;
             InitDB = new Thread(ConnectDB);
@@ -100,7 +100,7 @@ namespace UAS_AutoPass
                 Master.Text = BaseUtil.GetCacheData("Master").ToString();
                 AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
             }
-            catch (Exception ex) { Console.WriteLine(ex.Message); }
+            catch (Exception ex) { MessageBox.Show(ex.Message); }
             for (int i = 0; i < DB.Rows.Count; i++)
             {
                 if (Master.Text == DB.Rows[i]["ma_user"].ToString())
@@ -228,19 +228,29 @@ namespace UAS_AutoPass
                     test_date = myReader.GetAttribute("test_date");
                     imageurl = myReader.GetAttribute("imgurl");
                 }
-                if (myReader.NodeType == XmlNodeType.Text)
+                //if (myReader.NodeType == XmlNodeType.Text)
+                //{
+                //    if (code_or_location % 2 == 0)
+                //    {
+                //        badcode.Add(myReader.Value);
+                //        code_or_location++;
+                //    }
+                //    else
+                //    {
+                //        badlocation.Add(myReader.Value);
+                //        code_or_location++;
+                //    }
+                //}
+                if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_reason" && myReader.IsStartElement())
                 {
-                    if (code_or_location % 2 == 0)
-                    {
-                        badcode.Add(myReader.Value);
-                        code_or_location++;
-                    }
-                    else
-                    {
-                        badlocation.Add(myReader.Value);
-                        code_or_location++;
-                    }
+                    badcode.Add(myReader.ReadInnerXml() + " ");
                 }
+                if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_location" && myReader.IsStartElement())
+                {
+                    badlocation.Add(myReader.ReadInnerXml() + " ");
+                }
+
+
             }
             myReader.Close();
             //获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
@@ -310,7 +320,7 @@ namespace UAS_AutoPass
                         NoteAlready = true;
                     }
                 }
-                if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
+                if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
                 {
                     if (!NoteAlready)
                     {
@@ -381,7 +391,7 @@ namespace UAS_AutoPass
                         if (!File.Exists(BackUpFolderPath.Text + @"\" + e.Name))
                         {
                             file.MoveTo(BackUpFolderPath.Text + @"\" + e.Name);
-                            OperateResult.AppendText("成功解析文件" + e.Name + "\n"); 
+                            OperateResult.AppendText("成功解析文件" + e.Name + "\n");
                             break;
                         }
                         else if (!File.Exists(BackUpFolderPath.Text + @"\" + e.Name.Split('.')[0] + "(" + i + ")" + "." + e.Name.Split('.')[1]))
@@ -412,11 +422,11 @@ namespace UAS_AutoPass
             string[] ID = dh.GetSEQ("makebad_seq", badcode.Length);
             sql.Clear();
             sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
-            sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status,mb_badremark,mb_stauts) select :ID");
+            sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status,mb_badremark) select :ID");
             sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',");
-            sql.Append(":bc_code,'" + ibadgroup + "','','0',:location,'-1' from make left join makeSerial on ms_makecode=ma_code ");
+            sql.Append(":bc_code,'" + ibadgroup + "','','0',:location from make left join makeSerial on ms_makecode=ma_code ");
             sql.Append("where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'");
-            dh.BatchInsert(sql.ToString(), new string[] {"ID", "bc_code", "location" }, ID, badcode, badlocation);
+            dh.BatchInsert(sql.ToString(), new string[] { "ID", "bc_code", "location" }, ID, badcode, badlocation);
             sql.Clear();
             sql.Append("update makebad set mb_badname=(select DISTINCT bc_name from badcode where bc_code=mb_badcode),mb_bgname=(select DISTINCT bg_name from badgroup where bg_code=mb_bgcode) ");
             sql.Append("where mb_id=:ID");
@@ -509,7 +519,7 @@ namespace UAS_AutoPass
             var AllXmls = Directory.GetFiles(FolderPath.Text, "*.xml");
             foreach (var Xml in AllXmls)
             {
-                string fileName = Xml.Substring(Xml.LastIndexOf(@"\")+1, Xml.Length- Xml.LastIndexOf(@"\")-1);
+                string fileName = Xml.Substring(Xml.LastIndexOf(@"\") + 1, Xml.Length - Xml.LastIndexOf(@"\") - 1);
                 string test_date = "";
                 string test_result = "";
                 string test_sn = "";
@@ -532,18 +542,13 @@ namespace UAS_AutoPass
                         test_date = myReader.GetAttribute("test_date");
                         imageurl = myReader.GetAttribute("imgurl");
                     }
-                    if (myReader.NodeType == XmlNodeType.Text)
+                    if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_reason" && myReader.IsStartElement())
                     {
-                        if (code_or_location % 2 == 0)
-                        {
-                            badcode.Add(myReader.Value);
-                            code_or_location++;
-                        }
-                        else
-                        {
-                            badlocation.Add(myReader.Value);
-                            code_or_location++;
-                        }
+                        badcode.Add(myReader.ReadInnerXml() + " ");
+                    }
+                    if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_location" && myReader.IsStartElement())
+                    {
+                        badlocation.Add(myReader.ReadInnerXml() + " ");
                     }
                 }
                 myReader.Close();