From 9e6b28f0b0c29523d0dd11d0a01a53af5f1ada33 Mon Sep 17 00:00:00 2001 From: dengjunjie <dengjunjie@hnkhzn.com> Date: 星期六, 11 一月 2025 21:32:35 +0800 Subject: [PATCH] 添加PDA平库出库 --- 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/HostedService/WarehouseHostedService.cs | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 38 insertions(+), 12 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 20b4120..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" @@ -1,34 +1,60 @@ 锘� using SqlSugar; using WIDESEAWCS_Core.Helper; +using WIDESEAWCS_Core.Seed; using WIDESEAWCS_DTO.BasicInfo; +using WIDESEAWCS_Model.Models; +using ICacheService = WIDESEAWCS_Core.Caches.ICacheService; namespace WIDESEAWCS_Server.HostedService { public class WarehouseHostedService : IHostedService { + private readonly ICacheService _cacheService; + private readonly DBContext _dbContext; + + public WarehouseHostedService(ICacheService cacheService, DBContext dbContext) + { + _cacheService = cacheService; + _dbContext = dbContext; + } + 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 SqlSugarClient(new ConnectionConfig() + catch (Exception ex) { - ConnectionString = connStr, - IsAutoCloseConnection = true, - DbType = DbType.SqlServer - }); - - List<WarehouseDTO> warehouses = sugarClient.Queryable<WarehouseDTO>().ToList(); - + Console.WriteLine(ex.ToString()); + } return Task.CompletedTask; } public Task StopAsync(CancellationToken cancellationToken) { - throw new NotImplementedException(); + return Task.CompletedTask; } } } -- Gitblit v1.9.3