mirror of https://github.com/abpframework/abp.git
committed by
GitHub
10 changed files with 243 additions and 111 deletions
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Volo.Abp.BackgroundWorkers.Hangfire; |
||||
|
|
||||
|
public class AbpHangfirePeriodicBackgroundWorkerAdapterOptions |
||||
|
{ |
||||
|
public TimeZoneInfo TimeZone { get; set; } = TimeZoneInfo.Utc; |
||||
|
|
||||
|
public string Queue { get; set; } = default!; |
||||
|
} |
||||
@ -0,0 +1,22 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Hangfire; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.BackgroundWorkers; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace Volo.Abp.BackgroundJobs.DemoApp.HangFire; |
||||
|
|
||||
|
public class TestWorker : AsyncPeriodicBackgroundWorkerBase |
||||
|
{ |
||||
|
public TestWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) |
||||
|
: base(timer, serviceScopeFactory) |
||||
|
{ |
||||
|
CronExpression = Cron.Minutely(); |
||||
|
} |
||||
|
|
||||
|
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) |
||||
|
{ |
||||
|
Console.WriteLine($"[{DateTime.Now}] TestWorker executed."); |
||||
|
} |
||||
|
} |
||||
@ -1,41 +0,0 @@ |
|||||
using System; |
|
||||
using Microsoft.EntityFrameworkCore.Migrations; |
|
||||
|
|
||||
namespace Volo.Abp.BackgroundJobs.DemoApp.Migrations; |
|
||||
|
|
||||
public partial class Initial : Migration |
|
||||
{ |
|
||||
protected override void Up(MigrationBuilder migrationBuilder) |
|
||||
{ |
|
||||
migrationBuilder.CreateTable( |
|
||||
name: "AbpBackgroundJobs", |
|
||||
columns: table => new { |
|
||||
Id = table.Column<Guid>(nullable: false), |
|
||||
ExtraProperties = table.Column<string>(nullable: true), |
|
||||
ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true), |
|
||||
JobName = table.Column<string>(maxLength: 128, nullable: false), |
|
||||
JobArgs = table.Column<string>(maxLength: 1048576, nullable: false), |
|
||||
TryCount = table.Column<short>(nullable: false, defaultValue: (short)0), |
|
||||
CreationTime = table.Column<DateTime>(nullable: false), |
|
||||
NextTryTime = table.Column<DateTime>(nullable: false), |
|
||||
LastTryTime = table.Column<DateTime>(nullable: true), |
|
||||
IsAbandoned = table.Column<bool>(nullable: false, defaultValue: false), |
|
||||
Priority = table.Column<byte>(nullable: false, defaultValue: (byte)15) |
|
||||
}, |
|
||||
constraints: table => |
|
||||
{ |
|
||||
table.PrimaryKey("PK_AbpBackgroundJobs", x => x.Id); |
|
||||
}); |
|
||||
|
|
||||
migrationBuilder.CreateIndex( |
|
||||
name: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime", |
|
||||
table: "AbpBackgroundJobs", |
|
||||
columns: new[] { "IsAbandoned", "NextTryTime" }); |
|
||||
} |
|
||||
|
|
||||
protected override void Down(MigrationBuilder migrationBuilder) |
|
||||
{ |
|
||||
migrationBuilder.DropTable( |
|
||||
name: "AbpBackgroundJobs"); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,49 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace Volo.Abp.BackgroundJobs.DemoApp.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class Initial : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpBackgroundJobs", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), |
||||
|
ApplicationName = table.Column<string>(type: "nvarchar(96)", maxLength: 96, nullable: true), |
||||
|
JobName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false), |
||||
|
JobArgs = table.Column<string>(type: "nvarchar(max)", maxLength: 1048576, nullable: false), |
||||
|
TryCount = table.Column<short>(type: "smallint", nullable: false, defaultValue: (short)0), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
||||
|
NextTryTime = table.Column<DateTime>(type: "datetime2", nullable: false), |
||||
|
LastTryTime = table.Column<DateTime>(type: "datetime2", nullable: true), |
||||
|
IsAbandoned = table.Column<bool>(type: "bit", nullable: false, defaultValue: false), |
||||
|
Priority = table.Column<byte>(type: "tinyint", nullable: false, defaultValue: (byte)15), |
||||
|
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: false), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpBackgroundJobs", x => x.Id); |
||||
|
}); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime", |
||||
|
table: "AbpBackgroundJobs", |
||||
|
columns: new[] { "IsAbandoned", "NextTryTime" }); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpBackgroundJobs"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue