From 08af2a04e8e27642111de41cec15870ced75d599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=AD=E7=9D=BFAMD7950X?= <774114798@qq.com> Date: Tue, 10 Dec 2024 10:26:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=80=9A=E4=BF=A1=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OperationsGatewayAppModule.cs | 82 +++++++------------ OperationsMainSiteGatewayServer/Program.cs | 6 +- .../EntityFrameworkCore/Seed/SeedHelper.cs | 4 +- 3 files changed, 33 insertions(+), 59 deletions(-) diff --git a/OperationsMainSiteGatewayServer/OperationsGatewayAppModule.cs b/OperationsMainSiteGatewayServer/OperationsGatewayAppModule.cs index feb97c8..c34b8f5 100644 --- a/OperationsMainSiteGatewayServer/OperationsGatewayAppModule.cs +++ b/OperationsMainSiteGatewayServer/OperationsGatewayAppModule.cs @@ -10,34 +10,38 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using YunDa.ISAS.Application.Core; using YunDa.ISAS.Application.Core.Configuration; using YunDa.ISAS.Configuration; using YunDa.ISAS.Core; +using YunDa.ISAS.DataTransferObject; +using YunDa.ISAS.EntityFrameworkCore.EntityFrameworkCore; +using YunDa.ISAS.MongoDB; using YunDa.ISAS.MongoDB.Configuration; +using YunDa.ISAS.Redis; using YunDa.ISAS.Redis.Configuration; +using YunDa.ISMS.BASE.Entities; namespace Yunda.SOMS.OperationsMainSiteGatewayServer { [DependsOn( - typeof(AbpAspNetCoreModule) - )] + typeof(ISASCoreModule), + typeof(ISASEntityFrameworkCoreModule), + typeof(ISMS_BASEEntityFrameworkCoreModule), + typeof(ISASMongoDBModule), + typeof(ISASRedisModule) + )] public class OperationsGatewayAppModule : AbpModule { + public OperationsGatewayAppModule(ISASEntityFrameworkCoreModule isasEntityFrameworkModule) + { + isasEntityFrameworkModule.SkipDbSeed = true; + + } public override void PreInitialize() { // 预初始化阶段,可以进行一些配置 Console.WriteLine("PreInitialize: ABP Module Setup"); - } - - public override void Initialize() - { - // 初始化阶段 - IocManager.RegisterAssemblyByConvention(typeof(OperationsGatewayAppModule).GetAssembly()); - Console.WriteLine("Initialize: ABP Module Initialized"); - } - - public override void PostInitialize() - { var _appConfiguration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); @@ -47,43 +51,7 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer ISASConsts.ConnectionMysqlStringKey ); - //基于abpModule - // 输入时间格式(支持多种格式解析) - Configuration.Modules.AbpAspNetCore().InputDateTimeFormats = new List - { - // 标准日期时间格式 - "yyyy-MM-ddTHH:mm:ss", // ISO 8601 格式 - "yyyy-MM-ddTHH:mm:ssZ", // ISO 8601 UTC 格式 - "yyyy-MM-ddTHH:mm:ss.fff", // 带毫秒的 ISO 格式 - "yyyy-MM-ddTHH:mm:ss.fffZ", // 带毫秒的 ISO UTC 格式 - - // 自定义日期时间格式 - "yyyy-MM-dd HH:mm:ss", // 常见的日期时间格式 - "yyyy-MM-dd HH:mm:ss.fff", // 带毫秒的日期时间格式 - "yyyy-MM-dd", // 简单日期格式 - "yyyy/MM/dd HH:mm:ss", // 斜线分隔的日期时间 - "yyyy/MM/dd", // 斜线分隔的简单日期 - - // 带时间标识(AM/PM) - "yyyy-MM-dd hh:mm:ss tt", // 12 小时制,带 AM/PM - "yyyy/MM/dd hh:mm:ss tt", // 12 小时制,带 AM/PM 的斜线分隔 - - // 支持带时区偏移的格式 - "yyyy-MM-ddTHH:mm:sszzz", // 带时区的 ISO 格式 - "yyyy-MM-dd HH:mm:sszzz", // 带时区偏移的自定义格式 - - // 长格式(英文) - "ddd, dd MMM yyyy HH:mm:ss GMT",// HTTP 标准格式 - "dddd, dd MMMM yyyy HH:mm:ss", // 长格式带月份全名 - "ddd, dd MMM yyyy HH:mm:ss zzz" // 带时区的长格式 - - // Unix 时间戳(扩展支持可解析为 DateTime) - // 需要额外解析逻辑时也可以支持 - }; - - // 输出时间格式 - Configuration.Modules.AbpAspNetCore().OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; // 自定义时间格式 Debug.WriteLine("MySql数据库连接:" + _appConfiguration.GetConnectionString(ISASConsts.ConnectionMysqlStringKey)); #region 设置MogngoDBConfig @@ -100,12 +68,20 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer Console.WriteLine("Redis数据库连接:" + redisConfiguration.Host + ":" + redisConfiguration.Port); #endregion - #region 设置AppConfig + + } - var appServiceConfiguration = Configuration.Modules.ISASConfiguration(); - ConfigurationHelper.SetAppServiceConfiguration(_appConfiguration, ref appServiceConfiguration); + public override void Initialize() + { + // 初始化阶段 + IocManager.RegisterAssemblyByConvention(typeof(OperationsGatewayAppModule).GetAssembly()); + Console.WriteLine("Initialize: ABP Module Initialized"); + //ServiceCollectionRegistrar.Register(IocManager); + } - #endregion 设置AppConfig + public override void PostInitialize() + { + } public override void Shutdown() diff --git a/OperationsMainSiteGatewayServer/Program.cs b/OperationsMainSiteGatewayServer/Program.cs index ce93b31..82d1f81 100644 --- a/OperationsMainSiteGatewayServer/Program.cs +++ b/OperationsMainSiteGatewayServer/Program.cs @@ -23,15 +23,14 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer try { + _bootstrapper = InitializeBootstrapper(); // 初始化 ABP 应用程序 - var app = AbpBootstrapper.Create(); - app.Initialize(); var configuration = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); ConfigureLogger(configuration); Log.Information("程序启动"); - _bootstrapper = InitializeBootstrapper(); + await RunApplication(ConfigureServerAddr(configuration)); Log.Information("程序运行完成"); using (var cts = new CancellationTokenSource()) @@ -42,7 +41,6 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer { e.Cancel = true; // 阻止程序立即退出 cts.Cancel(); // 触发取消 - app.Dispose(); }; try diff --git a/src/YunDa.Domain/YunDa.ISAS.EntityFrameworkCore/EntityFrameworkCore/Seed/SeedHelper.cs b/src/YunDa.Domain/YunDa.ISAS.EntityFrameworkCore/EntityFrameworkCore/Seed/SeedHelper.cs index de9c929..2e7921a 100644 --- a/src/YunDa.Domain/YunDa.ISAS.EntityFrameworkCore/EntityFrameworkCore/Seed/SeedHelper.cs +++ b/src/YunDa.Domain/YunDa.ISAS.EntityFrameworkCore/EntityFrameworkCore/Seed/SeedHelper.cs @@ -30,8 +30,8 @@ namespace YunDa.ISAS.EntityFrameworkCore.EntityFrameworkCore.Seed { try { - var context = uowManager.Object.Current.GetDbContext(MultiTenancySides.Host); - contextAction(context); + //var context = uowManager.Object.Current.GetDbContext(); + //contextAction(context); uow.Complete(); } catch (Exception ex)