|
|
@@ -58,6 +58,8 @@ namespace FileWatcher
|
|
|
/// </summary>
|
|
|
List<string> _FileName = new List<string>();
|
|
|
|
|
|
+ ftpOperater ftp = new ftpOperater();
|
|
|
+
|
|
|
public AutoAnalysisXml()
|
|
|
{
|
|
|
tipform = new Tip();
|
|
|
@@ -93,9 +95,9 @@ namespace FileWatcher
|
|
|
//获取缓存信息
|
|
|
try
|
|
|
{
|
|
|
- FolderPath.Text = BaseUtil.GetCacheData("FolderPath").ToString();
|
|
|
- BackUpFolderPath.Text = BaseUtil.GetCacheData("BackUpFolderPath").ToString();
|
|
|
- Master.Text = BaseUtil.GetCacheData("Master").ToString();
|
|
|
+ //FolderPath.Text = BaseUtil.GetCacheData("FolderPath").ToString();
|
|
|
+ //BackUpFolderPath.Text = BaseUtil.GetCacheData("BackUpFolderPath").ToString();
|
|
|
+ //Master.Text = BaseUtil.GetCacheData("Master").ToString();
|
|
|
//AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
|
|
|
}
|
|
|
catch (Exception ex) { MessageBox.Show(ex.Message); }
|
|
|
@@ -103,7 +105,7 @@ namespace FileWatcher
|
|
|
{
|
|
|
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=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
+ DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
dh = new DataHelper();
|
|
|
}
|
|
|
}
|
|
|
@@ -124,9 +126,9 @@ namespace FileWatcher
|
|
|
|
|
|
private void StartWatch_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (FolderPath.Text == "" || BackUpFolderPath.Text == "")
|
|
|
+ if (FolderPath.Text == "")
|
|
|
{
|
|
|
- OperateResult.AppendText("请选择监控文件夹和备份文件夹\n");
|
|
|
+ OperateResult.AppendText("请选择监控文件夹\n");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
@@ -136,51 +138,35 @@ namespace FileWatcher
|
|
|
OperateResult.AppendText("监控文件夹不存在\n");
|
|
|
return;
|
|
|
}
|
|
|
- if (!Directory.Exists(BackUpFolderPath.Text))
|
|
|
- {
|
|
|
- OperateResult.AppendText("备份文件夹不存在\n");
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if (FolderPath.Text == BackUpFolderPath.Text)
|
|
|
- {
|
|
|
- OperateResult.AppendText("监控文件夹和备份文件夹不能相同\n");
|
|
|
- return;
|
|
|
}
|
|
|
for (int i = 0; i < DB.Rows.Count; i++)
|
|
|
{
|
|
|
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=192.168.10.10)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
+ DataHelper.DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=DGW;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=81.71.42.91)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
|
|
|
dh = new DataHelper();
|
|
|
LogicHandler.dh = new DataHelper();
|
|
|
}
|
|
|
}
|
|
|
//存在工单必须是已下放状态
|
|
|
- if (!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") && ma_code.Text != "" && Device.Text == "AOI设备")
|
|
|
+ if ((!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") || ma_code.Text == "") && Device.Text == "AOI设备")
|
|
|
{
|
|
|
OperateResult.AppendText("工单不存在或者未下放\n");
|
|
|
return;
|
|
|
}
|
|
|
- if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'") && ma_code.Text != "" && Device.Text == "选焊设备")
|
|
|
- {
|
|
|
- OperateResult.AppendText("工单不存\n");
|
|
|
- return;
|
|
|
- }
|
|
|
XmlWatcher.Path = FolderPath.Text;
|
|
|
XmlWatcher.Filter = "*.txt";
|
|
|
XmlWatcher.EnableRaisingEvents = true;
|
|
|
//设置缓存数据
|
|
|
- BaseUtil.SetCacheData("FolderPath", FolderPath.Text);
|
|
|
- BaseUtil.SetCacheData("BackUpFolderPath", BackUpFolderPath.Text);
|
|
|
- BaseUtil.SetCacheData("Master", Master.Text);
|
|
|
- BaseUtil.SetCacheData("AutoStart", AutoStart.Checked);
|
|
|
+ //BaseUtil.SetCacheData("FolderPath", FolderPath.Text);
|
|
|
+ //BaseUtil.SetCacheData("BackUpFolderPath", BackUpFolderPath.Text);
|
|
|
+ //BaseUtil.SetCacheData("Master", Master.Text);
|
|
|
+ //BaseUtil.SetCacheData("AutoStart", AutoStart.Checked);
|
|
|
//设置按钮不可点击
|
|
|
StartWatch.Enabled = false;
|
|
|
ChooseFolder.Enabled = false;
|
|
|
Master.Enabled = false;
|
|
|
ma_code.Enabled = false;
|
|
|
- ChooseBackUpFolder.Enabled = false;
|
|
|
StopWatch.Enabled = true;
|
|
|
OperateResult.AppendText("开始执行监控\n");
|
|
|
}
|
|
|
@@ -231,242 +217,178 @@ namespace FileWatcher
|
|
|
{
|
|
|
StreamReader sR = File.OpenText(FileName);
|
|
|
|
|
|
- string[] data1 = null;
|
|
|
+ DataTable filedt = new DataTable();
|
|
|
+ //文件内的行,用一个DataTable存储
|
|
|
+ int Rowindex = 0;
|
|
|
while ((nextLine = sR.ReadLine()) != null)
|
|
|
{
|
|
|
- data1 = nextLine.Split(';');
|
|
|
- }
|
|
|
- string SoftVersion = data1[0];
|
|
|
- List<string[]> dic = new List<string[]>();
|
|
|
- List<string> sndata = new List<string>();
|
|
|
- for (int i = 0; i < data1.Length; i++)
|
|
|
- {
|
|
|
- //如果软件版本相同的时候,则表示一个新的SN
|
|
|
- if ((SoftVersion == data1[i] && i != 0) || i == data1.Length - 1)
|
|
|
- {
|
|
|
- dic.Add(sndata.ToArray());
|
|
|
- sndata.Clear();
|
|
|
- }
|
|
|
- sndata.Add(data1[i]);
|
|
|
- }
|
|
|
- foreach (string[] content in dic)
|
|
|
- {
|
|
|
- string SN = "";
|
|
|
- string Machine = "";
|
|
|
- string EmName = "";
|
|
|
- string Day = "";
|
|
|
- string Time = "";
|
|
|
- string Result = "";
|
|
|
- string TotalPart = "";
|
|
|
- string NGPart = "";
|
|
|
- int MissTest = 0;
|
|
|
- string[] data = content;
|
|
|
- for (int i = 0; i < data.Length; i++)
|
|
|
+ //DataTable用第一行的数据作为列名
|
|
|
+ string[] title = nextLine.Split(',');
|
|
|
+ DataRow dr = filedt.NewRow();
|
|
|
+ for (int i = 0; i < title.Length; i++)
|
|
|
{
|
|
|
- switch (i.ToString())
|
|
|
+ if (Rowindex == 0)
|
|
|
{
|
|
|
- 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;
|
|
|
+ filedt.Columns.Add(title[i]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dr[filedt.Columns[i].ColumnName] = title[i];
|
|
|
}
|
|
|
}
|
|
|
- if (SN == "")
|
|
|
+ //除了第一行,然后添加到表格中
|
|
|
+ if (Rowindex > 0)
|
|
|
{
|
|
|
- tipform.startthread("序列号不能为空", "NG");
|
|
|
- continue;
|
|
|
+ filedt.Rows.Add(dr);
|
|
|
}
|
|
|
- if (data.Length > 15)
|
|
|
+ Rowindex = Rowindex + 1;
|
|
|
+ }
|
|
|
+ sR.Close();
|
|
|
+ string SN = FileName.Substring(FileName.LastIndexOf(@"\") + 1).Replace("-", "/").ToUpper().Replace(".TXT", "");
|
|
|
+ string Result = "OK";
|
|
|
+ string makecode = "";
|
|
|
+ string stepcode = "";
|
|
|
+ string oErrMessage = "";
|
|
|
+ string oMSID = "";
|
|
|
+ isource = "SMT_01_AOI";
|
|
|
+ iusercode = "SMT_01_AOI";
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ ilinecode = dt.Rows[0]["sc_linecode"].ToString();
|
|
|
+ istepcode = dt.Rows[0]["sc_stepcode"].ToString();
|
|
|
+ ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
|
|
|
+ }
|
|
|
+ if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, SN, iusercode, out makecode, out oMSID, out oErrMessage))
|
|
|
+ {
|
|
|
+ for (int i = 0; i < filedt.Rows.Count; i++)
|
|
|
{
|
|
|
- for (int i = 15; i < data.Length; i++)
|
|
|
+ if (filedt.Rows[i]["c_result"].ToString() != "OK" && filedt.Rows[i]["c_result"].ToString() != "FC")
|
|
|
{
|
|
|
- switch ((i - 15) % 6)
|
|
|
+ Result = "NG";
|
|
|
+ //只添加一条记录
|
|
|
+ if (badcode.Count == 0)
|
|
|
{
|
|
|
- case 0:
|
|
|
- if (badlocation.Count >= 1)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- badlocation.Add(data[i]);
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- if (badprod.Count >= 1)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- badprod.Add(data[i]);
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- if (badcode.Count >= 1)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- badcode.Add(data[i].ToUpper());
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ badcode.Add(filedt.Rows[i]["w_ng_name"].ToString());
|
|
|
+ badlocation.Add(filedt.Rows[i]["c_subboard_number"].ToString());
|
|
|
+ badprod.Add(filedt.Rows[i]["c_subboard_number"].ToString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- sR.Close();
|
|
|
- //如果没有不良位号等数据则是15个数据
|
|
|
- if (Result == "0001")
|
|
|
+ //获取序列号ID最大的工单
|
|
|
+ dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id,ms_stepcode from makeserial where ms_sncode='" + SN + "' order by ms_id desc", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- if (data.Length > 16)
|
|
|
+ ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
+ makecode = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
+ stepcode = dt.Rows[0]["ms_stepcode"].ToString();
|
|
|
+ if (stepcode == istepcode)
|
|
|
{
|
|
|
- MissTest = -1;
|
|
|
- Result = "NG";
|
|
|
+ tipform.startthread("序列号 " + SN + "已执行过" + istepcode, "NG");
|
|
|
+ OperateResult.AppendText("序列号 " + SN + "已执行过" + istepcode + "\n");
|
|
|
}
|
|
|
- else
|
|
|
+ switch (Result)
|
|
|
{
|
|
|
- Result = "OK";
|
|
|
+ case "OK":
|
|
|
+ if (!LogicHandler.SetStepResult(makecode, isource, SN, "自动过站采集", Result, iusercode, out oErrMessage))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
+ tipform.startthread(oErrMessage, Result);
|
|
|
+ }
|
|
|
+ tipform.startthread("序列号 " + SN + "通过检测", Result);
|
|
|
+ OperateResult.AppendText("序列号 " + SN + "通过检测" + "\n");
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ tipform.startthread("序列号 " + SN + "未通过检测", Result);
|
|
|
+ OperateResult.AppendText("序列号 " + SN + "未通过检测" + "\n");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+ File.Delete(FileName);
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- Result = "OK";
|
|
|
- }
|
|
|
- string makecode = "";
|
|
|
- string stepcode = "";
|
|
|
- string oErrMessage = "";
|
|
|
- string oMSID = "";
|
|
|
- if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, SN, iusercode, out makecode, out oMSID, out oErrMessage))
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
+ tipform.startthread(oErrMessage, Result);
|
|
|
+ File.Delete(FileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (Device.Text == "测试设备")
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string filename = FileName;
|
|
|
+ if (filename.Substring(filename.LastIndexOf(".") + 1).ToUpper() == "TXT")
|
|
|
{
|
|
|
- //获取序列号ID最大的工单
|
|
|
- dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id,ms_stepcode from makeserial where ms_sncode='" + SN + "' order by ms_id desc", "select");
|
|
|
- if (dt.Rows.Count > 0)
|
|
|
+ string folderpath = FileName.Substring(0, FileName.LastIndexOf(@"\"));
|
|
|
+ string SN = FileName.Substring(FileName.LastIndexOf(@"\") + 1).Replace("-", "/").ToUpper().Replace(".TXT", "");
|
|
|
+ if (SN.Length == 12)
|
|
|
{
|
|
|
- ma_code.Text = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
- makecode = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
- stepcode = dt.Rows[0]["ms_stepcode"].ToString();
|
|
|
- if (stepcode == istepcode)
|
|
|
+ string Result = "";
|
|
|
+ string makecode = ma_code.Text;
|
|
|
+ string oErrMessage = "";
|
|
|
+ string oMSID = "";
|
|
|
+ string ms_sncode = dh.getFieldDataByCondition("makeserial", "ms_sncode", "substr(ms_sncode,0,12)='" + SN + "' order by ms_id").ToString();
|
|
|
+ isource = "SMT_01_TEST01";
|
|
|
+ iusercode = "SMT_01_TEST01";
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- tipform.startthread("序列号 " + SN + "已执行过" + istepcode, "NG");
|
|
|
- OperateResult.AppendText("序列号 " + SN + "已执行过" + istepcode + "\n");
|
|
|
- continue;
|
|
|
+ ilinecode = dt.Rows[0]["sc_linecode"].ToString();
|
|
|
+ istepcode = dt.Rows[0]["sc_stepcode"].ToString();
|
|
|
+ ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
|
|
|
}
|
|
|
- SoundPlayer player = new SoundPlayer();
|
|
|
- switch (Result)
|
|
|
+ if (LogicHandler.CheckStepSNAndMacode(ma_code.Text, isource, ms_sncode, iusercode, out makecode, out oMSID, out oErrMessage))
|
|
|
{
|
|
|
- case "OK":
|
|
|
- if (!LogicHandler.SetStepResult(makecode, isource, SN, "自动过站采集", Result, iusercode, out oErrMessage))
|
|
|
- {
|
|
|
- OperateResult.AppendText(oErrMessage + "\n");
|
|
|
- tipform.startthread(oErrMessage, Result);
|
|
|
- continue;
|
|
|
- }
|
|
|
- tipform.startthread("序列号 " + SN + "通过检测", Result);
|
|
|
- player.SoundLocation = Application.StartupPath + @"\8378.wav";
|
|
|
- player.Load();
|
|
|
- player.Play();
|
|
|
- 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);
|
|
|
- continue;
|
|
|
- }
|
|
|
- tipform.startthread("序列号 " + SN + "未通过检测", Result);
|
|
|
- player.SoundLocation = Application.StartupPath + @"\5185.wav";
|
|
|
- player.Load();
|
|
|
- player.Play();
|
|
|
- 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
|
|
|
+ ma_code.Text = makecode;
|
|
|
+ if (LogicHandler.SetStepResult(makecode, isource, ms_sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
|
|
|
{
|
|
|
- for (int i = 1; i <= 20; i++)
|
|
|
+ try
|
|
|
{
|
|
|
- if (!File.Exists(BackUpFolderPath.Text + @"\" + FileName))
|
|
|
+ string ftppath = "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
|
|
|
+ ftp.UpLoadFile(folderpath, SN + ".txt", ftppath, "");
|
|
|
+ int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class)select STEPTESTDETAIL_seq.nextval,ms_sncode,ms_makecode,sysdate,'http://81.71.42.91:8099/ftp" + ftppath + SN + ".txt" + "' from makeserial where substr(ms_sncode,0,12)='" + SN + "'", "insert").ToString());
|
|
|
+ if (num > 0)
|
|
|
{
|
|
|
- file.MoveTo(BackUpFolderPath.Text + @"\" + FileName);
|
|
|
- OperateResult.AppendText("成功解析文件" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " " + FileName + "\n");
|
|
|
- break;
|
|
|
+ OperateResult.AppendText("序列号:" + SN + "上传成功\n");
|
|
|
}
|
|
|
- else if (!File.Exists(BackUpFolderPath.Text + @"\" + FileName.Split('.')[0] + "(" + i + ")" + "." + FileName.Split('.')[1]))
|
|
|
+ else
|
|
|
{
|
|
|
- file.MoveTo(BackUpFolderPath.Text + @"\" + FileName.Split('.')[0] + "(" + i + ")" + "." + FileName.Split('.')[1]);
|
|
|
- OperateResult.AppendText("成功解析文件" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + " " + FileName + "\n");
|
|
|
- break;
|
|
|
+ OperateResult.AppendText("序列号: " + SN + "前工段未扫描\n");
|
|
|
+ MessageBox.Show("序列号: " + ms_sncode + "前工段未扫描", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
|
|
|
}
|
|
|
}
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine(ex.Message);
|
|
|
+ }
|
|
|
+ File.Delete(FileName);
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
+ else
|
|
|
{
|
|
|
- OperateResult.AppendText(FileName + ex.Message + "\n");
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
+ tipform.startthread(oErrMessage, Result);
|
|
|
+
|
|
|
}
|
|
|
+ tipform.startthread("序列号 " + ms_sncode + "通过检测", Result);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ File.Delete(FileName);
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
+ tipform.startthread(oErrMessage, Result);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- OperateResult.AppendText(oErrMessage + "\n");
|
|
|
- tipform.startthread(oErrMessage, Result);
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else if (Device.Text == "选焊设备")
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
- BaseUtil.GetWriteInfo(FileName, out dic);
|
|
|
- string sql = "insert into AOITESTDETAIL(atd_id,atd_makecode,atd_indate,";
|
|
|
- string sql1 = " values(AOITESTDETAIL_seq.nextval,'" + ma_code.Text + "',sysdate,";
|
|
|
- foreach (var item in dic)
|
|
|
- {
|
|
|
- sql += item.Key + ",";
|
|
|
- if (item.Key.Contains("starttime") || item.Key.Contains("endtime"))
|
|
|
- sql1 += "to_date('" + item.Value + "','dd/mm/yyyy hh24:mi:ss'),";
|
|
|
- else
|
|
|
- sql1 += "'" + item.Value + "',";
|
|
|
- }
|
|
|
- sql = sql.Substring(0, sql.Length - 1) + ")" + sql1.Substring(0, sql1.Length - 1) + ")";
|
|
|
- dh.ExecuteSql(sql, "insert");
|
|
|
OperateResult.AppendText("解析成功:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n" + FileName + "\n");
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
@@ -522,8 +444,6 @@ namespace FileWatcher
|
|
|
{
|
|
|
badlocation.Add(myReader.ReadInnerXml() + " ");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
myReader.Close();
|
|
|
//获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
|
|
|
@@ -659,21 +579,7 @@ namespace FileWatcher
|
|
|
{
|
|
|
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)
|
|
|
{
|
|
|
@@ -690,13 +596,13 @@ namespace FileWatcher
|
|
|
dh.ExecuteSql(sql.ToString(), "update");
|
|
|
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_badlocation,mb_soncode,mb_content) select :ID");
|
|
|
+ sql.Append(",mb_sourcecode,mb_badname,mb_bgcode,mb_badtable,mb_status,mb_badlocation,mb_soncode,mb_content) select :ID");
|
|
|
sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',");
|
|
|
- sql.Append(":bc_code,'" + ibadgroup + "','','0',:location,:soncode,'" + nextLine + "' from make left join makeSerial on ms_makecode=ma_code ");
|
|
|
+ sql.Append(":bc_code,'WG','','0',:location,:soncode,'" + nextLine + "' 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", "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("update makebad set mb_badcode=(select DISTINCT bc_code from badcode where bc_name=mb_badcode),mb_badname=mb_badcode,mb_bgname=(select DISTINCT bg_name from badgroup where bg_code=mb_bgcode) ");
|
|
|
sql.Append("where mb_id=:ID");
|
|
|
dh.BatchInsert(sql.ToString(), new string[] { "ID" }, ID);
|
|
|
//记录判断日志
|
|
|
@@ -713,7 +619,7 @@ namespace FileWatcher
|
|
|
ma_code.Enabled = true;
|
|
|
Master.Enabled = true;
|
|
|
ChooseFolder.Enabled = true;
|
|
|
- ChooseBackUpFolder.Enabled = true;
|
|
|
+
|
|
|
StopWatch.Enabled = false;
|
|
|
OperateResult.AppendText("停止执行监控\n");
|
|
|
}
|
|
|
@@ -741,7 +647,7 @@ namespace FileWatcher
|
|
|
DialogResult result = folder.ShowDialog();
|
|
|
if (result == DialogResult.OK)
|
|
|
{
|
|
|
- BackUpFolderPath.Text = folder.SelectedPath;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -795,21 +701,5 @@ namespace FileWatcher
|
|
|
{
|
|
|
dh.ExecuteSql("select sysdate from dual", "select");
|
|
|
}
|
|
|
-
|
|
|
- private void button1_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- SoundPlayer player = new SoundPlayer();
|
|
|
- player.SoundLocation = Application.StartupPath + @"\8378.wav";
|
|
|
- player.Load();
|
|
|
- player.Play();
|
|
|
- }
|
|
|
-
|
|
|
- private void button2_Click(object sender, EventArgs e)
|
|
|
- {
|
|
|
- SoundPlayer player = new SoundPlayer();
|
|
|
- player.SoundLocation = Application.StartupPath + @"\5185.wav";
|
|
|
- player.Load();
|
|
|
- player.Play();
|
|
|
- }
|
|
|
}
|
|
|
}
|