📝 feat(新增/修改): 添加文档说明
This commit is contained in:
parent
5e8ecbd031
commit
a08916057a
|
@ -16,7 +16,7 @@ public class CronJob : IJob
|
|||
var count = dataMap.Get("count");
|
||||
var triggerCount = jobDataMap.Get("triggerCount");
|
||||
|
||||
Console.WriteLine($"用户名:{username},密码: {password},count:{count},triggerCount:{triggerCount}");
|
||||
Console.WriteLine($"CronJob:username:{username},password:{password},count:{count},triggerCount:{triggerCount}");
|
||||
|
||||
// 设置 count 值
|
||||
dataMap.Put("count", Convert.ToInt32(count) + 1);
|
||||
|
|
|
@ -27,7 +27,7 @@ public static class CronJobService
|
|||
.UsingJobData("triggerCount", 1)
|
||||
.WithIdentity("testTrigger", "测试发出器")
|
||||
.StartNow()
|
||||
.WithCronSchedule("0/1 * * * * ?")
|
||||
.WithCronSchedule("0/6 * * * * ?")
|
||||
.Build();
|
||||
|
||||
scheduler.ScheduleJob(trigger).GetAwaiter().GetResult();
|
||||
|
|
|
@ -6,11 +6,10 @@ public class SimpleJob : IJob
|
|||
{
|
||||
public Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
Console.WriteLine("执行一个简单的任务");
|
||||
var dataMap = context.JobDetail.JobDataMap;
|
||||
var username = dataMap.GetString("username");
|
||||
var password = dataMap.GetString("password");
|
||||
Console.WriteLine($"用户名:{username},密码: {password}");
|
||||
Console.WriteLine($"SimpleJob:用户名:{username},密码: {password}");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
|
@ -33,8 +33,7 @@ public static class ServiceRegistration
|
|||
public static void AddApplicationBackendServices(this WebApplicationBuilder builder)
|
||||
{
|
||||
// 测试注入后台服务
|
||||
// https://github.com/quartznet/quartznet/tree/main/database/tables
|
||||
// builder.AddCreateSimpleJobService();
|
||||
builder.AddCreateSimpleJobService();
|
||||
builder.AddCronJobService();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
设置后台服务,原生写法
|
||||
## 后台服务设置
|
||||
|
||||
### Quartz写法
|
||||
|
||||
- 持久化存储生成数据SQL语句参考
|
||||
- https://github.com/quartznet/quartznet/tree/main/database/tables
|
||||
|
||||
### 原生写法
|
||||
|
||||
- 设置每秒执行多少,设置后台服务,原生写法
|
||||
|
||||
```csharp
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
@ -22,4 +31,34 @@ public class TemplateBackgroundModule : BackgroundService
|
|||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## 验证码生成
|
||||
|
||||
- 验证码生成相关配置
|
||||
|
||||
```csharp
|
||||
var service = builder.Services;
|
||||
// 使用图形验证码
|
||||
service.AddDistributedMemoryCache();
|
||||
// 验证码相关配置内容
|
||||
service.AddCaptcha(options =>
|
||||
{
|
||||
options.CaptchaType = CaptchaType.DEFAULT; // 验证码类型
|
||||
options.CodeLength = 4; // 验证码长度
|
||||
options.ExpirySeconds = 60; // 过期时间(单位/秒)
|
||||
options.IgnoreCase = true; // 比较忽略大小写
|
||||
options.ImageOption.Animation = true; // 是否启用动画
|
||||
options.ImageOption.Width = 130; // 验证码宽度
|
||||
options.ImageOption.Height = 48; // 验证码高度
|
||||
options.ImageOption.BackgroundColor = SKColors.White;
|
||||
options.ImageOption.BubbleCount = 6; // 气泡数量
|
||||
options.ImageOption.BubbleMinRadius = 2; // 气泡最小半径
|
||||
options.ImageOption.BubbleMaxRadius = 6; // 气泡最大半径
|
||||
options.ImageOption.BubbleThickness = 2; // 气泡边沿厚度
|
||||
options.ImageOption.InterferenceLineCount = 2; // 干扰线数量
|
||||
options.ImageOption.FontSize = 36; // 字体大小
|
||||
options.ImageOption.FontFamily = DefaultFontFamilys.Instance.Kaiti; // 字体,中文使用kaiti,其他字符可根据喜好设置
|
||||
});
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue