kazelee
2 天以前 6d2faa6e299bdfe545ee339269e64f2900229147
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using 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 {
        private static SnapDevice _snapDevice { get; set; }
        public SnapManager(Config.Snap snap) {
            if (_snapDevice == null) {
                _snapDevice = new SnapDevice();
            }
            _snapDevice.LoadInfo(snap); // SNAP
        }
 
        public static string GetCapturePicturePath() {
            //return string.Empty;
            // SNAP
 
            DateTime now = DateTime.Now;
            //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 url;
            }
            else {
                return string.Empty;
            }
        }
 
        // 大概率用不到,应该不是本地抓图,只可能是网络抓图,图片保存到后台
 
        public static string GetCapturePictureLocal() {
            return _snapDevice.GetCapturePictureLocalPath();
        }
    }
}