From f2ed12518f6adc91bcc09434582c1ae3f090629e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Tue, 11 Jun 2024 16:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=95=B0=E6=8D=AE=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/Common/ChunkedUpload.cs | 91 +++++++++++++++++++++++++-------- CPF_Cef/FrmMain.cs | 12 ++--- CPF_Cef/MainModel.cs | 70 +++++++++++++++++++++++++ CPF_Cef/Parame.cs | 2 + CPF_Cef/Ramark.txt | 3 +- 5 files changed, 149 insertions(+), 29 deletions(-) diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs index 77cab30..06fde77 100644 --- a/CPF_Cef/Common/ChunkedUpload.cs +++ b/CPF_Cef/Common/ChunkedUpload.cs @@ -396,7 +396,7 @@ namespace AksWebBrowser.Common if (jo2["code"].ToString() == "0") { if (type == "open" && typeCode == 1) - { + { //读取指纹 if (typeCode == 1) { @@ -497,17 +497,25 @@ namespace AksWebBrowser.Common public async Task PublicFinger(string type, int typeCode, int timeout) { string body = string.Empty; - timeout = timeout == 0 ? Parame.timeout : timeout; - var client = new HttpClient(); - client.Timeout = TimeSpan.FromSeconds(timeout); - var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); - var content = new StringContent("{\r\n \"command\": \"finger\",\r\n \"command_num\": 121,\r\n \"data\": {\r\n \"operation\": \"" + type + "\",\r\n \"operation_code\": " + typeCode + ",\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain"); - request.Content = content; - var response = await client.SendAsync(request); - response.EnsureSuccessStatusCode(); - if (response.StatusCode.ToString() == "OK") + try { - body = await response.Content.ReadAsStringAsync(); + timeout = timeout == 0 ? Parame.timeout : timeout; + var client = new HttpClient(); + client.Timeout = TimeSpan.FromSeconds(timeout); + var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); + var content = new StringContent("{\r\n \"command\": \"finger\",\r\n \"command_num\": 121,\r\n \"data\": {\r\n \"operation\": \"" + type + "\",\r\n \"operation_code\": " + typeCode + ",\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain"); + request.Content = content; + var response = await client.SendAsync(request); + response.EnsureSuccessStatusCode(); + if (response.StatusCode.ToString() == "OK") + { + body = await response.Content.ReadAsStringAsync(); + } + } + catch (Exception) + { + + return ""; } return body; } @@ -604,19 +612,60 @@ namespace AksWebBrowser.Common public async Task PublicIdcard(string type, int typeCode, int timeout) { string body = string.Empty; - timeout = timeout == 0 ? Parame.timeout : timeout; - var client = new HttpClient(); - client.Timeout = TimeSpan.FromSeconds(timeout); - var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); - var content = new StringContent("{\r\n \"command\": \"idcard\",\r\n \"command_num\": 141,\r\n \"data\": {\r\n \"operation\": \"close\",\r\n \"operation_code\": 2,\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain"); - request.Content = content; - var response = await client.SendAsync(request); - response.EnsureSuccessStatusCode(); - if (response.StatusCode.ToString() == "OK") + try { - body = await response.Content.ReadAsStringAsync(); + timeout = timeout == 0 ? Parame.timeout : timeout; + var client = new HttpClient(); + client.Timeout = TimeSpan.FromSeconds(timeout); + var request = new HttpRequestMessage(HttpMethod.Post, Parame.signUrl); + var content = new StringContent("{\r\n \"command\": \"idcard\",\r\n \"command_num\": 141,\r\n \"data\": {\r\n \"operation\": \"close\",\r\n \"operation_code\": 2,\r\n \"parameters\": {\r\n }\r\n }\r\n}", null, "text/plain"); + request.Content = content; + var response = await client.SendAsync(request); + response.EnsureSuccessStatusCode(); + if (response.StatusCode.ToString() == "OK") + { + body = await response.Content.ReadAsStringAsync(); + } + } + catch (Exception) + { + return ""; } return body; } + + /// + /// 获取问题 + /// + /// + /// + /// + /// + /// + /// + public async Task GetQuestionAnswer(string PetitionId, string PId, string Name, int PageIndex, int PageSize) + { + string body = string.Empty; + try + { + var client = new HttpClient(); + var request = new HttpRequestMessage(HttpMethod.Post, Parame.qwUrl + "/api/QuestionAnswer/Query"); + var content = new StringContent("{\r\n \"PetitionId\": \"" + PetitionId + "\",\r\n \"PId\": \"" + PId + "\",\r\n \"Name\": \"" + Name + "\",\r\n \"PageIndex\": " + PageIndex + ",\r\n \"PageSize\": " + PageSize + "\r\n}", null, "application/json"); + request.Content = content; + var response = await client.SendAsync(request); + response.EnsureSuccessStatusCode(); + if (response.StatusCode.ToString() == "OK") + { + body = await response.Content.ReadAsStringAsync(); + } + } + catch (Exception) + { + return ""; + } + return body; + } + + } } diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index 760153b..b064d08 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -18,10 +18,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser { public class FrmMain : Window { - //public int w = 1080; - //public int h = 1920; - public int h = 1080; - public int w = 1920; + public int w = 1080; + public int h = 1920; + //public int h = 1080; + //public int w = 1920; protected override void InitializeComponent() { @@ -32,8 +32,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser Title = "控申业务专用浏览器"; CanResize = false; ShowInTaskbar = true; - //WindowState = WindowState.FullScreen; - WindowState = WindowState.Maximized; + WindowState = WindowState.FullScreen; + //WindowState = WindowState.Maximized; Children.Add( new Border diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 52258bb..a36c0ea 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -20,11 +20,13 @@ using System.Net; using System.Net.Http; using System.Net.WebSockets; using System.Reflection.Metadata; +using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Web; +using System.Xml.Linq; using static System.Net.Mime.MediaTypeNames; namespace AKS.EnterpriseLibrary.WebBrowser @@ -159,6 +161,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser case "aks100116": result = BurnFile(content); break; + //读取问答:{ "code":"aks100117", "PetitionId": "34", "PId": "", "Name": "", "PageIndex": 1,"PageSize": 10} + case "aks100117": + result = ReadQuestionAnswer(content); + break; default: result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; break; @@ -1194,6 +1200,52 @@ namespace AKS.EnterpriseLibrary.WebBrowser } } + + /// + /// aks100117 读取问答 (已国产化) + /// + /// + /// + public static string ReadQuestionAnswer(string content) + { + try + { + var param = content.ConvertToAnonymousType(new + { + code = default(string), + PetitionId = default(string), + PId = default(string), + Name = default(string), + PageIndex = default(int), + PageSize = default(int) + }); + if (param == null) + { + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "参数解析错误" + "\"}"; + } + else + { + Task.Run(async () => + { + QuestionAnswer(param.PetitionId, param.PId, param.Name, param.PageIndex, param.PageSize); + }); + @event10.WaitOne(); + if (string.IsNullOrEmpty(qwStr)) + { + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取数据失败" + "\"}"; + } + else { + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + qwStr + "\"}"; + } + } + } + catch (Exception ex) + { + //Log.Error("唤醒键盘异常: " + ex.Message + ""); + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; + } + } + /// /// 执行文件 /// @@ -1680,6 +1732,24 @@ namespace AKS.EnterpriseLibrary.WebBrowser } } + //读取问答 + private static string qwStr = string.Empty; + private static AutoResetEvent @event10 = new AutoResetEvent(false); + private static async void QuestionAnswer(string PetitionId, string PId, string Name, int PageIndex, int PageSize) + { + try + { + var httpClient = new HttpClient(); + var uploader = new ChunkedUpload(httpClient); + qwStr = await uploader.GetQuestionAnswer(PetitionId, PId, Name, PageIndex, PageSize); + @event10.Set(); + } + catch (Exception ex) + { + //Log.Error("上传本地文件中转异常:" + ex.Message); + } + } + //根据程序名称杀死进程 public static void KillProcessByName(string processName) { diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs index ca0944c..e37c3ec 100644 --- a/CPF_Cef/Parame.cs +++ b/CPF_Cef/Parame.cs @@ -52,6 +52,8 @@ namespace AksWebBrowser public static int score = 65; //人脸比对阈值 public static string ImgBase64 = string.Empty; + //获取问答 + public static string qwUrl = "http://116.205.231.210:82"; } public struct Func { diff --git a/CPF_Cef/Ramark.txt b/CPF_Cef/Ramark.txt index c96dd5e..39d6a6c 100644 --- a/CPF_Cef/Ramark.txt +++ b/CPF_Cef/Ramark.txt @@ -10,8 +10,7 @@ sudo apt install libsox-fmt-all sudo apt-get install libgdiplus sudo apt-get install alsa-utils sudo apt-get install espeak -sudo apt-get install gcc -sudo apt-get install g++ + sudo apt-get install imagemagick sudo apt-get install libvlc-dev sudo apt-get install vlc