2022-10-14 16:08:54 +08:00
|
|
|
|
using Backend.Models;
|
|
|
|
|
using BackendWorkerService.Quartz;
|
|
|
|
|
using BackendWorkerService.Quartz.Jobs;
|
|
|
|
|
using BackendWorkerService.Services.Implement;
|
|
|
|
|
using BackendWorkerService.Services.Interface;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using Quartz.Impl;
|
|
|
|
|
using Quartz.Spi;
|
|
|
|
|
using Repository.BackendRepository.Implement;
|
|
|
|
|
using Repository.BackendRepository.Interface;
|
|
|
|
|
using Repository.BaseRepository.Implement;
|
|
|
|
|
using Repository.BaseRepository.Interface;
|
|
|
|
|
using Repository.FrontendRepository.Implement;
|
|
|
|
|
using Repository.FrontendRepository.Interface;
|
|
|
|
|
using Repository.Helper;
|
|
|
|
|
using Repository.Models;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BackendWorkerService
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
CreateHostBuilder(args).Build().Run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
|
|
|
Host.CreateDefaultBuilder(args)
|
|
|
|
|
.UseWindowsService()
|
|
|
|
|
.ConfigureServices((hostContext, services) =>
|
|
|
|
|
{
|
|
|
|
|
IConfiguration configuration = hostContext.Configuration;
|
|
|
|
|
|
|
|
|
|
services.AddLogging(
|
|
|
|
|
builder =>
|
|
|
|
|
{
|
|
|
|
|
builder.AddFilter("Microsoft", LogLevel.Warning)
|
|
|
|
|
.AddFilter("System", LogLevel.Warning)
|
|
|
|
|
.AddFilter("NToastNotify", LogLevel.Warning)
|
|
|
|
|
.AddConsole();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//services.AddHostedService<Worker>();
|
|
|
|
|
|
2023-06-06 16:43:46 +08:00
|
|
|
|
//#region <20>T<EFBFBD><54><EFBFBD>q<EFBFBD><71>
|
2022-10-14 16:08:54 +08:00
|
|
|
|
|
2023-06-06 16:43:46 +08:00
|
|
|
|
//#region SMPT<50>t<EFBFBD>m
|
|
|
|
|
//services.AddTransient<ISendEmailService, SendEmailService>();
|
|
|
|
|
//services.Configure<SMTPConfig>(configuration.GetSection("SMTPConfig"));
|
|
|
|
|
//#endregion
|
2022-10-14 16:08:54 +08:00
|
|
|
|
|
2023-06-06 16:43:46 +08:00
|
|
|
|
//#region SMS<4D>t<EFBFBD>m
|
|
|
|
|
//services.AddTransient<ISendSMSService, SendSMSService>();
|
|
|
|
|
//services.Configure<SMSConfig>(configuration.GetSection("SMSConfig"));
|
|
|
|
|
//#endregion
|
2022-10-14 16:08:54 +08:00
|
|
|
|
|
2023-06-06 16:43:46 +08:00
|
|
|
|
//#region Line Notify<66>t<EFBFBD>m
|
|
|
|
|
//services.AddTransient<ISendLineNotifyService, SendLineNotifyService>();
|
|
|
|
|
//#endregion
|
2022-10-14 16:08:54 +08:00
|
|
|
|
|
2023-06-06 16:43:46 +08:00
|
|
|
|
//#endregion <20>T<EFBFBD><54><EFBFBD>q<EFBFBD><71>
|
2022-10-14 16:08:54 +08:00
|
|
|
|
|
|
|
|
|
#region DBHelper <EFBFBD>`<EFBFBD>J
|
|
|
|
|
services.Configure<DBConfig>(configuration.GetSection("DBConfig"));
|
|
|
|
|
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
|
|
|
|
#endregion DBHelper <EFBFBD>`<EFBFBD>J
|
|
|
|
|
|
2023-03-02 14:24:34 +08:00
|
|
|
|
|
|
|
|
|
#region BackEndConfigHelper <EFBFBD>`<EFBFBD>J
|
|
|
|
|
services.Configure<BackEndConfig>(configuration.GetSection("BackEndConfig"));
|
|
|
|
|
services.AddTransient<IBackEndConfigHelper, BackEndConfigHelper>();
|
|
|
|
|
#endregion BackEndConfigHelper <EFBFBD>`<EFBFBD>J
|
|
|
|
|
|
|
|
|
|
|
2022-10-14 16:08:54 +08:00
|
|
|
|
#region Repository <EFBFBD>`<EFBFBD>J
|
|
|
|
|
services.AddTransient<IBackendRepository, BackendRepository>();
|
|
|
|
|
services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();
|
2023-05-04 16:45:05 +08:00
|
|
|
|
services.AddTransient<IBackgroundServiceMsSqlRepository, BackgroundServiceMsSqlRepository>();
|
2022-10-14 16:08:54 +08:00
|
|
|
|
services.AddTransient<IFrontendRepository, FrontendRepository>();
|
|
|
|
|
services.AddTransient<IBaseRepository, BaseRepository>();
|
|
|
|
|
#endregion Repository <EFBFBD>`<EFBFBD>J
|
|
|
|
|
|
|
|
|
|
//<2F>K<EFBFBD>[Quartz<74>A<EFBFBD><41>
|
|
|
|
|
services.AddTransient<IJobFactory, SingletonJobFactory>();
|
|
|
|
|
services.AddTransient<ISchedulerFactory, StdSchedulerFactory>();
|
|
|
|
|
services.AddHostedService<QuartzHostedService>();
|
|
|
|
|
|
2023-05-31 18:12:14 +08:00
|
|
|
|
//#region <20>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>p<EFBFBD>e(<28>]<5D>w1min<69><6E><EFBFBD><EFBFBD><EFBFBD>@<40><>)
|
|
|
|
|
//services.AddSingleton<ExecutionBackgroundServicePlanJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(ExecutionBackgroundServicePlanJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ExecutionBackgroundServicePlanJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region <20>T<EFBFBD><54><EFBFBD>q<EFBFBD><71>(<28>]<5D>w<EFBFBD>C 30min <20><><EFBFBD><EFBFBD><EFBFBD>@<40><>)
|
|
|
|
|
//services.AddSingleton<MessageNotificationJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(MessageNotificationJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:MessageNotificationJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region <20>w<EFBFBD>ɱN<C9B1>S<EFBFBD>w<EFBFBD><77><EFBFBD>ƪ<EFBFBD><C6AA>[<5B>J<EFBFBD>ܬ<EFBFBD><DCAC>e<EFBFBD><65><EFBFBD><EFBFBD>(<28>]<5D>w<EFBFBD>C<EFBFBD><43> 2AM <20><><EFBFBD><EFBFBD><EFBFBD>@<40><>)
|
|
|
|
|
//services.AddSingleton<RegularUpdateDBTableJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(RegularUpdateDBTableJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:RegularUpdateDBTableJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
//#region <20><><EFBFBD>Ƭ<EFBFBD><C6AC>e(<28>]<5D>w<EFBFBD>C 5min <20><><EFBFBD><EFBFBD><EFBFBD>@<40><>)
|
|
|
|
|
//services.AddSingleton<DataDeliveryJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(DataDeliveryJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:DataDeliveryJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
|
|
|
|
|
2024-02-01 15:06:59 +08:00
|
|
|
|
//#region <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>z(<28>]<5D>w<EFBFBD>C 5<><35> <20><><EFBFBD><EFBFBD><EFBFBD>@<40><>)
|
|
|
|
|
//services.AddSingleton<ParkingJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(ParkingJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ParkingJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
2023-05-31 18:12:14 +08:00
|
|
|
|
|
2023-11-16 17:00:10 +08:00
|
|
|
|
//#region <20>q<EFBFBD><71><EFBFBD>k<EFBFBD><6B>(<28>]<5D>w<EFBFBD>C <20>p<EFBFBD><70> <20><><EFBFBD><EFBFBD><EFBFBD>@<40><>)
|
|
|
|
|
//services.AddSingleton<ArchiveElectricMeterHourJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(ArchiveElectricMeterHourJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ArchiveElectricMeterHourJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
2023-06-06 16:43:46 +08:00
|
|
|
|
|
2022-10-14 16:08:54 +08:00
|
|
|
|
#region <EFBFBD>q<EFBFBD><EFBFBD><EFBFBD>k<EFBFBD><EFBFBD>(<EFBFBD>]<EFBFBD>w<EFBFBD>C <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<EFBFBD><EFBFBD>)
|
|
|
|
|
services.AddSingleton<ArchiveElectricMeterDayJob>();
|
|
|
|
|
services.AddSingleton(
|
|
|
|
|
new JobSchedule(jobType: typeof(ArchiveElectricMeterDayJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:ArchiveElectricMeterDayJob"))
|
|
|
|
|
);
|
|
|
|
|
#endregion
|
|
|
|
|
|
2024-02-01 15:06:59 +08:00
|
|
|
|
//#region <20>w<EFBFBD>ɨ<EFBFBD><C9A8>o<EFBFBD><6F><EFBFBD>HAPI
|
|
|
|
|
//services.AddSingleton<Quartz.Jobs.WeatherAPIJob>();
|
|
|
|
|
//services.AddSingleton(
|
|
|
|
|
//new JobSchedule(jobType: typeof(Quartz.Jobs.WeatherAPIJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:WeatherAPIJob"))
|
|
|
|
|
//);
|
|
|
|
|
//#endregion
|
2022-10-14 16:08:54 +08:00
|
|
|
|
|
|
|
|
|
}).ConfigureLogging((hostContext, logFactory) => {
|
|
|
|
|
IConfiguration configuration = hostContext.Configuration;
|
|
|
|
|
|
|
|
|
|
//logFactory.AddFile("Logs/log-{Date}.txt");
|
|
|
|
|
logFactory.AddFile(configuration.GetValue<string>("LoggerPath") + "/log-{Date}.txt");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|