|
@@ -3,6 +3,7 @@ using Cognex.VisionPro;
|
|
|
using Cognex.VisionPro.ToolBlock;
|
|
using Cognex.VisionPro.ToolBlock;
|
|
|
using CSScripting;
|
|
using CSScripting;
|
|
|
using CSScriptLib;
|
|
using CSScriptLib;
|
|
|
|
|
+using iTextSharp.xmp.impl.xpath;
|
|
|
using MathNet.Numerics.Distributions;
|
|
using MathNet.Numerics.Distributions;
|
|
|
using MathNet.Numerics.LinearAlgebra;
|
|
using MathNet.Numerics.LinearAlgebra;
|
|
|
using MathNet.Numerics.RootFinding;
|
|
using MathNet.Numerics.RootFinding;
|
|
@@ -27,6 +28,7 @@ using System.Data;
|
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
using System.Drawing;
|
|
using System.Drawing;
|
|
|
using System.IO;
|
|
using System.IO;
|
|
|
|
|
+using System.IO.Compression;
|
|
|
using System.Linq;
|
|
using System.Linq;
|
|
|
using System.Net.Sockets;
|
|
using System.Net.Sockets;
|
|
|
using System.Reflection.Metadata;
|
|
using System.Reflection.Metadata;
|
|
@@ -63,6 +65,7 @@ using TeamAAS_VP.Views.Product;
|
|
|
using TouchSocket.Core;
|
|
using TouchSocket.Core;
|
|
|
using TouchSocket.SerialPorts;
|
|
using TouchSocket.SerialPorts;
|
|
|
using TouchSocket.Sockets;
|
|
using TouchSocket.Sockets;
|
|
|
|
|
+using XAMLMarkupExtensions.Base;
|
|
|
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
|
|
using static MaterialDesignThemes.Wpf.Theme.ToolBar;
|
|
|
using static Org.BouncyCastle.Math.EC.ECCurve;
|
|
using static Org.BouncyCastle.Math.EC.ECCurve;
|
|
|
using static System.Windows.Forms.AxHost;
|
|
using static System.Windows.Forms.AxHost;
|
|
@@ -2360,7 +2363,7 @@ namespace TeamAAS_VP.Core
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (currentProduct.ID!= productId)
|
|
|
|
|
|
|
+ if (currentProduct.ID != productId)
|
|
|
{
|
|
{
|
|
|
//切换产品
|
|
//切换产品
|
|
|
_productService.LoadProduct(productId);
|
|
_productService.LoadProduct(productId);
|
|
@@ -2556,19 +2559,39 @@ namespace TeamAAS_VP.Core
|
|
|
if (recordResult)
|
|
if (recordResult)
|
|
|
{
|
|
{
|
|
|
SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
|
|
SendTaskMessage($"{i}:{stationConfig.DeviceName}产品记录保存成功", MessageLevel.Debug);
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- //(bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN[i], "");
|
|
|
|
|
- //if (isSuc)
|
|
|
|
|
- //{
|
|
|
|
|
- // LogHelper.WriteLogMes($"上传数据成功");
|
|
|
|
|
- // SendTaskMessage($"上传数据成功", MessageLevel.Debug);
|
|
|
|
|
- //}
|
|
|
|
|
- //else
|
|
|
|
|
- //{
|
|
|
|
|
- // LogHelper.WriteLogMes($"上传数据失败");
|
|
|
|
|
- // SendTaskMessage($"上传数据失败", MessageLevel.Error);
|
|
|
|
|
- //}
|
|
|
|
|
|
|
+ //上传数据
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ DateTime dt = DateTime.Now;
|
|
|
|
|
+ string filename = ProductMainSN[i] + "_" + dt.ToString("yyyyMMddHHmmss");
|
|
|
|
|
+ var device = _configService.GetDeviceInfo();
|
|
|
|
|
+ (bool isSuc, string resp) = await _mesService.SendFtpFileAsync(ProductMainSN[i], filename);
|
|
|
|
|
+ if (isSuc)
|
|
|
|
|
+ {
|
|
|
|
|
+ LogHelper.WriteLogMes($"上传数据成功");
|
|
|
|
|
+ SendTaskMessage($"上传数据成功", MessageLevel.Debug);
|
|
|
|
|
+ string filePath = $"D:\\image\\Recored\\{dt.ToString("yyyy-MM")}\\{dt.ToString("MM-dd")}\\{currentProduct.Name}\\{ProductMainSN[i]}";
|
|
|
|
|
+ //复制csv
|
|
|
|
|
+ string source_csv = $"{stationConfig.SaveCsvPath}\\{dt.ToString("yyyy-MM")}\\{i}_{stationConfig.DataInfo.PROCESS_NAME}_{dt.ToString("yyyy-MM-dd")}.csv";
|
|
|
|
|
+ string target_csv = Path.Combine(filePath, Path.GetFileName(source_csv)); ;
|
|
|
|
|
+ File.Copy(source_csv, target_csv, true);
|
|
|
|
|
+ //复制log
|
|
|
|
|
+ string source_log = $"..\\Log\\LogInfo\\{dt.ToString("yyyy-MM")}\\{dt.ToString("yyyy-MM-dd")}.txt";
|
|
|
|
|
+ string target_log = Path.Combine(filePath, Path.GetFileName(source_log));
|
|
|
|
|
+ File.Copy(source_log, target_log, true);
|
|
|
|
|
+ CompressionImage(filePath, filename, device.FixtureId);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ LogHelper.WriteLogMes($"上传数据失败");
|
|
|
|
|
+ SendTaskMessage($"上传数据失败", MessageLevel.Error);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"上传数据时出错:{ex.Message}", MessageLevel.Error);
|
|
|
|
|
+ LogHelper.WriteLogError($"上传数据时出错", ex);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -3248,6 +3271,34 @@ namespace TeamAAS_VP.Core
|
|
|
}
|
|
}
|
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
+ #region 压缩图片文件夹
|
|
|
|
|
+ public async void CompressionImage(string sourcePath, string zipname,string fixid)
|
|
|
|
|
+ {
|
|
|
|
|
+ string zipPath = "";
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ SendTaskMessage($"开始压缩文件", MessageLevel.Info);
|
|
|
|
|
+ await Task.Run(() =>
|
|
|
|
|
+ {
|
|
|
|
|
+ zipPath = $"Z:\\{fixid}\\{DateTime.Now.ToString("yyyyMMdd")}\\{zipname}.zip";//生成的zip文件路径
|
|
|
|
|
+ ZipFile.CreateFromDirectory(sourcePath, zipPath);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ LogHelper.WriteLogError($"压缩文件时出错", ex);
|
|
|
|
|
+ }
|
|
|
|
|
+ finally
|
|
|
|
|
+ {
|
|
|
|
|
+ // 清理临时文件
|
|
|
|
|
+ if (File.Exists(zipPath))
|
|
|
|
|
+ {
|
|
|
|
|
+ File.Delete(zipPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ #endregion
|
|
|
#endregion
|
|
#endregion
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|