Browse Source

AOI文件解析

callm 4 years ago
parent
commit
889fa3323b

+ 1 - 1
UAS_AutoPass/App.config

@@ -12,7 +12,7 @@
     <userSettings>
         <UAS_AutoPass.Properties.Settings>
             <setting name="MES" serializeAs="String">
-                <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=yitoadt.wicp.io)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
+                <value>Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</value>
             </setting>
         </UAS_AutoPass.Properties.Settings>
         <UAS_AutoPast.Properties.Settings>

+ 176 - 255
UAS_AutoPass/AutoAnalysisXml.cs

@@ -86,7 +86,7 @@ namespace UAS_AutoPass
             stw.StartPosition = FormStartPosition.CenterScreen;
             stw.ShowDialog();
             List<string> CacheInf = new List<string>();
-            DB = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address,ma_inneraddress from master", "select");
+            DB = (DataTable)dh.ExecuteSql("select ms_pwd,ma_user,ma_address,ma_inneraddress from master where ma_user='MES'", "select");
             Master.DataSource = DB;
             Master.DisplayMember = "ma_user";
             Master.ValueMember = "ma_user";
@@ -103,7 +103,7 @@ namespace UAS_AutoPass
             {
                 if (Master.Text == DB.Rows[i]["ma_user"].ToString())
                 {
-                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=" + DB.Rows[i]["ma_user"].ToString() + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=117.25.180.218)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=" + DB.Rows[i]["ma_user"].ToString() + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                     dh = new DataHelper();
                 }
             }
