From c40ce123424183b2fce3bf9dfb24d859f3eacb52 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 09 一月 2025 17:00:03 +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