From e423cc4214704642a7760fe48612b784000b1023 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 14:38:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=8D=95=E6=9C=BA=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CPF_Cef/Common/Utils.cs | 2 +- CPF_Cef/FrmMain.cs | 26 +++++++++++++++++++++++--- CPF_Cef/MainModel.cs | 2 -- CPF_Cef/Parame.cs | 2 +- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CPF_Cef/Common/Utils.cs b/CPF_Cef/Common/Utils.cs index 9f3015f..00fcbc5 100644 --- a/CPF_Cef/Common/Utils.cs +++ b/CPF_Cef/Common/Utils.cs @@ -219,7 +219,7 @@ namespace AksWebBrowser.Common /// public static int AddOneIfRemainder(int number1, int number2) { - decimal num = (decimal) number1 / number2; + decimal num = (decimal)number1 / number2; decimal fraction = num - Math.Floor(num); return Convert.ToInt32(num + (fraction > 0 ? 1 : 0)); } diff --git a/CPF_Cef/FrmMain.cs b/CPF_Cef/FrmMain.cs index b064d08..931e1cb 100644 --- a/CPF_Cef/FrmMain.cs +++ b/CPF_Cef/FrmMain.cs @@ -10,9 +10,11 @@ using System; using System.Collections.Generic; using System.IO; using System.Net.Http; +using System.Net.Sockets; using System.Text; using System.Threading; using System.Threading.Tasks; +using System.Timers; namespace AKS.EnterpriseLibrary.WebBrowser { @@ -85,7 +87,7 @@ namespace AKS.EnterpriseLibrary.WebBrowser //浏览器大小 Parame.webBrowser.Width = w; Parame.webBrowser.Height = h; - Parame.webBrowser.Url = "http://192.168.0.34:8078/#/main-out"; + Parame.webBrowser.Url = "http://127.0.0.1:8096/#/main-out"; //Parame.webBrowser.Url = Application.StartupPath + @"\html\index.html"; //开发者工具暂时只能支持Windows //webBrowser.ShowDev(); @@ -108,8 +110,6 @@ namespace AKS.EnterpriseLibrary.WebBrowser showDev = true; Parame.webBrowser.ShowDev(); } - //获取授权 - GetSQObject(); //获取设备 MainModel.GetSnIndex(); //打开高拍仪 @@ -119,6 +119,26 @@ namespace AKS.EnterpriseLibrary.WebBrowser } //开启/关闭纠偏显示 MainModel.EnableDeskImage(1); + + //开启定时 + System.Timers.Timer timer = new System.Timers.Timer(1000);//3秒钟的时间间隔 + timer.Elapsed += OnTimedEvent; + timer.AutoReset = true;//重复执行 + timer.Enabled = true;//启动定时器 + } + + //矫正授权 + private void OnTimedEvent(Object source, ElapsedEventArgs e) + { + try + { + //获取授权 + GetSQObject(); + //检测服务是否启动 + MainModel.StartShll(); + } + catch { } + finally { } } public void Writelog(string str, string dirName = @"logs") diff --git a/CPF_Cef/MainModel.cs b/CPF_Cef/MainModel.cs index a36c0ea..4f92c8e 100644 --- a/CPF_Cef/MainModel.cs +++ b/CPF_Cef/MainModel.cs @@ -58,8 +58,6 @@ namespace AKS.EnterpriseLibrary.WebBrowser //读取参数 if (content != "ping" && !string.IsNullOrEmpty(content)) { - //检测服务是否启动 - StartShll(); //返回内容 string result = string.Empty; content = Base64str2(content); diff --git a/CPF_Cef/Parame.cs b/CPF_Cef/Parame.cs index e37c3ec..ec06f35 100644 --- a/CPF_Cef/Parame.cs +++ b/CPF_Cef/Parame.cs @@ -19,7 +19,7 @@ namespace AksWebBrowser public static Window frm { get; set; } public static List FuncObject { get; set; } //接口地址 - public static string apiUrl = "http://192.168.0.34:92"; + public static string apiUrl = "http://127.0.0.1:8098"; //授权key public static string key = "1"; //硬件Ip