From 6ca8cb2376f6f02e93e233130da9896565706a7f Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期一, 30 十二月 2024 11:10:32 +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