From ca08d1f380987254814242e2fe3ea9de28228132 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期六, 04 一月 2025 09:36:21 +0800
Subject: [PATCH] 代码更新

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/HostedService/WarehouseHostedService.cs |   46 ++++++++++++++++++++++++++--------------------
 1 files changed, 26 insertions(+), 20 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/HostedService/WarehouseHostedService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/HostedService/WarehouseHostedService.cs"
index 64b2c52..08ad5c7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/HostedService/WarehouseHostedService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/HostedService/WarehouseHostedService.cs"
@@ -21,34 +21,40 @@
 
         public Task StartAsync(CancellationToken cancellationToken)
         {
-            string connStr = AppSettings.GetValue("WMSConnectionStrings");
-            if (string.IsNullOrEmpty(connStr))
+            try
             {
-                throw new Exception("WMS杩炴帴瀛楃涓查敊璇�");
+                string connStr = AppSettings.GetValue("WMSConnectionStrings");
+                if (string.IsNullOrEmpty(connStr))
+                {
+                    throw new Exception("WMS杩炴帴瀛楃涓查敊璇�");
+                }
+                SqlSugarClient sugarClient = new(new ConnectionConfig()
+                {
+                    ConnectionString = connStr,
+                    IsAutoCloseConnection = true,
+                    DbType = DbType.SqlServer
+                });
+
+                //List<Dt_Warehouse> warehouses = sugarClient.Queryable<Dt_Warehouse>().ToList();
+
+                //_dbContext.Db.Deleteable<Dt_Warehouse>().ExecuteCommand();
+
+                //_dbContext.Db.Insertable(warehouses).ExecuteCommand();
+
+                List<Dt_ApiInfo> apiInfos = _dbContext.Db.Queryable<Dt_ApiInfo>().ToList();
+
+                _cacheService.AddOrUpdate(nameof(apiInfos), apiInfos);
             }
-            SqlSugarClient sugarClient = new(new ConnectionConfig()
+            catch (Exception ex)
             {
-                ConnectionString = connStr,
-                IsAutoCloseConnection = true,
-                DbType = DbType.SqlServer
-            });
-
-            List<Dt_Warehouse> warehouses = sugarClient.Queryable<Dt_Warehouse>().ToList();
-
-            _dbContext.Db.Deleteable<Dt_Warehouse>().ExecuteCommand();
-
-            _dbContext.Db.Insertable(warehouses).ExecuteCommand();
-
-            List<Dt_ApiInfo> apiInfos = _dbContext.Db.Queryable<Dt_ApiInfo>().ToList();
-
-            _cacheService.AddOrUpdate(nameof(apiInfos), apiInfos);
-
+                Console.WriteLine(ex.ToString());
+            }
             return Task.CompletedTask;
         }
 
         public Task StopAsync(CancellationToken cancellationToken)
         {
-            throw new NotImplementedException();
+            return Task.CompletedTask;
         }
     }
 }

--
Gitblit v1.9.3