|
|
@@ -110,6 +110,12 @@ namespace UAS_MES_NEW.Make
|
|
|
txtPath.SelectAll();
|
|
|
return;
|
|
|
}
|
|
|
+ string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
|
|
|
+ if (txtFiles.Length == 0)
|
|
|
+ {
|
|
|
+ LogMessage($"当前没有{currFileType.ToUpper()}文件");
|
|
|
+ return;
|
|
|
+ }
|
|
|
RefreshFileList();
|
|
|
}
|
|
|
private void Choose_Click(object sender, EventArgs e)
|
|
|
@@ -148,7 +154,6 @@ namespace UAS_MES_NEW.Make
|
|
|
break;
|
|
|
case 2:
|
|
|
dialog.Description = "请选择读取印刷机设备的文本文件夹";
|
|
|
- currFileType = "xml";
|
|
|
equiType = "印刷机";
|
|
|
break;
|
|
|
case 3:
|
|
|
@@ -163,7 +168,18 @@ namespace UAS_MES_NEW.Make
|
|
|
txtPath.Enabled = false;
|
|
|
Device.Enabled = false;
|
|
|
var watcher = new FileSystemWatcher(txtPath.Text);
|
|
|
- watcher.Filter = $"*.{currFileType}";
|
|
|
+ if (equiType == "印刷机")
|
|
|
+ {
|
|
|
+ var xmlFiles = Directory.GetFiles(txtPath.Text, "*.xml");
|
|
|
+ var csvFiles = Directory.GetFiles(txtPath.Text, "*.csv");
|
|
|
+ currFileType = xmlFiles.Length > 0 ? "xml" : "csv";
|
|
|
+ watcher.Filter = $"*.{currFileType}";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ watcher.Filter = $"*.{currFileType}";
|
|
|
+ }
|
|
|
+
|
|
|
watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite;
|
|
|
watcher.Created += OnFileCreated;
|
|
|
/*watcher.Changed += OnFileChanged;
|
|
|
@@ -240,7 +256,8 @@ namespace UAS_MES_NEW.Make
|
|
|
// 在UI线程上执行更新
|
|
|
if (lstFiles.InvokeRequired)
|
|
|
{
|
|
|
- lstFiles.Invoke(new Action(RefreshFileList));
|
|
|
+ //lstFiles.Invoke(new Action(RefreshFileList));
|
|
|
+ lstFiles.BeginInvoke(new Action(RefreshFileList));
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -253,10 +270,8 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
|
|
|
string[] txtFiles = Directory.GetFiles(txtPath.Text, $"*.{currFileType}");
|
|
|
-
|
|
|
if (txtFiles.Length == 0)
|
|
|
{
|
|
|
- LogMessage($"当前没有{currFileType.ToUpper()}文件");
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
@@ -276,12 +291,20 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
else if (Device.SelectedIndex == 2) // 印刷机 待测试对接
|
|
|
{
|
|
|
- // 印刷机xml文件解析
|
|
|
- //PrinterData xmlData = ReadWithXmlReader(file);
|
|
|
- //Console.WriteLine();
|
|
|
-
|
|
|
- // 印刷机csv文件解析
|
|
|
- //var csvData = ParseCsvFile(file);
|
|
|
+ string fileType = Path.GetExtension(file).ToLower();
|
|
|
+ PrinterData xmlData;
|
|
|
+ List<MesData> csvData;
|
|
|
+ if (fileType == ".csv"){
|
|
|
+ csvData = ParseCsvFile(file);
|
|
|
+ }
|
|
|
+ else if (fileType == ".xml"){
|
|
|
+ xmlData = ReadWithXmlReader(file);
|
|
|
+ }
|
|
|
+ string xmlContent = File.ReadAllText(file);
|
|
|
+ if (ConsoleLog(xmlContent, file))
|
|
|
+ {
|
|
|
+ File.Delete(file);
|
|
|
+ }
|
|
|
}
|
|
|
else if (Device.SelectedIndex == 3) // 贴片机 导站位表已测试对接
|
|
|
{
|