From f1f4e3fac410f5dad33901fa89ccbcb8104f9c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=BD=87=E9=98=B3?= Date: Mon, 24 Jun 2024 16:43:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=A7=86=E9=A2=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/AksVideoPlayer.cs | 22 ++++------- CPF_Cef/Common/ChunkedUpload.cs | 62 ++++++++++++++++++++++++++++++- CPF_Cef/Devices/PrintPJ.cs | 2 +- CPF_Cef/FrmMain.cs | 7 +++- CPF_Cef/MainModel.cs | 65 +++++++++++++++++++++++++++++++-- 5 files changed, 135 insertions(+), 23 deletions(-) diff --git a/CPF_Cef/AksVideoPlayer.cs b/CPF_Cef/AksVideoPlayer.cs index 3574053..ff482c4 100644 --- a/CPF_Cef/AksVideoPlayer.cs +++ b/CPF_Cef/AksVideoPlayer.cs @@ -1,17 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using CPF; -using CPF.Drawing; -using CPF.Controls; -using CPF.Shapes; -using CPF.Styling; +using CPF; using CPF.Animation; -using CPF.Svg; -using CPF.Input; -using static System.Net.Mime.MediaTypeNames; -using LibVLCSharp.Shared; +using CPF.Controls; +using CPF.Drawing; +using System; +using System.Text; namespace AksWebBrowser { @@ -55,7 +47,7 @@ namespace AksWebBrowser { IsAntiAlias = true; CornerRadius = "3,3,3,3"; - Height = "360"; + Height = "320"; Width = "640"; Background = "#2c2c2c"; ZIndex = 100; @@ -65,7 +57,7 @@ namespace AksWebBrowser MarginTop = 10f, Classes = "imgAndText", FontFamily = "微软雅黑",//Alibaba PuHuiTi - Text = "Close", + Text = "X", FontSize = 16, Cursor = CPF.Cursors.Hand, Foreground = Color.White, diff --git a/CPF_Cef/Common/ChunkedUpload.cs b/CPF_Cef/Common/ChunkedUpload.cs index d6fe28b..e169a8e 100644 --- a/CPF_Cef/Common/ChunkedUpload.cs +++ b/CPF_Cef/Common/ChunkedUpload.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Net; using System.Net.Http; using System.Threading.Tasks; @@ -621,7 +622,7 @@ namespace AksWebBrowser.Common return ""; } } - catch (Exception ex) + catch (Exception ex) { //关闭身份证 await PublicIdcard(timeout); @@ -701,5 +702,64 @@ namespace AksWebBrowser.Common } + /// + /// 读取body数据 + /// + /// + /// + /// + /// + public async Task ReadBody() + { + string body = string.Empty; + try + { + Init(); + + HttpClientHandler httpClientHandler = new HttpClientHandler(); + httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, + errors) => true; + HttpClient httpClient = new HttpClient(httpClientHandler); + + Log.Info("开始读取body数据"); + var client = new HttpClient(); + var request = new HttpRequestMessage + { + Method = HttpMethod.Get, + RequestUri = new Uri("https://wsxf.gj.jcy/xfnwweb/nwxf/tyyw_kg_xfjsdj/ty_v2_zhcxeditform/get?openviewtag=READONLY&srfkey=2af82e4c14bfb5f34fe01f3ed98a9f16"), + Headers = { + { "Authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiLmnajpkat8NTEwMTkyIiwiZXhwIjoxNzE5MjExNzczLCJpYXQiOjE3MTkxOTczNzN9.y3rq49XSvCMFSb_RxX5SsuC13v_2CR1yG8WbztOsv2uhQS2UL8pP7IY2s2Rbg-G4e0Xz4dFg0Oc9TvvVqp4YAQ" }, + { "User-Agent", "Apipost/8 (https://www.apipost.cn)" }, + }, + }; + using (var response = await client.SendAsync(request)) + { + response.EnsureSuccessStatusCode(); + body = await response.Content.ReadAsStringAsync(); + } + Log.Info("结束读取body数据"); + } + catch (Exception ex) + { + body=ex.Message; + } + return body; + } + + public static void Init() + { +#if NETSTANDARD || NET5_0_OR_GREATER + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; +#else + ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 + | SecurityProtocolType.Tls + | SecurityProtocolType.Tls11 + | SecurityProtocolType.Tls12; +#endif + ServicePointManager.ServerCertificateValidationCallback = (a, b, c, d) => { return true; }; + ServicePointManager.CheckCertificateRevocationList = true; + ServicePointManager.DefaultConnectionLimit = 1000; + ServicePointManager.Expect100Continue = false; + } } } diff --git a/CPF_Cef/Devices/PrintPJ.cs b/CPF_Cef/Devices/PrintPJ.cs index 5b6265b..e162e1d 100644 --- a/CPF_Cef/Devices/PrintPJ.cs +++ b/CPF_Cef/Devices/PrintPJ.cs @@ -72,7 +72,7 @@ namespace AksWebBrowser.Devices { try { - string txt = string.Format(" 您预约办理的{0}业务-,排号为:", ywmc); + string txt = string.Format(" 您预约办理的 {0} 业务,排号为:", ywmc); LibPrint.SetClean(); LibPrint.SetReadZKmode(0); LibPrint.SetAlignment(0); diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index 2f65d84..03820ea 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -4,6 +4,7 @@ using AKSWebBrowser.Commen; using CPF; using CPF.Cef; using CPF.Controls; +using CPF.Platform; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -72,7 +73,7 @@ namespace AksWebBrowser ); } private TextBox textBox; - + protected override async void OnInitialized() { LoadStyleFile("res://AksWebBrowser/StyleSheet.css"); @@ -86,10 +87,12 @@ namespace AksWebBrowser Parame.webBrowser = FindPresenterByName(nameof(Parame.webBrowser)); textBox = FindPresenterByName(nameof(textBox)); Parame.webBrowser.CusRequest.CusResquestEvent += CusRequest_CusResquestEvent; + //浏览器大小 Parame.webBrowser.Width = w; Parame.webBrowser.Height = h; Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; + // Parame.webBrowser.Url = "http://192.168.0.232:8848/html/index.html"; //Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; //Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html"; //开发者工具暂时只能支持Windows @@ -105,7 +108,7 @@ namespace AksWebBrowser { MainModel.KillProcessByName("AksWebBrowser"); } - + bool showDev = false; private void WebBrowser_LoadEnd(object sender, LoadEndEventArgs e) { diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index 3f2df32..a898153 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -3,6 +3,8 @@ using AksWebBrowser.Common; using AksWebBrowser.Devices; using AKSWebBrowser.Commen; using CPF; +using CPF.Cef; +using CPF.Controls; using CPF.Linux; using CPF.Windows; using Fleck; @@ -170,6 +172,10 @@ namespace AksWebBrowser case "aks100118": result = SendSQ(content); break; + //{"code":"aks100119"} + case "aks100119": + result = ReadByBody(); + break; default: result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"keycode\":\"" + "" + "\",\"message\":\"Falied\",\"code\":\"400\",\"status\":false,\"data\":\"无效指令\"}"; break; @@ -671,7 +677,7 @@ namespace AksWebBrowser } /// - /// aks100106指纹 (已国产化,未完成测试) + /// aks100106指纹 (已国产化) /// /// /// @@ -1075,7 +1081,8 @@ namespace AksWebBrowser { try { - Task.Run(() => { + Task.Run(() => + { // 在你的窗口或应用程序需要时调用 Bash("/usr/bin/python3 /usr/bin/onboard"); }); @@ -1110,9 +1117,16 @@ namespace AksWebBrowser } else { - Parame.frm.Invoke(() => + //Parame.frm.Invoke(() => + //{ + // new AksVideoPlayer(Parame.frm, param.title, param.url); + //}); + Task.Run(() => { - new AksVideoPlayer(Parame.frm, param.title, param.url); + string command = $"pkill ffplay"; + ShllCommad(command); + command = $"ffplay -fs -autoexit -window_title {param.title} -i {param.url}"; + ShllCommad(command); }); string result = "{\"timestamp\":\"" + Utils.GetTimestamp() + "\",\"message\":\"success\",\"code\":\"200\",\"status\":true,\"suffix\":\"jpg\",\"data\":\"" + "播放成功" + "\"}"; SubmitLogs(result, "playVideo"); @@ -2228,5 +2242,48 @@ namespace AksWebBrowser process.WaitForExit(); } } + + + public static string ReadByBody() + { + Task.Run(async () => + { + GetReadBody(); + }); + @event11.WaitOne(); + return body; + } + + /// + /// 读取业务数据 + /// + private static string body = string.Empty; + private static AutoResetEvent @event11 = new AutoResetEvent(false); + private static async void GetReadBody() + { + try + { + var httpClient = new HttpClient(); + var uploader = new ChunkedUpload(httpClient); + body = await uploader.ReadBody(); + @event11.Set(); + } + catch (Exception ex) + { + Log.Error("读取业务数据异常:" + ex.Message); + } + } + + [JSFunction] + public void test33(string code) + { + + + + Parame.frm.Invoke(() => + { + new AksVideoPlayer(Parame.frm, "rrr", "http://192.168.0.34:92/CaseFile/card/2024-06-03/20240603120112952.mp4"); + }); + } } }