|
@@ -26,6 +26,7 @@ using UAS_MES_NEW.DataOperate;
|
|
|
using UAS_MES_NEW.Entity;
|
|
using UAS_MES_NEW.Entity;
|
|
|
using UAS_MES_NEW.PublicMethod;
|
|
using UAS_MES_NEW.PublicMethod;
|
|
|
using static DevExpress.Xpo.DB.DataStoreLongrunnersWatch;
|
|
using static DevExpress.Xpo.DB.DataStoreLongrunnersWatch;
|
|
|
|
|
+using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;
|
|
|
|
|
|
|
|
namespace UAS_MES_NEW.Make
|
|
namespace UAS_MES_NEW.Make
|
|
|
{
|
|
{
|
|
@@ -36,7 +37,7 @@ namespace UAS_MES_NEW.Make
|
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- FileSystemWatcher watcher = new FileSystemWatcher();
|
|
|
|
|
|
|
+ FileSystemWatcher watcher;
|
|
|
|
|
|
|
|
LogStringBuilder sql = new LogStringBuilder();
|
|
LogStringBuilder sql = new LogStringBuilder();
|
|
|
DataTable Dbfind;
|
|
DataTable Dbfind;
|
|
@@ -48,6 +49,9 @@ namespace UAS_MES_NEW.Make
|
|
|
string SN, omakeCode, oMsid, oErrorMessage = "";
|
|
string SN, omakeCode, oMsid, oErrorMessage = "";
|
|
|
string equiType = "";
|
|
string equiType = "";
|
|
|
List<string> fileList = new List<string>();
|
|
List<string> fileList = new List<string>();
|
|
|
|
|
+
|
|
|
|
|
+ Timer formsTimer;
|
|
|
|
|
+ string outXmlFilePath;
|
|
|
private void Make_ParseLog_Load(object sender, EventArgs e)
|
|
private void Make_ParseLog_Load(object sender, EventArgs e)
|
|
|
{
|
|
{
|
|
|
dh = SystemInf.dh;
|
|
dh = SystemInf.dh;
|
|
@@ -59,6 +63,18 @@ namespace UAS_MES_NEW.Make
|
|
|
fileList.Add(""); // 贴片机
|
|
fileList.Add(""); // 贴片机
|
|
|
fileList.Add("D:\\JANETSSC\\SMT\\MachineMonitoring"); // JUKI贴片机
|
|
fileList.Add("D:\\JANETSSC\\SMT\\MachineMonitoring"); // JUKI贴片机
|
|
|
|
|
|
|
|
|
|
+ formsTimer = new Timer();
|
|
|
|
|
+ formsTimer.Interval = 10000;
|
|
|
|
|
+ formsTimer.Tick += timer1_Tick;
|
|
|
|
|
+ //outXmlFilePath = "C:\\Users\\MI\\Desktop\\贴片机\\outLogs";
|
|
|
|
|
+ outXmlFilePath = "D:\\JANETSSR";
|
|
|
|
|
+
|
|
|
|
|
+ watcher = new FileSystemWatcher();
|
|
|
|
|
+ watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
|
|
|
|
|
+ watcher.Created += OnFileCreated;
|
|
|
|
|
+ /*watcher.Changed += OnFileChanged;
|
|
|
|
|
+ watcher.Deleted += OnFileChanged;
|
|
|
|
|
+ watcher.Renamed += OnFileChanged;*/
|
|
|
|
|
|
|
|
//设置锁定工单
|
|
//设置锁定工单
|
|
|
LockMakeCode.GetMakeCodeCtl(ma_code);
|
|
LockMakeCode.GetMakeCodeCtl(ma_code);
|
|
@@ -108,6 +124,33 @@ namespace UAS_MES_NEW.Make
|
|
|
MessageBox.Show(this.ParentForm, "请选择工单", "提示");
|
|
MessageBox.Show(this.ParentForm, "请选择工单", "提示");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ switch (Device.SelectedIndex)
|
|
|
|
|
+ {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ currFileType = "txt";
|
|
|
|
|
+ equiType = "SPI";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ currFileType = "csv";
|
|
|
|
|
+ equiType = "SPI";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ currFileType = "txt";
|
|
|
|
|
+ equiType = "AOI";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ currFileType = "csv";
|
|
|
|
|
+ equiType = "印刷机";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ currFileType = "xml";
|
|
|
|
|
+ equiType = "贴片机";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ currFileType = "xml";
|
|
|
|
|
+ equiType = "贴片机";
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
txtPath.Text = fileList[Device.SelectedIndex];
|
|
txtPath.Text = fileList[Device.SelectedIndex];
|
|
|
txtPath.Focus();
|
|
txtPath.Focus();
|
|
@@ -157,6 +200,7 @@ namespace UAS_MES_NEW.Make
|
|
|
txtPath.Text = dialog.SelectedPath;
|
|
txtPath.Text = dialog.SelectedPath;
|
|
|
txtPath.Enabled = false;
|
|
txtPath.Enabled = false;
|
|
|
Device.Enabled = false;
|
|
Device.Enabled = false;
|
|
|
|
|
+ watcher.EnableRaisingEvents = false;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -228,25 +272,85 @@ namespace UAS_MES_NEW.Make
|
|
|
currFileType = txtFiles.Length > csvFiles.Length ? "txt" : "csv";
|
|
currFileType = txtFiles.Length > csvFiles.Length ? "txt" : "csv";
|
|
|
watcher.Filter = $"*.{currFileType}";*/
|
|
watcher.Filter = $"*.{currFileType}";*/
|
|
|
#endregion
|
|
#endregion
|
|
|
-
|
|
|
|
|
watcher.Path = txtPath.Text;
|
|
watcher.Path = txtPath.Text;
|
|
|
watcher.Filter = $"*.{currFileType}";
|
|
watcher.Filter = $"*.{currFileType}";
|
|
|
- watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
|
|
|
|
|
- watcher.Created += OnFileCreated;
|
|
|
|
|
- /*watcher.Changed += OnFileChanged;
|
|
|
|
|
- watcher.Deleted += OnFileChanged;
|
|
|
|
|
- watcher.Renamed += OnFileChanged;*/
|
|
|
|
|
|
|
|
|
|
if (onWatch.Text == "开启解析")
|
|
if (onWatch.Text == "开启解析")
|
|
|
{
|
|
{
|
|
|
watcher.EnableRaisingEvents = true;
|
|
watcher.EnableRaisingEvents = true;
|
|
|
onWatch.Text = "关闭解析";
|
|
onWatch.Text = "关闭解析";
|
|
|
|
|
+
|
|
|
|
|
+ if (Device.SelectedIndex == 5) // JUKI贴片机
|
|
|
|
|
+ {
|
|
|
|
|
+ formsTimer.Start();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
watcher.EnableRaisingEvents = false;
|
|
watcher.EnableRaisingEvents = false;
|
|
|
- watcher.Dispose();
|
|
|
|
|
|
|
+ //watcher.Dispose();
|
|
|
onWatch.Text = "开启解析";
|
|
onWatch.Text = "开启解析";
|
|
|
|
|
+ formsTimer.Stop();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ MessageBox.Show(this.ParentForm, ex.Message, "警告");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void timer1_Tick(object sender, EventArgs e)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ sql.Clear();
|
|
|
|
|
+ sql.Append($@"SELECT dd_date,dd_name,dd_status,dd_id FROM devicedata WHERE dd_status = 0");
|
|
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ string currentDate = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|
|
|
|
+ XmlWriterSettings settings = new XmlWriterSettings
|
|
|
|
|
+ {
|
|
|
|
|
+ Indent = true,
|
|
|
|
|
+ Encoding = System.Text.Encoding.UTF8
|
|
|
|
|
+ };
|
|
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
|
|
+ {
|
|
|
|
|
+ var hasFileAry = Directory.GetFiles(outXmlFilePath, $"*.{currFileType}");
|
|
|
|
|
+ string xmlName;
|
|
|
|
|
+ if (hasFileAry.Length > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ var lastFile = Directory.GetFiles(outXmlFilePath).Select(f => new FileInfo(f))
|
|
|
|
|
+ .Where(f => f.CreationTime.Date == DateTime.Today)
|
|
|
|
|
+ .OrderByDescending(f => f.CreationTime).FirstOrDefault().Name;
|
|
|
|
|
+
|
|
|
|
|
+ string seqNumStr = lastFile.Substring(lastFile.Length - 7, 3);
|
|
|
|
|
+ string fileSeqNum = (int.Parse(seqNumStr) + 1).ToString().PadLeft(seqNumStr.Length, '0'); ;
|
|
|
|
|
+ xmlName = $"1.08_{currentDate}_{currentDate}{fileSeqNum}.xml";
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ xmlName = $"1.08_{currentDate}_{currentDate}001.xml";
|
|
|
|
|
+ }
|
|
|
|
|
+ string fullPath = Path.Combine(outXmlFilePath, xmlName);
|
|
|
|
|
+
|
|
|
|
|
+ using (XmlWriter writer = XmlWriter.Create(fullPath, settings))
|
|
|
|
|
+ {
|
|
|
|
|
+ writer.WriteStartDocument();
|
|
|
|
|
+ writer.WriteStartElement("RequestTotalProductionInfo");
|
|
|
|
|
+ writer.WriteAttributeString("MachineName", dr["dd_name"].ToString());
|
|
|
|
|
+ writer.WriteEndElement();
|
|
|
|
|
+ writer.WriteEndDocument();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (File.Exists(fullPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ File.ReadAllText(fullPath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ sql.Clear();
|
|
|
|
|
+ sql.Append($"UPDATE devicedata SET dd_status = -1 WHERE dd_name = '{dr["dd_name"].ToString()}'");
|
|
|
|
|
+ dh.ExecuteSql(sql.GetString(), "update");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -254,7 +358,6 @@ namespace UAS_MES_NEW.Make
|
|
|
MessageBox.Show(this.ParentForm, ex.Message, "警告");
|
|
MessageBox.Show(this.ParentForm, ex.Message, "警告");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
|
|
|
private void OnFileCreated(object sender, FileSystemEventArgs e)
|
|
private void OnFileCreated(object sender, FileSystemEventArgs e)
|
|
|
{
|
|
{
|
|
@@ -1154,7 +1257,6 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
private class PrinterData
|
|
private class PrinterData
|
|
|
{
|
|
{
|