Browse Source

refactor: 优化share host

aspnetcore
zzzwangjun@gmail.com 8 months ago
parent
commit
456e6c621d
  1. 7
      aspnet-core/Lion.AbpPro.sln
  2. 2
      aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion.AbpPro.AspNetCore.csproj
  3. 5
      aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreConsts.cs
  4. 7
      aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreModule.cs
  5. 17
      aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs
  6. 14
      aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Serilog/SerilogToEsExtensions.cs
  7. 10
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/GlobalUsings.cs
  8. 12
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion.AbpPro.Hangfire.csproj
  9. 2
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/AutoDeleteAfterSuccessAttribute.cs
  10. 77
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/CronType.cs
  11. 10
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/CustomHangfireAuthorizeFilter.cs
  12. 9
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/IRecurringJob.cs
  13. 4
      aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/JobRetryLastFilter.cs
  14. 57
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostConst.cs
  15. 198
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs
  16. 78
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/CronType.cs
  17. 11
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/CustomHangfireAuthorizeFilter.cs
  18. 15
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/RecurringJobsExtensions.cs
  19. 3
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/GlobalUsings.cs
  20. 74
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj
  21. 9
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs
  22. 61
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json
  23. 27
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json
  24. 11
      aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Jobs/IRecurringJob.cs
  25. 1
      aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj
  26. 11
      aspnet-core/services/src/Lion.AbpPro.Application/Jobs/TestJob.cs
  27. 2
      aspnet-core/services/src/Lion.AbpPro.DbMigrator/appsettings.json

7
aspnet-core/Lion.AbpPro.sln

@ -251,6 +251,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.HttpClient", "f
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.AspNetCore", "frameworks\src\Lion.AbpPro.AspNetCore\Lion.AbpPro.AspNetCore.csproj", "{89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.AspNetCore", "frameworks\src\Lion.AbpPro.AspNetCore\Lion.AbpPro.AspNetCore.csproj", "{89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lion.AbpPro.Hangfire", "frameworks\src\Lion.AbpPro.Hangfire\Lion.AbpPro.Hangfire.csproj", "{6C2FDD3D-F711-46B0-A2F2-B94BC33F136B}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -617,6 +619,10 @@ Global
{89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}.Debug|Any CPU.Build.0 = Debug|Any CPU {89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}.Debug|Any CPU.Build.0 = Debug|Any CPU
{89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}.Release|Any CPU.ActiveCfg = Release|Any CPU {89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}.Release|Any CPU.ActiveCfg = Release|Any CPU
{89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}.Release|Any CPU.Build.0 = Release|Any CPU {89CCAEA6-8176-4E4B-8D84-A2ACE2715F88}.Release|Any CPU.Build.0 = Release|Any CPU
{6C2FDD3D-F711-46B0-A2F2-B94BC33F136B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C2FDD3D-F711-46B0-A2F2-B94BC33F136B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C2FDD3D-F711-46B0-A2F2-B94BC33F136B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C2FDD3D-F711-46B0-A2F2-B94BC33F136B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -737,6 +743,7 @@ Global
{A70659A2-91F4-4FE7-80D0-DA12430543FD} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} {A70659A2-91F4-4FE7-80D0-DA12430543FD} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{9C88C5AE-21A1-4A62-9FA3-173806CD9EE3} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} {9C88C5AE-21A1-4A62-9FA3-173806CD9EE3} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{89CCAEA6-8176-4E4B-8D84-A2ACE2715F88} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3} {89CCAEA6-8176-4E4B-8D84-A2ACE2715F88} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
{6C2FDD3D-F711-46B0-A2F2-B94BC33F136B} = {7BE85EBC-99AD-4CDE-957E-4BDD087FC4E3}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F} SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}

2
aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion.AbpPro.AspNetCore.csproj

@ -33,7 +33,7 @@
<PackageReference Include="Serilog.Sinks.Console" /> <PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" /> <PackageReference Include="Serilog.Sinks.Elasticsearch" />
<PackageReference Include="Serilog.Sinks.File" /> <PackageReference Include="Serilog.Sinks.File" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> <PackageReference Include="Serilog.Sinks.Async" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

5
aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreConsts.cs

@ -41,4 +41,9 @@ public class AbpProAspNetCoreConsts
/// 审计配置节名称 /// 审计配置节名称
/// </summary> /// </summary>
public const string Audit = "Audit"; public const string Audit = "Audit";
/// <summary>
/// token
/// </summary>
public const string Jwt = "Jwt";
} }

7
aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Lion/AbpPro/AspNetCore/AbpProAspNetCoreModule.cs

@ -6,17 +6,12 @@ public class AbpProAspNetCoreModule : AbpModule
{ {
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)
{ {
var s = context.Configuration.GetSection(AbpProAspNetCoreConsts.Cors);
context.Services.Configure<AbpProGatewayOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Gateway)); context.Services.Configure<AbpProGatewayOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Gateway));
context.Services.Configure<AbpProCorsOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Cors)); context.Services.Configure<AbpProCorsOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Cors));
context.Services.Configure<AbpProMiniProfilerOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.MiniProfiler)); context.Services.Configure<AbpProMiniProfilerOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.MiniProfiler));
context.Services.Configure<AbpProMultiTenancyOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.MultiTenancy)); context.Services.Configure<AbpProMultiTenancyOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.MultiTenancy));
context.Services.Configure<AbpProSwaggerOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Swagger)); context.Services.Configure<AbpProSwaggerOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Swagger));
context.Services.Configure<AbpProAuditOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Audit)); context.Services.Configure<AbpProAuditOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Audit));
} context.Services.Configure<AbpProJwtOptions>(context.Configuration.GetSection(AbpProAspNetCoreConsts.Jwt));
public override void ConfigureServices(ServiceConfigurationContext context)
{
} }
} }

