|
|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Volo.Abp.Autofac;
|
|
|
|
|
using Volo.Abp.BackgroundJobs.DemoApp.Shared;
|
|
|
|
|
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
|
|
|
|
|
using Volo.Abp.Data;
|
|
|
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
|
|
|
@ -12,6 +12,7 @@ using Volo.Abp.Modularity;
|
|
|
|
|
namespace Volo.Abp.BackgroundJobs.DemoApp
|
|
|
|
|
{
|
|
|
|
|
[DependsOn(
|
|
|
|
|
typeof(DemoAppSharedModule),
|
|
|
|
|
typeof(BackgroundJobsEntityFrameworkCoreModule),
|
|
|
|
|
typeof(AbpAutofacModule),
|
|
|
|
|
typeof(AbpEntityFrameworkCoreSqlServerModule)
|
|
|
|
|
@ -20,7 +21,8 @@ namespace Volo.Abp.BackgroundJobs.DemoApp
|
|
|
|
|
{
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
|
|
|
{
|
|
|
|
|
var configuration = BuildConfiguration();
|
|
|
|
|
var configuration = ConfigurationHelper.BuildConfiguration();
|
|
|
|
|
|
|
|
|
|
context.Services.AddConfiguration(configuration);
|
|
|
|
|
|
|
|
|
|
context.Services.Configure<DbConnectionOptions>(options =>
|
|
|
|
|
@ -54,33 +56,5 @@ namespace Volo.Abp.BackgroundJobs.DemoApp
|
|
|
|
|
.GetRequiredService<ILoggerFactory>()
|
|
|
|
|
.AddConsole(LogLevel.Debug);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static IConfigurationRoot BuildConfiguration(string fileName = "appsettings")
|
|
|
|
|
{
|
|
|
|
|
var fileNameWithExtension = fileName + ".json";
|
|
|
|
|
var directory = Directory.GetCurrentDirectory();
|
|
|
|
|
|
|
|
|
|
while (!File.Exists(Path.Combine(directory, fileNameWithExtension)))
|
|
|
|
|
{
|
|
|
|
|
var parentDirectory = new DirectoryInfo(directory).Parent;
|
|
|
|
|
if (parentDirectory == null)
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
directory = parentDirectory.FullName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(File.Exists(Path.Combine(directory, fileNameWithExtension)))
|
|
|
|
|
{
|
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(directory)
|
|
|
|
|
.AddJsonFile(fileNameWithExtension, optional: false);
|
|
|
|
|
|
|
|
|
|
return builder.Build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|