diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln
index 0261585f25..72d2c942af 100644
--- a/framework/Volo.Abp.sln
+++ b/framework/Volo.Abp.sln
@@ -204,6 +204,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.BackgroundJobs.Abs
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.BackgroundJobs.HangFire", "src\Volo.Abp.BackgroundJobs.HangFire\Volo.Abp.BackgroundJobs.HangFire.csproj", "{35AC93EF-E383-4F4E-839D-6EE1C62681F1}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.HangFire", "src\Volo.Abp.HangFire\Volo.Abp.HangFire.csproj", "{EE01E964-E60E-4C3C-BCF0-AF1A0C0A3DC9}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -574,6 +576,10 @@ Global
{35AC93EF-E383-4F4E-839D-6EE1C62681F1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35AC93EF-E383-4F4E-839D-6EE1C62681F1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35AC93EF-E383-4F4E-839D-6EE1C62681F1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EE01E964-E60E-4C3C-BCF0-AF1A0C0A3DC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EE01E964-E60E-4C3C-BCF0-AF1A0C0A3DC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EE01E964-E60E-4C3C-BCF0-AF1A0C0A3DC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EE01E964-E60E-4C3C-BCF0-AF1A0C0A3DC9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -672,6 +678,7 @@ Global
{D86548EA-7047-4623-8824-F6285CD254AA} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{EB9C3B4D-FEBD-4691-8F34-AAC2C13F6F2F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{35AC93EF-E383-4F4E-839D-6EE1C62681F1} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
+ {EE01E964-E60E-4C3C-BCF0-AF1A0C0A3DC9} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}
diff --git a/framework/src/Volo.Abp.HangFire/Volo.Abp.HangFire.csproj b/framework/src/Volo.Abp.HangFire/Volo.Abp.HangFire.csproj
new file mode 100644
index 0000000000..78c88ca36f
--- /dev/null
+++ b/framework/src/Volo.Abp.HangFire/Volo.Abp.HangFire.csproj
@@ -0,0 +1,24 @@
+
+
+
+
+
+ netstandard2.0
+ Volo.Abp.HangFire
+ Volo.Abp.HangFire
+ $(AssetTargetFallback);portable-net45+win8+wp8+wpa81;
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireModule.cs b/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireModule.cs
new file mode 100644
index 0000000000..f5c3123fa6
--- /dev/null
+++ b/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireModule.cs
@@ -0,0 +1,35 @@
+using Hangfire;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+using Volo.Abp.Modularity;
+
+namespace Volo.Abp.Hangfire
+{
+ public class AbpHangfireModule : AbpModule
+ {
+ private BackgroundJobServer _backgroundJobServer;
+
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ context.Services.AddHangfire(configuration =>
+ {
+ context.Services.ExecutePreConfiguredActions(configuration);
+ });
+
+ context.Services.AddAssemblyOf();
+ }
+
+ public override void OnApplicationInitialization(ApplicationInitializationContext context)
+ {
+ var options = context.ServiceProvider.GetRequiredService>().Value;
+ _backgroundJobServer = options.BackgroundJobServerFactory.Invoke(context.ServiceProvider);
+ }
+
+ public override void OnApplicationShutdown(ApplicationShutdownContext context)
+ {
+ //TODO: ABP may provide two methods for application shutdown: OnPreApplicationShutdown & OnApplicationShutdown
+ _backgroundJobServer.SendStop();
+ _backgroundJobServer.Dispose();
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireOptions.cs b/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireOptions.cs
new file mode 100644
index 0000000000..4d7f652791
--- /dev/null
+++ b/framework/src/Volo.Abp.HangFire/Volo/Abp/Hangfire/AbpHangfireOptions.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using Hangfire;
+using Hangfire.Client;
+using Hangfire.Common;
+using Hangfire.Server;
+using Hangfire.States;
+using JetBrains.Annotations;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Volo.Abp.Hangfire
+{
+ public class AbpHangfireOptions
+ {
+ [CanBeNull]
+ public BackgroundJobServerOptions ServerOptions { get; set; }
+
+ [CanBeNull]
+ public IEnumerable AdditionalProcesses { get; set; }
+
+ [CanBeNull]
+ public JobStorage Storage { get; set; }
+
+ [NotNull]
+ public Func BackgroundJobServerFactory
+ {
+ get => _backgroundJobServerFactory;
+ set => _backgroundJobServerFactory = Check.NotNull(value, nameof(value));
+ }
+ private Func _backgroundJobServerFactory;
+
+ public AbpHangfireOptions()
+ {
+ _backgroundJobServerFactory = CreateJobServer;
+ }
+
+ private BackgroundJobServer CreateJobServer(IServiceProvider serviceProvider)
+ {
+ Storage = Storage ?? serviceProvider.GetRequiredService();
+ ServerOptions = ServerOptions ?? serviceProvider.GetService() ?? new BackgroundJobServerOptions();
+ AdditionalProcesses = AdditionalProcesses ?? serviceProvider.GetServices();
+
+ return new BackgroundJobServer(ServerOptions, Storage, AdditionalProcesses,
+ ServerOptions.FilterProvider ?? serviceProvider.GetRequiredService(),
+ ServerOptions.Activator ?? serviceProvider.GetRequiredService(),
+ serviceProvider.GetService(),
+ serviceProvider.GetService(),
+ serviceProvider.GetService()
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/background-jobs/Volo.Abp.BackgroundJobs.sln b/modules/background-jobs/Volo.Abp.BackgroundJobs.sln
index 50872d8025..8c6f5a0cad 100644
--- a/modules/background-jobs/Volo.Abp.BackgroundJobs.sln
+++ b/modules/background-jobs/Volo.Abp.BackgroundJobs.sln
@@ -25,7 +25,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BackgroundJobs.Ent
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BackgroundJobs.MongoDB.Tests", "test\Volo.Abp.BackgroundJobs.MongoDB.Tests\Volo.Abp.BackgroundJobs.MongoDB.Tests.csproj", "{AA783A34-86E4-41A5-AE21-5D9FBD98D858}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.BackgroundJobs.DemoApp", "app\Volo.Abp.BackgroundJobs.DemoApp\Volo.Abp.BackgroundJobs.DemoApp.csproj", "{9A871D66-BE8D-440C-BF79-F778F8A50BF3}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.BackgroundJobs.DemoApp", "app\Volo.Abp.BackgroundJobs.DemoApp\Volo.Abp.BackgroundJobs.DemoApp.csproj", "{9A871D66-BE8D-440C-BF79-F778F8A50BF3}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.BackgroundJobs.DemoApp.Shared", "app\Volo.Abp.BackgroundJobs.DemoApp.Shared\Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj", "{DE6914FF-F60A-461A-8498-461198E917BE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.BackgroundJobs.DemoApp.HangFire", "app\Volo.Abp.BackgroundJobs.DemoApp.HangFire\Volo.Abp.BackgroundJobs.DemoApp.HangFire.csproj", "{2060AC85-2598-4342-A87C-A684A2C71A37}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -69,6 +73,14 @@ Global
{9A871D66-BE8D-440C-BF79-F778F8A50BF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A871D66-BE8D-440C-BF79-F778F8A50BF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A871D66-BE8D-440C-BF79-F778F8A50BF3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE6914FF-F60A-461A-8498-461198E917BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DE6914FF-F60A-461A-8498-461198E917BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE6914FF-F60A-461A-8498-461198E917BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DE6914FF-F60A-461A-8498-461198E917BE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2060AC85-2598-4342-A87C-A684A2C71A37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2060AC85-2598-4342-A87C-A684A2C71A37}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2060AC85-2598-4342-A87C-A684A2C71A37}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2060AC85-2598-4342-A87C-A684A2C71A37}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -83,6 +95,8 @@ Global
{E5906DE1-B2F5-472E-BE1B-1D96A68B834D} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}
{AA783A34-86E4-41A5-AE21-5D9FBD98D858} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}
{9A871D66-BE8D-440C-BF79-F778F8A50BF3} = {E400416D-2895-4512-9D17-90681EEC7E0A}
+ {DE6914FF-F60A-461A-8498-461198E917BE} = {E400416D-2895-4512-9D17-90681EEC7E0A}
+ {2060AC85-2598-4342-A87C-A684A2C71A37} = {E400416D-2895-4512-9D17-90681EEC7E0A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4324B3B4-B60B-4E3C-91D8-59576B4E26DD}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/DemoAppHangfireModule.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/DemoAppHangfireModule.cs
new file mode 100644
index 0000000000..09abcc4eeb
--- /dev/null
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/DemoAppHangfireModule.cs
@@ -0,0 +1,43 @@
+using Hangfire;
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.Autofac;
+using Volo.Abp.BackgroundJobs.DemoApp.Shared;
+using Volo.Abp.Hangfire;
+using Volo.Abp.Modularity;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+
+namespace Volo.Abp.BackgroundJobs.DemoApp.HangFire
+{
+ [DependsOn(
+ typeof(DemoAppSharedModule),
+ typeof(AbpAutofacModule),
+ typeof(AbpHangfireModule)
+ )]
+ public class DemoAppHangfireModule : AbpModule
+ {
+ public override void PreConfigureServices(ServiceConfigurationContext context)
+ {
+ var configuration = ConfigurationHelper.BuildConfiguration();
+ context.Services.AddConfiguration(configuration);
+
+ context.Services.PreConfigure(hangfireConfiguration =>
+ {
+ hangfireConfiguration.UseSqlServerStorage(configuration.GetConnectionString("Default"));
+ });
+ }
+
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ context.Services.AddAssemblyOf();
+ }
+
+ public override void OnApplicationInitialization(ApplicationInitializationContext context)
+ {
+ context
+ .ServiceProvider
+ .GetRequiredService()
+ .AddConsole(LogLevel.Debug);
+ }
+ }
+}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Program.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Program.cs
new file mode 100644
index 0000000000..00781d38f6
--- /dev/null
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Program.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace Volo.Abp.BackgroundJobs.DemoApp.HangFire
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ using (var application = AbpApplicationFactory.Create(options =>
+ {
+ options.UseAutofac();
+ }))
+ {
+ application.Initialize();
+
+ Console.WriteLine("Started: " + typeof(Program).Namespace);
+ Console.WriteLine("Press ENTER to stop the application..!");
+ Console.ReadLine();
+
+ application.Shutdown();
+ }
+ }
+ }
+}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.csproj b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.csproj
new file mode 100644
index 0000000000..e65af611a5
--- /dev/null
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.HangFire/Volo.Abp.BackgroundJobs.DemoApp.HangFire.csproj
@@ -0,0 +1,15 @@
+
+
+
+ Exe
+ netcoreapp2.1
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/ConfigurationHelper.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/ConfigurationHelper.cs
new file mode 100644
index 0000000000..c71aec904e
--- /dev/null
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/ConfigurationHelper.cs
@@ -0,0 +1,37 @@
+using System.IO;
+using Microsoft.Extensions.Configuration;
+
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared
+{
+ public static class ConfigurationHelper
+ {
+ public static IConfigurationRoot BuildConfiguration()
+ {
+ const string fileName = "appsettings.json";
+
+ var directory = Directory.GetCurrentDirectory();
+
+ while (!File.Exists(Path.Combine(directory, fileName)))
+ {
+ var parentDirectory = new DirectoryInfo(directory).Parent;
+ if (parentDirectory == null)
+ {
+ break;
+ }
+
+ directory = parentDirectory.FullName;
+ }
+
+ if (File.Exists(Path.Combine(directory, fileName)))
+ {
+ var builder = new ConfigurationBuilder()
+ .SetBasePath(directory)
+ .AddJsonFile(fileName, optional: false);
+
+ return builder.Build();
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs
new file mode 100644
index 0000000000..7e3428ba2a
--- /dev/null
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/DemoAppSharedModule.cs
@@ -0,0 +1,24 @@
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs;
+using Volo.Abp.Modularity;
+
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared
+{
+ [DependsOn(
+ typeof(AbpBackgroundJobsAbstractionsModule)
+ )]
+ public class DemoAppSharedModule : AbpModule
+ {
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ context.Services.AddAssemblyOf();
+ }
+
+ public override void OnApplicationInitialization(ApplicationInitializationContext context)
+ {
+ context.ServiceProvider
+ .GetRequiredService()
+ .CreateJobs();
+ }
+ }
+}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/SampleJobCreator.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/SampleJobCreator.cs
similarity index 93%
rename from modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/SampleJobCreator.cs
rename to modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/SampleJobCreator.cs
index 5363101213..0349632d07 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/SampleJobCreator.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/SampleJobCreator.cs
@@ -1,6 +1,6 @@
using Volo.Abp.DependencyInjection;
-namespace Volo.Abp.BackgroundJobs.DemoApp.Jobs
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{
public class SampleJobCreator : ITransientDependency
{
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleGreenJob.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJob.cs
similarity index 87%
rename from modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleGreenJob.cs
rename to modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJob.cs
index 9930ce7d9e..8d1d989a7a 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleGreenJob.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJob.cs
@@ -1,13 +1,13 @@
using System;
using Volo.Abp.DependencyInjection;
-namespace Volo.Abp.BackgroundJobs.DemoApp.Jobs
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{
public class WriteToConsoleGreenJob : BackgroundJob, ITransientDependency
{
public override void Execute(WriteToConsoleGreenJobArgs args)
{
- if (RandomHelper.GetRandom(0,100) < 70)
+ if (RandomHelper.GetRandom(0, 100) < 70)
{
throw new ApplicationException("A sample exception from the WriteToConsoleGreenJob!");
}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleGreenJobArgs.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJobArgs.cs
similarity index 70%
rename from modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleGreenJobArgs.cs
rename to modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJobArgs.cs
index 77ec28b4f8..6e3fb82e57 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleGreenJobArgs.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleGreenJobArgs.cs
@@ -1,4 +1,4 @@
-namespace Volo.Abp.BackgroundJobs.DemoApp.Jobs
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{
[BackgroundJobName("GreenJob")]
public class WriteToConsoleGreenJobArgs
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleYellowJob.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJob.cs
similarity index 93%
rename from modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleYellowJob.cs
rename to modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJob.cs
index 3532e1a3c7..90838bc87d 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleYellowJob.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJob.cs
@@ -1,7 +1,7 @@
using System;
using Volo.Abp.DependencyInjection;
-namespace Volo.Abp.BackgroundJobs.DemoApp.Jobs
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{
public class WriteToConsoleYellowJob : BackgroundJob, ITransientDependency
{
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleYellowJobArgs.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJobArgs.cs
similarity index 71%
rename from modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleYellowJobArgs.cs
rename to modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJobArgs.cs
index 40b54c49ae..e33ca2aa89 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Jobs/WriteToConsoleYellowJobArgs.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Jobs/WriteToConsoleYellowJobArgs.cs
@@ -1,4 +1,4 @@
-namespace Volo.Abp.BackgroundJobs.DemoApp.Jobs
+namespace Volo.Abp.BackgroundJobs.DemoApp.Shared.Jobs
{
[BackgroundJobName("YellowJob")]
public class WriteToConsoleYellowJobArgs
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj
new file mode 100644
index 0000000000..53f5f1c6f8
--- /dev/null
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp.Shared/Volo.Abp.BackgroundJobs.DemoApp.Shared.csproj
@@ -0,0 +1,14 @@
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs
index a1016fdb44..af6b4f756d 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/DemoAppModule.cs
@@ -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(options =>
@@ -54,33 +56,5 @@ namespace Volo.Abp.BackgroundJobs.DemoApp
.GetRequiredService()
.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;
- }
}
}
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Program.cs b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Program.cs
index de863ca426..b8bb19383e 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Program.cs
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Program.cs
@@ -1,6 +1,4 @@
using System;
-using Microsoft.Extensions.DependencyInjection;
-using Volo.Abp.BackgroundJobs.DemoApp.Jobs;
namespace Volo.Abp.BackgroundJobs.DemoApp
{
@@ -15,11 +13,7 @@ namespace Volo.Abp.BackgroundJobs.DemoApp
{
application.Initialize();
- application
- .ServiceProvider
- .GetRequiredService()
- .CreateJobs();
-
+ Console.WriteLine("Started: " + typeof(Program).Namespace);
Console.WriteLine("Press ENTER to stop the application..!");
Console.ReadLine();
diff --git a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.csproj b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.csproj
index 028482d72c..d386d134bf 100644
--- a/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.csproj
+++ b/modules/background-jobs/app/Volo.Abp.BackgroundJobs.DemoApp/Volo.Abp.BackgroundJobs.DemoApp.csproj
@@ -6,14 +6,12 @@
-
-
-
+