From a33016b52de09583be7313471c920b89f26e5faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Mon, 3 Jun 2024 19:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/Common/ChunkedUpload.cs | 4 ++-- CPF_Cef/MainModel.cs | 25 +++++++++++++------------ CPF_Cef/Parame.cs | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs index f0d910a..20d6330 100644 --- a/CPF_Cef/Common/ChunkedUpload.cs +++ b/CPF_Cef/Common/ChunkedUpload.cs @@ -190,7 +190,7 @@ namespace AksWebBrowser.Common } else if (jo2["code"].ToString() == "2") { - return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "用户取消签字" + "\"}"; + return "{\"timestamp\":\"" + "" + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "取消签字" + "\"}"; } else { @@ -206,7 +206,7 @@ namespace AksWebBrowser.Common } else if (jo2["code"].ToString() == "2") { - return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "用户取消签字" + "\"}"; + return "{\"timestamp\":\"" + "" + "\",\"keycode\":\"" + code + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"suffix\":\"png\",\"data\":\"" + "取消签字" + "\"}"; } else { diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 14b3f4d..22ed378 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -14,6 +14,7 @@ using System.IO; using System.Linq; using System.Net; using System.Net.Http; +using System.Net.WebSockets; using System.Reflection.Metadata; using System.Text; using System.Text.RegularExpressions; @@ -25,24 +26,26 @@ namespace AKS.EnterpriseLibrary.WebBrowser { public class MainModel : CPF.CpfObject { - + private static List allSockets; //初始化网络连接 public static void DeviceControllerInit() { try { - List lit = new List(); + allSockets = new List(); var server = new WebSocketServer("ws://0.0.0.0:19983"); server.Start(socket => { Parame.socket = socket; socket.OnOpen = () => { + allSockets.Add(socket); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"连接成功\"}"; socket.Send(result); }; socket.OnClose = () => { + allSockets.Remove(socket); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"连接关闭\"}"; socket.Send(result); }; @@ -67,7 +70,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser if (json != null) { //释放所有硬件 - Task.Run(() => { + Task.Run(() => + { HttpResponseClose(); }); @event8.WaitOne(); @@ -170,10 +174,6 @@ namespace AKS.EnterpriseLibrary.WebBrowser } try { - - //Log.Info("答复请求者:" + result); - //答复请求者(处理完请求后在些答复) - //byte[] bytes = SerializeContent(result); socket.Send(result); } catch { result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "hert" + "\",\"message\":\"seccse\",\"code\":\"400\",\"status\":true,\"data\":\"返回参数失败\"}"; } @@ -594,7 +594,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser } else { - Task.Run(() => {HttpPostResponseBySign("open", 1, param.code, param.timeout); }); + Task.Run(() => { HttpPostResponseBySign("open", 1, param.code, param.timeout); }); @event3.WaitOne(); string result = sginStr; SubmitLogs(result, "OpenSign"); @@ -686,7 +686,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser } else { - Task.Run(() => {HttpPostResponseByFinger("open", 1, param.timeout); }); + Task.Run(() => { HttpPostResponseByFinger("open", 1, param.timeout); }); event2.WaitOne(); string result = string.Empty; if (string.IsNullOrEmpty(fingerStr)) @@ -1464,7 +1464,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser { var httpClient = new HttpClient(); var uploader = new ChunkedUpload(httpClient); - await uploader.PublicSign("close", 2,0); + await uploader.PublicSign("close", 2, 0); await uploader.PublicFinger("close", 2, 0); await uploader.PublicIdcard("close", 2, 0); @event8.Set(); @@ -1474,7 +1474,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser //Log.Error("高拍仪异常:" + ex.Message); } } - + /// /// 初始文件上传 /// @@ -1876,7 +1876,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser return ""; } - public static string StartShll() { + public static string StartShll() + { string commod = "lsof -i:9039"; return ""; } diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs index e88e202..6c95420 100644 --- a/CPF_Cef/Parame.cs +++ b/CPF_Cef/Parame.cs @@ -30,7 +30,7 @@ namespace AksWebBrowser //高拍仪devIndex public static string gpydevIndex = "0"; //签字版、指纹、身份证 - public static string signUrl = "http://127.0.0.1:9399/device"; + public static string signUrl = "http://192.168.0.234:9399/device"; public static int timeout = 3000; //票据打印机 public static string pritPj = "/dev/ttyS7";