zoule 7 maanden geleden
bovenliggende
commit
5a11327e62

+ 1 - 15
ips.sln

@@ -118,10 +118,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ips.Sps.Controllers", "ipst
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ips.Service.CapServer", "ipsservice\Ips.Service.CapServer\Ips.Service.CapServer.csproj", "{6A45BAC3-F60B-48CB-8AF3-6820BEF111F4}"
 EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GrpcClientTest", "ipsservice\GrpcClientTest\GrpcClientTest.csproj", "{30CE0FDD-F3ED-42EF-9DC1-33D072B379B2}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GrpcService1", "GrpcService1\GrpcService1.csproj", "{906F279E-556F-48EA-BFA3-EB23F1FFB5FB}"
-EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ips.Service.GpuServer", "ipsservice\Ips.Service.GpuServer\Ips.Service.GpuServer.csproj", "{EA1F2DED-C326-4A00-A034-B52E054510AD}"
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ips.Library.WebApi", "ipslib\Ips.Library.WebApi\Ips.Library.WebApi.csproj", "{E578156B-18BE-43E2-967A-ED46F909CE62}"
@@ -294,14 +290,6 @@ Global
 		{6A45BAC3-F60B-48CB-8AF3-6820BEF111F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{6A45BAC3-F60B-48CB-8AF3-6820BEF111F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{6A45BAC3-F60B-48CB-8AF3-6820BEF111F4}.Release|Any CPU.Build.0 = Release|Any CPU
-		{30CE0FDD-F3ED-42EF-9DC1-33D072B379B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{30CE0FDD-F3ED-42EF-9DC1-33D072B379B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{30CE0FDD-F3ED-42EF-9DC1-33D072B379B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{30CE0FDD-F3ED-42EF-9DC1-33D072B379B2}.Release|Any CPU.Build.0 = Release|Any CPU
-		{906F279E-556F-48EA-BFA3-EB23F1FFB5FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{906F279E-556F-48EA-BFA3-EB23F1FFB5FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{906F279E-556F-48EA-BFA3-EB23F1FFB5FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{906F279E-556F-48EA-BFA3-EB23F1FFB5FB}.Release|Any CPU.Build.0 = Release|Any CPU
 		{EA1F2DED-C326-4A00-A034-B52E054510AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{EA1F2DED-C326-4A00-A034-B52E054510AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{EA1F2DED-C326-4A00-A034-B52E054510AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -370,14 +358,12 @@ Global
 		{277D0294-7760-4923-BDC8-74C0824822D5} = {2FF18177-1972-48E9-9B05-421A74CADF7C}
 		{AFA0281E-7824-4F69-9C19-8F16A681EE03} = {5012D30A-5FC7-4439-B43A-62AE16C0AD43}
 		{6A45BAC3-F60B-48CB-8AF3-6820BEF111F4} = {3E225FCF-CC48-4E75-88C9-DE6881464471}
-		{30CE0FDD-F3ED-42EF-9DC1-33D072B379B2} = {3E225FCF-CC48-4E75-88C9-DE6881464471}
-		{906F279E-556F-48EA-BFA3-EB23F1FFB5FB} = {3E225FCF-CC48-4E75-88C9-DE6881464471}
 		{EA1F2DED-C326-4A00-A034-B52E054510AD} = {3E225FCF-CC48-4E75-88C9-DE6881464471}
 		{E578156B-18BE-43E2-967A-ED46F909CE62} = {A6AFA3D1-7346-455B-8512-DC2FB7DD790D}
 		{889BA62C-665A-4175-8362-1686508DF3B1} = {3E225FCF-CC48-4E75-88C9-DE6881464471}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
-		VisualSVNWorkingCopyRoot = .
 		SolutionGuid = {6C1F8DBC-5AD4-40F8-8123-AB98E502F828}
+		VisualSVNWorkingCopyRoot = .
 	EndGlobalSection
 EndGlobal

+ 7 - 0
ipslib/Ips.Library.WebApi/BaseController.cs

@@ -29,6 +29,13 @@ namespace Ips.Library.WebApi
             this.uploadFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot");
         }
 
+        /// <summary>
+        /// 确保Controller程序集被加载
+        /// </summary>
+        [NonAction]
+        public void EnsureAssemblyLoaded()
+        { 
+        }
         /// <summary>
         /// 返回本地文件
         /// </summary>

+ 1 - 19
ipslib/Ips.Library.WebApi/WebApiHelper.cs

@@ -31,27 +31,9 @@ namespace Ips.Library.WebApi
         private static CancellationTokenSource _cts;
 
 
-        public static WebApplicationBuilder CreateDefault()
-        {
-
-        }
-
-        /// <summary>
-        /// 启用Swagger
-        /// </summary>
-        /// <param name="builder"></param>
-        /// <param name="xmlName"></param>
-        public static void LoadController()
-        {
-        }
-
-        public static void UseStaticDir()
-        {
-            
-        }
-
         /// <summary>
         /// 启动AspNetCore WebAPI
+        /// (如果Controller所在程序集未被代码使用,且入口Exe被发布为自包含程序,会找不到Controller)
         /// </summary>
         /// <param name="_localPort">本地端口</param>
         /// <param name="controllerXmlName">Controller所在程序集XML描述文档名称,默认使用入口程序生成的xml</param>

+ 13 - 13
ipsservice/Ips.Service.CapServer/DirectXForm1.Designer.cs

@@ -41,7 +41,7 @@
             labelControl3 = new DevExpress.XtraEditors.LabelControl();
             txtSvrNo = new DevExpress.XtraEditors.TextEdit();
             labelControl4 = new DevExpress.XtraEditors.LabelControl();
-            txtRptAddr = new DevExpress.XtraEditors.TextEdit();
+            txtRegistryAddr = new DevExpress.XtraEditors.TextEdit();
             btnStart = new DevExpress.XtraEditors.SimpleButton();
             btnShowApi = new DevExpress.XtraBars.BarButtonItem();
             directXFormContainerControl1.SuspendLayout();
@@ -51,7 +51,7 @@
             ((System.ComponentModel.ISupportInitialize)txtLocalPort.Properties).BeginInit();
             ((System.ComponentModel.ISupportInitialize)txtCardType.Properties).BeginInit();
             ((System.ComponentModel.ISupportInitialize)txtSvrNo.Properties).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)txtRptAddr.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtRegistryAddr.Properties).BeginInit();
             SuspendLayout();
             // 
             // directXFormContainerControl1
@@ -83,7 +83,7 @@
             stackPanel1.Controls.Add(labelControl3);
             stackPanel1.Controls.Add(txtSvrNo);
             stackPanel1.Controls.Add(labelControl4);
-            stackPanel1.Controls.Add(txtRptAddr);
+            stackPanel1.Controls.Add(txtRegistryAddr);
             stackPanel1.Controls.Add(btnStart);
             stackPanel1.Dock = DockStyle.Top;
             stackPanel1.Location = new Point(0, 0);
@@ -161,14 +161,14 @@
             labelControl4.TabIndex = 0;
             labelControl4.Text = "服务注册地址";
             // 
-            // txtRptAddr
+            // txtRegistryAddr
             // 
-            txtRptAddr.EditValue = "";
-            txtRptAddr.Location = new Point(563, 7);
-            txtRptAddr.Name = "txtRptAddr";
-            txtRptAddr.Properties.AutoHeight = false;
-            txtRptAddr.Size = new Size(234, 24);
-            txtRptAddr.TabIndex = 2;
+            txtRegistryAddr.EditValue = "";
+            txtRegistryAddr.Location = new Point(563, 7);
+            txtRegistryAddr.Name = "txtRegistryAddr";
+            txtRegistryAddr.Properties.AutoHeight = false;
+            txtRegistryAddr.Size = new Size(234, 24);
+            txtRegistryAddr.TabIndex = 2;
             // 
             // btnStart
             // 
@@ -189,7 +189,7 @@
             toolTipItem2.Text = "查看Http接口";
             superToolTip2.Items.Add(toolTipItem2);
             btnShowApi.SuperTip = superToolTip2;
-            btnShowApi.ItemClick += barbtnShowApi_ItemClick;
+            btnShowApi.ItemClick += BtnShowApi_ItemClick;
             // 
             // DirectXForm1
             // 
@@ -212,7 +212,7 @@
             ((System.ComponentModel.ISupportInitialize)txtLocalPort.Properties).EndInit();
             ((System.ComponentModel.ISupportInitialize)txtCardType.Properties).EndInit();
             ((System.ComponentModel.ISupportInitialize)txtSvrNo.Properties).EndInit();
-            ((System.ComponentModel.ISupportInitialize)txtRptAddr.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtRegistryAddr.Properties).EndInit();
             ResumeLayout(false);
         }
 
@@ -228,7 +228,7 @@
         private DevExpress.XtraEditors.ComboBoxEdit txtCardType;
         private DevExpress.XtraEditors.LabelControl labelControl3;
         private DevExpress.XtraEditors.LabelControl labelControl4;
-        private DevExpress.XtraEditors.TextEdit txtRptAddr;
+        private DevExpress.XtraEditors.TextEdit txtRegistryAddr;
         private DevExpress.XtraEditors.GroupControl groupControl1;
         private DevExpress.XtraEditors.SimpleButton btnStart;
     }

+ 9 - 5
ipsservice/Ips.Service.CapServer/DirectXForm1.cs

@@ -97,7 +97,7 @@ namespace Ips.Service.CapServer
                 await Task.Delay(10000, token);
             }
         }
-        private void barbtnShowApi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private void BtnShowApi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             string addr = $"http://127.0.0.1:{AppConst.LocalPort}/swagger";
             try
@@ -136,7 +136,7 @@ namespace Ips.Service.CapServer
                     }
                     try
                     {
-                        var u = new Uri(txtRptAddr.Text.Trim());
+                        var u = new Uri(txtRegistryAddr.Text.Trim());
                     }
                     catch
                     {
@@ -145,11 +145,15 @@ namespace Ips.Service.CapServer
                     AppConst.LocalPort = localPort;
                     AppConst.SvrNo = txtSvrNo.Text.Trim();
                     AppConst.CardType = txtCardType.Text.GetEnumByDisplayName<EnumCapDevType>();
-                    AppConst.RegistryUri = txtRptAddr.Text.Trim();
+                    AppConst.RegistryUri = txtRegistryAddr.Text.Trim();
                     WebApiHelper.Start(AppConst.LocalPort, "Ips.Library.Entity.xml", AppConst.DataDir.ToStrArray());
                     btnStart.Text = "停止服务";
                     stackPanel1.DisabledChildWithout(btnStart);
                     IpsLogger.Info($"服务启动成功.接口地址http://+:{localPort}/swagger");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/{Path.GetFileName(AppConst.DataDir)}");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/upload");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/download");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/logs");
                     apiRuning = true;
                     cts = new CancellationTokenSource();
                     RegistrySvr(cts.Token);
@@ -178,7 +182,7 @@ namespace Ips.Service.CapServer
                 sb.AppendLine(txtLocalPort.Text);
                 sb.AppendLine(txtCardType.SelectedIndex.ToString());
                 sb.AppendLine(txtSvrNo.Text);
-                sb.AppendLine(txtRptAddr.Text);
+                sb.AppendLine(txtRegistryAddr.Text);
                 sb.AppendLine(btnStart.Text);
                 File.WriteAllText("Params\\Params.txt", sb.ToString());
             }
@@ -197,7 +201,7 @@ namespace Ips.Service.CapServer
                     txtLocalPort.Text = lines[0];
                     txtCardType.SelectedIndex = Convert.ToInt32(lines[1]);
                     txtSvrNo.Text = lines[2];
-                    txtRptAddr.Text = lines[3];
+                    txtRegistryAddr.Text = lines[3];
                     if (lines[4] == "停止服务")//上次状态是启动状态,加载后直接启动
                     {
                         btnStart_Click(null, null);

+ 21 - 5
ipsservice/Ips.Service.CpuServe/AppConst.cs

@@ -1,4 +1,5 @@
-using System;
+using Ips.Library.Entity;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -9,19 +10,34 @@ namespace Ips.Service.CpuServer
     public static class AppConst
     {
         /// <summary>
-        /// 本地Http服务IP
+        /// 文件上传保存的目录
         /// </summary>
-        public static string LocalIp;
+        public static readonly string UploadDir = "Upload";
+
+        /// <summary>
+        /// 采集服务使用的Http通信IP
+        /// </summary>
+        public static string LocalIp { get; set; }
+
+        /// <summary>
+        /// 采集服务使用的Http通信端口
+        /// </summary>
+        public static int LocalPort { get; set; }
 
         /// <summary>
         /// 服务编号
         /// </summary>
-        public static string SvrNo;
+        public static string SvrNo { get; set; }
+
+        /// <summary>
+        /// 注册的容器http地址
+        /// </summary>
+        public static string RegistryUri { get; set; }
 
         /// <summary>
         /// 是否启用同频对消API
         /// </summary>
-        public static bool UseTpdx = false;
+        public static bool UseTpdx = true;
 
         /// <summary>
         /// 是否启用参数估计API

+ 46 - 37
ipsservice/Ips.Service.CpuServe/DirectXForm1.Designer.cs

@@ -29,8 +29,8 @@
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DirectXForm1));
-            DevExpress.Utils.SuperToolTip superToolTip2 = new DevExpress.Utils.SuperToolTip();
-            DevExpress.Utils.ToolTipItem toolTipItem2 = new DevExpress.Utils.ToolTipItem();
+            DevExpress.Utils.SuperToolTip superToolTip3 = new DevExpress.Utils.SuperToolTip();
+            DevExpress.Utils.ToolTipItem toolTipItem3 = new DevExpress.Utils.ToolTipItem();
             directXFormContainerControl1 = new DevExpress.XtraEditors.DirectXFormContainerControl();
             groupControl1 = new DevExpress.XtraEditors.GroupControl();
             stackPanel1 = new DevExpress.Utils.Layout.StackPanel();
@@ -42,8 +42,9 @@
             txtRegistryAddr = new DevExpress.XtraEditors.TextEdit();
             txtUseTpdx = new DevExpress.XtraEditors.CheckEdit();
             txtUseCg = new DevExpress.XtraEditors.CheckEdit();
-            btnShowApi = new DevExpress.XtraBars.BarButtonItem();
             txtUseCheck = new DevExpress.XtraEditors.CheckEdit();
+            btnStart = new DevExpress.XtraEditors.SimpleButton();
+            btnShowApi = new DevExpress.XtraBars.BarButtonItem();
             directXFormContainerControl1.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)groupControl1).BeginInit();
             ((System.ComponentModel.ISupportInitialize)stackPanel1).BeginInit();
