From ab94f070d797edbe927d7d58a460cc4eddf48b03 Mon Sep 17 00:00:00 2001
From: jace.tang <1536884497@qq.com>
Date: 星期一, 13 六月 2022 10:58:40 +0800
Subject: [PATCH] 1.添加检测异常抛出时图片保存动作

---
 DetectionData.cs |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/DetectionData.cs b/DetectionData.cs
index 40c0f37..ec0f301 100644
--- a/DetectionData.cs
+++ b/DetectionData.cs
@@ -6,6 +6,8 @@
 using System.Text;
 using System.Windows.Forms;
 using System.Drawing;
+using System.Diagnostics;
+using System.Collections.Generic;
 
 namespace M423project
 {
@@ -167,6 +169,41 @@
                 }
             }
         }
+
+        public void SaveTrayBarcode(List<int> detectIDList, string carrierCode = null)
+        {
+            //string trayCode = CarrierBarcodeCtrl.GlobalCarrierBarcode;
+
+            if (carrierCode == null)
+            {
+                carrierCode = CarrierBarcodeCtrl.GlobalCarrierBarcode;
+            }
+
+            if (detectIDList.Count == 0)
+            {
+                return;
+            }
+            lock (synObj)
+            {
+                string idList = string.Join(",", detectIDList);
+                try
+                {
+                    string sql = $"Update ProductDetectionDetail set CarrierBarcode='{carrierCode}' where AutoID in ({idList})";
+
+                    using (SqlCommand cmd = new SqlCommand(sql, connection))
+                    {
+                        cmd.ExecuteNonQuery();
+                    }
+
+                    Trace.TraceInformation($"{idList}浜у搧缁戝畾杞藉叿鐮侊細{carrierCode}");
+                }
+                catch (Exception ex)
+                {
+                    Trace.TraceError($"{idList}浜у搧缁戝畾杞藉叿鐮侊細{carrierCode}寮傚父锛歿ex.Message}");
+                    //throw;
+                }
+            }
+        }
         #endregion
 
         #region add by Patrick 2019-04-16
@@ -285,8 +322,14 @@
         public void SaveToCsv(ProductMeasureResult pmr)
         {
             string fileName = @"E:\DailyReport\detectdata" + DateTime.Now.ToString("yyyyMMdd") + ".csv";
-            bool IsNewFile = !File.Exists(fileName);
 
+            CSVDataRecord(pmr, fileName);
+
+        }
+
+        public void CSVDataRecord(ProductMeasureResult pmr, string fileName)
+        {
+            bool IsNewFile = !File.Exists(fileName);
             lock (csvLock)
             {
                 using (FileStream myStream = new FileStream(fileName, FileMode.OpenOrCreate))

--
Gitblit v1.8.0