From 2aa6ffae020b4dab66ac30ee4436346aa15ff3cb Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期二, 15 七月 2025 17:26:54 +0800
Subject: [PATCH] 修复绑定解绑可能导致的信息丢失问题

---
 device/SnapManager.cs |   50 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/device/SnapManager.cs b/device/SnapManager.cs
index fd494b6..5dee262 100644
--- a/device/SnapManager.cs
+++ b/device/SnapManager.cs
@@ -1,8 +1,11 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+
+using NetSDKCS;
 
 namespace HH.WCS.Mobox3.AnGang.device {
     public class SnapManager {
@@ -11,24 +14,47 @@
             if (_snapDevice == null) {
                 _snapDevice = new SnapDevice();
             }
-            //_snapDevice.LoadInfo(snap); // TODO SNAP
+            _snapDevice.LoadInfo(snap); // SNAP
         }
 
         public static string GetCapturePicturePath() {
-            //DateTime now = DateTime.Now;
+            //return string.Empty;
+            // SNAP
+
+            DateTime now = DateTime.Now;
             //string path = Settings.CaptureUrl;
-            //string fileName = string.Format("{0}{1}{2}{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg";
-            //string filePath = path + "\\" + fileName;
+            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"StaticStorage/image/{now.Year}/{now.Month}/{now.Day}");
+            string fileName = string.Format("{0}-{1}-{2}-{3}{4}{5}", now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second) + ".jpg";
+            string filePath = path + "\\" + fileName;
+            string url = Path.Combine(Settings.WebApiUrl, $"static/image/{now.Year}/{now.Month}/{now.Day}", fileName);
+            //// 鑾峰彇褰撳墠鏃堕棿
+            //DateTime now = DateTime.Now;
 
-            //if (_snapDevice.SnapPictureToFileOK(ref filePath)) {
-            //    return filePath;
-            //}
-            //else {
-            //    return string.Empty;
-            //}
+            //// 鏋勫缓鏂囦欢鍚嶏細yyyy-MM-dd-HHmmss.jpg
+            //string fileName = $"{now:yyyy-MM-dd-HHmmss}.jpg";
 
-            // TODO SNAP
-            return string.Empty;
+            //// 鏋勫缓鏂囦欢澶硅矾寰勶細path\yyyy\MM\dd
+            //string directoryPath = Path.Combine(path, now.Year.ToString(), now.Month.ToString("00"), now.Day.ToString("00"));
+
+            //// 濡傛灉鐩綍涓嶅瓨鍦ㄥ垯鍒涘缓
+            //Directory.CreateDirectory(directoryPath);
+
+            //// 瀹屾暣鐨勬枃浠惰矾寰�+            //string filePath = Path.Combine(directoryPath, fileName);
+
+            if (_snapDevice.SnapPictureToFileOK(ref filePath)) {
+                //return filePath;
+                return url;
+            }
+            else {
+                return string.Empty;
+            }
+        }
+
+        // 澶ф鐜囩敤涓嶅埌锛屽簲璇ヤ笉鏄湰鍦版姄鍥撅紝鍙彲鑳芥槸缃戠粶鎶撳浘锛屽浘鐗囦繚瀛樺埌鍚庡彴
+
+        public static string GetCapturePictureLocal() {
+            return _snapDevice.GetCapturePictureLocalPath();
         }
     }
 }

--
Gitblit v1.9.1