From ee5e3a086a5dc145e7f5df3de32e0e072c183949 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期五, 06 六月 2025 15:19:40 +0800
Subject: [PATCH] 1

---
 project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserFaceController.cs |  134 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 134 insertions(+), 0 deletions(-)

diff --git a/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserFaceController.cs b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserFaceController.cs
new file mode 100644
index 0000000..3a9ddb4
--- /dev/null
+++ b/project/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/System/Sys_UserFaceController.cs
@@ -0,0 +1,134 @@
+锘�
+using System.IO;
+using System.Net.Mime;
+using System.Text.RegularExpressions;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Caching.Memory;
+using Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using StackExchange.Profiling;
+using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.Authorization;
+using WIDESEAWCS_Core.BaseController;
+using WIDESEAWCS_Core.Const;
+using WIDESEAWCS_Core.Extensions;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.HttpContextUser;
+using WIDESEAWCS_Core.Utilities;
+using WIDESEAWCS_DTO.SerialPort;
+using WIDESEAWCS_ISystemServices;
+using WIDESEAWCS_Model;
+using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_Model.Models.System;
+using IOFile = System.IO.File;
+
+namespace WIDESEAWCS_WCSServer.Controllers
+{
+    [Route("api/UserFace")]
+    [ApiController]
+    public class Sys_UserFaceController : ApiBaseController<ISys_UserFaceService, Sys_UserFace>
+    {
+        private readonly IHttpContextAccessor _httpContextAccessor;
+
+        public Sys_UserFaceController(ISys_UserFaceService userService, IHttpContextAccessor httpContextAccessor) : base(userService)
+        {
+            _httpContextAccessor = httpContextAccessor;
+        }
+        [HttpPost, Route("FaceRecognition"), AllowAnonymous]
+        public WebResponseContent FaceRecognition([FromBody] ImageModel model)
+        {
+            return Service.FaceRecognition(model);
+        }
+
+        [HttpPost, Route("FaceEnter")]
+        public WebResponseContent FaceEnter([FromBody] ImageModel model)
+        {
+            return Service.FaceEnter(model);
+        }
+
+        [HttpPost, HttpGet, Route("DownlodaFacePlugin"), AllowAnonymous]
+        public ActionResult DownlodaFacePlugin()
+        {
+            try
+            {
+                string path = $"{AppDomain.CurrentDomain.BaseDirectory}DownLoad/";
+                if (!Directory.Exists(path)) Directory.CreateDirectory(path);
+                path += "face-plugin.zip";
+
+                if (IOFile.Exists(path))
+                {
+                    byte[] fileBytes = IOFile.ReadAllBytes(path);
+                    return File(
+                            fileBytes,
+                            MediaTypeNames.Application.Octet,
+                            Path.GetFileName(path)
+                        );
+                }
+                else
+                {
+                    return Json(WebResponseContent.Instance.Error($"鏈壘鍒版枃浠�"));
+                }
+            }
+            catch (Exception ex)
+            {
+                return Json(WebResponseContent.Instance.Error($"涓嬭浇澶辫触锛歿ex.Message}"));
+            }
+        }
+
+        [HttpPost, HttpGet, Route("DownloadRegFile"), AllowAnonymous]
+        public ActionResult DownloadRegFile([FromBody] PathModel model)
+        {
+            try
+            {
+                string folderPath = model.Path;
+
+                foreach (var item in folderPath.ToCharArray())
+                {
+                    if (Regex.IsMatch(item.ToString(), @"[\u4e00-\u9fa5]"))
+                    {
+                        return Json(WebResponseContent.Instance.Error($"鎻掍欢璺緞涓嶈兘鍖呭惈涓枃"));
+                    }
+                }
+
+                string path = $"{AppDomain.CurrentDomain.BaseDirectory}DownLoad/";
+
+                // 濡傛灉鏂囦欢澶逛笉瀛樺湪锛屽垯鍒涘缓鏂囦欢澶�
+                //if (!Directory.Exists(folderPath))
+                //{
+                //    return Json(WebResponseContent.Instance.Error($"鎻掍欢璺緞涓嶅瓨鍦�"));
+                //}
+                // 鑾峰彇鏃ュ織鏂囦欢璺緞
+                string filePath = Path.Combine(path, "reg.reg");
+
+                if (IOFile.Exists(filePath))
+                {
+                    IOFile.Delete(filePath); // 鍒犻櫎宸插瓨鍦ㄧ殑鏃ュ織鏂囦欢
+                }
+
+                // 鏋勯�犳棩蹇楀唴瀹�
+                string content = $"Windows Registry Editor Version 5.00\r\n[HKEY_CLASSES_ROOT\\myapp]\r\n@=\"URL:MyApp Protocol\"\r\n\"URL Protocol\"=\"\"\r\n[HKEY_CLASSES_ROOT\\myapp\\shell]\r\n[HKEY_CLASSES_ROOT\\myapp\\shell\\open]\r\n[HKEY_CLASSES_ROOT\\myapp\\shell\\open\\command]\r\n@=\"\\\"{model.Path.Replace(@"\", @"\\")}\\\\FaceSdkX64Register.exe\\\" \\\"%1\\\"\"";
+
+                // 灏嗘棩蹇楀唴瀹硅拷鍔犲埌鏃ュ織鏂囦欢涓�
+                IOFile.AppendAllText(filePath, content);
+
+                byte[] fileBytes = IOFile.ReadAllBytes(filePath);
+                return File(
+                        fileBytes,
+                        MediaTypeNames.Application.Octet,
+                        Path.GetFileName(filePath)
+                    );
+            }
+            catch (Exception ex)
+            {
+                return Json(WebResponseContent.Instance.Error($"涓嬭浇澶辫触锛歿ex.Message}"));
+            }
+        }
+    }
+    public class PathModel
+    {
+        public string Path { get; set; }
+    }
+}

--
Gitblit v1.9.3