@@ -63,15 +64,15 @@
             directXFormContainerControl1.Location = new Point(1, 31);
             directXFormContainerControl1.Margin = new Padding(3, 4, 3, 4);
             directXFormContainerControl1.Name = "directXFormContainerControl1";
-            directXFormContainerControl1.Size = new Size(879, 306);
+            directXFormContainerControl1.Size = new Size(1024, 306);
             directXFormContainerControl1.TabIndex = 0;
             // 
             // groupControl1
             // 
             groupControl1.Dock = DockStyle.Fill;
-            groupControl1.Location = new Point(0, 32);
+            groupControl1.Location = new Point(0, 39);
             groupControl1.Name = "groupControl1";
-            groupControl1.Size = new Size(879, 274);
+            groupControl1.Size = new Size(1024, 267);
             groupControl1.TabIndex = 1;
             groupControl1.Text = "日志信息";
             // 
@@ -86,16 +87,17 @@
             stackPanel1.Controls.Add(txtUseTpdx);
             stackPanel1.Controls.Add(txtUseCg);
             stackPanel1.Controls.Add(txtUseCheck);
+            stackPanel1.Controls.Add(btnStart);
             stackPanel1.Dock = DockStyle.Top;
             stackPanel1.Location = new Point(0, 0);
             stackPanel1.Margin = new Padding(3, 4, 3, 4);
             stackPanel1.Name = "stackPanel1";
-            stackPanel1.Size = new Size(879, 32);
+            stackPanel1.Size = new Size(1024, 39);
             stackPanel1.TabIndex = 0;
             // 
             // labelControl1
             // 
-            labelControl1.Location = new Point(3, 9);
+            labelControl1.Location = new Point(3, 12);
             labelControl1.Margin = new Padding(3, 4, 3, 4);
             labelControl1.Name = "labelControl1";
             labelControl1.Size = new Size(48, 14);
@@ -105,17 +107,17 @@
             // txtLocalPort
             // 
             txtLocalPort.EditValue = "16002";
-            txtLocalPort.Location = new Point(57, 6);
+            txtLocalPort.Location = new Point(57, 7);
             txtLocalPort.Margin = new Padding(3, 4, 3, 4);
             txtLocalPort.Name = "txtLocalPort";
-            txtLocalPort.Size = new Size(100, 20);
+            txtLocalPort.Properties.AutoHeight = false;
+            txtLocalPort.Size = new Size(100, 24);
             txtLocalPort.TabIndex = 2;
             txtLocalPort.ToolTip = "创建Http服务使用的本地端口,修改后需要重启软件";
-            txtLocalPort.EditValueChanged += Parms_TextChanged;
             // 
             // labNo
             // 
-            labNo.Location = new Point(163, 9);
+            labNo.Location = new Point(163, 12);
             labNo.Margin = new Padding(3, 4, 3, 4);
             labNo.Name = "labNo";
             labNo.Size = new Size(48, 14);
@@ -125,17 +127,17 @@
             // txtSvrNo
             // 
             txtSvrNo.EditValue = "CPU010";
-            txtSvrNo.Location = new Point(217, 6);
+            txtSvrNo.Location = new Point(217, 7);
             txtSvrNo.Margin = new Padding(3, 4, 3, 4);
             txtSvrNo.Name = "txtSvrNo";
-            txtSvrNo.Size = new Size(100, 20);
+            txtSvrNo.Properties.AutoHeight = false;
+            txtSvrNo.Size = new Size(100, 24);
             txtSvrNo.TabIndex = 1;
             txtSvrNo.ToolTip = "部署多个此程序时编号不能重复";
-            txtSvrNo.EditValueChanged += Parms_TextChanged;
             // 
             // labelControl2
             // 
