2024-12-09 17:31:21 +08:00
|
|
|
|
using Abp.AspNetCore;
|
|
|
|
|
using Abp.AspNetCore.Configuration;
|
|
|
|
|
using Abp.Dependency;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using Abp.Modules;
|
2024-12-09 17:31:21 +08:00
|
|
|
|
using Abp.Reflection.Extensions;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-12-09 17:31:21 +08:00
|
|
|
|
using System.Diagnostics;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-12-09 17:31:21 +08:00
|
|
|
|
using YunDa.ISAS.Application.Core.Configuration;
|
|
|
|
|
using YunDa.ISAS.Configuration;
|
|
|
|
|
using YunDa.ISAS.Core;
|
|
|
|
|
using YunDa.ISAS.MongoDB.Configuration;
|
|
|
|
|
using YunDa.ISAS.Redis.Configuration;
|
2024-11-26 13:45:28 +08:00
|
|
|
|
|
|
|
|
|
namespace Yunda.SOMS.OperationsMainSiteGatewayServer
|
|
|
|
|
{
|
2024-12-09 17:31:21 +08:00
|
|
|
|
[DependsOn(
|
|
|
|
|
typeof(AbpAspNetCoreModule)
|
|
|
|
|
)]
|
2024-11-26 13:45:28 +08:00
|
|
|
|
public class OperationsGatewayAppModule : AbpModule
|
|
|
|
|
{
|
|
|
|
|
public override void PreInitialize()
|
|
|
|
|
{
|
2024-12-09 17:31:21 +08:00
|
|
|
|
// 预初始化阶段,可以进行一些配置
|
|
|
|
|
Console.WriteLine("PreInitialize: ABP Module Setup");
|
2024-11-26 13:45:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
2024-12-09 17:31:21 +08:00
|
|
|
|
// 初始化阶段
|
|
|
|
|
IocManager.RegisterAssemblyByConvention(typeof(OperationsGatewayAppModule).GetAssembly());
|
|
|
|
|
Console.WriteLine("Initialize: ABP Module Initialized");
|
2024-11-26 13:45:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PostInitialize()
|
|
|
|
|
{
|
2024-12-09 17:31:21 +08:00
|
|
|
|
var _appConfiguration = new ConfigurationBuilder()
|
|
|
|
|
.AddJsonFile("appsettings.json")
|
|
|
|
|
.Build();
|
|
|
|
|
// 后初始化阶段
|
|
|
|
|
Console.WriteLine("PostInitialize: ABP Module Post Initialization");
|
|
|
|
|
Configuration.DefaultNameOrConnectionString = _appConfiguration.GetConnectionString(
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
var mongoConfiguration = Configuration.Modules.ISASConfiguration<IMongoDBConfiguration>();
|
|
|
|
|
ConfigurationHelper.SetMongoDBConfiguration(_appConfiguration, ref mongoConfiguration);
|
|
|
|
|
Console.WriteLine("MongoDB数据库连接:" + mongoConfiguration.HostString + ":" + mongoConfiguration.Port);
|
|
|
|
|
|
|
|
|
|
#endregion 设置MogngoDBConfig
|
|
|
|
|
|
|
|
|
|
#region 设置redisconfig
|
|
|
|
|
var redisConfiguration = Configuration.Modules.ISASConfiguration<IRedisConfiguration>();
|
|
|
|
|
ConfigurationHelper.SetRedisConfiguration(_appConfiguration, ref redisConfiguration);
|
|
|
|
|
Console.WriteLine("Redis数据库连接:" + redisConfiguration.Host + ":" + redisConfiguration.Port);
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 设置AppConfig
|
|
|
|
|
|
|
|
|
|
var appServiceConfiguration = Configuration.Modules.ISASConfiguration<IAppServiceConfiguration>();
|
|
|
|
|
ConfigurationHelper.SetAppServiceConfiguration(_appConfiguration, ref appServiceConfiguration);
|
|
|
|
|
|
|
|
|
|
#endregion 设置AppConfig
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Shutdown()
|
|
|
|
|
{
|
|
|
|
|
// 关闭时调用
|
|
|
|
|
Console.WriteLine("Shutdown: ABP Module Shut down");
|
2024-11-26 13:45:28 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|