|
|
@@ -9,6 +9,9 @@ using System.Xml;
|
|
|
using System.Text;
|
|
|
using System.Media;
|
|
|
using System.Linq;
|
|
|
+using NPOI.SS.Formula.Functions;
|
|
|
+using System.Windows.Media.TextFormatting;
|
|
|
+using UMESDLLService;
|
|
|
|
|
|
namespace FileWatcher
|
|
|
{
|
|
|
@@ -82,7 +85,6 @@ namespace FileWatcher
|
|
|
string ftpulr = "";
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
-
|
|
|
tipform.Show();
|
|
|
CheckForIllegalCrossThreadCalls = false;
|
|
|
FormBorderStyle = FormBorderStyle.FixedSingle;
|
|
|
@@ -93,8 +95,20 @@ namespace FileWatcher
|
|
|
stw.StartPosition = FormStartPosition.CenterScreen;
|
|
|
stw.ShowDialog();
|
|
|
List<string> CacheInf = new List<string>();
|
|
|
- ftpulr = dh.getFieldDataByCondition("configs", "data", "code='UploadFTP' and caller='MESSetting'").ToString();
|
|
|
- fieltype = dh.getFieldDataByCondition("configs", "data", "code='UploadFile' and caller='MESSetting'").ToString();
|
|
|
+ StreamReader sR = new StreamReader(Application.StartupPath + @"\MES_SETTING.txt", Encoding.Default);
|
|
|
+ while ((nextLine = sR.ReadLine()) != null)
|
|
|
+ {
|
|
|
+ string name = nextLine.ToString().Split('=')[0];
|
|
|
+ string value = nextLine.ToString().Split('=')[1];
|
|
|
+ if (name == "FTPURL")
|
|
|
+ {
|
|
|
+ ftpulr = value;
|
|
|
+ }
|
|
|
+ if (name == "FileType")
|
|
|
+ {
|
|
|
+ fieltype = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
string[] FTPInf = ftpulr.Split('#');
|
|
|
ftp = new ftpOperater(FTPInf[0], FTPInf[1], FTPInf[2]);
|
|
|
//获取缓存信息
|
|
|
@@ -103,7 +117,9 @@ namespace FileWatcher
|
|
|
FolderPath.Text = BaseUtil.GetCacheData("FolderPath").ToString();
|
|
|
BackUpFolderPath.Text = BaseUtil.GetCacheData("BackUpFolderPath").ToString();
|
|
|
Master.Text = BaseUtil.GetCacheData("Master").ToString();
|
|
|
- //AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
|
|
|
+ li_code.Text = BaseUtil.GetCacheData("Line").ToString();
|
|
|
+ MachineType.Text = BaseUtil.GetCacheData("MachineType").ToString();
|
|
|
+ Device.Text = BaseUtil.GetCacheData("Device").ToString();
|
|
|
}
|
|
|
catch (Exception ex) { MessageBox.Show(ex.Message); }
|
|
|
}
|
|
|
@@ -128,11 +144,11 @@ namespace FileWatcher
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- //if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
|
|
|
- //{
|
|
|
- // OperateResult.AppendText("工单号不存在\n");
|
|
|
- // return;
|
|
|
- //}
|
|
|
+ if (!dh.CheckExist("line", "li_code='" + li_code.Text + "'"))
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("线别不存在\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
XmlWatcher.Path = FolderPath.Text;
|
|
|
XmlWatcher.Filter = "*.*";
|
|
|
XmlWatcher.EnableRaisingEvents = true;
|
|
|
@@ -140,6 +156,9 @@ namespace FileWatcher
|
|
|
BaseUtil.SetCacheData("FolderPath", FolderPath.Text);
|
|
|
BaseUtil.SetCacheData("BackUpFolderPath", BackUpFolderPath.Text);
|
|
|
BaseUtil.SetCacheData("Master", Master.Text);
|
|
|
+ BaseUtil.SetCacheData("Line", li_code.Text);
|
|
|
+ BaseUtil.SetCacheData("MachineType", MachineType.Text);
|
|
|
+ BaseUtil.SetCacheData("Device", Device.Text);
|
|
|
//BaseUtil.SetCacheData("AutoStart", AutoStart.Checked);
|
|
|
Timer.Interval = 1000 * 10;
|
|
|
Timer.Start();
|
|
|
@@ -163,13 +182,13 @@ namespace FileWatcher
|
|
|
string[] str = fieltype.Split('#');
|
|
|
for (int i = 0; i < str.Length; i++)
|
|
|
{
|
|
|
- if (e.FullPath.EndsWith(str[i]))
|
|
|
+ if (e.FullPath.ToUpper().EndsWith(str[i].ToUpper()))
|
|
|
{
|
|
|
TxtHandleProcess(e.FullPath);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ string nextLine;
|
|
|
private void TxtHandleProcess(string FileName)
|
|
|
{
|
|
|
List<string> badcode = new List<string>();
|
|
|
@@ -185,15 +204,133 @@ namespace FileWatcher
|
|
|
try
|
|
|
{
|
|
|
string sn1 = SN.Split('.')[0];
|
|
|
- string makecode = dh.getFieldDataByCondition("makeserial","ms_makecode","ms_sncode='"+sn1+"'").ToString();
|
|
|
- ma_code.Text = makecode;
|
|
|
- string ftppath = "/" + ma_code.Text + "/";
|
|
|
- ftp.UpLoadFile(folderpath, SN, ftppath, "");
|
|
|
- int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,STD_RESCODE,std_stepcode)select STEPTESTDETAIL_seq.nextval,'" + SN + "','',sysdate,'" + ftpulr.Split('#')[0] + imaster + "/" + ftppath + SN + "','" + isource + "','' from dual", "insert").ToString());
|
|
|
- if (num > 0)
|
|
|
+ //string makecode = dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_sncode='" + sn1 + "'").ToString();
|
|
|
+ //MachineType.Text = makecode;
|
|
|
+ string ftppath = "/" + MachineType.Text + "/";
|
|
|
+ //string ErrMessage = ftp.UpLoadFile(folderpath, SN, ftppath, "");
|
|
|
+
|
|
|
+ DirectoryInfo info = new DirectoryInfo(folderpath);
|
|
|
+ String path = info.Parent.Parent.FullName;
|
|
|
+ MachineType.Text = info.Name;//获取当前路径最后一级文件夹名称
|
|
|
+ if (Device.Text == "炉后AOI")
|
|
|
{
|
|
|
- OperateResult.AppendText("序列号:" + SN + "上传成功\n");
|
|
|
- //File.Delete(FileName);
|
|
|
+ StreamReader sR = new StreamReader(FileName, Encoding.Default);
|
|
|
+ string ASN = "";
|
|
|
+ string Model = "";
|
|
|
+ string Shift = "";
|
|
|
+ string Rep_Date_Time = "";
|
|
|
+ string OPID = "";
|
|
|
+ string StationName = "";
|
|
|
+ string Surface = "";
|
|
|
+ string CycleTime = "";
|
|
|
+ string Result = "";
|
|
|
+ int Rowindex = 0;
|
|
|
+ List<string> Location = new List<string>();
|
|
|
+ List<string> PinNum = new List<string>();
|
|
|
+ List<string> ErrCode = new List<string>();
|
|
|
+ List<string> RepairStatus = new List<string>();
|
|
|
+ while ((nextLine = sR.ReadLine()) != null)
|
|
|
+ {
|
|
|
+ string data = nextLine.ToString().Split('=')[1];
|
|
|
+ string itemname = nextLine.ToString().Split('=')[0];
|
|
|
+ switch (Rowindex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ ASN = data;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ Model = data;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ Shift = data;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ Rep_Date_Time = data;
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ OPID = data;
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ StationName = data;
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ Surface = data;
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ CycleTime = data;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (itemname == "Result")
|
|
|
+ {
|
|
|
+ Result = data;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (Rowindex >= 8)
|
|
|
+ {
|
|
|
+ //Location
|
|
|
+ if ((Rowindex - 8) % 4 == 0)
|
|
|
+ {
|
|
|
+ Location.Add(data);
|
|
|
+ }
|
|
|
+ //PinNum
|
|
|
+ if ((Rowindex - 8) % 4 == 1)
|
|
|
+ {
|
|
|
+ PinNum.Add(data);
|
|
|
+ }
|
|
|
+ //ErrCode
|
|
|
+ if ((Rowindex - 8) % 4 == 2)
|
|
|
+ {
|
|
|
+ ErrCode.Add(data);
|
|
|
+ }
|
|
|
+ //RepairStatus
|
|
|
+ if ((Rowindex - 8) % 4 == 3)
|
|
|
+ {
|
|
|
+ RepairStatus.Add(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Rowindex = Rowindex + 1;
|
|
|
+ }
|
|
|
+ sR.Close();
|
|
|
+ Thread.Sleep(500);
|
|
|
+ int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,STD_RESCODE,std_stepcode,std_linecode,std_machinetype)select STEPTESTDETAIL_seq.nextval,'" + SN + "','',sysdate,'" + ftpulr.Split('#')[0] + imaster + "/" + ftppath + SN + "','" + isource + "','" + Device.Text + "','" + li_code.Text + "','" + MachineType.Text + "' from dual", "insert").ToString());
|
|
|
+ if (Result.ToUpper() == "FAIL")
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into makebad(mb_id,MB_MSCODE, MB_SNCODE, MB_INDATE, MB_STEPCODE, MB_SOURCECODE, MB_BADCODE, MB_YMD, MB_LINECODE,MB_BADNAME)");
|
|
|
+ sql.Append("values(makebad_seq.nextval,'" + ASN + "','" + ASN + "',sysdate,'AOI-B','',:MB_BADCODE,to_char(sysdate,'yyyymmdd'),'" + li_code.Text + "',:MB_BADNAME)");
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "mb_badcode", "mb_badname" }, ErrCode.ToArray(), Location.ToArray());
|
|
|
+ }
|
|
|
+ if (num > 0)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("序列号:" + SN + "上传成功\n");
|
|
|
+ string Backupfilename = BackUpFolderPath.Text + @"\" + MachineType.Text + @"\" + SN;
|
|
|
+ if (!Directory.Exists(BackUpFolderPath.Text + @"\" + MachineType.Text))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(BackUpFolderPath.Text + @"\" + MachineType.Text);
|
|
|
+ }
|
|
|
+ if (File.Exists(Backupfilename))
|
|
|
+ {
|
|
|
+ File.Delete(Backupfilename);
|
|
|
+ }
|
|
|
+ File.Move(FileName, Backupfilename);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ int num = int.Parse(dh.ExecuteSql("insert into STEPTESTDETAIL (std_id,std_sn,std_makecode,std_indate,std_class,STD_RESCODE,std_stepcode,std_linecode,std_machinetype)select STEPTESTDETAIL_seq.nextval,'" + SN + "','',sysdate,'" + ftpulr.Split('#')[0] + imaster + "/" + ftppath + SN + "','" + isource + "','" + Device.Text + "','" + li_code.Text + "','" + MachineType.Text + "' from dual", "insert").ToString());
|
|
|
+ if (num > 0)
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("序列号:" + SN + "上传成功\n");
|
|
|
+ string Backupfilename = BackUpFolderPath.Text + @"\" + MachineType.Text + @"\" + SN;
|
|
|
+ if (!Directory.Exists(BackUpFolderPath.Text + @"\" + MachineType.Text))
|
|
|
+ {
|
|
|
+ Directory.CreateDirectory(BackUpFolderPath.Text + @"\" + MachineType.Text);
|
|
|
+ }
|
|
|
+ File.Move(FileName, Backupfilename);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
@@ -242,7 +379,7 @@ namespace FileWatcher
|
|
|
DialogResult result = folder.ShowDialog();
|
|
|
if (result == DialogResult.OK)
|
|
|
{
|
|
|
-
|
|
|
+ BackUpFolderPath.Text = folder.SelectedPath;
|
|
|
}
|
|
|
}
|
|
|
|