-            labelControl2.Location = new Point(323, 9);
+            labelControl2.Location = new Point(323, 12);
             labelControl2.Margin = new Padding(3, 4, 3, 4);
             labelControl2.Name = "labelControl2";
             labelControl2.Size = new Size(48, 14);
@@ -145,33 +147,49 @@
             // txtRegistryAddr
             // 
             txtRegistryAddr.EditValue = "http://127.0.0.1:16015";
-            txtRegistryAddr.Location = new Point(377, 6);
+            txtRegistryAddr.Location = new Point(377, 7);
             txtRegistryAddr.Margin = new Padding(3, 4, 3, 4);
             txtRegistryAddr.Name = "txtRegistryAddr";
-            txtRegistryAddr.Size = new Size(224, 20);
+            txtRegistryAddr.Properties.AutoHeight = false;
+            txtRegistryAddr.Size = new Size(234, 24);
             txtRegistryAddr.TabIndex = 1;
             txtRegistryAddr.ToolTip = "多个地址用空格隔开";
-            txtRegistryAddr.EditValueChanged += Parms_TextChanged;
             // 
             // txtUseTpdx
             // 
             txtUseTpdx.EditValue = true;
-            txtUseTpdx.Location = new Point(607, 6);
+            txtUseTpdx.Location = new Point(617, 9);
             txtUseTpdx.Name = "txtUseTpdx";
             txtUseTpdx.Properties.Caption = "同频对消";
             txtUseTpdx.Size = new Size(80, 20);
             txtUseTpdx.TabIndex = 3;
-            txtUseTpdx.EditValueChanged += Parms_TextChanged;
             // 
             // txtUseCg
             // 
             txtUseCg.EditValue = true;
-            txtUseCg.Location = new Point(693, 6);
+            txtUseCg.Location = new Point(703, 9);
             txtUseCg.Name = "txtUseCg";
             txtUseCg.Properties.Caption = "参数估计";
             txtUseCg.Size = new Size(80, 20);
             txtUseCg.TabIndex = 3;
-            txtUseCg.EditValueChanged += Parms_TextChanged;
+            // 
+            // txtUseCheck
+            // 
+            txtUseCheck.EditValue = true;
+            txtUseCheck.Location = new Point(789, 9);
+            txtUseCheck.Name = "txtUseCheck";
+            txtUseCheck.Properties.Caption = "信号检测";
+            txtUseCheck.Size = new Size(80, 20);
+            txtUseCheck.TabIndex = 3;
+            // 
+            // btnStart
+            // 
+            btnStart.Location = new Point(875, 7);
+            btnStart.Name = "btnStart";
+            btnStart.Size = new Size(75, 24);
+            btnStart.TabIndex = 4;
+            btnStart.Text = "启动服务";
+            btnStart.Click += btnStart_Click;
             // 
             // btnShowApi
             // 
@@ -180,28 +198,18 @@
             btnShowApi.Id = 0;
             btnShowApi.ImageOptions.SvgImage = (DevExpress.Utils.Svg.SvgImage)resources.GetObject("btnShowApi.ImageOptions.SvgImage");
             btnShowApi.Name = "btnShowApi";
-            toolTipItem2.Text = "查看Http接口文档";
-            superToolTip2.Items.Add(toolTipItem2);
-            btnShowApi.SuperTip = superToolTip2;
+            toolTipItem3.Text = "查看Http接口文档";
+            superToolTip3.Items.Add(toolTipItem3);
+            btnShowApi.SuperTip = superToolTip3;
             btnShowApi.ItemClick += BtnShowApi_ItemClick;
             // 
-            // txtUseCheck
-            // 
-            txtUseCheck.EditValue = true;
-            txtUseCheck.Location = new Point(779, 6);
-            txtUseCheck.Name = "txtUseCheck";
-            txtUseCheck.Properties.Caption = "信号检测";
-            txtUseCheck.Size = new Size(80, 20);
-            txtUseCheck.TabIndex = 3;
-            txtUseCheck.EditValueChanged += Parms_TextChanged;
-            // 
             // DirectXForm1
             // 
             Appearance.Options.UseFont = true;
             AutoScaleDimensions = new SizeF(7F, 17F);
             AutoScaleMode = AutoScaleMode.Font;
             ChildControls.Add(directXFormContainerControl1);
-            ClientSize = new Size(881, 338);
+            ClientSize = new Size(1026, 338);
             Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point);
             IconOptions.SvgImage = (DevExpress.Utils.Svg.SvgImage)resources.GetObject("DirectXForm1.IconOptions.SvgImage");
             Links.Add(btnShowApi);
@@ -236,5 +244,6 @@
         private DevExpress.XtraEditors.CheckEdit txtUseTpdx;
         private DevExpress.XtraEditors.CheckEdit txtUseCg;
         private DevExpress.XtraEditors.CheckEdit txtUseCheck;
+        private DevExpress.XtraEditors.SimpleButton btnStart;
     }
 }

+ 102 - 88
ipsservice/Ips.Service.CpuServe/DirectXForm1.cs

@@ -1,4 +1,5 @@
-using Ips.Library.Basic;
+using DevExpress.CodeParser;
+using Ips.Library.Basic;
 using Ips.Library.DxpLib;
 using Ips.Library.Entity;
 using Ips.Library.WebApi;
@@ -19,54 +20,28 @@ namespace Ips.Service.CpuServer
 {
     public partial class DirectXForm1 : DevExpress.XtraEditors.DirectXForm
     {
-        private bool _inited = false;
-        private string _localPort;//本地端口
-        private string _svrNo;//服务编号
-        private string _rptAddr;//服务注册上报http地址
+        private bool apiRuning = false;
+        private CancellationTokenSource cts;
         public DirectXForm1()
         {
             InitializeComponent();
             this.Size = new Size(1024, 768);
             this.Text = "CPU服务";
         }
-        protected async override void OnLoad(EventArgs e)
+        protected override void OnLoad(EventArgs e)
         {
             base.OnLoad(e);
             new Library.DxpLib.LogCtrl() { Parent = groupControl1 };
             LoadParams();
-            if (int.TryParse(_localPort, out int intPort))
-            {
-                var controllerXml = $"{AppDomain.CurrentDomain.FriendlyName}.xml";
-                var dtoXml = "Ips.Library.Entity.xml";
-                var staticDir = new string[] { "Download","Upload", "Logs"};
-                WebApiHelper.Start(intPort, controllerXml, dtoXml, staticDir);
-                this.FormClosing += (_, _) => WebApiHelper.Stop();
-                _inited = true;
-                await StateRpt();
-            }
-            _inited = true;
         }
-        private async Task StateRpt()
+        private async void RegistrySvr(CancellationToken token)
         {
-            string localIp;
-
-            while (true)
+            while (!this.Disposing && apiRuning)
             {
                 string getIpUrl = null;
                 try
                 {
-                    if (_rptAddr == null)
-                    {
-                        await Task.Delay(5000);
-                        continue;
-                    }
-                    if (!_rptAddr.ToLower().StartsWith("http://"))
-                    {
-                        IpsLogger.Error($"注册地址必须以http://开头");
-                        await Task.Delay(5000);
-                        continue;
-                    }
-                    getIpUrl = _rptAddr.AppendUrlSuffix("api/getclientip");
+                    getIpUrl = AppConst.RegistryUri.AppendUrlSuffix("api/getclientip");
                     var rsp = await HttpHelper.GetRequestAsync<string>(getIpUrl, 5);
                     if (rsp.code == 0)
                     {
@@ -75,32 +50,29 @@ namespace Ips.Service.CpuServer
                     }
                     else
                     {
-                        localIp = rsp.data;
+                        AppConst.LocalIp = rsp.data;
                     }
                     break;
                 }
                 catch (Exception ex)
                 {
-                    IpsLogger.Error($"无法连接到{getIpUrl},请检测地址是否正确并确保远程设备设备防火墙入栈规则允许TCP端口{getIpUrl.GetUrlPort()}通过", ex);
-                    await Task.Delay(5000);
+                    IpsLogger.Error($"无法注册到{getIpUrl},请检测地址是否正确并确保远程设备设备防火墙入栈规则允许TCP端口{getIpUrl.GetUrlPort()}通过", ex);
+                    await Task.Delay(10000, token);
                 }
             }
-            AppConst.LocalIp = localIp;
-            IpsLogger.Info($"服务启动成功.接口地址http://{localIp}:{_localPort}/swagger");
-
             bool preSucceed = false;
-            while (!this.Disposing)
+            while (!this.Disposing && apiRuning)
             {
-                string url = _rptAddr.AppendUrlSuffix("api/SvrStateRpt/Report");
+                string url = AppConst.RegistryUri.AppendUrlSuffix("api/SvrStateRpt/Report");
                 try
                 {
                     var dto = new ModelSvrRpt()
                     {
-                        SvrType = EnumSvrType.CpuSvr,
-                        SvrNo = _svrNo,
+                        SvrType = EnumSvrType.CapSvr,
+                        SvrNo = AppConst.SvrNo,
                         SvrRptType = EnumSvrRptType.Online,
-                        BaseHttpAddr = $"http://{localIp}:{_localPort}",
-                        SwaggerAddr = $"http://{localIp}:{_localPort}/Swagger",
+                        BaseHttpAddr = $"http://{AppConst.LocalIp}:{AppConst.LocalPort}",
+                        SwaggerAddr = $"http://{AppConst.LocalIp}:{AppConst.LocalPort}/Swagger",
                     };
                     List<string> list = new List<string>();
                     if (AppConst.UseCg)
@@ -117,32 +89,102 @@ namespace Ips.Service.CpuServer
                     }
                     dto.Features = string.Join(" ", list);
                     var res = await HttpHelper.PostRequestAsync<object>(url, dto);
-
                     if (res.code != 200)
                     {
-                        IpsLogger.Error($"状态上报异常[url={url}].{res.msg}");
+                        IpsLogger.Error($"服务注册异常[url={url}].{res.msg}");
                         preSucceed = false;
                     }
                     else
                     {
                         if (!preSucceed)
-                            IpsLogger.Info($"状态上报成功![url={url}]");
+                            IpsLogger.Info($"服务注册成功![url={url}]");
                         preSucceed = true;
                     }
                 }
                 catch (Exception ex)
                 {
-                    IpsLogger.Error($"状态上报异常[url={url}]", ex);
+                    IpsLogger.Error($"服务注册异常[url={url}]", ex);
                     preSucceed = false;
                 }
-                await Task.Delay(10000);
+                await Task.Delay(10000, token);
             }
         }
-
-        private void Parms_TextChanged(object sender, EventArgs e)
+        private void BtnShowApi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            if (!_inited) return;
-            SaveParams();
+            string addr = $"http://127.0.0.1:{AppConst.LocalPort}/swagger";
+            try
+            {
+                //System.Diagnostics.Process.Start(addr);//NetFramework可用,NetCore使用CMD启动
+                ProcessStartInfo info = new ProcessStartInfo();
+                info.Arguments = $"/C start {addr}";
+                info.FileName = "cmd";
+                info.UseShellExecute = false;
+                info.CreateNoWindow = true;
+                Process.Start(info);
+            }
+            catch (Exception ex)
+            {
+                IpsLogger.Error($"无法打开默认浏览器,请手动打开浏览器查看接口文档.地址{addr}", ex);
+            }
+        }
+        private void btnStart_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                if (btnStart.Text == "启动服务")
+                {
+                    if (!int.TryParse(txtLocalPort.Text.Trim(), out int localPort))
+                    {
+                        throw new Exception("本地端口输入错误");
+                    }
+                    if (localPort < 1024 || localPort > 49151)
+                    {
+                        //1024以下给vip程序预留的,49152-65535用于客户端随机分配的
+                        throw new Exception("本地端口范围[1024,49151]");
+                    }
+                    if (txtSvrNo.Text.Trim().Length < 3 || txtSvrNo.Text.Trim().Length > 15)
+                    {
+                        throw new Exception("服务编号长度范围[3,15]");
+                    }
+                    try
+                    {
+                        var u = new Uri(txtRegistryAddr.Text.Trim());
+                    }
+                    catch
+                    {
+                        throw new Exception("服务注册地址不是有效的URI");
+                    }
+                    AppConst.LocalPort = localPort;
+                    AppConst.SvrNo = txtSvrNo.Text.Trim();
+                    AppConst.RegistryUri = txtRegistryAddr.Text.Trim();
+                    AppConst.UseTpdx = txtUseTpdx.Checked;
+                    AppConst.UseCg = txtUseCg.Checked;
+                    AppConst.UseSigCheck = txtUseCheck.Checked;
+                    WebApiHelper.Start(AppConst.LocalPort, "Ips.Library.Entity.xml");
+                    btnStart.Text = "停止服务";
+                    stackPanel1.DisabledChildWithout(btnStart);
+                    IpsLogger.Info($"服务启动成功.接口地址http://+:{localPort}/swagger");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/upload");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/download");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/logs");
+                    apiRuning = true;
+                    cts = new CancellationTokenSource();
+                    RegistrySvr(cts.Token);
+                }
+                else
+                {
+                    apiRuning = false;
+                    btnStart.Text = "启动服务";
+                    WebApiHelper.Stop();
+                    cts?.Cancel();
+                    stackPanel1.EnableChild();
+                }
+                SaveParams();
+            }
+            catch (Exception ex)
+            {
+                IpsLogger.Error(ex.Message, ex);
+            }
         }
         void SaveParams()
         {
@@ -156,20 +198,13 @@ namespace Ips.Service.CpuServer
                 sb.AppendLine(txtUseTpdx.Checked.ToString());
                 sb.AppendLine(txtUseCg.Checked.ToString());
                 sb.AppendLine(txtUseCheck.Checked.ToString());
+                sb.AppendLine(btnStart.Text);
                 File.WriteAllText("Params\\Params.txt", sb.ToString());
-                IpsLogger.Info("用户修改了UI参数!");
             }
             catch (Exception ex)
             {
                 IpsLogger.Error("保存Params.txt文件异常", ex);
             }
-            _localPort = txtLocalPort.Text.Trim();
-            _svrNo = txtSvrNo.Text.Trim();
-            _rptAddr = txtRegistryAddr.Text.Trim();
-            AppConst.UseTpdx = txtUseTpdx.Checked;
-            AppConst.UseCg = txtUseCg.Checked;
-            AppConst.UseSigCheck= txtUseCheck.Checked;
-            AppConst.SvrNo = _svrNo;
         }
         void LoadParams()
         {
@@ -183,38 +218,17 @@ namespace Ips.Service.CpuServer
                     txtRegistryAddr.Text = lines[2];
                     txtUseTpdx.Checked = lines[3].ToLower() == "true";
                     txtUseCg.Checked = lines[4].ToLower() == "true";
-                    txtUseCheck.Checked = lines[5].ToLower() == "true";
+                    txtUseCheck.Checked= lines[5].ToLower() == "true";
+                    if (lines[6] == "停止服务")//上次状态是启动状态,加载后直接启动
+                    {
+                        btnStart_Click(null, null);
+                    }
                 }
                 catch (Exception ex)
                 {
                     IpsLogger.Error("加载Params.txt文件异常", ex);
                 }
             }
-            _localPort = txtLocalPort.Text.Trim();
-            _svrNo = txtSvrNo.Text.Trim();
-            _rptAddr = txtRegistryAddr.Text.Trim();
-            AppConst.UseTpdx = txtUseCg.Checked;
-            AppConst.UseCg = txtUseCg.Checked;
-            AppConst.SvrNo = _svrNo;
-            AppConst.UseSigCheck = txtUseCg.Checked;
-        }
-        private void BtnShowApi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            string addr = $"http://127.0.0.1:{_localPort}/swagger";
-            try
-            {
-                //System.Diagnostics.Process.Start(addr);//NetFramework可用,NetCore使用CMD启动
-                ProcessStartInfo info = new ProcessStartInfo();
-                info.Arguments = $"/C start {addr}";
-                info.FileName = "cmd";
-                info.UseShellExecute = false;
-                info.CreateNoWindow = true;
-                Process.Start(info);
-            }
-            catch (Exception ex)
-            {
-                IpsLogger.Error($"无法打开默认浏览器,请手动打开浏览器查看接口文档.地址{addr}", ex);
-            }
         }
     }
 }

+ 5 - 5
ipsservice/Ips.Service.CpuServe/DirectXForm1.resx

@@ -117,10 +117,10 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <assembly alias="DevExpress.Data.v23.2" name="DevExpress.Data.v23.2, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
-  <data name="btnShowApi.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v23.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <assembly alias="DevExpress.Data.v24.1" name="DevExpress.Data.v24.1, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
+  <data name="btnShowApi.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v24.1" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
-        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIzLjIsIFZlcnNpb249MjMuMi4z
+        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjI0LjEsIFZlcnNpb249MjQuMS42
         LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
         dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAANYEAAAC77u/
         PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi
@@ -146,9 +146,9 @@
         MTEuNiwxNC40eiIgY2xhc3M9IkJsdWUiIC8+DQo8L3N2Zz4L
 </value>
   </data>
-  <data name="DirectXForm1.IconOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v23.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <data name="DirectXForm1.IconOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v24.1" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
-        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIzLjIsIFZlcnNpb249MjMuMi4z
+        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjI0LjEsIFZlcnNpb249MjQuMS42
         LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
         dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAAOkEAAAC77u/
         PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgd2lkdGg9Ijk2cHgiIGhl

+ 2 - 1
ipsservice/Ips.Service.CpuServe/Program.cs

@@ -47,7 +47,8 @@ namespace Ips.Service.CpuServer
             };
             Application.ThreadException += (sender, e) =>
             {
-                IpsLogger.Error("出现未处理的线程异常!", e.Exception);
+                if (e.Exception.GetType() != typeof(TaskCanceledException))
+                    IpsLogger.Error("出现未处理的线程异常!", e.Exception);
             };
         }
         /// <summary>

+ 20 - 4
ipsservice/Ips.Service.GpuServer/AppConst.cs

@@ -9,23 +9,39 @@ namespace Ips.Service.GpuServer
     public static class AppConst
     {
         /// <summary>
-        /// 本地Http服务IP
+        /// 文件上传保存的目录
         /// </summary>
-        public static string LocalIp;
+        public static readonly string UploadDir = "Upload";
+
+        /// <summary>
+        /// 采集服务使用的Http通信IP
+        /// </summary>
+        public static string LocalIp { get; set; }
+
+        /// <summary>
+        /// 采集服务使用的Http通信端口
+        /// </summary>
+        public static int LocalPort { get; set; }
 
         /// <summary>
         /// 服务编号
         /// </summary>
-        public static string SvrNo;
+        public static string SvrNo { get; set; }
+
+        /// <summary>
+        /// 注册的容器http地址
+        /// </summary>
+        public static string RegistryUri { get; set; }
 
         /// <summary>
         /// 是否启用同频对消API
         /// </summary>
-        public static bool UseTpdx = false;
+        public static bool UseTpdx = true;
 
         /// <summary>
         /// 是否启用参数估计API
         /// </summary>
         public static bool UseCg = true;
+
     }
 }

+ 151 - 142
ipsservice/Ips.Service.GpuServer/DirectXForm1.Designer.cs

@@ -29,184 +29,192 @@
         private void InitializeComponent()
         {
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DirectXForm1));
-            DevExpress.Utils.SuperToolTip superToolTip11 = new DevExpress.Utils.SuperToolTip();
-            DevExpress.Utils.ToolTipItem toolTipItem11 = new DevExpress.Utils.ToolTipItem();
-            this.directXFormContainerControl1 = new DevExpress.XtraEditors.DirectXFormContainerControl();
-            this.groupControl1 = new DevExpress.XtraEditors.GroupControl();
-            this.stackPanel1 = new DevExpress.Utils.Layout.StackPanel();
-            this.labelControl1 = new DevExpress.XtraEditors.LabelControl();
-            this.txtLocalPort = new DevExpress.XtraEditors.TextEdit();
-            this.labNo = new DevExpress.XtraEditors.LabelControl();
-            this.txtSvrNo = new DevExpress.XtraEditors.TextEdit();
-            this.labelControl2 = new DevExpress.XtraEditors.LabelControl();
-            this.txtRegistryAddr = new DevExpress.XtraEditors.TextEdit();
-            this.btnShowApi = new DevExpress.XtraBars.BarButtonItem();
-            this.txtUseTpdx = new DevExpress.XtraEditors.CheckEdit();
-            this.txtUseCg = new DevExpress.XtraEditors.CheckEdit();
-            this.directXFormContainerControl1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.stackPanel1)).BeginInit();
-            this.stackPanel1.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.txtLocalPort.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtSvrNo.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtRegistryAddr.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtUseTpdx.Properties)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtUseCg.Properties)).BeginInit();
-            this.SuspendLayout();
+            DevExpress.Utils.SuperToolTip superToolTip1 = new DevExpress.Utils.SuperToolTip();
+            DevExpress.Utils.ToolTipItem toolTipItem1 = new DevExpress.Utils.ToolTipItem();
+            directXFormContainerControl1 = new DevExpress.XtraEditors.DirectXFormContainerControl();
+            groupControl1 = new DevExpress.XtraEditors.GroupControl();
+            stackPanel1 = new DevExpress.Utils.Layout.StackPanel();
+            labelControl1 = new DevExpress.XtraEditors.LabelControl();
+            txtLocalPort = new DevExpress.XtraEditors.TextEdit();
+            labNo = new DevExpress.XtraEditors.LabelControl();
+            txtSvrNo = new DevExpress.XtraEditors.TextEdit();
+            labelControl2 = new DevExpress.XtraEditors.LabelControl();
+            txtRegistryAddr = new DevExpress.XtraEditors.TextEdit();
+            txtUseTpdx = new DevExpress.XtraEditors.CheckEdit();
+            txtUseCg = new DevExpress.XtraEditors.CheckEdit();
+            btnStart = new DevExpress.XtraEditors.SimpleButton();
+            btnShowApi = new DevExpress.XtraBars.BarButtonItem();
+            directXFormContainerControl1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)groupControl1).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)stackPanel1).BeginInit();
+            stackPanel1.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)txtLocalPort.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtSvrNo.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtRegistryAddr.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtUseTpdx.Properties).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)txtUseCg.Properties).BeginInit();
+            SuspendLayout();
             // 
             // directXFormContainerControl1
             // 
-            this.directXFormContainerControl1.Controls.Add(this.groupControl1);
-            this.directXFormContainerControl1.Controls.Add(this.stackPanel1);
-            this.directXFormContainerControl1.Location = new System.Drawing.Point(1, 31);
-            this.directXFormContainerControl1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.directXFormContainerControl1.Name = "directXFormContainerControl1";
-            this.directXFormContainerControl1.Size = new System.Drawing.Size(879, 306);
-            this.directXFormContainerControl1.TabIndex = 0;
+            directXFormContainerControl1.Controls.Add(groupControl1);
+            directXFormContainerControl1.Controls.Add(stackPanel1);
+            directXFormContainerControl1.Location = new Point(1, 31);
+            directXFormContainerControl1.Margin = new Padding(3, 4, 3, 4);
+            directXFormContainerControl1.Name = "directXFormContainerControl1";
+            directXFormContainerControl1.Size = new Size(1024, 306);
+            directXFormContainerControl1.TabIndex = 0;
             // 
             // groupControl1
             // 
-            this.groupControl1.Dock = System.Windows.Forms.DockStyle.Fill;
-            this.groupControl1.Location = new System.Drawing.Point(0, 32);
-            this.groupControl1.Name = "groupControl1";
-            this.groupControl1.Size = new System.Drawing.Size(879, 274);
-            this.groupControl1.TabIndex = 1;
-            this.groupControl1.Text = "日志信息";
+            groupControl1.Dock = DockStyle.Fill;
+            groupControl1.Location = new Point(0, 39);
+            groupControl1.Name = "groupControl1";
+            groupControl1.Size = new Size(1024, 267);
+            groupControl1.TabIndex = 1;
+            groupControl1.Text = "日志信息";
             // 
             // stackPanel1
             // 
-            this.stackPanel1.Controls.Add(this.labelControl1);
-            this.stackPanel1.Controls.Add(this.txtLocalPort);
-            this.stackPanel1.Controls.Add(this.labNo);
-            this.stackPanel1.Controls.Add(this.txtSvrNo);
-            this.stackPanel1.Controls.Add(this.labelControl2);
-            this.stackPanel1.Controls.Add(this.txtRegistryAddr);
-            this.stackPanel1.Controls.Add(this.txtUseTpdx);
-            this.stackPanel1.Controls.Add(this.txtUseCg);
-            this.stackPanel1.Dock = System.Windows.Forms.DockStyle.Top;
-            this.stackPanel1.Location = new System.Drawing.Point(0, 0);
-            this.stackPanel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.stackPanel1.Name = "stackPanel1";
-            this.stackPanel1.Size = new System.Drawing.Size(879, 32);
-            this.stackPanel1.TabIndex = 0;
+            stackPanel1.Controls.Add(labelControl1);
+            stackPanel1.Controls.Add(txtLocalPort);
+            stackPanel1.Controls.Add(labNo);
+            stackPanel1.Controls.Add(txtSvrNo);
+            stackPanel1.Controls.Add(labelControl2);
+            stackPanel1.Controls.Add(txtRegistryAddr);
+            stackPanel1.Controls.Add(txtUseTpdx);
+            stackPanel1.Controls.Add(txtUseCg);
+            stackPanel1.Controls.Add(btnStart);
+            stackPanel1.Dock = DockStyle.Top;
+            stackPanel1.Location = new Point(0, 0);
+            stackPanel1.Margin = new Padding(3, 4, 3, 4);
+            stackPanel1.Name = "stackPanel1";
+            stackPanel1.Size = new Size(1024, 39);
+            stackPanel1.TabIndex = 0;
             // 
             // labelControl1
             // 
-            this.labelControl1.Location = new System.Drawing.Point(3, 9);
-            this.labelControl1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.labelControl1.Name = "labelControl1";
-            this.labelControl1.Size = new System.Drawing.Size(48, 14);
-            this.labelControl1.TabIndex = 0;
-            this.labelControl1.Text = "本地端口";
+            labelControl1.Location = new Point(3, 12);
+            labelControl1.Margin = new Padding(3, 4, 3, 4);
+            labelControl1.Name = "labelControl1";
+            labelControl1.Size = new Size(48, 14);
+            labelControl1.TabIndex = 0;
+            labelControl1.Text = "本地端口";
             // 
             // txtLocalPort
             // 
-            this.txtLocalPort.EditValue = "16002";
-            this.txtLocalPort.Location = new System.Drawing.Point(57, 6);
-            this.txtLocalPort.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.txtLocalPort.Name = "txtLocalPort";
-            this.txtLocalPort.Size = new System.Drawing.Size(100, 20);
-            this.txtLocalPort.TabIndex = 2;
-            this.txtLocalPort.ToolTip = "创建Http服务使用的本地端口,修改后需要重启软件";
-            this.txtLocalPort.EditValueChanged += new System.EventHandler(this.Parms_TextChanged);
+            txtLocalPort.EditValue = "16002";
+            txtLocalPort.Location = new Point(57, 7);
+            txtLocalPort.Margin = new Padding(3, 4, 3, 4);
+            txtLocalPort.Name = "txtLocalPort";
+            txtLocalPort.Properties.AutoHeight = false;
+            txtLocalPort.Size = new Size(100, 24);
+            txtLocalPort.TabIndex = 2;
+            txtLocalPort.ToolTip = "创建Http服务使用的本地端口,修改后需要重启软件";
             // 
             // labNo
             // 
-            this.labNo.Location = new System.Drawing.Point(163, 9);
-            this.labNo.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.labNo.Name = "labNo";
-            this.labNo.Size = new System.Drawing.Size(48, 14);
-            this.labNo.TabIndex = 0;
-            this.labNo.Text = "服务编号";
+            labNo.Location = new Point(163, 12);
+            labNo.Margin = new Padding(3, 4, 3, 4);
+            labNo.Name = "labNo";
+            labNo.Size = new Size(48, 14);
+            labNo.TabIndex = 0;
+            labNo.Text = "服务编号";
             // 
             // txtSvrNo
             // 
-            this.txtSvrNo.EditValue = "GPU020";
-            this.txtSvrNo.Location = new System.Drawing.Point(217, 6);
-            this.txtSvrNo.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.txtSvrNo.Name = "txtSvrNo";
-            this.txtSvrNo.Size = new System.Drawing.Size(100, 20);
-            this.txtSvrNo.TabIndex = 1;
-            this.txtSvrNo.ToolTip = "部署多个此程序时编号不能重复";
-            this.txtSvrNo.EditValueChanged += new System.EventHandler(this.Parms_TextChanged);
+            txtSvrNo.EditValue = "GPU020";
+            txtSvrNo.Location = new Point(217, 7);
+            txtSvrNo.Margin = new Padding(3, 4, 3, 4);
+            txtSvrNo.Name = "txtSvrNo";
+            txtSvrNo.Properties.AutoHeight = false;
+            txtSvrNo.Size = new Size(100, 24);
+            txtSvrNo.TabIndex = 1;
+            txtSvrNo.ToolTip = "部署多个此程序时编号不能重复";
             // 
             // labelControl2
             // 
-            this.labelControl2.Location = new System.Drawing.Point(323, 9);
-            this.labelControl2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.labelControl2.Name = "labelControl2";
-            this.labelControl2.Size = new System.Drawing.Size(48, 14);
-            this.labelControl2.TabIndex = 0;
-            this.labelControl2.Text = "注册地址";
+            labelControl2.Location = new Point(323, 12);
+            labelControl2.Margin = new Padding(3, 4, 3, 4);
+            labelControl2.Name = "labelControl2";
+            labelControl2.Size = new Size(48, 14);
+            labelControl2.TabIndex = 0;
+            labelControl2.Text = "注册地址";
             // 
             // txtRegistryAddr
             // 
-            this.txtRegistryAddr.EditValue = "http://127.0.0.1:16015";
-            this.txtRegistryAddr.Location = new System.Drawing.Point(377, 6);
-            this.txtRegistryAddr.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.txtRegistryAddr.Name = "txtRegistryAddr";
-            this.txtRegistryAddr.Size = new System.Drawing.Size(224, 20);
-            this.txtRegistryAddr.TabIndex = 1;
-            this.txtRegistryAddr.ToolTip = "多个地址用空格隔开";
-            this.txtRegistryAddr.EditValueChanged += new System.EventHandler(this.Parms_TextChanged);
-            // 
-            // btnShowApi
-            // 
-            this.btnShowApi.Alignment = DevExpress.XtraBars.BarItemLinkAlignment.Right;
-            this.btnShowApi.Caption = "barButtonItem1";
-            this.btnShowApi.Id = 0;
-            this.btnShowApi.ImageOptions.SvgImage = ((DevExpress.Utils.Svg.SvgImage)(resources.GetObject("btnShowApi.ImageOptions.SvgImage")));
-            this.btnShowApi.Name = "btnShowApi";
-            toolTipItem11.Text = "查看Http接口文档";
-            superToolTip11.Items.Add(toolTipItem11);
-            this.btnShowApi.SuperTip = superToolTip11;
-            this.btnShowApi.ItemClick += BtnShowApi_ItemClick;
+            txtRegistryAddr.EditValue = "http://127.0.0.1:16015";
+            txtRegistryAddr.Location = new Point(377, 7);
+            txtRegistryAddr.Margin = new Padding(3, 4, 3, 4);
+            txtRegistryAddr.Name = "txtRegistryAddr";
+            txtRegistryAddr.Properties.AutoHeight = false;
+            txtRegistryAddr.Size = new Size(234, 24);
+            txtRegistryAddr.TabIndex = 1;
+            txtRegistryAddr.ToolTip = "多个地址用空格隔开";
             // 
             // txtUseTpdx
             // 
-            this.txtUseTpdx.Location = new System.Drawing.Point(607, 6);
-            this.txtUseTpdx.Name = "txtUseTpdx";
-            this.txtUseTpdx.Properties.Caption = "同频对消";
-            this.txtUseTpdx.Size = new System.Drawing.Size(80, 20);
-            this.txtUseTpdx.TabIndex = 3;
-            this.txtUseTpdx.Checked = true;
-            this.txtUseTpdx.EditValueChanged += new System.EventHandler(this.Parms_TextChanged);
+            txtUseTpdx.EditValue = true;
+            txtUseTpdx.Location = new Point(617, 9);
+            txtUseTpdx.Name = "txtUseTpdx";
+            txtUseTpdx.Properties.Caption = "同频对消";
+            txtUseTpdx.Size = new Size(80, 20);
+            txtUseTpdx.TabIndex = 3;
             // 
             // txtUseCg
             // 
-            this.txtUseCg.Location = new System.Drawing.Point(693, 6);
-            this.txtUseCg.Name = "txtUseCg";
-            this.txtUseCg.Properties.Caption = "参数估计";
-            this.txtUseCg.Size = new System.Drawing.Size(80, 20);
-            this.txtUseCg.TabIndex = 3;
-            this.txtUseCg.Checked = true;
-            this.txtUseCg.EditValueChanged += new System.EventHandler(this.Parms_TextChanged);
+            txtUseCg.EditValue = true;
+            txtUseCg.Location = new Point(703, 9);
+            txtUseCg.Name = "txtUseCg";
+            txtUseCg.Properties.Caption = "参数估计";
+            txtUseCg.Size = new Size(80, 20);
+            txtUseCg.TabIndex = 3;
+            // 
+            // btnStart
+            // 
+            btnStart.Location = new Point(789, 7);
+            btnStart.Name = "btnStart";
+            btnStart.Size = new Size(75, 24);
+            btnStart.TabIndex = 4;
+            btnStart.Text = "启动服务";
+            btnStart.Click += btnStart_Click;
+            // 
+            // btnShowApi
+            // 
+            btnShowApi.Alignment = DevExpress.XtraBars.BarItemLinkAlignment.Right;
+            btnShowApi.Caption = "barButtonItem1";
+            btnShowApi.Id = 0;
+            btnShowApi.ImageOptions.SvgImage = (DevExpress.Utils.Svg.SvgImage)resources.GetObject("btnShowApi.ImageOptions.SvgImage");
+            btnShowApi.Name = "btnShowApi";
+            toolTipItem1.Text = "查看Http接口文档";
+            superToolTip1.Items.Add(toolTipItem1);
+            btnShowApi.SuperTip = superToolTip1;
+            btnShowApi.ItemClick += BtnShowApi_ItemClick;
             // 
             // DirectXForm1
             // 
-            this.Appearance.Options.UseFont = true;
-            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ChildControls.Add(this.directXFormContainerControl1);
-            this.ClientSize = new System.Drawing.Size(881, 338);
-            this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            this.IconOptions.SvgImage = ((DevExpress.Utils.Svg.SvgImage)(resources.GetObject("DirectXForm1.IconOptions.SvgImage")));
-            this.Links.Add(this.btnShowApi);
-            this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
-            this.Name = "DirectXForm1";
-            this.Text = "DirectXForm1";
-            this.directXFormContainerControl1.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.groupControl1)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.stackPanel1)).EndInit();
-            this.stackPanel1.ResumeLayout(false);
-            this.stackPanel1.PerformLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.txtLocalPort.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtSvrNo.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtRegistryAddr.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtUseTpdx.Properties)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.txtUseCg.Properties)).EndInit();
-            this.ResumeLayout(false);
-
+            Appearance.Options.UseFont = true;
+            AutoScaleDimensions = new SizeF(7F, 17F);
+            AutoScaleMode = AutoScaleMode.Font;
+            ChildControls.Add(directXFormContainerControl1);
+            ClientSize = new Size(1026, 338);
+            Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point);
+            IconOptions.SvgImage = (DevExpress.Utils.Svg.SvgImage)resources.GetObject("DirectXForm1.IconOptions.SvgImage");
+            Links.Add(btnShowApi);
+            Margin = new Padding(3, 4, 3, 4);
+            Name = "DirectXForm1";
+            Text = "DirectXForm1";
+            directXFormContainerControl1.ResumeLayout(false);
+            ((System.ComponentModel.ISupportInitialize)groupControl1).EndInit();
+            ((System.ComponentModel.ISupportInitialize)stackPanel1).EndInit();
+            stackPanel1.ResumeLayout(false);
+            stackPanel1.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)txtLocalPort.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtSvrNo.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtRegistryAddr.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtUseTpdx.Properties).EndInit();
+            ((System.ComponentModel.ISupportInitialize)txtUseCg.Properties).EndInit();
+            ResumeLayout(false);
         }
         #endregion
 
@@ -222,5 +230,6 @@
         private DevExpress.XtraEditors.GroupControl groupControl1;
         private DevExpress.XtraEditors.CheckEdit txtUseTpdx;
         private DevExpress.XtraEditors.CheckEdit txtUseCg;
+        private DevExpress.XtraEditors.SimpleButton btnStart;
     }
 }

+ 100 - 82
ipsservice/Ips.Service.GpuServer/DirectXForm1.cs

@@ -1,4 +1,5 @@
-using Ips.Library.Basic;
+using DevExpress.CodeParser;
+using Ips.Library.Basic;
 using Ips.Library.DxpLib;
 using Ips.Library.Entity;
 using Ips.Library.WebApi;
@@ -19,51 +20,28 @@ namespace Ips.Service.GpuServer
 {
     public partial class DirectXForm1 : DevExpress.XtraEditors.DirectXForm
     {
-        private bool _inited = false;
-        private string _localPort;//本地端口
-        private string _svrNo;//服务编号
-        private string _rptAddr;//服务注册上报http地址
+        private bool apiRuning = false;
+        private CancellationTokenSource cts;
         public DirectXForm1()
         {
             InitializeComponent();
             this.Size = new Size(1024, 768);
             this.Text = "GPU服务";
         }
-        protected async override void OnLoad(EventArgs e)
+        protected override void OnLoad(EventArgs e)
         {
             base.OnLoad(e);
             new Library.DxpLib.LogCtrl() { Parent = groupControl1 };
             LoadParams();
-            if (int.TryParse(_localPort, out int intPort))
-            {
-                WebApiHelper.Start(intPort, "Ips.Library.Entity.xml");
-                this.FormClosing += (_, _) => WebApiHelper.Stop();
-                _inited = true;
-                await StateRpt();
-            }
-            _inited = true;
         }
-        private async Task StateRpt()
+        private async void RegistrySvr(CancellationToken token)
         {
-            string localIp;
-
-            while (true)
+            while (!this.Disposing && apiRuning)
             {
                 string getIpUrl = null;
                 try
                 {
-                    if (_rptAddr == null)
-                    {
-                        await Task.Delay(5000);
-                        continue;
-                    }
-                    if (!_rptAddr.ToLower().StartsWith("http://"))
-                    {
-                        IpsLogger.Error($"注册地址必须以http://开头");
-                        await Task.Delay(5000);
-                        continue;
-                    }
-                    getIpUrl = _rptAddr.AppendUrlSuffix("api/getclientip");
+                    getIpUrl = AppConst.RegistryUri.AppendUrlSuffix("api/getclientip");
                     var rsp = await HttpHelper.GetRequestAsync<string>(getIpUrl, 5);
                     if (rsp.code == 0)
                     {
@@ -72,32 +50,29 @@ namespace Ips.Service.GpuServer
                     }
                     else
                     {
-                        localIp = rsp.data;
+                        AppConst.LocalIp = rsp.data;
                     }
                     break;
                 }
                 catch (Exception ex)
                 {
-                    IpsLogger.Error($"无法连接到{getIpUrl},请检测地址是否正确并确保远程设备设备防火墙入栈规则允许TCP端口{getIpUrl.GetUrlPort()}通过", ex);
-                    await Task.Delay(5000);
+                    IpsLogger.Error($"无法注册到{getIpUrl},请检测地址是否正确并确保远程设备设备防火墙入栈规则允许TCP端口{getIpUrl.GetUrlPort()}通过", ex);
+                    await Task.Delay(10000, token);
                 }
             }
-            AppConst.LocalIp = localIp;
-            IpsLogger.Info($"服务启动成功.接口地址http://{localIp}:{_localPort}/swagger");
-
             bool preSucceed = false;
-            while (!this.Disposing)
+            while (!this.Disposing && apiRuning)
             {
-                string url = _rptAddr.AppendUrlSuffix("api/SvrStateRpt/Report");
+                string url = AppConst.RegistryUri.AppendUrlSuffix("api/SvrStateRpt/Report");
                 try
                 {
                     var dto = new ModelSvrRpt()
                     {
-                        SvrType = EnumSvrType.GpuSvr,
-                        SvrNo = _svrNo,
+                        SvrType = EnumSvrType.CapSvr,
+                        SvrNo = AppConst.SvrNo,
                         SvrRptType = EnumSvrRptType.Online,
-                        BaseHttpAddr = $"http://{localIp}:{_localPort}",
-                        SwaggerAddr = $"http://{localIp}:{_localPort}/Swagger",
+                        BaseHttpAddr = $"http://{AppConst.LocalIp}:{AppConst.LocalPort}",
+                        SwaggerAddr = $"http://{AppConst.LocalIp}:{AppConst.LocalPort}/Swagger",
                     };
                     List<string> list = new List<string>();
                     if (AppConst.UseCg)
@@ -110,32 +85,101 @@ namespace Ips.Service.GpuServer
                     }
                     dto.Features = string.Join(" ", list);
                     var res = await HttpHelper.PostRequestAsync<object>(url, dto);
-
                     if (res.code != 200)
                     {
-                        IpsLogger.Error($"状态上报异常[url={url}].{res.msg}");
+                        IpsLogger.Error($"服务注册异常[url={url}].{res.msg}");
                         preSucceed = false;
                     }
                     else
                     {
                         if (!preSucceed)
-                            IpsLogger.Info($"状态上报成功![url={url}]");
+                            IpsLogger.Info($"服务注册成功![url={url}]");
                         preSucceed = true;
                     }
                 }
                 catch (Exception ex)
                 {
-                    IpsLogger.Error($"状态上报异常[url={url}]", ex);
+                    IpsLogger.Error($"服务注册异常[url={url}]", ex);
                     preSucceed = false;
                 }
-                await Task.Delay(10000);
+                await Task.Delay(10000, token);
             }
         }
-
-        private void Parms_TextChanged(object sender, EventArgs e)
+        private void BtnShowApi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
-            if (!_inited) return;
-            SaveParams();
+            string addr = $"http://127.0.0.1:{AppConst.LocalPort}/swagger";
+            try
+            {
+                //System.Diagnostics.Process.Start(addr);//NetFramework可用,NetCore使用CMD启动
+                ProcessStartInfo info = new ProcessStartInfo();
+                info.Arguments = $"/C start {addr}";
+                info.FileName = "cmd";
+                info.UseShellExecute = false;
+                info.CreateNoWindow = true;
+                Process.Start(info);
+            }
+            catch (Exception ex)
+            {
+                IpsLogger.Error($"无法打开默认浏览器,请手动打开浏览器查看接口文档.地址{addr}", ex);
+            }
+        }
+        private void btnStart_Click(object sender, EventArgs e)
+        {
+            try
+            {
+                if (btnStart.Text == "启动服务")
+                {
+                    if (!int.TryParse(txtLocalPort.Text.Trim(), out int localPort))
+                    {
+                        throw new Exception("本地端口输入错误");
+                    }
+                    if (localPort < 1024 || localPort > 49151)
+                    {
+                        //1024以下给vip程序预留的,49152-65535用于客户端随机分配的
+                        throw new Exception("本地端口范围[1024,49151]");
+                    }
+                    if (txtSvrNo.Text.Trim().Length < 3 || txtSvrNo.Text.Trim().Length > 15)
+                    {
+                        throw new Exception("服务编号长度范围[3,15]");
+                    }
+                    try
+                    {
+                        var u = new Uri(txtRegistryAddr.Text.Trim());
+                    }
+                    catch
+                    {
+                        throw new Exception("服务注册地址不是有效的URI");
+                    }
+                    AppConst.LocalPort = localPort;
+                    AppConst.SvrNo = txtSvrNo.Text.Trim();
+                    AppConst.RegistryUri = txtRegistryAddr.Text.Trim();
+                    AppConst.UseTpdx = txtUseTpdx.Checked;
+                    AppConst.UseCg = txtUseCg.Checked;
+                    WebApiHelper.Start(AppConst.LocalPort, "Ips.Library.Entity.xml");
+                    btnStart.Text = "停止服务";
+                    stackPanel1.DisabledChildWithout(btnStart);
+                    IpsLogger.Info($"服务启动成功.接口地址http://+:{localPort}/swagger");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/upload");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/download");
+                    IpsLogger.Info($"服务启动成功.静态文件预览地址http://+:{localPort}/logs");
+                    apiRuning = true;
+                    cts = new CancellationTokenSource();
+                    RegistrySvr(cts.Token);
+                }
+                else
+                {
+                    apiRuning = false;
+                    btnStart.Text = "启动服务";
+                    WebApiHelper.Stop();
+                    cts?.Cancel();
+                    stackPanel1.EnableChild();
+                }
+                SaveParams();
+            }
+            catch (Exception ex)
+            {
+                IpsLogger.Error(ex.Message, ex);
+            }
         }
         void SaveParams()
         {
@@ -148,19 +192,13 @@ namespace Ips.Service.GpuServer
                 sb.AppendLine(txtRegistryAddr.Text);
                 sb.AppendLine(txtUseTpdx.Checked.ToString());
                 sb.AppendLine(txtUseCg.Checked.ToString());
+                sb.AppendLine(btnStart.Text);
                 File.WriteAllText("Params\\Params.txt", sb.ToString());
-                IpsLogger.Info("用户修改了UI参数!");
             }
             catch (Exception ex)
             {
                 IpsLogger.Error("保存Params.txt文件异常", ex);
             }
-            _localPort = txtLocalPort.Text.Trim();
-            _svrNo = txtSvrNo.Text.Trim();
-            _rptAddr = txtRegistryAddr.Text.Trim();
-            AppConst.UseTpdx = txtUseTpdx.Checked;
-            AppConst.UseCg = txtUseCg.Checked;
-            AppConst.SvrNo = _svrNo;
         }
         void LoadParams()
         {
@@ -174,36 +212,16 @@ namespace Ips.Service.GpuServer
                     txtRegistryAddr.Text = lines[2];
                     txtUseTpdx.Checked = lines[3].ToLower() == "true";
                     txtUseCg.Checked = lines[4].ToLower() == "true";
+                    if (lines[5] == "停止服务")//上次状态是启动状态,加载后直接启动
+                    {
+                        btnStart_Click(null, null);
+                    }
                 }
                 catch (Exception ex)
                 {
                     IpsLogger.Error("加载Params.txt文件异常", ex);
                 }
             }
-            _localPort = txtLocalPort.Text.Trim();
-            _svrNo = txtSvrNo.Text.Trim();
-            _rptAddr = txtRegistryAddr.Text.Trim();
-            AppConst.UseTpdx = txtUseCg.Checked;
-            AppConst.UseCg = txtUseCg.Checked;
-            AppConst.SvrNo = _svrNo;
-        }
-        private void BtnShowApi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            string addr = $"http://127.0.0.1:{_localPort}/swagger";
-            try
-            {
-                //System.Diagnostics.Process.Start(addr);//NetFramework可用,NetCore使用CMD启动
-                ProcessStartInfo info = new ProcessStartInfo();
-                info.Arguments = $"/C start {addr}";
-                info.FileName = "cmd";
-                info.UseShellExecute = false;
-                info.CreateNoWindow = true;
-                Process.Start(info);
-            }
-            catch (Exception ex)
-            {
-                IpsLogger.Error($"无法打开默认浏览器,请手动打开浏览器查看接口文档.地址{addr}", ex);
-            }
         }
     }
 }

+ 31 - 31
ipsservice/Ips.Service.GpuServer/DirectXForm1.resx

@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="utf-8"?>
 <root>
-  <!-- 
+  <!--
     Microsoft ResX Schema 
-    
+
     Version 2.0
-    
-    The primary goals of this format is to allow a simple XML format 
-    that is mostly human readable. The generation and parsing of the 
-    various data types are done through the TypeConverter classes 
+
+    The primary goals of this format is to allow a simple XML format
+    that is mostly human readable. The generation and parsing of the
+    various data types are done through the TypeConverter classes
     associated with the data types.
-    
+
     Example:
-    
+
     ... ado.net/XML headers & schema ...
     <resheader name="resmimetype">text/microsoft-resx</resheader>
     <resheader name="version">2.0</resheader>
     <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
     <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
     <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
-    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
     <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
         <value>[base64 mime encoded serialized .NET Framework object]</value>
     </data>
@@ -26,36 +26,36 @@
         <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
         <comment>This is a comment</comment>
     </data>
-                
-    There are any number of "resheader" rows that contain simple 
+
+    There are any number of "resheader" rows that contain simple
     name/value pairs.
-    
-    Each data row contains a name, and value. The row also contains a 
-    type or mimetype. Type corresponds to a .NET class that support 
-    text/value conversion through the TypeConverter architecture. 
-    Classes that don't support this are serialized and stored with the 
+
+    Each data row contains a name, and value. The row also contains a
+    type or mimetype. Type corresponds to a .NET class that support
+    text/value conversion through the TypeConverter architecture.
+    Classes that don't support this are serialized and stored with the
     mimetype set.
-    
-    The mimetype is used for serialized objects, and tells the 
-    ResXResourceReader how to depersist the object. This is currently not 
+
+    The mimetype is used for serialized objects, and tells the
+    ResXResourceReader how to depersist the object. This is currently not
     extensible. For a given mimetype the value must be set accordingly:
-    
-    Note - application/x-microsoft.net.object.binary.base64 is the format 
-    that the ResXResourceWriter will generate, however the reader can 
+
+    Note - application/x-microsoft.net.object.binary.base64 is the format
+    that the ResXResourceWriter will generate, however the reader can
     read any of the formats listed below.
-    
+
     mimetype: application/x-microsoft.net.object.binary.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
             : and then encoded with base64 encoding.
     
     mimetype: application/x-microsoft.net.object.soap.base64
-    value   : The object must be serialized with 
+    value   : The object must be serialized with
             : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
             : and then encoded with base64 encoding.
 
     mimetype: application/x-microsoft.net.object.bytearray.base64
-    value   : The object must be serialized into a byte array 
+    value   : The object must be serialized into a byte array
             : using a System.ComponentModel.TypeConverter
             : and then encoded with base64 encoding.
     -->
@@ -117,10 +117,10 @@
   <resheader name="writer">
     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <assembly alias="DevExpress.Data.v23.2" name="DevExpress.Data.v23.2, Version=23.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
-  <data name="btnShowApi.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v23.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <assembly alias="DevExpress.Data.v24.1" name="DevExpress.Data.v24.1, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
+  <data name="btnShowApi.ImageOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v24.1" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
-        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIzLjIsIFZlcnNpb249MjMuMi4z
+        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjI0LjEsIFZlcnNpb249MjQuMS42
         LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
         dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAANYEAAAC77u/
         PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgeD0iMHB4IiB5PSIwcHgi
@@ -146,9 +146,9 @@
         MTEuNiwxNC40eiIgY2xhc3M9IkJsdWUiIC8+DQo8L3N2Zz4L
 </value>
   </data>
-  <data name="DirectXForm1.IconOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v23.2" mimetype="application/x-microsoft.net.object.bytearray.base64">
+  <data name="DirectXForm1.IconOptions.SvgImage" type="DevExpress.Utils.Svg.SvgImage, DevExpress.Data.v24.1" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
-        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjIzLjIsIFZlcnNpb249MjMuMi4z
+        AAEAAAD/////AQAAAAAAAAAMAgAAAFlEZXZFeHByZXNzLkRhdGEudjI0LjEsIFZlcnNpb249MjQuMS42
         LjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjg4ZDE3NTRkNzAwZTQ5YQUBAAAAHURl
         dkV4cHJlc3MuVXRpbHMuU3ZnLlN2Z0ltYWdlAQAAAAREYXRhBwICAAAACQMAAAAPAwAAAOkEAAAC77u/
         PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz4NCjxzdmcgd2lkdGg9Ijk2cHgiIGhl

+ 3 - 2
ipsservice/Ips.Service.GpuServer/Program.cs

@@ -47,7 +47,8 @@ namespace Ips.Service.GpuServer
             };
             Application.ThreadException += (sender, e) =>
             {
-                IpsLogger.Error("出现未处理的线程异常!", e.Exception);
+                if (e.Exception.GetType() != typeof(TaskCanceledException))
+                    IpsLogger.Error("出现未处理的线程异常!", e.Exception);
             };
         }
         /// <summary>
@@ -57,7 +58,7 @@ namespace Ips.Service.GpuServer
         static void Main()
         {
             //必须要用一个委托包装一下,否则发布后运行不会显示UI,我也不知道为啥
-            AppHelper.MultStart(() =>
+            AppHelper.OneStart("GPU服务",() =>
             {
                 ChsLocalizer.UseChs();
                 ApplicationConfiguration.Initialize();

+ 2 - 2
ipstool/ipssps2/Ips.Sps.Host.Win/MainWin.cs

@@ -61,7 +61,7 @@ namespace Ips.Sps
         private void MainWin_Load(object sender, EventArgs e)
         {
             //Ips.Sps.Controllers.dll被反射加载,不调用一下运行单文件发布的程序会找不到此程序集
-            //var t = new HomeController();
+            new HomeController().EnsureAssemblyLoaded();
             ServerContext.Instance.Init();
             string autoClearPath = ToolConfig.GetAppSetting("FileClearPath");
             if (autoClearPath.IsNotNullOrWhitespace())
@@ -69,7 +69,7 @@ namespace Ips.Sps
                 _driveMonitor = new DriveMonitor(autoClearPath);
                 _driveMonitor.Start();
             }
-            WebApiHelper.Start(Convert.ToInt32(SpsConst.HttpPort),  "Ips.Library.Entity.xml",null, $"Ips.Sps.Controllers.xml");
+            WebApiHelper.Start(Convert.ToInt32(SpsConst.HttpPort), "Ips.Library.Entity.xml", null, $"Ips.Sps.Controllers.xml");
             IpsLogger.Info("系统启动完成");
             SplashScreenManager.CloseForm();
         }