|
|
|
@ -31,8 +31,16 @@ using Volo.Abp.VirtualFileSystem; |
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Volo.Abp.AspNetCore.Mvc.Validation; |
|
|
|
using Volo.Abp.BackgroundJobs.Hangfire; |
|
|
|
using Hangfire; |
|
|
|
using Hangfire.PostgreSql; |
|
|
|
using Hangfire.Dashboard; |
|
|
|
|
|
|
|
namespace Shentun.Sms; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// AbpBackgroundJobsHangfireModule 后台作业
|
|
|
|
/// </summary>
|
|
|
|
[DependsOn( |
|
|
|
typeof(SmsHttpApiModule), |
|
|
|
typeof(AbpAutofacModule), |
|
|
|
@ -42,7 +50,8 @@ namespace Shentun.Sms; |
|
|
|
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule), |
|
|
|
typeof(AbpAccountWebOpenIddictModule), |
|
|
|
typeof(AbpAspNetCoreSerilogModule), |
|
|
|
typeof(AbpSwashbuckleModule) |
|
|
|
typeof(AbpSwashbuckleModule), |
|
|
|
typeof(AbpBackgroundJobsHangfireModule) |
|
|
|
)] |
|
|
|
public class SmsHttpApiHostModule : AbpModule |
|
|
|
{ |
|
|
|
@ -64,7 +73,7 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
var configuration = context.Services.GetConfiguration(); |
|
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConfigureAuthentication(context); |
|
|
|
ConfigureBundles(); |
|
|
|
ConfigureUrls(configuration); |
|
|
|
@ -73,7 +82,7 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
ConfigureVirtualFileSystem(context); |
|
|
|
ConfigureCors(context, configuration); |
|
|
|
ConfigureSwaggerServices(context, configuration); |
|
|
|
|
|
|
|
ConfigureHangfire(context, configuration); //后台作业
|
|
|
|
|
|
|
|
//密码策略配置
|
|
|
|
context.Services.Configure<IdentityOptions>(opt => |
|
|
|
@ -96,7 +105,7 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
options.Filters.Add(typeof(CustomerExceptionFilterAttribute)); |
|
|
|
options.Filters.Add(typeof(CustomerActionFilterAttribute)); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
@ -108,6 +117,34 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 后台作业
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="context"></param>
|
|
|
|
/// <param name="configuration"></param>
|
|
|
|
private void ConfigureHangfire(ServiceConfigurationContext context, IConfiguration configuration) |
|
|
|
{ |
|
|
|
context.Services.AddHangfire(config => |
|
|
|
{ |
|
|
|
config.UseStorage(new PostgreSqlStorage(configuration.GetConnectionString("Default"))); |
|
|
|
// config.usep(configuration.GetConnectionString("Default"));
|
|
|
|
//config.UseDashboardMetric(DashboardMetrics.ServerCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.RecurringJobCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.RetriesCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.AwaitingCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.EnqueuedAndQueueCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.ScheduledCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.ProcessingCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.SucceededCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.FailedCount)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.EnqueuedCountOrNull)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.FailedCountOrNull)
|
|
|
|
// .UseDashboardMetric(DashboardMetrics.DeletedCount);
|
|
|
|
}); |
|
|
|
|
|
|
|
context.Services.AddHangfireServer(); |
|
|
|
} |
|
|
|
|
|
|
|
private void ConfigureAuthentication(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); |
|
|
|
@ -221,19 +258,19 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
{ |
|
|
|
options.AddDefaultPolicy(builder => |
|
|
|
{ |
|
|
|
builder |
|
|
|
.WithOrigins( |
|
|
|
configuration["App:CorsOrigins"] |
|
|
|
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|
|
|
.Select(o => o.RemovePostFix("/")) |
|
|
|
.ToArray() |
|
|
|
) |
|
|
|
.WithAbpExposedHeaders() |
|
|
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|
|
|
.AllowAnyHeader() |
|
|
|
.AllowAnyMethod() |
|
|
|
.AllowCredentials(); |
|
|
|
}); |
|
|
|
builder |
|
|
|
.WithOrigins( |
|
|
|
configuration["App:CorsOrigins"] |
|
|
|
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|
|
|
.Select(o => o.RemovePostFix("/")) |
|
|
|
.ToArray() |
|
|
|
) |
|
|
|
.WithAbpExposedHeaders() |
|
|
|
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|
|
|
.AllowAnyHeader() |
|
|
|
.AllowAnyMethod() |
|
|
|
.AllowCredentials(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@ -252,7 +289,7 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
var commentsFileapi = Path.Combine(baseDirectory, "Shentun.Sms.HttpApi.xml"); |
|
|
|
options.IncludeXmlComments(commentsFileapi, true); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
#endregion
|
|
|
|
} |
|
|
|
|
|
|
|
@ -273,6 +310,28 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
app.UseErrorPage(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// app.UseHangfireDashboard("/hangfire", new DashboardOptions
|
|
|
|
// {
|
|
|
|
// Authorization = new[] {new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
|
|
|
|
//{
|
|
|
|
// RequireSsl = false,
|
|
|
|
// SslRedirect = false,
|
|
|
|
// LoginCaseSensitive = true,
|
|
|
|
// Users = new []
|
|
|
|
// {
|
|
|
|
// new BasicAuthAuthorizationUser
|
|
|
|
// {
|
|
|
|
// Login = "admin",
|
|
|
|
// PasswordClear = "admin"
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//})}
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.UseCorrelationId(); |
|
|
|
app.UseStaticFiles(); |
|
|
|
app.UseRouting(); |
|
|
|
@ -301,5 +360,7 @@ public class SmsHttpApiHostModule : AbpModule |
|
|
|
app.UseAuditing(); |
|
|
|
app.UseAbpSerilogEnrichers(); |
|
|
|
app.UseConfiguredEndpoints(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |