主站网关
This commit is contained in:
parent
fe55f045a3
commit
5d0210dd73
@ -1,33 +1,117 @@
|
|||||||
using Abp.Dependency;
|
using Abp.AspNetCore;
|
||||||
|
using Abp.AspNetCore.Configuration;
|
||||||
|
using Abp.Dependency;
|
||||||
using Abp.Modules;
|
using Abp.Modules;
|
||||||
|
using Abp.Reflection.Extensions;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using YunDa.ISAS.Application.Core.Configuration;
|
||||||
|
using YunDa.ISAS.Configuration;
|
||||||
|
using YunDa.ISAS.Core;
|
||||||
|
using YunDa.ISAS.MongoDB.Configuration;
|
||||||
|
using YunDa.ISAS.Redis.Configuration;
|
||||||
|
|
||||||
namespace Yunda.SOMS.OperationsMainSiteGatewayServer
|
namespace Yunda.SOMS.OperationsMainSiteGatewayServer
|
||||||
{
|
{
|
||||||
|
[DependsOn(
|
||||||
|
typeof(AbpAspNetCoreModule)
|
||||||
|
)]
|
||||||
public class OperationsGatewayAppModule : AbpModule
|
public class OperationsGatewayAppModule : AbpModule
|
||||||
{
|
{
|
||||||
public override void PreInitialize()
|
public override void PreInitialize()
|
||||||
{
|
{
|
||||||
// 配置其他服务
|
// 预初始化阶段,可以进行一些配置
|
||||||
|
Console.WriteLine("PreInitialize: ABP Module Setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
// 自动注册程序集中的依赖
|
// 初始化阶段
|
||||||
IocManager.RegisterAssemblyByConvention(typeof(OperationsGatewayAppModule).Assembly);
|
IocManager.RegisterAssemblyByConvention(typeof(OperationsGatewayAppModule).GetAssembly());
|
||||||
|
Console.WriteLine("Initialize: ABP Module Initialized");
|
||||||
// 手动注册服务
|
|
||||||
//IocManager.Register<MonitoringDataService>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PostInitialize()
|
public override void PostInitialize()
|
||||||
{
|
{
|
||||||
// 应用启动时的后期初始化逻辑
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using Abp;
|
using Abp;
|
||||||
|
using Abp.Modules;
|
||||||
using Castle.Core;
|
using Castle.Core;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@ -22,7 +23,9 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// 初始化 ABP 应用程序
|
||||||
|
var app = AbpBootstrapper.Create<OperationsGatewayAppModule>();
|
||||||
|
app.Initialize();
|
||||||
var configuration = new ConfigurationBuilder()
|
var configuration = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appsettings.json")
|
.AddJsonFile("appsettings.json")
|
||||||
.Build();
|
.Build();
|
||||||
@ -39,6 +42,7 @@ namespace Yunda.SOMS.OperationsMainSiteGatewayServer
|
|||||||
{
|
{
|
||||||
e.Cancel = true; // 阻止程序立即退出
|
e.Cancel = true; // 阻止程序立即退出
|
||||||
cts.Cancel(); // 触发取消
|
cts.Cancel(); // 触发取消
|
||||||
|
app.Dispose();
|
||||||
};
|
};
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Abp" Version="9.4.2" />
|
<PackageReference Include="Abp" Version="9.4.2" />
|
||||||
|
<PackageReference Include="Abp.AspNetCore" Version="9.4.2" />
|
||||||
<PackageReference Include="DotNetty.Codecs" Version="0.7.6" />
|
<PackageReference Include="DotNetty.Codecs" Version="0.7.6" />
|
||||||
<PackageReference Include="DotNetty.Transport" Version="0.7.6" />
|
<PackageReference Include="DotNetty.Transport" Version="0.7.6" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
@ -31,8 +32,10 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\src\YunDa.Application\YunDa.ISAS.DataTransferObject\YunDa.SOMS.DataTransferObject.csproj" />
|
<ProjectReference Include="..\src\YunDa.Application\YunDa.ISAS.DataTransferObject\YunDa.SOMS.DataTransferObject.csproj" />
|
||||||
|
<ProjectReference Include="..\src\YunDa.Domain\YunDa.ISAS.MongoDB\YunDa.SOMS.MongoDB.csproj" />
|
||||||
<ProjectReference Include="..\src\YunDa.Domain\YunDa.ISAS.Redis.Entities\YunDa.SOMS.Redis.Entities.csproj" />
|
<ProjectReference Include="..\src\YunDa.Domain\YunDa.ISAS.Redis.Entities\YunDa.SOMS.Redis.Entities.csproj" />
|
||||||
<ProjectReference Include="..\src\YunDa.Domain\YunDa.ISAS.Redis\YunDa.SOMS.Redis.csproj" />
|
<ProjectReference Include="..\src\YunDa.Domain\YunDa.ISAS.Redis\YunDa.SOMS.Redis.csproj" />
|
||||||
|
<ProjectReference Include="..\src\YunDa.Web\YunDa.ISAS.Web.Core\YunDa.SOMS.Web.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user