17
aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs

@ -30,7 +30,7 @@ public static class ServiceCollectionExtensions
public static IServiceCollection AddAbpProConsul(this IServiceCollection service) public static IServiceCollection AddAbpProConsul(this IServiceCollection service)
{ {
var consulOptions = service.GetRequiredService<IOptions<AbpProGatewayOptions>>().Value; var consulOptions = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProGatewayOptions>>().Value;
if (!consulOptions.Enabled) if (!consulOptions.Enabled)
return service; return service;
@ -46,6 +46,7 @@ public static class ServiceCollectionExtensions
{ {
// TODO 检查数据库和redis是否正常 AspNetCore.HealthChecks.Redis AspNetCore.HealthChecks.MySql // TODO 检查数据库和redis是否正常 AspNetCore.HealthChecks.Redis AspNetCore.HealthChecks.MySql
// context.Services.AddHealthChecks().AddRedis(redisConnectionString).AddMySql(connectString); // context.Services.AddHealthChecks().AddRedis(redisConnectionString).AddMySql(connectString);
service.AddHealthChecks();
return service; return service;
} }
@ -94,7 +95,7 @@ public static class ServiceCollectionExtensions
/// </summary> /// </summary>
public static IServiceCollection AddAbpProCors(this IServiceCollection service) public static IServiceCollection AddAbpProCors(this IServiceCollection service)
{ {
var corsOptions = service.GetRequiredService<IOptions<AbpProCorsOptions>>().Value; var corsOptions = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProCorsOptions>>().Value;
if (!corsOptions.Enabled) return service; if (!corsOptions.Enabled) return service;
service.AddCors(options => service.AddCors(options =>
@ -150,7 +151,7 @@ public static class ServiceCollectionExtensions
/// </summary> /// </summary>
public static IServiceCollection AddAbpProSwagger(this IServiceCollection service, string name, string version = "v1") public static IServiceCollection AddAbpProSwagger(this IServiceCollection service, string name, string version = "v1")
{ {
var swaggerOptions = service.GetRequiredService<IOptions<AbpProSwaggerOptions>>().Value; var swaggerOptions = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProSwaggerOptions>>().Value;
if (!swaggerOptions.Enabled) return service; if (!swaggerOptions.Enabled) return service;
service.AddSwaggerGen(options => service.AddSwaggerGen(options =>
@ -221,9 +222,9 @@ public static class ServiceCollectionExtensions
/// </summary> /// </summary>
public static IServiceCollection AddAbpProMiniProfiler(this IServiceCollection service) public static IServiceCollection AddAbpProMiniProfiler(this IServiceCollection service)
{ {
var options = service.GetRequiredService<IOptions<AbpProMiniProfilerOptions>>().Value; var options = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProMiniProfilerOptions>>().Value;
if (!options.Enabled) return service; if (!options.Enabled) return service;
service.AddMiniProfiler(opt => opt.RouteBasePath = "/profiler").AddEntityFramework(); service.AddMiniProfiler(opt => opt.RouteBasePath = options.RouteBasePath).AddEntityFramework();
return service; return service;
} }
@ -232,7 +233,7 @@ public static class ServiceCollectionExtensions
/// </summary> /// </summary>
public static IServiceCollection AddAbpProMultiTenancy(this IServiceCollection service) public static IServiceCollection AddAbpProMultiTenancy(this IServiceCollection service)
{ {
var multiTenancyOptions = service.GetRequiredService<IOptions<AbpProMultiTenancyOptions>>().Value; var multiTenancyOptions = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProMultiTenancyOptions>>().Value;
service.Configure<AbpMultiTenancyOptions>(options => { options.IsEnabled = multiTenancyOptions.Enabled; }); service.Configure<AbpMultiTenancyOptions>(options => { options.IsEnabled = multiTenancyOptions.Enabled; });
return service; return service;
} }
@ -242,7 +243,7 @@ public static class ServiceCollectionExtensions
/// </summary> /// </summary>
public static IServiceCollection AddAbpProAuthentication(this IServiceCollection service) public static IServiceCollection AddAbpProAuthentication(this IServiceCollection service)
{ {
var jwtOptions = service.GetRequiredService<IOptions<AbpProJwtOptions>>().Value; var jwtOptions = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProJwtOptions>>().Value;
service.AddAuthentication(options => service.AddAuthentication(options =>
{ {
@ -315,7 +316,7 @@ public static class ServiceCollectionExtensions
/// </summary> /// </summary>
public static IServiceCollection AddAbpProAuditLog(this IServiceCollection service) public static IServiceCollection AddAbpProAuditLog(this IServiceCollection service)
{ {
var auditOptions = service.GetRequiredService<IOptions<AbpProAuditOptions>>().Value; var auditOptions = service.BuildServiceProvider().GetRequiredService<IOptions<AbpProAuditOptions>>().Value;
service.Configure<AbpAuditingOptions> service.Configure<AbpAuditingOptions>
(options => (options =>
{ {

14
aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/Serilog/SerilogToEsExtensions.cs

@ -8,30 +8,32 @@ public static class SerilogToEsExtensions
loggerConfiguration loggerConfiguration
.ReadFrom.Configuration(configuration) .ReadFrom.Configuration(configuration)
.Enrich.FromLogContext(); .Enrich.FromLogContext();
var writeToSections = configuration.GetSection("Serilog:WriteTo").GetChildren();
var elasticSection = writeToSections.FirstOrDefault(s => s.GetValue<string>("Name") == "Elastic");
var writeToElasticSearch = configuration.GetValue("ElasticSearch:Enabled", false); var writeToElasticSearch = elasticSection?.GetSection("Args").GetValue<bool>("Enabled") ?? false;
// LogToElasticSearch:Enabled = true 才输出至ES // LogToElasticSearch:Enabled = true 才输出至ES
if (!writeToElasticSearch) if (!writeToElasticSearch)
return; return;
var applicationName = "Lion.AbpPro.HttpApi.Host"; var applicationName = elasticSection?.GetSection("Args").GetValue<string>("ApplicationName") ?? string.Empty;
var esUrl = configuration["ElasticSearch:Url"]; var esUrl = elasticSection?.GetSection("Args").GetValue<string>("Url");
// 需要设置ES URL // 需要设置ES URL
if (string.IsNullOrEmpty(esUrl)) if (string.IsNullOrEmpty(esUrl))
return; return;
var indexFormat = configuration["ElasticSearch:IndexFormat"]; var indexFormat = elasticSection?.GetSection("Args").GetValue<string>("IndexFormat");
// 需要设置ES URL // 需要设置ES URL
if (string.IsNullOrEmpty(indexFormat)) if (string.IsNullOrEmpty(indexFormat))
return; return;
var esUserName = configuration["ElasticSearch:UserName"]; var esUserName = elasticSection?.GetSection("Args").GetValue<string>("UserName");
var esPassword = configuration["ElasticSearch:Password"]; var esPassword = elasticSection?.GetSection("Args").GetValue<string>("Password");
loggerConfiguration.Enrich.FromLogContext().Enrich.WithExceptionDetails().WriteTo loggerConfiguration.Enrich.FromLogContext().Enrich.WithExceptionDetails().WriteTo
.Elasticsearch(BuildElasticSearchSinkOptions(esUrl, indexFormat, esUserName, esPassword)); .Elasticsearch(BuildElasticSearchSinkOptions(esUrl, indexFormat, esUserName, esPassword));

10
aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/GlobalUsings.cs

@ -0,0 +1,10 @@
// Global using directives
global using Hangfire;
global using Hangfire.Common;
global using Hangfire.Dashboard;
global using Hangfire.States;
global using Hangfire.Storage;
global using Microsoft.Extensions.DependencyInjection;
global using Volo.Abp.DependencyInjection;
global using Volo.Abp.Users;

12
aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion.AbpPro.Hangfire.csproj

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" />
</ItemGroup>
</Project>

2
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/AutoDeleteAfterSuccessAttribute.cs → aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/AutoDeleteAfterSuccessAttribute.cs

@ -1,4 +1,4 @@
namespace Lion.AbpPro.Extensions.Hangfire; namespace Lion.AbpPro.Hangfire;
public class AutoDeleteAfterSuccessAttribute : JobFilterAttribute, IApplyStateFilter public class AutoDeleteAfterSuccessAttribute : JobFilterAttribute, IApplyStateFilter
{ {

77
aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/CronType.cs

@ -0,0 +1,77 @@
namespace Lion.AbpPro.Hangfire;
/// <summary>
/// Cron类型
/// </summary>
public static class CronType
{
/// <summary>
/// 周期性为分钟的任务
/// </summary>
/// <param name="interval">执行周期的间隔,默认为每分钟一次</param>
/// <returns></returns>
public static string Minute(int interval = 1)
{
return "1 0/" + interval.ToString() + " * * * ? ";
}
/// <summary>
/// 周期性为小时的任务
/// </summary>
/// <param name="minute">第几分钟开始,默认为第一分钟</param>
/// <param name="interval">执行周期的间隔,默认为每小时一次</param>
/// <returns></returns>
public static string Hour(int minute = 1, int interval = 1)
{
return "1 " + minute + " 0/" + interval.ToString() + " * * ? ";
}
/// <summary>
/// 周期性为天的任务
/// </summary>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <param name="interval">执行周期的间隔,默认为每天一次</param>
/// <returns></returns>
public static string Day(int hour = 1, int minute = 1, int interval = 1)
{
return "1 " + minute.ToString() + " " + hour.ToString() + " 1/" + interval.ToString() + " * ? ";
}
/// <summary>
/// 周期性为周的任务
/// </summary>
/// <param name="dayOfWeek">星期几开始,默认从星期一点开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Week(DayOfWeek dayOfWeek = DayOfWeek.Monday, int hour = 1, int minute = 1)
{
return Cron.Weekly(dayOfWeek, hour, minute);
}
/// <summary>
/// 周期性为月的任务
/// </summary>
/// <param name="day">几号开始,默认从一号开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Month(int day = 1, int hour = 1, int minute = 1)
{
return Cron.Monthly(day, hour, minute);
}
/// <summary>
/// 周期性为年的任务
/// </summary>
/// <param name="month">几月开始,默认从一月开始</param>
/// <param name="day">几号开始,默认从一号开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Year(int month = 1, int day = 1, int hour = 1, int minute = 1)
{
return Cron.Yearly(month, day, hour, minute);
}
}

10
aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/CustomHangfireAuthorizeFilter.cs

@ -0,0 +1,10 @@
namespace Lion.AbpPro.Hangfire;
public class CustomHangfireAuthorizeFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
var currentUser = context.GetHttpContext().RequestServices.GetRequiredService<ICurrentUser>();
return currentUser.IsAuthenticated;
}
}

9
aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/IRecurringJob.cs

@ -0,0 +1,9 @@
namespace Lion.AbpPro.Hangfire;
public interface IRecurringJob : ITransientDependency
{
/// <summary>
/// 执行任务
/// </summary>
Task ExecuteAsync();
}

4
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/JobRetryLastFilter.cs → aspnet-core/frameworks/src/Lion.AbpPro.Hangfire/Lion/AbpPro/Hangfire/JobRetryLastFilter.cs

@ -1,4 +1,4 @@
namespace Lion.AbpPro.Extensions.Hangfire; namespace Lion.AbpPro.Hangfire;
/// <summary> /// <summary>
/// 重试最后一次 /// 重试最后一次
@ -18,7 +18,7 @@ public class JobRetryLastFilter : JobFilterAttribute, IElectStateFilter
var retryAttempt = context.GetJobParameter<int>("RetryCount"); var retryAttempt = context.GetJobParameter<int>("RetryCount");
if (RetryCount == retryAttempt) if (RetryCount == retryAttempt)
{ {
Log.Error("最后一次重试"); // 最后一次重试
} }
} }
} }

57
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostConst.cs

@ -1,40 +1,39 @@
namespace Lion.AbpPro namespace Lion.AbpPro;
public static class AbpProHttpApiHostConst
{ {
public static class AbpProHttpApiHostConst /// <summary>
{ /// 跨域策略名
/// <summary> /// </summary>
/// 跨域策略名 public const string DefaultCorsPolicyName = "Default";
/// </summary>
public const string DefaultCorsPolicyName = "Default";
/// <summary> /// <summary>
/// Cookies名称 /// Cookies名称
/// </summary> /// </summary>
public const string DefaultCookieName = "Lion.AbpPro.Http.Api"; public const string DefaultCookieName = "Lion.AbpPro.Http.Api";
/// <summary> /// <summary>
/// SwaggerUi 端点 /// SwaggerUi 端点
/// </summary> /// </summary>
public const string SwaggerUiEndPoint = "/swagger"; public const string SwaggerUiEndPoint = "/swagger";
/// <summary> /// <summary>
/// Hangfire 端点 /// Hangfire 端点
/// </summary> /// </summary>
public const string HangfireDashboardEndPoint = "/hangfire"; public const string HangfireDashboardEndPoint = "/hangfire";
/// <summary> /// <summary>
/// CAP 端点 /// CAP 端点
/// </summary> /// </summary>
public const string CapDashboardEndPoint = "/cap"; public const string CapDashboardEndPoint = "/cap";
public const string MoreEndPoint = "https://doc.cncore.club/"; public const string MoreEndPoint = "https://doc.cncore.club/";
/// <summary> /// <summary>
/// HMiniprofiler端点 /// HMiniprofiler端点
/// </summary> /// </summary>
public const string MiniprofilerEndPoint = "/profiler/results-index"; public const string MiniprofilerEndPoint = "/profiler/results-index";
}
} }

198
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs

@ -1,143 +1,75 @@
namespace Lion.AbpPro namespace Lion.AbpPro;
[DependsOn(
typeof(AbpProHttpApiModule),
typeof(AbpProAspNetCoreModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpProEntityFrameworkCoreModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebModule),
typeof(AbpProApplicationModule),
// typeof(AbpProCapModule),
// typeof(AbpProCapEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpDistributedLockingModule),
typeof(AbpBlobStoringFileSystemModule),
typeof(AbpProStarterModule),
typeof(AbpSwashbuckleModule)
//typeof(AbpBackgroundJobsHangfireModule)
)]
public partial class AbpProHttpApiHostModule : AbpModule
{ {
[DependsOn( public override void ConfigureServices(ServiceConfigurationContext context)
typeof(AbpProHttpApiModule),
typeof(AbpProAspNetCoreModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpProEntityFrameworkCoreModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebModule),
typeof(AbpProApplicationModule),
// typeof(AbpProCapModule),
// typeof(AbpProCapEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpDistributedLockingModule),
typeof(AbpBlobStoringFileSystemModule),
typeof(AbpProStarterModule)
//typeof(AbpBackgroundJobsHangfireModule)
)]
public partial class AbpProHttpApiHostModule : AbpModule
{ {
public override void OnPostApplicationInitialization(ApplicationInitializationContext context) context.Services
{
// 应用程序初始化的时候注册hangfire
//context.CreateRecurringJob();
base.OnPostApplicationInitialization(context);
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services
.AddAbpProAuditLog() .AddAbpProAuditLog()
.AddAbpProAuthentication() .AddAbpProAuthentication()
.AddAbpProMultiTenancy() .AddAbpProMultiTenancy()
.AddAbpProRedis() .AddAbpProRedis()
.AddAbpProRedisDistributedLocking() .AddAbpProRedisDistributedLocking()
.AddAbpProMiniProfiler() .AddAbpProMiniProfiler()
.AddAbpProCors() .AddAbpProCors()
.AddAbpProAntiForgery() .AddAbpProAntiForgery()
.AddAbpProIdentity() .AddAbpProIdentity()
.AddAbpProBlobStorage() .AddAbpProBlobStorage()
.AddAbpProSignalR() .AddAbpProSignalR()
.AddAbpProHealthChecks() .AddAbpProHealthChecks()
.AddAbpProTenantResolvers() .AddAbpProTenantResolvers()
.AddAbpProLocalization() .AddAbpProLocalization()
.AddAbpProExceptions() .AddAbpProExceptions()
.AddAbpProSwagger("AbpPro"); .AddAbpProSwagger("AbpPro");
}
// //ConfigureCache(context);
// context.Services.AddAbpProRedis();
//
// //ConfigurationDistributedLocking(context);
// context.Services.AddAbpProRedisDistributedLocking();
//
//
// //ConfigureSwaggerServices(context);
// context.Services.AddAbpProSwagger("AbpPro");
//
// //ConfigureJwtAuthentication(context, configuration);
// context.Services.AddAbpProAuthentication();
//
// //ConfigureHangfire(context);
//
// //ConfigureMiniProfiler(context);
// context.Services.AddAbpProMiniProfiler();
//
// //ConfigureIdentity(context);
// context.Services.AddAbpProIdentity();
//
// //ConfigureCap(context);
//
// //ConfigureAuditLog(context);
// context.Services.AddAbpProAuditLog();
//
// //ConfigurationSignalR(context);
// context.Services.AddAbpProSignalR();
//
// //ConfigurationMultiTenancy();
// context.Services.AddAbpProMultiTenancy();
//
// //ConfigureBlobStorage();
// context.Services.AddAbpProBlobStorage();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context) public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
app.UseAbpProRequestLocalization();
app.UseCorrelationId();
app.MapAbpStaticAssets();
app.UseAbpProMiniProfiler();
app.UseRouting();
app.UseAbpProCors();
app.UseAuthentication();
app.UseAbpProMultiTenancy();
app.UseAuthorization();
app.UseAbpProSwaggerUI("/swagger/AbpPro/swagger.json","AbpPro");
app.UseAbpProAuditing();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();
app.UseConfiguredEndpoints(endpoints =>
{ {
var app = context.GetApplicationBuilder(); endpoints.MapHealthChecks("/health");
//var configuration = context.GetConfiguration();
app.UseAbpProRequestLocalization(); // endpoints.MapHangfireDashboard("/hangfire", new DashboardOptions()
app.UseCorrelationId();
app.MapAbpStaticAssets();
// if (configuration.GetValue("MiniProfiler:Enabled", false))
// {
// app.UseMiniProfiler();
// }
app.UseAbpProMiniProfiler();
app.UseRouting();
//app.UseCors(AbpProHttpApiHostConst.DefaultCorsPolicyName);
app.UseAbpProCors();
app.UseAuthentication();
// if (MultiTenancyConsts.IsEnabled)
// {
// app.UseMultiTenancy();
// }
app.UseAbpProMultiTenancy();
app.UseAuthorization();
// app.UseSwagger();
// app.UseAbpSwaggerUI(options =>
// { // {
// options.SwaggerEndpoint("/swagger/AbpPro/swagger.json", "AbpPro API"); // Authorization = new[] { new CustomHangfireAuthorizeFilter() },
// options.DocExpansion(DocExpansion.None); // IgnoreAntiforgeryToken = true
// options.DefaultModelsExpandDepth(-1);
// }); // });
app.UseAbpProSwaggerUI("/swagger/AbpPro/swagger.json","AbpPro"); });
//app.UseAuditing(); app.UseAbpProConsul();
app.UseAbpProAuditing();
app.UseAbpSerilogEnrichers();
app.UseUnitOfWork();
app.UseConfiguredEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/health");
// endpoints.MapHangfireDashboard("/hangfire", new DashboardOptions()
// {
// Authorization = new[] { new CustomHangfireAuthorizeFilter() },
// IgnoreAntiforgeryToken = true
// });
});
app.UseAbpProConsul();
}
} }
} }

78
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/CronType.cs

@ -1,78 +0,0 @@
namespace Lion.AbpPro.Extensions.Hangfire
{
/// <summary>
/// Cron类型
/// </summary>
public static class CronType
{
/// <summary>
/// 周期性为分钟的任务
/// </summary>
/// <param name="interval">执行周期的间隔,默认为每分钟一次</param>
/// <returns></returns>
public static string Minute(int interval = 1)
{
return "1 0/" + interval.ToString() + " * * * ? ";
}
/// <summary>
/// 周期性为小时的任务
/// </summary>
/// <param name="minute">第几分钟开始,默认为第一分钟</param>
/// <param name="interval">执行周期的间隔,默认为每小时一次</param>
/// <returns></returns>
public static string Hour(int minute = 1, int interval = 1)
{
return "1 " + minute + " 0/" + interval.ToString() + " * * ? ";
}
/// <summary>
/// 周期性为天的任务
/// </summary>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <param name="interval">执行周期的间隔,默认为每天一次</param>
/// <returns></returns>
public static string Day(int hour = 1, int minute = 1, int interval = 1)
{
return "1 " + minute.ToString() + " " + hour.ToString() + " 1/" + interval.ToString() + " * ? ";
}
/// <summary>
/// 周期性为周的任务
/// </summary>
/// <param name="dayOfWeek">星期几开始,默认从星期一点开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Week(DayOfWeek dayOfWeek = DayOfWeek.Monday, int hour = 1, int minute = 1)
{
return Cron.Weekly(dayOfWeek, hour, minute);
}
/// <summary>
/// 周期性为月的任务
/// </summary>
/// <param name="day">几号开始,默认从一号开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Month(int day = 1, int hour = 1, int minute = 1)
{
return Cron.Monthly(day, hour, minute);
}
/// <summary>
/// 周期性为年的任务
/// </summary>
/// <param name="month">几月开始,默认从一月开始</param>
/// <param name="day">几号开始,默认从一号开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Year(int month = 1, int day = 1, int hour = 1, int minute = 1)
{
return Cron.Yearly(month, day, hour, minute);
}
}
}

11
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/CustomHangfireAuthorizeFilter.cs

@ -1,11 +0,0 @@
namespace Lion.AbpPro.Extensions.Hangfire
{
public class CustomHangfireAuthorizeFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
var _currentUser = context.GetHttpContext().RequestServices.GetRequiredService<ICurrentUser>();
return _currentUser.IsAuthenticated;
}
}
}

15
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Extensions/Hangfire/RecurringJobsExtensions.cs

@ -1,15 +0,0 @@
using Lion.AbpPro.Jobs;
namespace Lion.AbpPro.Extensions.Hangfire
{
public static class RecurringJobsExtensions
{
public static void CreateRecurringJob(this ApplicationInitializationContext context)
{
RecurringJob.AddOrUpdate<TestJob>("测试Job", e => e.ExecuteAsync(), CronType.Minute(1), new RecurringJobOptions()
{
TimeZone = TimeZoneInfo.Local
});
}
}
}

3
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/GlobalUsings.cs

@ -21,8 +21,6 @@ global using Lion.AbpPro.CAP;
global using Lion.AbpPro.CAP.EntityFrameworkCore; global using Lion.AbpPro.CAP.EntityFrameworkCore;
global using Lion.AbpPro.EntityFrameworkCore; global using Lion.AbpPro.EntityFrameworkCore;
global using Lion.AbpPro.Core; global using Lion.AbpPro.Core;
global using Lion.AbpPro.Extensions;
global using Lion.AbpPro.Extensions.Hangfire;
global using Lion.AbpPro.MultiTenancy; global using Lion.AbpPro.MultiTenancy;
global using Lion.AbpPro.Starter; global using Lion.AbpPro.Starter;
global using Magicodes.ExporterAndImporter.Core; global using Magicodes.ExporterAndImporter.Core;
@ -80,5 +78,6 @@ global using Volo.Abp.Json;
global using Volo.Abp.Localization; global using Volo.Abp.Localization;
global using Volo.Abp.Modularity; global using Volo.Abp.Modularity;
global using Volo.Abp.MultiTenancy; global using Volo.Abp.MultiTenancy;
global using Volo.Abp.Swashbuckle;
global using Volo.Abp.Users; global using Volo.Abp.Users;
global using Volo.Abp.Validation; global using Volo.Abp.Validation;

74
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj

@ -1,6 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<RootNamespace>Lion.AbpPro</RootNamespace> <RootNamespace>Lion.AbpPro</RootNamespace>
@ -8,59 +6,47 @@
<UserSecretsId>Lion.AbpPro-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId> <UserSecretsId>Lion.AbpPro-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" /> <PackageReference Include="Volo.Abp.Account.Web"/>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy"/>
<PackageReference Include="Volo.Abp.Account.Web" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis"/>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog"/>
<PackageReference Include="Volo.Abp.Autofac" /> <PackageReference Include="Volo.Abp.Swashbuckle"/>
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer"/>
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic"/>
<PackageReference Include="Volo.Abp.Swashbuckle" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Exceptions" />
<PackageReference Include="Serilog.Extensions.Logging" />
<PackageReference Include="Serilog.Settings.Configuration" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" />
<PackageReference Include="Serilog.Sinks.File" />
<PackageReference Include="Serilog.Sinks.Async" />
<PackageReference Include="Hangfire.Redis.StackExchange" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" />
<PackageReference Include="DotNetCore.CAP.MySql" />
<PackageReference Include="DotNetCore.CAP.RabbitMQ" />
<PackageReference Include="DotNetCore.CAP.Dashboard" />
<PackageReference Include="MiniProfiler.AspNetCore.Mvc" />
<PackageReference Include="MiniProfiler.EntityFrameworkCore" />
<PackageReference Include="MiniProfiler.Shared" />
<PackageReference Include="Volo.Abp.BackgroundJobs.HangFire" />
<PackageReference Include="Volo.Abp.DistributedLocking"/> <PackageReference Include="Volo.Abp.DistributedLocking"/>
<PackageReference Include="Volo.Abp.BlobStoring.FileSystem"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis"/>
<PackageReference Include="DotNetCore.CAP.MySql"/>
<PackageReference Include="DotNetCore.CAP.RabbitMQ"/>
<PackageReference Include="DotNetCore.CAP.Dashboard"/>
<PackageReference Include="DistributedLock.Redis"/> <PackageReference Include="DistributedLock.Redis"/>
<PackageReference Include="Volo.Abp.BlobStoring.FileSystem" /> <PackageReference Include="Hangfire.Redis.StackExchange"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.AspNetCore\Lion.AbpPro.AspNetCore.csproj" /> <ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.AspNetCore\Lion.AbpPro.AspNetCore.csproj"/>
<ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.CAP.EntityFrameworkCore\Lion.AbpPro.CAP.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.CAP.EntityFrameworkCore\Lion.AbpPro.CAP.EntityFrameworkCore.csproj"/>
<ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.CAP\Lion.AbpPro.CAP.csproj" /> <ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.CAP\Lion.AbpPro.CAP.csproj"/>
<ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.Starter\Lion.AbpPro.Starter.csproj" /> <ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.Starter\Lion.AbpPro.Starter.csproj"/>
<ProjectReference Include="..\..\src\Lion.AbpPro.Application\Lion.AbpPro.Application.csproj" /> <ProjectReference Include="..\..\src\Lion.AbpPro.Application\Lion.AbpPro.Application.csproj"/>
<ProjectReference Include="..\..\src\Lion.AbpPro.EntityFrameworkCore\Lion.AbpPro.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\src\Lion.AbpPro.EntityFrameworkCore\Lion.AbpPro.EntityFrameworkCore.csproj"/>
<ProjectReference Include="..\..\src\Lion.AbpPro.HttpApi\Lion.AbpPro.HttpApi.csproj" /> <ProjectReference Include="..\..\src\Lion.AbpPro.HttpApi\Lion.AbpPro.HttpApi.csproj"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Remove="Logs\**" /> <Compile Remove="Logs\**"/>
<Content Remove="Logs\**" /> <Content Remove="Logs\**"/>
<EmbeddedResource Remove="Logs\**" /> <EmbeddedResource Remove="Logs\**"/>
<None Remove="Logs\**" /> <None Remove="Logs\**"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*.json" /> <Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*.json"/>
</ItemGroup> </ItemGroup>
</Project> </Project>

9
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs

@ -1,4 +1,6 @@
#pragma warning disable CS0618 // Type or member is obsolete using Lion.AbpPro.Hangfire;
#pragma warning disable CS0618 // Type or member is obsolete
namespace Microsoft.Extensions.DependencyInjection; namespace Microsoft.Extensions.DependencyInjection;
@ -99,14 +101,13 @@ public static class ServiceCollectionExtensions
service.AddHangfire(config => service.AddHangfire(config =>
{ {
config.UseRedisStorage( config.UseRedisStorage(service.GetConfiguration().GetValue<string>("Hangfire:Redis:Host"), redisStorageOptions)
service.GetConfiguration().GetValue<string>("Hangfire:Redis:Host"), redisStorageOptions)
.WithJobExpirationTimeout(TimeSpan.FromDays(7)); .WithJobExpirationTimeout(TimeSpan.FromDays(7));
var delaysInSeconds = new[] { 10, 60, 60 * 3 }; // 重试时间间隔 var delaysInSeconds = new[] { 10, 60, 60 * 3 }; // 重试时间间隔
const int attempts = 3; // 重试次数 const int attempts = 3; // 重试次数
config.UseFilter(new AutomaticRetryAttribute() { Attempts = 3, DelaysInSeconds = delaysInSeconds }); config.UseFilter(new AutomaticRetryAttribute() { Attempts = 3, DelaysInSeconds = delaysInSeconds });
//config.UseFilter(new AutoDeleteAfterSuccessAttribute(TimeSpan.FromDays(7))); //config.UseFilter(new AutoDeleteAfterSuccessAttribute(TimeSpan.FromDays(7)));
config.UseFilter(new JobRetryLastFilter(attempts)); //config.UseFilter(new JobRetryLastFilter(attempts));
}); });
return service; return service;
} }

61
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.Production.json

@ -5,7 +5,7 @@
"Serilog.Sinks.File" "Serilog.Sinks.File"
], ],
"MinimumLevel": { "MinimumLevel": {
"Default": "Information", "Default": "Debug",
"Override": { "Override": {
"Microsoft": "Information", "Microsoft": "Information",
"Volo.Abp": "Information", "Volo.Abp": "Information",
@ -26,25 +26,35 @@
"path": "logs/logs-.txt", "path": "logs/logs-.txt",
"rollingInterval": "Day" "rollingInterval": "Day"
} }
},
{
"Name": "Elastic",
"Args": {
"Enabled": false,
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"ApplicationName": "Lion.AbpPro.HttpApi.Host"
}
} }
] ]
}, },
"App": { "App": {
"SelfUrl": "http://localhost:44315", "SelfUrl": "http://localhost:44315",
"CorsOrigins": "http://localhost:80,http://43.139.143.143:80,http://43.139.143.143"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Data Source=mysql;Port=3306;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" "Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=f616b8803ac7a9a0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"Redis": {
"Configuration": "redis:6379,password=1q2w3E*,defaultdatabase=3"
}, },
"Hangfire": { "Hangfire": {
"Redis": { "Redis": {
"Host": "redis:6379,password=1q2w3E*", "Host": "localhost:6379,password=1q2w3E*",
"DB": "2" "DB": "2"
} }
}, },
"Redis": {
"Configuration": "localhost:6379,password=75He82bB5jFA84XZ1,defaultdatabase=2"
},
"Jwt": { "Jwt": {
"Audience": "Lion.AbpPro", "Audience": "Lion.AbpPro",
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=", "SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
@ -53,23 +63,40 @@
}, },
"Cap": { "Cap": {
"RabbitMq": { "RabbitMq": {
"HostName": "rabbitmq", "HostName": "localhost",
"UserName": "admin", "UserName": "admin",
"Password": "1q2w3E*", "Password": "1q2w3E*",
"Port": 5672 "Port": 5672
} }
}, },
"ElasticSearch": { "ElasticSearch": {
"Enabled": false, "Host": "http://es.cn",
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic", "UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy", "Password": "aVVhjQ95RP7nbwNy"
"SearchIndexFormat": "Lion.AbpPro.development*" },
"MiniProfiler": {
"Enabled": true,
"RouteBasePath": "/profiler"
},
"Swagger": {
"Enabled": true
},
"Audit": {
"Enabled": true,
"ApplicationName": "Lion.AbpPro"
},
"Cors": {
"Enabled": true,
"CorsOrigins": "http://localhost:4200,http://localhost:4201"
},
"Gateway": {
"Enabled": false
},
"MultiTenancy": {
"Enabled": true
}, },
"Consul": { "Preheat": {
"Enabled": false, "Enabled": true,
"Host": "http://localhost:8500", "RequestUrl": "http://localhost:44315/api/abp/application-configuration?IncludeLocalizationResources=false"
"Service": "Project-Service"
} }
} }

27
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/appsettings.json

@ -26,24 +26,34 @@
"path": "logs/logs-.txt", "path": "logs/logs-.txt",
"rollingInterval": "Day" "rollingInterval": "Day"
} }
},
{
"Name": "Elastic",
"Args": {
"Enabled": false,
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"ApplicationName": "Lion.AbpPro.HttpApi.Host"
}
} }
] ]
}, },
"App": { "App": {
"SelfUrl": "http://localhost:44315", "SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.AbpPro.com,http://localhost:4200,http://localhost:44320,http://localhost:44321,http://localhost:44322,http://localhost:44318"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" "Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=f616b8803ac7a9a0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
}, },
"Hangfire": { "Hangfire": {
"Redis": { "Redis": {
"Host": "117.72.203.231:6379,password=1q2w3E*", "Host": "localhost:6379,password=1q2w3E*",
"DB": "2" "DB": "2"
} }
}, },
"Redis": { "Redis": {
"Configuration": "117.72.203.231:6379,password=75He82bB5jFA84XZ1,defaultdatabase=2" "Configuration": "localhost:6379,password=75He82bB5jFA84XZ1,defaultdatabase=2"
}, },
"Jwt": { "Jwt": {
"Audience": "Lion.AbpPro", "Audience": "Lion.AbpPro",
@ -60,16 +70,13 @@
} }
}, },
"ElasticSearch": { "ElasticSearch": {
"Enabled": false, "Host": "http://es.cn",
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic", "UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy", "Password": "aVVhjQ95RP7nbwNy"
"SearchIndexFormat": "Lion.AbpPro.development*"
}, },
"MiniProfiler": { "MiniProfiler": {
"Enabled": true, "Enabled": true,
"RouteBasePath": "profiler" "RouteBasePath": "/profiler"
}, },
"Swagger": { "Swagger": {
"Enabled": true "Enabled": true

11
aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Jobs/IRecurringJob.cs

@ -1,11 +0,0 @@
namespace Lion.AbpPro.Jobs
{
public interface IRecurringJob : ITransientDependency
{
/// <summary>
/// 执行任务
/// </summary>
/// <returns></returns>
Task ExecuteAsync();
}
}

1
aspnet-core/services/src/Lion.AbpPro.Application.Contracts/Lion.AbpPro.Application.Contracts.csproj

@ -5,6 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\frameworks\src\Lion.AbpPro.Hangfire\Lion.AbpPro.Hangfire.csproj" />
<ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Application.Contracts\Lion.AbpPro.BasicManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Application.Contracts\Lion.AbpPro.BasicManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Application.Contracts\Lion.AbpPro.DataDictionaryManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\DataDictionaryManagement\src\Lion.AbpPro.DataDictionaryManagement.Application.Contracts\Lion.AbpPro.DataDictionaryManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.Application.Contracts\Lion.AbpPro.FileManagement.Application.Contracts.csproj" /> <ProjectReference Include="..\..\..\modules\FileManagement\src\Lion.AbpPro.FileManagement.Application.Contracts\Lion.AbpPro.FileManagement.Application.Contracts.csproj" />

11
aspnet-core/services/src/Lion.AbpPro.Application/Jobs/TestJob.cs

@ -1,11 +0,0 @@
namespace Lion.AbpPro.Jobs
{
public class TestJob : IRecurringJob
{
public Task ExecuteAsync()
{
Console.WriteLine($"job 测试");
return Task.CompletedTask;
}
}
}

2
aspnet-core/services/src/Lion.AbpPro.DbMigrator/appsettings.json

@ -1,5 +1,5 @@
{ {
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" "Default": "Data Source=117.72.203.231;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=f616b8803ac7a9a0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
} }
} }
Loading…
Cancel
Save