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