完成通信网关的数据库链接
This commit is contained in:
parent
130942cafc
commit
08af2a04e8
@ -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<string>
|
||||
{
|
||||
// 标准日期时间格式
|
||||
"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<IAppServiceConfiguration>();
|
||||
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()
|
||||
|
@ -23,15 +23,14 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer
|
||||
|
||||
try
|
||||
{
|
||||
_bootstrapper = InitializeBootstrapper();
|
||||
// 初始化 ABP 应用程序
|
||||
var app = AbpBootstrapper.Create<OperationsGatewayAppModule>();
|
||||
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
|
||||
|
@ -30,8 +30,8 @@ namespace YunDa.ISAS.EntityFrameworkCore.EntityFrameworkCore.Seed
|
||||
{
|
||||
try
|
||||
{
|
||||
var context = uowManager.Object.Current.GetDbContext<TDbContext>(MultiTenancySides.Host);
|
||||
contextAction(context);
|
||||
//var context = uowManager.Object.Current.GetDbContext<TDbContext>();
|
||||
//contextAction(context);
|
||||
uow.Complete();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user