Files
KinginfoGateway/framework/admin/ThingsGateway.Admin.Application/Job/JobPersistence.cs

68 lines
1.9 KiB
C#
Raw Normal View History

2023-05-23 23:54:28 +08:00
#region copyright
//------------------------------------------------------------------------------
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
// 此代码版权除特别声明外的代码归作者本人Diego所有
// 源代码使用协议遵循本仓库的开源协议及附加协议
2023-07-16 17:48:22 +08:00
// Gitee源代码仓库https://gitee.com/diego2098/ThingsGateway
2023-05-23 23:54:28 +08:00
// Github源代码仓库https://github.com/kimdiego2098/ThingsGateway
2023-07-16 17:48:22 +08:00
// 使用文档https://diego2098.gitee.io/thingsgateway-docs/
2023-05-23 23:54:28 +08:00
// QQ群605534569
//------------------------------------------------------------------------------
#endregion
using Furion.Schedule;
2023-03-04 18:41:11 +08:00
2023-08-07 15:09:53 +08:00
using Microsoft.Extensions.DependencyInjection;
2023-03-04 18:41:11 +08:00
2023-08-07 15:09:53 +08:00
namespace ThingsGateway.Admin.Application;
2023-06-06 19:37:04 +08:00
/// <inheritdoc cref="IJobPersistence"/>
2023-03-04 18:41:11 +08:00
public class JobPersistence : IJobPersistence
{
private readonly IServiceScope _serviceScope;
2023-06-06 19:37:04 +08:00
/// <inheritdoc/>
2023-11-18 22:43:36 +08:00
public JobPersistence(IServiceScopeFactory serviceScopeFactory)
2023-03-04 18:41:11 +08:00
{
2023-11-18 22:43:36 +08:00
_serviceScope = serviceScopeFactory.CreateScope();
2023-03-04 18:41:11 +08:00
}
2023-11-18 22:43:36 +08:00
/// <inheritdoc/>
public void Dispose()
2023-03-04 18:41:11 +08:00
{
2023-11-18 22:43:36 +08:00
_serviceScope?.Dispose();
}
/// <inheritdoc/>
public void OnChanged(PersistenceContext context)
{
2023-03-04 18:41:11 +08:00
}
/// <summary>
/// 作业计划初始化通知
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public SchedulerBuilder OnLoading(SchedulerBuilder builder)
{
return builder;
}
2023-06-06 19:37:04 +08:00
/// <inheritdoc/>
2023-11-18 22:43:36 +08:00
public void OnTriggerChanged(PersistenceTriggerContext context)
2023-03-04 18:41:11 +08:00
{
2023-03-10 09:11:26 +08:00
2023-03-04 18:41:11 +08:00
}
2023-11-18 22:43:36 +08:00
/// <summary>
/// 作业调度服务启动时
/// </summary>
/// <returns></returns>
public IEnumerable<SchedulerBuilder> Preload()
2023-03-04 18:41:11 +08:00
{
2023-11-18 22:43:36 +08:00
// 获取所有定义的作业
var allJobs = App.EffectiveTypes.ScanToBuilders().ToList();
return allJobs;
2023-03-04 18:41:11 +08:00
}
}