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 | 37 +++++++++++++++++++++++++++++++++---- 1 files changed, 33 insertions(+), 4 deletions(-) diff --git a/device/SnapManager.cs b/device/SnapManager.cs index 3a647a3..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,21 +14,47 @@ if (_snapDevice == null) { _snapDevice = new SnapDevice(); } - _snapDevice.LoadInfo(snap); + _snapDevice.LoadInfo(snap); // SNAP } public static string GetCapturePicturePath() { + //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 path = Settings.CaptureUrl; + 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; + + //// 鏋勫缓鏂囦欢鍚嶏細yyyy-MM-dd-HHmmss.jpg + //string fileName = $"{now:yyyy-MM-dd-HHmmss}.jpg"; + + //// 鏋勫缓鏂囦欢澶硅矾寰勶細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 filePath; + return url; } else { return string.Empty; } } + + // 澶ф鐜囩敤涓嶅埌锛屽簲璇ヤ笉鏄湰鍦版姄鍥撅紝鍙彲鑳芥槸缃戠粶鎶撳浘锛屽浘鐗囦繚瀛樺埌鍚庡彴 + + public static string GetCapturePictureLocal() { + return _snapDevice.GetCapturePictureLocalPath(); + } } } -- Gitblit v1.9.1