2023-02-08 14:33:22 +01:00
|
|
|
|
using System.Reflection;
|
2023-02-09 10:25:42 +01:00
|
|
|
|
using Application.Common.Behaviours;
|
|
|
|
|
using Application.Game.Card;
|
2023-02-14 19:14:19 +01:00
|
|
|
|
using Application.Jobs;
|
2023-02-08 14:33:22 +01:00
|
|
|
|
using MediatR;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2023-02-14 19:14:19 +01:00
|
|
|
|
using Quartz;
|
2023-02-08 14:33:22 +01:00
|
|
|
|
|
|
|
|
|
namespace Application;
|
|
|
|
|
|
|
|
|
|
public static class DependencyInjection
|
|
|
|
|
{
|
|
|
|
|
public static IServiceCollection AddApplication(this IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddMediatR(Assembly.GetExecutingAssembly());
|
|
|
|
|
|
2023-02-09 10:25:42 +01:00
|
|
|
|
services.AddScoped<ICardDependencyAggregate, CardDependencyAggregate>();
|
|
|
|
|
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(UnhandledExceptionBehaviour<,>));
|
2023-02-14 19:14:19 +01:00
|
|
|
|
services.AddQuartz(q =>
|
|
|
|
|
{
|
|
|
|
|
q.UseMicrosoftDependencyInjectionJobFactory();
|
2023-02-16 08:26:13 +01:00
|
|
|
|
|
|
|
|
|
q.AddJob<UpdatePlayNumRankJob>(options => options.WithIdentity(UpdatePlayNumRankJob.KEY));
|
2023-02-14 19:14:19 +01:00
|
|
|
|
q.AddTrigger(options =>
|
|
|
|
|
{
|
2023-02-16 08:26:13 +01:00
|
|
|
|
options.ForJob(UpdatePlayNumRankJob.KEY)
|
2023-02-14 19:14:19 +01:00
|
|
|
|
.WithIdentity("UpdatePlayNumRankJob-trigger")
|
|
|
|
|
.StartNow()
|
|
|
|
|
.WithSimpleSchedule(x =>
|
|
|
|
|
{
|
|
|
|
|
x.WithIntervalInHours(24).RepeatForever();
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-02-16 08:26:13 +01:00
|
|
|
|
|
|
|
|
|
q.AddJob<UpdateGlobalScoreRankJob>(options => options.WithIdentity(UpdateGlobalScoreRankJob.KEY));
|
|
|
|
|
q.AddTrigger(options =>
|
|
|
|
|
{
|
|
|
|
|
options.ForJob(UpdateGlobalScoreRankJob.KEY)
|
|
|
|
|
.WithIdentity("UpdateGlobalScoreRankJob-trigger")
|
|
|
|
|
.StartNow()
|
|
|
|
|
.WithSimpleSchedule(x =>
|
|
|
|
|
{
|
|
|
|
|
x.WithIntervalInHours(24).RepeatForever();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
q.AddJob<UpdateMonthlyScoreRankJob>(options => options.WithIdentity(UpdateMonthlyScoreRankJob.KEY));
|
|
|
|
|
q.AddTrigger(options =>
|
|
|
|
|
{
|
|
|
|
|
options.ForJob(UpdateMonthlyScoreRankJob.KEY)
|
|
|
|
|
.WithIdentity("UpdateMonthlyScoreRankJob-trigger")
|
|
|
|
|
.StartNow()
|
|
|
|
|
.WithSimpleSchedule(x =>
|
|
|
|
|
{
|
|
|
|
|
x.WithIntervalInHours(24).RepeatForever();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
q.AddJob<MaintainTenpoIdJob>(options => options.WithIdentity(MaintainTenpoIdJob.KEY));
|
|
|
|
|
q.AddTrigger(options =>
|
|
|
|
|
{
|
|
|
|
|
options.ForJob(MaintainTenpoIdJob.KEY)
|
|
|
|
|
.WithIdentity("MaintainTenpoIdJob-trigger")
|
|
|
|
|
.StartNow()
|
|
|
|
|
.WithSimpleSchedule(x =>
|
|
|
|
|
{
|
|
|
|
|
x.WithIntervalInHours(24).RepeatForever();
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-02-14 19:14:19 +01:00
|
|
|
|
});
|
|
|
|
|
services.AddQuartzHostedService(options =>
|
|
|
|
|
{
|
|
|
|
|
options.WaitForJobsToComplete = true;
|
|
|
|
|
});
|
2023-02-08 14:33:22 +01:00
|
|
|
|
return services;
|
|
|
|
|
}
|
|
|
|
|
}
|