From 9bf39cf89bb630e96d929707dc02e393677c64d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Wed, 12 Jun 2024 16:02:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=88=E6=9D=83=E6=8E=A8?= =?UTF-8?q?=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/FrmMain.cs | 9 +++++-- CPF_Cef/MainModel.cs | 58 +++++++++++++++++++++++++++++++++++++++++++- CPF_Cef/Parame.cs | 4 ++- 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index 0e46c5f..ee0d6aa 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -72,6 +72,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser ); } private TextBox textBox; + protected override async void OnInitialized() { //窗体大小 @@ -103,6 +104,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser { MainModel.KillProcessByName("AksWebBrowser"); } + bool showDev = false; private void WebBrowser_LoadEnd(object sender, LoadEndEventArgs e) { @@ -133,8 +135,11 @@ namespace AKS.EnterpriseLibrary.WebBrowser { try { - //获取授权 - GetSQObject(); + if (!Parame.isCloseHttp) + { + //获取授权 + GetSQObject(); + } //检测服务是否启动 MainModel.StartShll(); } diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 4f92c8e..48eabfb 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -11,6 +11,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using SkiaSharp; using System; +using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -163,6 +164,10 @@ namespace AKS.EnterpriseLibrary.WebBrowser case "aks100117": result = ReadQuestionAnswer(content); break; + //读取问答:{ "code":"aks100118", "isCloseHttp":true,"data": "{}"} + case "aks100118": + result = SendSQ(content); + break; default: result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; break; @@ -1232,7 +1237,8 @@ namespace AKS.EnterpriseLibrary.WebBrowser { return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "获取数据失败" + "\"}"; } - else { + else + { return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + qwStr + "\"}"; } } @@ -1244,6 +1250,56 @@ namespace AKS.EnterpriseLibrary.WebBrowser } } + /// + /// 获取授权数据 + /// + /// + /// + public static string SendSQ(string content) + { + try + { + var param = content.ConvertToAnonymousType(new + { + code = default(string), + data = default(string), + isCloseHttp = default(bool) + }); + if (param == null) + { + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + "参数解析错误" + "\"}"; + } + Parame.isCloseHttp = param.isCloseHttp; + List list = new List(); + JObject jo = (JObject)JsonConvert.DeserializeObject(param.data); + if (jo["IsSucceed"].ToString() == "True") + { + string result = jo["result"].ToString(); + if (!string.IsNullOrEmpty("result")) + { + JArray array = (JArray)JsonConvert.DeserializeObject(result); + foreach (JObject item in array) + { + Func func = new Func() + { + Id = item["Id"].ToString(), + Platform = item["Platform"].ToString(), + Interfaceaddress = item["Interfaceaddress"].ToString(), + }; + list.Add(func); + } + } + } + Parame.FuncObject = list; + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + param.code + "\",\"message\":\"seccse\",\"code\":\"200\",\"status\":true,\"data\":\"" + "推送成功" + "\"}"; + } + catch (Exception ex) + { + //Log.Error("执行文件异常:" + ex.Message); + return "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"" + ex.Message + "\"}"; + } + } + /// /// 执行文件 /// diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs index 2249759..4853937 100644 --- a/CPF_Cef/Parame.cs +++ b/CPF_Cef/Parame.cs @@ -41,9 +41,11 @@ namespace AksWebBrowser //打印名字 public static string PrinterName = "Lexmark-MS430-Series"; //是否启用双目 - public static bool isSM = false; + public static bool isSM = true; //是否开启高拍仪 public static bool isGPY = false; + //是否关闭授权定时请求 + public static bool isCloseHttp = false; //双目摄像头 public static string smWebsocket = "ws://127.0.0.1:22226"; //消息推送