|
|
@@ -52,7 +52,6 @@ namespace UAS_MES_NEW.Make
|
|
|
List<string> fileList = new List<string>();
|
|
|
|
|
|
Timer formsTimer;
|
|
|
- string outXmlFilePath;
|
|
|
|
|
|
private void Make_ParseLog_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -63,7 +62,8 @@ namespace UAS_MES_NEW.Make
|
|
|
formsTimer = new Timer();
|
|
|
formsTimer.Interval = 10000;
|
|
|
formsTimer.Tick += timer1_Tick;
|
|
|
- //outXmlFilePath = "D:\\JANETSSR";
|
|
|
+ //formsTimer.Start();
|
|
|
+ //formsTimer.Stop();
|
|
|
|
|
|
watcher = new FileSystemWatcher();
|
|
|
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
|
|
|
@@ -128,21 +128,23 @@ namespace UAS_MES_NEW.Make
|
|
|
|
|
|
private void Choose_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
- FolderBrowserDialog dialog = new FolderBrowserDialog();
|
|
|
- switch (Device.SelectedIndex)
|
|
|
- {
|
|
|
- case 0:
|
|
|
- dialog.Description = "请选择读取劲拓SPI设备文件夹";
|
|
|
- currFileType = "Log";
|
|
|
- equiType = "设备";
|
|
|
- break;
|
|
|
- }
|
|
|
- if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
+ using (var dialog = new FolderBrowserDialog())
|
|
|
{
|
|
|
- txtPath.Text = dialog.SelectedPath;
|
|
|
- txtPath.Enabled = false;
|
|
|
- Device.Enabled = false;
|
|
|
- watcher.EnableRaisingEvents = false;
|
|
|
+ switch (Device.SelectedIndex)
|
|
|
+ {
|
|
|
+ case 0:
|
|
|
+ dialog.Description = "请选择读取设备文件夹";
|
|
|
+ currFileType = "Log";
|
|
|
+ equiType = "设备";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
+ {
|
|
|
+ txtPath.Text = dialog.SelectedPath;
|
|
|
+ txtPath.Enabled = false;
|
|
|
+ Device.Enabled = false;
|
|
|
+ watcher.EnableRaisingEvents = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -210,10 +212,6 @@ namespace UAS_MES_NEW.Make
|
|
|
{
|
|
|
watcher.Path = txtPath.Text;
|
|
|
watcher.Filter = $"*.{currFileType}";
|
|
|
-
|
|
|
- //formsTimer.Start();
|
|
|
- //formsTimer.Stop();
|
|
|
-
|
|
|
if (onWatch.Text == "开启解析")
|
|
|
{
|
|
|
watcher.EnableRaisingEvents = true;
|
|
|
@@ -231,66 +229,6 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- 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");
|
|
|
- string currentDate1 = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
- XmlWriterSettings settings = new XmlWriterSettings
|
|
|
- {
|
|
|
- Indent = true
|
|
|
- //,Encoding = System.Text.Encoding.UTF8
|
|
|
- };
|
|
|
- foreach (DataRow dr in dt.Rows)
|
|
|
- {
|
|
|
- #region
|
|
|
- /*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}__RequestTotalProduction.xml";
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- xmlName = $"1.08_{currentDate}_{currentDate}001__RequestTotalProduction.xml";
|
|
|
- }*/
|
|
|
- #endregion
|
|
|
- string xmlName = $"1.08__{currentDate1}T101505_{currentDate}001__RequestTotalProduction.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();
|
|
|
- }
|
|
|
-
|
|
|
- sql.Clear();
|
|
|
- sql.Append($"UPDATE devicedata SET dd_status = -1 WHERE dd_name = '{dr["dd_name"].ToString()}' and dd_status = 0");
|
|
|
- dh.ExecuteSql(sql.GetString(), "update");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- LogMessage($"写入指令文件异常: {ex.Message}");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private void OnFileCreated(object sender, FileSystemEventArgs e)
|
|
|
{
|
|
|
RefreshFileList();
|
|
|
@@ -342,7 +280,7 @@ namespace UAS_MES_NEW.Make
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- if (Device.SelectedIndex == 0) // 测试设备
|
|
|
+ if (Device.SelectedIndex == 0)
|
|
|
{
|
|
|
ParseLogInsert(file);
|
|
|
}
|
|
|
@@ -370,14 +308,24 @@ namespace UAS_MES_NEW.Make
|
|
|
int fileNum = string.IsNullOrEmpty(lines[lines.Length - 1]) ? lines.Length - 1 : lines.Length;
|
|
|
foreach (var item in lines)
|
|
|
{
|
|
|
- if (string.IsNullOrEmpty(item)) continue;
|
|
|
+ if (string.IsNullOrEmpty(item)) break;
|
|
|
string[] currItem = item.Split(',');
|
|
|
if(equiType == "设备")
|
|
|
{
|
|
|
string[] resultArr = currItem[0].Split('=');
|
|
|
+
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append($@"select MAL_SNCODE from makeaddresslist where MAL_SN1_USER = '" + currItem[1] + "'");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ if (dt.Rows.Count == 0 || dt.Rows[0]["MAL_SNCODE"].ToString() == "")
|
|
|
+ {
|
|
|
+ LogMessage($"文件 {PathName}, 解析SN: {currItem[1]}无匹配过站SN");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
Log itemLog = new Log()
|
|
|
{
|
|
|
- SN = currItem[1],
|
|
|
+ SN = dt.Rows[0]["MAL_SNCODE"].ToString(),
|
|
|
Result = resultArr[1],
|
|
|
};
|
|
|
logArr.Add(itemLog);
|
|
|
@@ -418,18 +366,17 @@ namespace UAS_MES_NEW.Make
|
|
|
//记录操作日志
|
|
|
LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "日志解析", "日志解析成功", item.SN, "");
|
|
|
|
|
|
+ string outMsg = "";
|
|
|
param.Add(item.SN);
|
|
|
- string res = "";
|
|
|
- param.Add(res);
|
|
|
+ param.Add(omakeCode);
|
|
|
+ param.Add(User.UserSourceCode);
|
|
|
+ param.Add(item.Result);
|
|
|
+ param.Add(outMsg);
|
|
|
+
|
|
|
string[] paramList = param.ToArray();
|
|
|
- dh.CallProcedure("cs_insert_testrejects", ref paramList);
|
|
|
- param.Clear();
|
|
|
+ dh.CallProcedure("cs_insert_testdetail", ref paramList);
|
|
|
LogMessage($"文件: {PathName},共{fileNum}条记录已过站解析");
|
|
|
-
|
|
|
- if (logs.IndexOf(item) == logs.Count - 1)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
+ param.Clear();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -451,6 +398,18 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void timer1_Tick(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ LogMessage($"定时器异常: {ex.Message}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private bool ConsoleLog(string Content, string PathName)
|
|
|
{
|
|
|
try
|
|
|
@@ -510,7 +469,6 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private class Log
|
|
|
{
|
|
|
public string SN { set; get; }
|