@@ -151,7 +151,7 @@ namespace UAS_AutoPass
             {
                 if (Master.Text == DB.Rows[i]["ma_user"].ToString())
                 {
-                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=" + DB.Rows[i]["ma_user"].ToString() + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=117.25.180.218)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+                    DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=" + DB.Rows[i]["ma_user"].ToString() + ";Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
                     dh = new DataHelper();
                     LogicHandler.dh = new DataHelper();
                 }
@@ -193,7 +193,7 @@ namespace UAS_AutoPass
             {
                 try
                 {
-                    using (Stream stream = File.Open(e.FullPath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
+                    using (Stream stream = File.Open(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                     {
                         if (stream != null)
                             break;
@@ -219,85 +219,181 @@ namespace UAS_AutoPass
 
         private void TxtHandleProcess(string FileName)
         {
-            //获取文件夹命名的SN号
-            string sncode = FileName.Substring(FileName.LastIndexOf(@"\") + 1).Split('.')[0];
-
-            //string makecode = "";
-            //string oMSID = "";
-            //string status = "";
-            //string oErrMessage = "";
-            //string test_result = "";
-            //string test_date = "";
-
-            //if (!LogicHandler.GetMakeInfo(sncode, out makecode, out status, out oErrMessage))
-            //{
-            //    OperateResult.AppendText(oErrMessage + "\n");
-            //    tipform.startthread(oErrMessage, "NG");
-            //    return;
-            //}
-            //if (!LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
-            //{
-            //    OperateResult.AppendText(oErrMessage + "\n");
-            //    tipform.startthread(oErrMessage, "NG");
-            //    return;
-            //}
-
-            ////获取序列号ID最大的工单
-            //dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id from makeserial where ms_sncode='" + sncode + "' order by ms_id desc", "select");
-            //if (dt.Rows.Count > 0)
-            //{
-            //    ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
-            //    makecode = dt.Rows[0]["ms_makecode"].ToString();
-            //    switch (test_result)
-            //    {
-            //        case "OK":
-            //            if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out oErrMessage))
-            //            {
-            //                OperateResult.AppendText(oErrMessage + "\n");
-            //                tipform.startthread(oErrMessage, test_result);
-            //                return;
-            //            }
-            //            tipform.startthread("序列号 " + sncode + "通过检测", test_result);
-            //            break;
-            //        case "NG":
-            //            //RecordBadInfo(sncode, makecode, FileName, "", badcode.ToArray(), badlocation.ToArray());
-            //            //所有的序列号均采集为良品
-            //            if (!LogicHandler.SetTestNGDetail(sncode, makecode, iusercode, isource, test_result, out oErrMessage))
-            //            {
-            //                OperateResult.AppendText(oErrMessage + "\n");
-            //                tipform.startthread(oErrMessage, test_result);
-            //                return;
-            //            }
-            //            tipform.startthread("序列号 " + sncode + "未通过检测", test_result);
-            //            break;
-            //        default:
-            //            break;
-            //    }
-            //    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, FileName, test_result == "NG" ? "1" : "0", "0");
-            //}
-
             List<string> badcode = new List<string>();
-            List<string> location = new List<string>();
+            List<string> badlocation = new List<string>();
+            List<string> badprod = new List<string>();
             StreamReader sR = File.OpenText(FileName);
             string nextLine;
-            int Line = 0;
             string[] data = null;
             while ((nextLine = sR.ReadLine()) != null)
             {
-                Line = Line + 1;
-                if (Line == 3)
+                data = nextLine.Split(';');
+            }
+            string SoftVersion = "";
+            string SN = "";
+            string Machine = "";
+            string EmName = "";
+            string Day = "";
+            string Time = "";
+            string Result = "";
+            string TotalPart = "";
+            string NGPart = "";
+            int MissTest = 0;
+            for (int i = 0; i < data.Length; i++)
+            {
+                switch (i.ToString())
                 {
-                    Console.WriteLine(nextLine);
-                    data = nextLine.Split(';');
+                    case "0":
+                        SoftVersion = data[i];
+                        break;
+                    case "1":
+                        SN = data[i];
+                        break;
+                    case "2":
+                        Machine = data[i];
+                        break;
+                    case "4":
+                        EmName = data[i];
+                        break;
+                    case "6":
+                        Day = data[i];
+                        break;
+                    case "7":
+                        Time = data[i];
+                        break;
+                    case "8":
+                        Result += data[i];
+                        break;
+                    case "9":
+                        Result += data[i];
+                        break;
+                    case "10":
+                        Result += data[i];
+                        break;
+                    case "11":
+                        Result += data[i];
+                        break;
+                    case "13":
+                        TotalPart = data[i];
+                        break;
+                    case "14":
+                        NGPart = data[i];
+                        break;
+                    default:
+                        break;
                 }
             }
-            for (int i = 0; i < data.Length; i++)
+            if (data.Length > 15)
             {
-                Console.WriteLine(data[i]);
+                for (int i = 15; i < data.Length; i++)
+                {
+                    switch ((i - 15) % 6)
+                    {
+                        case 0:
+                            badlocation.Add(data[i]);
+                            break;
+                        case 1:
+                            badprod.Add(data[i]);
+                            break;
+                        case 2:
+                            badcode.Add(data[i].ToUpper());
+                            break;
+                        default:
+                            break;
+                    }
+                }
             }
             sR.Close();
+            //如果没有不良位号等数据则是15个数据
+            if (Result == "0001")
+            {
+                if (data.Length > 16)
+                {
+                    MissTest = -1;
+                    Result = "NG";
+                }
+                else
+                {
+                    Result = "OK";
+                }
+            }
+            else
+            {
+                Result = "OK";
+            }
+            string makecode = "";
+            string oErrMessage = "";
+            string oMSID = "";
+            if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, SN, iusercode, out makecode, out oMSID, out oErrMessage))
+            {
+                //获取序列号ID最大的工单
+                dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id from makeserial where ms_sncode='" + SN + "' order by ms_id desc", "select");
+                if (dt.Rows.Count > 0)
+                {
+                    ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
+                    makecode = dt.Rows[0]["ms_makecode"].ToString();
+                    switch (Result)
+                    {
+                        case "OK":
+                            if (!LogicHandler.SetStepResult(makecode, isource, SN, "自动过站采集", Result, iusercode, out oErrMessage))
+                            {
+                                OperateResult.AppendText(oErrMessage + "\n");
+                                tipform.startthread(oErrMessage, Result);
+                                return;
+                            }
+                            tipform.startthread("序列号 " + SN + "通过检测", Result);
+                            break;
+                        case "NG":
+                            RecordBadInfo(SN, makecode, FileName, "", badcode.ToArray(), badlocation.ToArray(), badprod.ToArray());
+                            //所有的序列号均采集为良品
+                            if (!LogicHandler.SetTestNGDetail(SN, makecode, iusercode, isource, Result, out oErrMessage))
+                            {
+                                OperateResult.AppendText(oErrMessage + "\n");
+                                tipform.startthread(oErrMessage, Result);
+                                return;
+                            }
+                            tipform.startthread("序列号 " + SN + "未通过检测", Result);
+                            break;
+                        default:
+                            break;
+                    }
+                    LogicHandler.AutoPassLog(SN, isource, makecode, Day + Time, istepcode, ilinecode, SoftVersion, Result == "NG" ? "-1" : "0", "0", MissTest, TotalPart, NGPart);
+                    FileName = FileName.Substring(FileName.LastIndexOf(@"\") + 1);
+                    FileInfo file = new FileInfo(FolderPath.Text + @"\" + FileName);
+                    if (file.Exists)
+                    {
+                        try
+                        {
+                            for (int i = 1; i <= 20; i++)
+                            {
+                                if (!File.Exists(BackUpFolderPath.Text + @"\" + FileName))
+                                {
+                                    file.MoveTo(BackUpFolderPath.Text + @"\" + FileName);
+                                    OperateResult.AppendText("成功解析文件" + FileName + "\n");
+                                    break;
+                                }
+                                else if (!File.Exists(BackUpFolderPath.Text + @"\" + FileName.Split('.')[0] + "(" + i + ")" + "." + FileName.Split('.')[1]))
+                                {
+                                    file.MoveTo(BackUpFolderPath.Text + @"\" + FileName.Split('.')[0] + "(" + i + ")" + "." + FileName.Split('.')[1]);
+                                    OperateResult.AppendText("成功解析文件" + FileName + "\n");
+                                    break;
+                                }
+                            }
+                        }
+                        catch (Exception ex)
+                        {
+                            OperateResult.AppendText(FileName + ex.Message + "\n");
+                        }
+                    }
+                }
+            }
+            else
+            {
+                OperateResult.AppendText(oErrMessage + "\n");
+                tipform.startthread(oErrMessage, Result);
+                return;
+            }
         }
-
         /// <summary>
         /// 使用进程处理文件,避免界面假死
         /// </summary>
@@ -376,11 +472,11 @@ namespace UAS_AutoPass
                 if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
                 {
                     //插入日志
-                    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, FileName, test_result == "NG" ? "-1" : "0", "-1");
+                    LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, FileName, test_result == "NG" ? "-1" : "0", "-1", 0, "", "");
                     //如果是不良品记录日志,用于测试采集判负
                     if (test_result == "NG")
                     {
-                        RecordBadInfo(sncode, makecode, FileName, combinecode, badcode.ToArray(), badlocation.ToArray());
+                        RecordBadInfo(sncode, makecode, FileName, combinecode, badcode.ToArray(), badlocation.ToArray(), null);
                     }
                     if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
                     {
@@ -454,7 +550,7 @@ namespace UAS_AutoPass
                                 tipform.startthread("序列号 " + sncode + "通过检测", test_result);
                                 break;
                             case "NG":
-                                RecordBadInfo(sncode, makecode, FileName, "", badcode.ToArray(), badlocation.ToArray());
+                                RecordBadInfo(sncode, makecode, FileName, "", badcode.ToArray(), badlocation.ToArray(), null);
                                 //所有的序列号均采集为良品
                                 if (!LogicHandler.SetTestNGDetail(sncode, makecode, iusercode, isource, test_result, out oErrMessage))
                                 {
@@ -467,7 +563,7 @@ namespace UAS_AutoPass
                             default:
                                 break;
                         }
-                        LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, FileName, test_result == "NG" ? "1" : "0", "0");
+                        LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, FileName, test_result == "NG" ? "1" : "0", "0", 0, "", "");
                     }
                 }
                 else
@@ -505,16 +601,16 @@ namespace UAS_AutoPass
             }
         }
 
-        private void RecordBadInfo(string sncode, string makecode, string filename, string combine, string[] badcode, string[] badlocation)
+        private void RecordBadInfo(string sncode, string makecode, string filename, string combine, string[] badcode, string[] badlocation, string[] soncode)
         {
             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) select :ID");
+            sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status,mb_badlocation,mb_soncode) select :ID");
             sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',");
-            sql.Append(":bc_code,'" + ibadgroup + "','','0',:location from make left join makeSerial on ms_makecode=ma_code ");
+            sql.Append(":bc_code,'" + ibadgroup + "','','0',:location,:soncode 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", "soncode" }, ID, badcode, badlocation, soncode);
             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");
@@ -604,185 +700,10 @@ namespace UAS_AutoPass
 
         private void BatchAnalysus_Click(object sender, EventArgs e)
         {
-            var AllXmls = Directory.GetFiles(FolderPath.Text, "*.xml");
+            var AllXmls = Directory.GetFiles(FolderPath.Text, "*.txt");
             foreach (var Xml in AllXmls)
             {
-                string fileName = Xml.Substring(Xml.LastIndexOf(@"\") + 1, Xml.Length - Xml.LastIndexOf(@"\") - 1);
-                string test_date = "";
-                string test_result = "";
-                string test_sn = "";
-                string imageurl = "";
-                string oMSID = "";
-                string oErrMessage = "";
-                XmlReader myReader = XmlReader.Create(FolderPath.Text + @"\" + fileName);
-                OperateResult.AppendText("读取文件" + fileName + "\n");
-                //获取采集的项目名称
-                List<string> badcode = new List<string>();
-                //获取采集项目的结果
-                List<string> badlocation = new List<string>();
-                while (myReader.Read())
-                {
-                    if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "test" && myReader.IsStartElement())
-                    {
-                        test_sn = myReader.GetAttribute("test_sn");
-                        test_result = myReader.GetAttribute("test_result");
-                        test_date = myReader.GetAttribute("test_date");
-                        imageurl = myReader.GetAttribute("imgurl");
-                    }
-                    if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_reason" && myReader.IsStartElement())
-                    {
-                        badcode.Add(myReader.ReadInnerXml() + " ");
-                    }
-                    if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_location" && myReader.IsStartElement())
-                    {
-                        badlocation.Add(myReader.ReadInnerXml() + " ");
-                    }
-                }
-                myReader.Close();
-                //获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
-                string sncode = fileName.Substring(0, 1) == "-" ? "" : fileName.Split('.')[0];
-                string makecode = "";
-                //获取序列号ID最大的工单号,所有序列号都测试为良品
-                if (sncode == "")
-                {
-                    //获取资源,线别,工序相等,并且状态在线的序列号进行分配
-                    sql.Clear();
-                    sql.Append("select ms_sncode,ms_makecode from makeserial left join source on sc_code=ms_sccode where ");
-                    sql.Append(" sc_linecode='" + ilinecode + "' and ms_nextstepcode='" + istepcode + "' and ms_status=1 order by ms_id");
-                    dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                    if (dt.Rows.Count > 0)
-                    {
-                        makecode = dt.Rows[0]["ms_makecode"].ToString();
-                        sncode = dt.Rows[0]["ms_sncode"].ToString();
-                    }
-                    else
-                    {
-                        OperateResult.AppendText("当前线别在" + istepcode + "无可分配序列号");
-                        continue;
-                    }
-                    //-2-NG2017/10/2514:46:29.xml取第二位版号
-                    string combinecode = fileName.Substring(1, 1);
-                    if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
-                    {
-                        //插入日志
-                        LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, fileName, test_result == "NG" ? "-1" : "0", "-1");
-                        //如果是不良品记录日志,用于测试采集判负
-                        if (test_result == "NG")
-                        {
-                            RecordBadInfo(sncode, makecode, fileName, combinecode, badcode.ToArray(), badlocation.ToArray());
-                        }
-                        if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
-                        {
-                            OperateResult.AppendText(oErrMessage + "\n");
-                            continue;
-                        }
-                    }
-                    else
-                    {
-                        OperateResult.AppendText(oErrMessage + "\n");
-                        continue;
-                    }
-                }
-                else
-                {
-                    string status = "";
-                    string errmessage = "";
-                    bool NoteAlready = false;
-                    LogicHandler.GetMakeInfo(sncode, out makecode, out status, out errmessage);
-                    if (ma_code.Text != makecode && makecode != "" && ma_code.Text != "" && status != "2")
-                    {
-                        string ChangeMakeCode = MessageBox.Show(this.ParentForm, "序列号" + sncode + "所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                        //如果选择不切换赋值当前界面工单
-                        if (ChangeMakeCode != "Yes")
-                        {
-                            makecode = ma_code.Text;
-                        }
-                        else
-                        {
-                            NoteAlready = true;
-                        }
-                    }
-                    if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out makecode, out oMSID, out oErrMessage))
-                    {
-                        if (!NoteAlready)
-                        {
-                            if (makecode != ma_code.Text && ma_code.Text != "")
-                            {
-                                string ChangeMakeCode = MessageBox.Show(this.ParentForm, "序列号所属工单不同,是否切换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
-                                //如果选择不切换赋值当前界面工单
-                                if (ChangeMakeCode == "Yes")
-                                {
-                                    ma_code.Text = makecode;
-                                }
-                                else
-                                {
-                                    OperateResult.AppendText(">>请重新采集序列号\n");
-                                    continue;
-                                }
-                            }
-                        }
-                        //获取序列号ID最大的工单
-                        dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id from makeserial where ms_sncode='" + sncode + "' order by ms_id desc", "select");
-                        if (dt.Rows.Count > 0)
-                        {
-                            ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
-                            makecode = dt.Rows[0]["ms_makecode"].ToString();
-                            switch (test_result)
-                            {
-                                case "OK":
-                                    if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out oErrMessage))
-                                    {
-                                        OperateResult.AppendText(oErrMessage + "\n");
-                                        continue;
-                                    }
-                                    break;
-                                case "NG":
-                                    RecordBadInfo(sncode, makecode, fileName, "", badcode.ToArray(), badlocation.ToArray());
-                                    //所有的序列号均采集为良品
-                                    if (!LogicHandler.SetTestNGDetail(sncode, makecode, iusercode, isource, test_result, out oErrMessage))
-                                    {
-                                        OperateResult.AppendText(oErrMessage + "\n");
-                                        continue;
-                                    }
-                                    break;
-                                default:
-                                    break;
-                            }
-                            LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, fileName, test_result == "NG" ? "1" : "0", "0");
-                        }
-                    }
-                    else
-                    {
-                        OperateResult.AppendText(oErrMessage + "\n");
-                        continue;
-                    }
-                }
-                FileInfo file = new FileInfo(FolderPath.Text + @"\" + fileName);
-                if (file.Exists)
-                {
-                    try
-                    {
-                        for (int i = 1; i <= 20; i++)
-                        {
-                            if (!File.Exists(BackUpFolderPath.Text + @"\" + fileName))
-                            {
-                                file.MoveTo(BackUpFolderPath.Text + @"\" + fileName);
-                                OperateResult.AppendText("成功解析文件" + fileName + "\n");
-                                break;
-                            }
-                            else if (!File.Exists(BackUpFolderPath.Text + @"\" + fileName.Split('.')[0] + "(" + i + ")" + "." + fileName.Split('.')[1]))
-                            {
-                                file.MoveTo(BackUpFolderPath.Text + @"\" + fileName.Split('.')[0] + "(" + i + ")" + "." + fileName.Split('.')[1]);
-                                OperateResult.AppendText("成功解析文件" + fileName + "\n");
-                                break;
-                            }
-                        }
-                    }
-                    catch (Exception ex)
-                    {
-                        OperateResult.AppendText(fileName + ex.Message + "\n");
-                    }
-                }
+                TxtHandleProcess(Xml);
             }
         }
 

+ 2 - 2
UAS_AutoPass/Properties/Settings.Designer.cs

@@ -26,8 +26,8 @@ namespace UAS_AutoPass.Properties {
         [global::System.Configuration.UserScopedSettingAttribute()]
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
         [global::System.Configuration.DefaultSettingValueAttribute("Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false" +
-            ";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=yitoadt.wic" +
-            "p.io)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
+            ";Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10." +
+            "10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));")]
         public string MES {
             get {
                 return ((string)(this["MES"]));

+ 1 - 1
UAS_AutoPass/Properties/Settings.settings

@@ -3,7 +3,7 @@
   <Profiles />
   <Settings>
     <Setting Name="MES" Type="System.String" Scope="User">
-      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=yitoadt.wicp.io)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
+      <Value Profile="(Default)">Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));</Value>
     </Setting>
   </Settings>
 </SettingsFile>

+ 6 - 6
UAS_AutoPass/ToolClass/BaseUtil.cs

@@ -19,7 +19,7 @@ namespace UAS_AutoPass.ToolClass
                 XmlNode node = doc.CreateXmlDeclaration("1.0", "utf-8", "");
                 doc.AppendChild(node);
                 //创建根节点  
-                XmlElement xeRoot = doc.CreateElement("CacheInf");
+                XmlElement xeRoot = doc.CreateElement("cacheInfo");
                 doc.AppendChild(xeRoot);
                 doc.Save(iSN + ".xml");
             }
@@ -38,7 +38,7 @@ namespace UAS_AutoPass.ToolClass
                 XmlReader reader = XmlReader.Create(AutoAnalysisXml.CachePath, settings);
                 doc.Load(reader);
                 //先得到根节点
-                XmlNode rootNode = doc.SelectSingleNode("CacheInf");
+                XmlNode rootNode = doc.SelectSingleNode("cacheInfo");
                 //再由根节点去找制定的节点
                 XmlNodeList nodeList = rootNode.ChildNodes;
                 foreach (XmlNode node in nodeList)
@@ -73,7 +73,7 @@ namespace UAS_AutoPass.ToolClass
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message+e.StackTrace);
+                Console.WriteLine(e.Message + e.StackTrace);
                 return "";
             }
         }
@@ -90,7 +90,7 @@ namespace UAS_AutoPass.ToolClass
                 XmlReader reader = XmlReader.Create(AutoAnalysisXml.CachePath, settings);
                 doc.Load(reader);
                 //先得到根节点
-                XmlNode rootNode = doc.SelectSingleNode("CacheInf");
+                XmlNode rootNode = doc.SelectSingleNode("cacheInfo");
                 //再由根节点去找制定的节点
                 XmlNodeList nodeList = rootNode.ChildNodes;
                 bool flag = false;
@@ -120,9 +120,9 @@ namespace UAS_AutoPass.ToolClass
                 reader.Close();
                 doc.Save(AutoAnalysisXml.CachePath);
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
+                Console.WriteLine(ex.Message + ex.StackTrace);
             }
         }
     }

+ 64 - 12
UAS_AutoPass/ToolClass/DataHelper.cs

@@ -9,9 +9,10 @@ namespace UAS_AutoPass.ToolClass
     class DataHelper
     {
         //系统默认的的连接字符串
-        private string ConnectionStrings = Properties.Settings.Default.Properties["MES"].DefaultValue.ToString();
+        private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        public static string DBConnectionString;
+        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=MES;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+
         public static OracleConnection connection = null;
         OracleCommand command = null;
         int ReconnectTime = 0;
@@ -54,20 +55,35 @@ namespace UAS_AutoPass.ToolClass
         {
             DataTable dt = new DataTable();
             string sql = "select " + Field + " from " + TableName + " where " + Condition;
-
             command = new OracleCommand(sql, connection);
-            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter();
             ad.SelectCommand = command;
-            ad.Fill(dt);
-            ad.Dispose();
-            command.Dispose();
+            try
+            {
+                ad.Fill(dt);
+                ReconnectTime = 0;
+            }
+            catch (Exception)
+            {
+                if (ReconnectTime == 0)
+                {
+                    ReconnectTime++;
+                    connection = new OracleConnection(DBConnectionString);
+                    //成功执行后将重复连接数置为0
+                    dt = (DataTable)getFieldDataByCondition(TableName, Field, Condition);
+                }
+            }
+
             if (dt.Rows.Count > 0)
             {
+                ad.Dispose();
+                command.Dispose();
                 return dt.Rows[0][0];
             }
             else
             {
+                ad.Dispose();
+                command.Dispose();
                 return "";
             }
         }
@@ -631,13 +647,40 @@ namespace UAS_AutoPass.ToolClass
                     }
                     break;
                 case "DELETE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        command.Connection.Open();
+                        result = command.ExecuteNonQuery();
+                    }
                     break;
                 case "UPDATE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        command.Connection.Open();
+                        result = command.ExecuteNonQuery();
+                    }
                     break;
                 case "INSERT":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        command.Connection = new OracleConnection(DBConnectionString);
+                        command.Connection.Open();
+                        result = command.ExecuteNonQuery();
+                    }
                     break;
             }
             command.Dispose();
@@ -720,7 +763,7 @@ namespace UAS_AutoPass.ToolClass
         public string[] GetSEQ(string SeqName, int Num)
         {
             DataTable dt = new DataTable();
-            dt = (DataTable)ExecuteSql("select " + SeqName + ".nextval from (select 1 from OQCITEMSAMPLES where rownum<" + (Num + 1) + ")", "select");
+            dt = (DataTable)ExecuteSql("select " + SeqName + ".nextval from (select 1 from Makebad where rownum<" + (Num + 1) + ")", "select");
             string[] SerialNum = new string[dt.Rows.Count];
             for (int i = 0; i < dt.Rows.Count; i++)
             {
@@ -970,7 +1013,16 @@ namespace UAS_AutoPass.ToolClass
             command.CommandType = CommandType.StoredProcedure;
             for (int i = 0; i < param.Length; i++)
                 command.Parameters.Add(new OracleParameter(param[i].ToString(), OracleDbType.Varchar2, 200, param[i], ParameterDirection.InputOutput));
-            command.ExecuteNonQuery();
+            try
+            {
+                command.ExecuteNonQuery();
+            }
+            catch (Exception)
+            {
+                command.Connection = new OracleConnection(DBConnectionString);
+                command.Connection.Open();
+                command.ExecuteNonQuery();
+            }
             for (int i = 0; i < command.Parameters.Count; i++)
                 param[i] = command.Parameters[i].Value.ToString();
             command.Dispose();

+ 4 - 4
UAS_AutoPass/ToolClass/LogicHandler.cs

@@ -30,13 +30,13 @@ namespace UAS_AutoPass.ToolClass
                 return false;
         }
 
-        public static void AutoPassLog(string iSN, string iSource, string iMakeCode, string iDate, string iStepCode, string iLineCode, string iFileName, string iIFNG,string iIFAutoSN)
+        public static void AutoPassLog(string iSN, string iSource, string iMakeCode, string iDate, string iStepCode, string iLineCode, string iFileName, string iIFNG, string iIFAutoSN, int iMiss, string iTestPart, string iNGPart)
         {
             sql.Clear();
             sql.Append("insert into AUTOSCANLOG(as_id,as_indate,as_testdate,as_sourcecode,as_stepcode,");
-            sql.Append("as_linecode,as_makecode,as_sncode,as_filename,as_ifng,as_autosn)values(AUTOSCANLOG_seq.nextval,");
-            sql.Append("sysdate,to_date('" + iDate + "','yyyy-mm-dd,hh24:mi:ss'),'" + iSource + "','" + iStepCode + "','" + iLineCode + "','" + iMakeCode + "',");
-            sql.Append("'" + iSN + "','" + iFileName + "','" + iIFNG + "','"+iIFAutoSN+"')");
+            sql.Append("as_linecode,as_makecode,as_sncode,as_filename,as_ifng,as_autosn,as_realng,as_testpart,as_ngpart)values(AUTOSCANLOG_seq.nextval,");
+            sql.Append("sysdate,to_date('" + iDate + "','yyyymmddhh24miss'),'" + iSource + "','" + iStepCode + "','" + iLineCode + "','" + iMakeCode + "',");
+            sql.Append("'" + iSN + "','" + iFileName + "','" + iIFNG + "','" + iIFAutoSN + "','" + iMiss + "','" + iTestPart + "','" + iNGPart + "')");
             dh.ExecuteSql(sql.ToString(), "select");
         }
 

+ 0 - 1
UAS_AutoPass/UAS_AutoPass.csproj

@@ -160,7 +160,6 @@
       <DependentUpon>Settings.settings</DependentUpon>
       <DesignTimeSharedInput>True</DesignTimeSharedInput>
     </Compile>
-    <None Include="UAS_AutoPass_TemporaryKey.pfx" />
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />