From f7e91120bed67bf81f3e873056b147c8df2d68c0 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期三, 23 四月 2025 15:38:15 +0800
Subject: [PATCH] 修复了一些已知问题

---
 Tiger.Api/ApiWebHostService.cs |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Tiger.Api/ApiWebHostService.cs b/Tiger.Api/ApiWebHostService.cs
index 3bead49..3c6a088 100644
--- a/Tiger.Api/ApiWebHostService.cs
+++ b/Tiger.Api/ApiWebHostService.cs
@@ -6,9 +6,27 @@
 using System.Threading.Tasks;
 using Rhea.Common;
 using Tiger.IBusiness;
+using System.ServiceProcess;
+using Tiger.Api.DbCache;
 
 namespace Tiger.Api
 {
+    public static class WebHostServiceExtensions
+    {
+        public static void RunAsApiService(this IWebHost host)
+        {
+            try
+            {
+                var webHostService = new ApiWebHostService(host);
+                ServiceBase.Run(webHostService);
+            }
+            catch (System.Exception ex)
+            {
+                Logger.Console.Fatal(ex, "Windows Services Exception");
+            }
+        }
+    }
+
     internal class ApiWebHostService : WebHostService
     {
         public ApiWebHostService(IWebHost host) : base(host)
@@ -38,9 +56,10 @@
                 //鍏抽棴鏈嶅姟鎬荤嚎
                 DI.Resolve<IServicesBus>().StopServices();
                 //鍏抽棴DB缂撳瓨鑷姩鏇存柊
-                DI.Resolve<IDbCacheBus>().StopAutoUpdate();
-                MQTTHelper.MQTTConn?.Close();
-	            base.OnStopping();
+                //DI.Resolve<IDbCacheBus>().StopAutoUpdate();
+                DbCacheBus.StopAutoUpdate();
+                //MQTTHelper.MQTTConn?.Close();
+                base.OnStopping();
             }
             catch (System.Exception ex)
             {

--
Gitblit v1.9.3