|
@@ -262,6 +262,7 @@ namespace FileWatcher
|
|
|
{
|
|
|
OperateResult.AppendText(oErrMessage + "\n");
|
|
|
tipform.startthread(oErrMessage, Result);
|
|
|
+ File.Delete(FileName);
|
|
|
}
|
|
|
tipform.startthread("序列号 " + SN + "通过检测", Result);
|
|
|
OperateResult.AppendText("序列号 " + SN + "通过检测" + "\n");
|
|
@@ -273,6 +274,7 @@ namespace FileWatcher
|
|
|
{
|
|
|
OperateResult.AppendText(oErrMessage + "\n");
|
|
|
tipform.startthread(oErrMessage, Result);
|
|
|
+ File.Delete(FileName);
|
|
|
}
|
|
|
tipform.startthread("序列号 " + SN + "未通过检测", Result);
|
|
|
OperateResult.AppendText("序列号 " + SN + "未通过检测" + "\n");
|
|
@@ -280,14 +282,13 @@ namespace FileWatcher
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- File.Delete(FileName);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
OperateResult.AppendText(oErrMessage + "\n");
|
|
|
tipform.startthread(oErrMessage, Result);
|
|
|
- File.Delete(FileName);
|
|
|
+ // File.Delete(FileName);
|
|
|
}
|
|
|
}
|
|
|
else if (Device.Text == "测试设备")
|
|
@@ -351,7 +352,7 @@ namespace FileWatcher
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- File.Delete(FileName);
|
|
|
+ //File.Delete(FileName);
|
|
|
OperateResult.AppendText(oErrMessage + "\n");
|
|
|
tipform.startthread(oErrMessage, Result);
|
|
|
}
|
|
@@ -372,7 +373,7 @@ namespace FileWatcher
|
|
|
istepcode = dt.Rows[0]["sc_stepcode"].ToString();
|
|
|
ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
|
|
|
}
|
|
|
- if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
|
|
|
+ if (LogicHandler.CheckStepSNAndMacode("", isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
|
|
|
{
|
|
|
ma_code.Text = makecode;
|
|
|
if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
|
|
@@ -409,7 +410,7 @@ namespace FileWatcher
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- File.Delete(FileName);
|
|
|
+ // File.Delete(FileName);
|
|
|
OperateResult.AppendText(oErrMessage + "\n");
|
|
|
tipform.startthread(oErrMessage, Result);
|
|
|
}
|
|
@@ -426,192 +427,6 @@ namespace FileWatcher
|
|
|
/// <summary>
|
|
|
/// 使用进程处理文件,避免界面假死
|
|
|
/// </summary>
|
|
|
- private void XmlHandleProcess(string FileName)
|
|
|
- {
|
|
|
- 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.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())
|
|
|
- {
|
|
|
- badcode.Add(myReader.ReadInnerXml() + " ");
|
|
|
- }
|
|
|
- if (myReader.NodeType == XmlNodeType.Element && myReader.Name == "err_location" && myReader.IsStartElement())
|
|
|
- {
|
|
|
- badlocation.Add(myReader.ReadInnerXml() + " ");
|
|
|
- }
|
|
|
- }
|
|
|
- myReader.Close();
|
|
|
- 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 + "无可分配序列号");
|
|
|
- tipform.startthread("当前线别在" + istepcode + "无可分配序列号", "NG");
|
|
|
- return;
|
|
|
- }
|
|
|
- //-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", 0, "", "");
|
|
|
- //如果是不良品记录日志,用于测试采集判负
|
|
|
- if (test_result == "NG")
|
|
|
- {
|
|
|
- RecordBadInfo(sncode, makecode, FileName, combinecode, badcode.ToArray(), badlocation.ToArray(), null);
|
|
|
- }
|
|
|
- if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
|
|
|
- {
|
|
|
- OperateResult.AppendText(oErrMessage + "\n");
|
|
|
- tipform.startthread(oErrMessage, "NG");
|
|
|
- return;
|
|
|
- }
|
|
|
- tipform.startthread("序列号 " + sncode + "通过检测", test_result);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- OperateResult.AppendText(oErrMessage + "\n");
|
|
|
- tipform.startthread(oErrMessage, "NG");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- 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(ma_code.Text == "" ? makecode : ma_code.Text, 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");
|
|
|
- tipform.startthread("请重新采集序列号", test_result);
|
|
|
- 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(), null);
|
|
|
- //所有的序列号均采集为良品
|
|
|
- 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", 0, "", "");
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- OperateResult.AppendText(oErrMessage + "\n");
|
|
|
- tipform.startthread(oErrMessage, "NG");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- FileInfo file = new FileInfo(FolderPath.Text + @"\" + FileName);
|
|
|
- if (file.Exists)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- OperateResult.AppendText(FileName + ex.Message + "\n");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
private void RecordBadInfo(string sncode, string makecode, string filename, string combine, string[] badcode, string[] badlocation, string[] soncode)
|
|
|
{
|