|
@@ -163,18 +163,26 @@ namespace SCADA_DAQ.Customer.Machines
|
|
|
{
|
|
|
if (Directory.Exists(CustomerEnv.CustomerConfig.MesShareDir))
|
|
|
{
|
|
|
- var fileName = Path.GetFullPath($"{CustomerEnv.CustomerConfig.MesShareDir}\\{barcode}.txt");
|
|
|
-
|
|
|
- using (var fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write))
|
|
|
+ try
|
|
|
{
|
|
|
- using (var wr = new StreamWriter(fs))
|
|
|
+ var fileName = Path.GetFullPath($"{CustomerEnv.CustomerConfig.MesShareDir}\\{barcode}.txt");
|
|
|
+ if (File.Exists(fileName)) FileHelper.DeleteFile(fileName);
|
|
|
+ using (var fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write))
|
|
|
{
|
|
|
- wr.Write($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},{barcode}");
|
|
|
- wr.Flush();
|
|
|
- wr.Close();
|
|
|
+ using (var wr = new StreamWriter(fs))
|
|
|
+ {
|
|
|
+ wr.Write($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},{barcode}");
|
|
|
+ wr.Flush();
|
|
|
+ wr.Close();
|
|
|
+ }
|
|
|
+ fs.Close();
|
|
|
}
|
|
|
- fs.Close();
|
|
|
}
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
var xmlDoc = XDocument.Load(filePath);
|
|
|
board = SCADA.CommonLib.Helper.XmlHelper.Deserialize<Board>(xmlDoc.Descendants("Plane").FirstOrDefault());
|