From 8a106fb53cb43bd4df2225909587d506b7ea020b Mon Sep 17 00:00:00 2001 From: feijie Date: Tue, 10 Dec 2024 22:07:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(docs):=20=E6=B7=BB=E5=8A=A0Hangfire?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../README.EN.md | 94 +++++++++++++++++++ .../README.md | 94 +++++++++++++++++++ .../README.EN.md | 82 ++++++++++++++++ .../README.md | 82 ++++++++++++++++ .../README.EN.md | 83 ++++++++++++++++ .../LINGYUN.Abp.Hangfire.Dashboard/README.md | 83 ++++++++++++++++ .../README.EN.md | 77 +++++++++++++++ .../README.md | 77 +++++++++++++++ .../README.EN.md | 75 +++++++++++++++ .../README.md | 75 +++++++++++++++ 10 files changed, 822 insertions(+) create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.EN.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.EN.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.EN.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.EN.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.EN.md create mode 100644 aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.md diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.EN.md b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.EN.md new file mode 100644 index 000000000..6e557659d --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.EN.md @@ -0,0 +1,94 @@ +# LINGYUN.Abp.BackgroundJobs.Hangfire + +English | [简体中文](README.md) + +## 1. Introduction + +`LINGYUN.Abp.BackgroundJobs.Hangfire` is an ABP background job module implemented based on [Hangfire](https://www.hangfire.io/). It provides a reliable background job execution framework that supports immediate, delayed, and recurring task execution. + +## 2. Features + +* Support for immediate task execution +* Support for delayed task execution +* Support for recurring tasks (using Cron expressions) +* Seamless integration with ABP background job system +* Job execution status tracking +* Job retry mechanism + +## 3. Installation + +```bash +dotnet add package LINGYUN.Abp.BackgroundJobs.Hangfire +``` + +## 4. Usage + +1. Add `AbpBackgroundJobsHangfireModule` to your module dependencies: + +```csharp +[DependsOn(typeof(AbpBackgroundJobsHangfireModule))] +public class YourModule : AbpModule +{ +} +``` + +2. Configure background jobs: + +```csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + Configure(options => + { + options.IsJobExecutionEnabled = true; // Enable job execution + }); +} +``` + +3. Use background jobs: + +```csharp +public class YourService +{ + private readonly IBackgroundJobManager _backgroundJobManager; + + public YourService(IBackgroundJobManager backgroundJobManager) + { + _backgroundJobManager = backgroundJobManager; + } + + public async Task CreateJobAsync() + { + // Create immediate job + await _backgroundJobManager.EnqueueAsync(new YourArgs()); + + // Create delayed job + await _backgroundJobManager.EnqueueAsync( + new YourArgs(), + delay: TimeSpan.FromMinutes(5) + ); + + // Create recurring job + await _backgroundJobManager.EnqueueAsync( + "0 0 * * *", // Cron expression: Execute at 00:00 every day + new YourArgs() + ); + } +} +``` + +## 5. Configuration + +### 5.1 Job Configuration + +* `AbpBackgroundJobOptions.IsJobExecutionEnabled`: Whether to enable job execution. Default value: `true` + +## 6. Dependencies + +* Volo.Abp.BackgroundJobs +* Hangfire.Core +* Hangfire.AspNetCore + +## 7. Documentation and Resources + +* [Hangfire Official Documentation](https://docs.hangfire.io/) +* [ABP Framework Documentation](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.md b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.md new file mode 100644 index 000000000..15bed0155 --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundJobs.Hangfire/README.md @@ -0,0 +1,94 @@ +# LINGYUN.Abp.BackgroundJobs.Hangfire + +[English](README.EN.md) | 简体中文 + +## 1. 介绍 + +`LINGYUN.Abp.BackgroundJobs.Hangfire` 是基于 [Hangfire](https://www.hangfire.io/) 实现的ABP后台作业模块。它提供了一个可靠的后台作业执行框架,支持即时任务、延迟任务和周期性任务的执行。 + +## 2. 功能特性 + +* 支持即时任务执行 +* 支持延迟任务执行 +* 支持周期性任务(使用Cron表达式) +* 与ABP后台作业系统无缝集成 +* 支持作业执行状态跟踪 +* 支持作业重试机制 + +## 3. 安装 + +```bash +dotnet add package LINGYUN.Abp.BackgroundJobs.Hangfire +``` + +## 4. 使用方法 + +1. 添加 `AbpBackgroundJobsHangfireModule` 到模块依赖中: + +```csharp +[DependsOn(typeof(AbpBackgroundJobsHangfireModule))] +public class YourModule : AbpModule +{ +} +``` + +2. 配置后台作业: + +```csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + Configure(options => + { + options.IsJobExecutionEnabled = true; // 启用作业执行 + }); +} +``` + +3. 使用后台作业: + +```csharp +public class YourService +{ + private readonly IBackgroundJobManager _backgroundJobManager; + + public YourService(IBackgroundJobManager backgroundJobManager) + { + _backgroundJobManager = backgroundJobManager; + } + + public async Task CreateJobAsync() + { + // 创建即时任务 + await _backgroundJobManager.EnqueueAsync(new YourArgs()); + + // 创建延迟任务 + await _backgroundJobManager.EnqueueAsync( + new YourArgs(), + delay: TimeSpan.FromMinutes(5) + ); + + // 创建周期性任务 + await _backgroundJobManager.EnqueueAsync( + "0 0 * * *", // Cron表达式:每天0点执行 + new YourArgs() + ); + } +} +``` + +## 5. 配置项 + +### 5.1 作业配置 + +* `AbpBackgroundJobOptions.IsJobExecutionEnabled`: 是否启用作业执行。默认值: `true` + +## 6. 依赖项 + +* Volo.Abp.BackgroundJobs +* Hangfire.Core +* Hangfire.AspNetCore + +## 7. 文档和资源 + +* [Hangfire官方文档](https://docs.hangfire.io/) +* [ABP框架文档](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.EN.md b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.EN.md new file mode 100644 index 000000000..7dbf9e43b --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.EN.md @@ -0,0 +1,82 @@ +# LINGYUN.Abp.BackgroundWorkers.Hangfire + +English | [简体中文](README.md) + +## 1. Introduction + +`LINGYUN.Abp.BackgroundWorkers.Hangfire` is an ABP background worker module implemented based on Hangfire. It provides a reliable way to manage and execute long-running background tasks, supporting automatic start, stop, and periodic execution features. + +## 2. Features + +* Support for automatic start and stop of background workers +* Support for periodically executing background tasks +* Seamless integration with ABP background worker system +* Worker status management +* Dependency injection support + +## 3. Installation + +```bash +dotnet add package LINGYUN.Abp.BackgroundWorkers.Hangfire +``` + +## 4. Usage + +1. Add `AbpBackgroundWorkersHangfireModule` to your module dependencies: + +```csharp +[DependsOn(typeof(AbpBackgroundWorkersHangfireModule))] +public class YourModule : AbpModule +{ +} +``` + +2. Create background worker: + +```csharp +public class YourBackgroundWorker : AsyncPeriodicBackgroundWorkerBase +{ + public YourBackgroundWorker( + AbpAsyncTimer timer, + IServiceScopeFactory serviceScopeFactory) + : base(timer, serviceScopeFactory) + { + Timer.Period = 5000; // Execute every 5 seconds + } + + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) + { + // Implement your background task logic here + await Task.CompletedTask; + } +} +``` + +3. Register background worker: + +```csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + context.Services.AddTransient(); + Configure(options => + { + options.IsEnabled = true; // Enable background workers + }); +} +``` + +## 5. Configuration + +### 5.1 Worker Configuration + +* `AbpBackgroundWorkerOptions.IsEnabled`: Whether to enable background workers. Default value: `true` + +## 6. Dependencies + +* Volo.Abp.BackgroundWorkers +* LINGYUN.Abp.BackgroundJobs.Hangfire + +## 7. Documentation and Resources + +* [Hangfire Official Documentation](https://docs.hangfire.io/) +* [ABP Framework Documentation](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.md b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.md new file mode 100644 index 000000000..83127d6c3 --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.BackgroundWorkers.Hangfire/README.md @@ -0,0 +1,82 @@ +# LINGYUN.Abp.BackgroundWorkers.Hangfire + +[English](README.EN.md) | 简体中文 + +## 1. 介绍 + +`LINGYUN.Abp.BackgroundWorkers.Hangfire` 是一个基于Hangfire实现的ABP后台工作者模块。它提供了一种可靠的方式来管理和执行长期运行的后台任务,支持自动启动、停止和定期执行等功能。 + +## 2. 功能特性 + +* 支持后台工作者的自动启动和停止 +* 支持定期执行的后台任务 +* 与ABP后台工作者系统无缝集成 +* 支持工作者状态管理 +* 支持依赖注入 + +## 3. 安装 + +```bash +dotnet add package LINGYUN.Abp.BackgroundWorkers.Hangfire +``` + +## 4. 使用方法 + +1. 添加 `AbpBackgroundWorkersHangfireModule` 到模块依赖中: + +```csharp +[DependsOn(typeof(AbpBackgroundWorkersHangfireModule))] +public class YourModule : AbpModule +{ +} +``` + +2. 创建后台工作者: + +```csharp +public class YourBackgroundWorker : AsyncPeriodicBackgroundWorkerBase +{ + public YourBackgroundWorker( + AbpAsyncTimer timer, + IServiceScopeFactory serviceScopeFactory) + : base(timer, serviceScopeFactory) + { + Timer.Period = 5000; // 每5秒执行一次 + } + + protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) + { + // 在这里实现你的后台任务逻辑 + await Task.CompletedTask; + } +} +``` + +3. 注册后台工作者: + +```csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + context.Services.AddTransient(); + Configure(options => + { + options.IsEnabled = true; // 启用后台工作者 + }); +} +``` + +## 5. 配置项 + +### 5.1 工作者配置 + +* `AbpBackgroundWorkerOptions.IsEnabled`: 是否启用后台工作者。默认值: `true` + +## 6. 依赖项 + +* Volo.Abp.BackgroundWorkers +* LINGYUN.Abp.BackgroundJobs.Hangfire + +## 7. 文档和资源 + +* [Hangfire官方文档](https://docs.hangfire.io/) +* [ABP框架文档](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.EN.md b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.EN.md new file mode 100644 index 000000000..269781fad --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.EN.md @@ -0,0 +1,83 @@ +# LINGYUN.Abp.Hangfire.Dashboard + +English | [简体中文](README.md) + +## 1. Introduction + +`LINGYUN.Abp.Hangfire.Dashboard` is an ABP module for integrating the Hangfire dashboard, providing a user-friendly web interface for monitoring and managing Hangfire background jobs. This module supports permission control and authentication to ensure secure access to the dashboard. + +## 2. Features + +* Integration with Hangfire dashboard +* Access control based on ABP permission system +* Support for loading dashboard in iframe +* Access token authentication support +* Dashboard permission caching mechanism + +## 3. Installation + +```bash +dotnet add package LINGYUN.Abp.Hangfire.Dashboard +``` + +## 4. Usage + +1. Add `AbpHangfireDashboardModule` to your module dependencies: + +```csharp +[DependsOn(typeof(AbpHangfireDashboardModule))] +public class YourModule : AbpModule +{ +} +``` + +2. Configure middleware: + +```csharp +public override void OnApplicationInitialization(ApplicationInitializationContext context) +{ + var app = context.GetApplicationBuilder(); + + // Add Hangfire authentication middleware + app.UseHangfireAuthorication(); +} +``` + +3. Configure dashboard options: + +```csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + PreConfigure(options => + { + options.Authorization = new[] + { + new DashboardAuthorizationFilter("YourPermissionName") + }; + }); +} +``` + +## 5. Authentication and Authorization + +### 5.1 Authentication Methods + +The module supports the following authentication methods: +* Pass access token via URL parameter: `?access_token=your_token` +* Pass access token via Cookie +* Pass access token via Authorization Header + +### 5.2 Permission Caching + +Permission check results are cached for 5 minutes to improve performance. + +## 6. Dependencies + +* Volo.Abp.Authorization +* Volo.Abp.Hangfire +* Microsoft.Extensions.Caching.Memory + +## 7. Documentation and Resources + +* [Hangfire Official Documentation](https://docs.hangfire.io/) +* [ABP Framework Documentation](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.md b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.md new file mode 100644 index 000000000..f188aa235 --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Dashboard/README.md @@ -0,0 +1,83 @@ +# LINGYUN.Abp.Hangfire.Dashboard + +[English](README.EN.md) | 简体中文 + +## 1. 介绍 + +`LINGYUN.Abp.Hangfire.Dashboard` 是一个用于集成Hangfire仪表板的ABP模块,它提供了一个用户友好的Web界面来监控和管理Hangfire后台作业。该模块支持权限控制和认证,确保仪表板的安全访问。 + +## 2. 功能特性 + +* 集成Hangfire仪表板 +* 基于ABP权限系统的访问控制 +* 支持通过iframe加载仪表板 +* 支持访问令牌认证 +* 仪表板权限缓存机制 + +## 3. 安装 + +```bash +dotnet add package LINGYUN.Abp.Hangfire.Dashboard +``` + +## 4. 使用方法 + +1. 添加 `AbpHangfireDashboardModule` 到模块依赖中: + +```csharp +[DependsOn(typeof(AbpHangfireDashboardModule))] +public class YourModule : AbpModule +{ +} +``` + +2. 配置中间件: + +```csharp +public override void OnApplicationInitialization(ApplicationInitializationContext context) +{ + var app = context.GetApplicationBuilder(); + + // 添加Hangfire认证中间件 + app.UseHangfireAuthorication(); +} +``` + +3. 配置仪表板选项: + +```csharp +public override void ConfigureServices(ServiceConfigurationContext context) +{ + PreConfigure(options => + { + options.Authorization = new[] + { + new DashboardAuthorizationFilter("YourPermissionName") + }; + }); +} +``` + +## 5. 认证和授权 + +### 5.1 认证方式 + +模块支持以下认证方式: +* 通过URL参数传递访问令牌: `?access_token=your_token` +* 通过Cookie传递访问令牌 +* 通过Authorization Header传递访问令牌 + +### 5.2 权限缓存 + +权限检查结果会被缓存5分钟,以提高性能。 + +## 6. 依赖项 + +* Volo.Abp.Authorization +* Volo.Abp.Hangfire +* Microsoft.Extensions.Caching.Memory + +## 7. 文档和资源 + +* [Hangfire官方文档](https://docs.hangfire.io/) +* [ABP框架文档](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.EN.md b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.EN.md new file mode 100644 index 000000000..b793dfc5b --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.EN.md @@ -0,0 +1,77 @@ +# LINGYUN.Abp.Hangfire.Storage.MySql + +English | [简体中文](README.md) + +## 1. Introduction + +`LINGYUN.Abp.Hangfire.Storage.MySql` is an ABP module for configuring Hangfire to use MySQL as storage. This module provides a simple configuration approach to easily use MySQL as Hangfire's persistent storage. + +## 2. Features + +* Simple MySQL storage configuration +* Custom connection string support +* MySQL storage options configuration +* Seamless integration with ABP configuration system + +## 3. Installation + +```bash +dotnet add package LINGYUN.Abp.Hangfire.Storage.MySql +``` + +## 4. Usage + +1. Add `AbpHangfireMySqlStorageModule` to your module dependencies: + +```csharp +[DependsOn(typeof(AbpHangfireMySqlStorageModule))] +public class YourModule : AbpModule +{ +} +``` + +2. Configure connection string and storage options in appsettings.json: + +```json +{ + "Hangfire": { + "MySql": { + "Connection": "Server=localhost;Database=YourDb;Uid=root;Pwd=123456;", + "TablePrefix": "Hangfire", + "CommandBatchMaxTimeout": "00:05:00", + "SlidingInvisibilityTimeout": "00:05:00", + "QueuePollInterval": "00:00:00", + "UseRecommendedIsolationLevel": true, + "DisableGlobalLocks": true + } + } +} +``` + +## 5. Configuration + +### 5.1 Connection String Configuration + +The module looks for connection string in the following order: +1. `Hangfire:MySql:Connection` +2. `ConnectionStrings:Default` + +### 5.2 Storage Options + +* `TablePrefix`: Table prefix for database tables +* `CommandBatchMaxTimeout`: Maximum timeout for command batches +* `SlidingInvisibilityTimeout`: Sliding invisibility timeout +* `QueuePollInterval`: Queue polling interval +* `UseRecommendedIsolationLevel`: Whether to use recommended isolation level +* `DisableGlobalLocks`: Whether to disable global locks + +## 6. Dependencies + +* Volo.Abp.Hangfire +* Hangfire.MySql.Core + +## 7. Documentation and Resources + +* [Hangfire Official Documentation](https://docs.hangfire.io/) +* [Hangfire.MySql.Core Documentation](https://github.com/arnoldasgudas/Hangfire.MySqlStorage) +* [ABP Framework Documentation](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.md b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.md new file mode 100644 index 000000000..31dc54ba4 --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.MySqlStorage/README.md @@ -0,0 +1,77 @@ +# LINGYUN.Abp.Hangfire.Storage.MySql + +[English](README.EN.md) | 简体中文 + +## 1. 介绍 + +`LINGYUN.Abp.Hangfire.Storage.MySql` 是一个用于配置Hangfire使用MySQL作为存储的ABP模块。该模块提供了简单的配置方式,让你能够轻松地将MySQL作为Hangfire的持久化存储。 + +## 2. 功能特性 + +* 简单的MySQL存储配置 +* 支持自定义连接字符串 +* 支持MySQL存储选项配置 +* 与ABP配置系统无缝集成 + +## 3. 安装 + +```bash +dotnet add package LINGYUN.Abp.Hangfire.Storage.MySql +``` + +## 4. 使用方法 + +1. 添加 `AbpHangfireMySqlStorageModule` 到模块依赖中: + +```csharp +[DependsOn(typeof(AbpHangfireMySqlStorageModule))] +public class YourModule : AbpModule +{ +} +``` + +2. 在appsettings.json中配置连接字符串和存储选项: + +```json +{ + "Hangfire": { + "MySql": { + "Connection": "Server=localhost;Database=YourDb;Uid=root;Pwd=123456;", + "TablePrefix": "Hangfire", + "CommandBatchMaxTimeout": "00:05:00", + "SlidingInvisibilityTimeout": "00:05:00", + "QueuePollInterval": "00:00:00", + "UseRecommendedIsolationLevel": true, + "DisableGlobalLocks": true + } + } +} +``` + +## 5. 配置项 + +### 5.1 连接字符串配置 + +模块会按以下顺序查找连接字符串: +1. `Hangfire:MySql:Connection` +2. `ConnectionStrings:Default` + +### 5.2 存储选项 + +* `TablePrefix`: 数据表前缀 +* `CommandBatchMaxTimeout`: 命令批处理最大超时时间 +* `SlidingInvisibilityTimeout`: 滑动不可见超时时间 +* `QueuePollInterval`: 队列轮询间隔 +* `UseRecommendedIsolationLevel`: 是否使用推荐的隔离级别 +* `DisableGlobalLocks`: 是否禁用全局锁 + +## 6. 依赖项 + +* Volo.Abp.Hangfire +* Hangfire.MySql.Core + +## 7. 文档和资源 + +* [Hangfire官方文档](https://docs.hangfire.io/) +* [Hangfire.MySql.Core文档](https://github.com/arnoldasgudas/Hangfire.MySqlStorage) +* [ABP框架文档](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.EN.md b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.EN.md new file mode 100644 index 000000000..1187c9a80 --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.EN.md @@ -0,0 +1,75 @@ +# LINGYUN.Abp.Hangfire.Storage.SqlServer + +English | [简体中文](README.md) + +## 1. Introduction + +`LINGYUN.Abp.Hangfire.Storage.SqlServer` is an ABP module for configuring Hangfire to use SQL Server as storage. This module provides a simple configuration approach to easily use SQL Server as Hangfire's persistent storage. + +## 2. Features + +* Simple SQL Server storage configuration +* Custom connection string support +* SQL Server storage options configuration +* Seamless integration with ABP configuration system + +## 3. Installation + +```bash +dotnet add package LINGYUN.Abp.Hangfire.Storage.SqlServer +``` + +## 4. Usage + +1. Add `AbpHangfireSqlServerStorageModule` to your module dependencies: + +```csharp +[DependsOn(typeof(AbpHangfireSqlServerStorageModule))] +public class YourModule : AbpModule +{ +} +``` + +2. Configure connection string and storage options in appsettings.json: + +```json +{ + "Hangfire": { + "SqlServer": { + "Connection": "Server=localhost;Database=YourDb;Trusted_Connection=True;", + "CommandBatchMaxTimeout": "00:05:00", + "SlidingInvisibilityTimeout": "00:05:00", + "QueuePollInterval": "00:00:00", + "UseRecommendedIsolationLevel": true, + "DisableGlobalLocks": true + } + } +} +``` + +## 5. Configuration + +### 5.1 Connection String Configuration + +The module looks for connection string in the following order: +1. `Hangfire:SqlServer:Connection` +2. `ConnectionStrings:Default` + +### 5.2 Storage Options + +* `CommandBatchMaxTimeout`: Maximum timeout for command batches +* `SlidingInvisibilityTimeout`: Sliding invisibility timeout +* `QueuePollInterval`: Queue polling interval +* `UseRecommendedIsolationLevel`: Whether to use recommended isolation level +* `DisableGlobalLocks`: Whether to disable global locks + +## 6. Dependencies + +* Volo.Abp.Hangfire +* Hangfire.SqlServer + +## 7. Documentation and Resources + +* [Hangfire Official Documentation](https://docs.hangfire.io/) +* [Hangfire.SqlServer Documentation](https://docs.hangfire.io/en/latest/configuration/using-sql-server.html) +* [ABP Framework Documentation](https://docs.abp.io/) diff --git a/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.md b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.md new file mode 100644 index 000000000..076ede94e --- /dev/null +++ b/aspnet-core/framework/common/LINGYUN.Abp.Hangfire.Storage.SqlServer/README.md @@ -0,0 +1,75 @@ +# LINGYUN.Abp.Hangfire.Storage.SqlServer + +[English](README.EN.md) | 简体中文 + +## 1. 介绍 + +`LINGYUN.Abp.Hangfire.Storage.SqlServer` 是一个用于配置Hangfire使用SQL Server作为存储的ABP模块。该模块提供了简单的配置方式,让你能够轻松地将SQL Server作为Hangfire的持久化存储。 + +## 2. 功能特性 + +* 简单的SQL Server存储配置 +* 支持自定义连接字符串 +* 支持SQL Server存储选项配置 +* 与ABP配置系统无缝集成 + +## 3. 安装 + +```bash +dotnet add package LINGYUN.Abp.Hangfire.Storage.SqlServer +``` + +## 4. 使用方法 + +1. 添加 `AbpHangfireSqlServerStorageModule` 到模块依赖中: + +```csharp +[DependsOn(typeof(AbpHangfireSqlServerStorageModule))] +public class YourModule : AbpModule +{ +} +``` + +2. 在appsettings.json中配置连接字符串和存储选项: + +```json +{ + "Hangfire": { + "SqlServer": { + "Connection": "Server=localhost;Database=YourDb;Trusted_Connection=True;", + "CommandBatchMaxTimeout": "00:05:00", + "SlidingInvisibilityTimeout": "00:05:00", + "QueuePollInterval": "00:00:00", + "UseRecommendedIsolationLevel": true, + "DisableGlobalLocks": true + } + } +} +``` + +## 5. 配置项 + +### 5.1 连接字符串配置 + +模块会按以下顺序查找连接字符串: +1. `Hangfire:SqlServer:Connection` +2. `ConnectionStrings:Default` + +### 5.2 存储选项 + +* `CommandBatchMaxTimeout`: 命令批处理最大超时时间 +* `SlidingInvisibilityTimeout`: 滑动不可见超时时间 +* `QueuePollInterval`: 队列轮询间隔 +* `UseRecommendedIsolationLevel`: 是否使用推荐的隔离级别 +* `DisableGlobalLocks`: 是否禁用全局锁 + +## 6. 依赖项 + +* Volo.Abp.Hangfire +* Hangfire.SqlServer + +## 7. 文档和资源 + +* [Hangfire官方文档](https://docs.hangfire.io/) +* [Hangfire.SqlServer文档](https://docs.hangfire.io/en/latest/configuration/using-sql-server.html) +* [ABP框架文档](https://docs.abp.io/)