93 lines
4.2 KiB
C#
93 lines
4.2 KiB
C#
|
using FrontendWorkerService.Models;
|
|||
|
using FrontendWorkerService.Quartz;
|
|||
|
using FrontendWorkerService.Quartz.Jobs;
|
|||
|
using Microsoft.AspNetCore.Hosting;
|
|||
|
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.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 FrontendWorkerService
|
|||
|
{
|
|||
|
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.Configure<ObixApiConfig>(configuration.GetSection("ObixApiConfig"));
|
|||
|
|
|||
|
#region DBHelper <EFBFBD>`<EFBFBD>J
|
|||
|
services.Configure<DBConfig>(configuration.GetSection("DBConfig"));
|
|||
|
services.AddTransient<IDatabaseHelper, DatabaseHelper>();
|
|||
|
#endregion DBHelper <EFBFBD>`<EFBFBD>J
|
|||
|
|
|||
|
#region Repository <EFBFBD>`<EFBFBD>J
|
|||
|
//services.AddTransient<IBackendRepository, BackendRepository>();
|
|||
|
//services.AddTransient<IBackgroundServiceRepository, BackgroundServiceRepository>();
|
|||
|
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>();
|
|||
|
|
|||
|
#region <EFBFBD>q<EFBFBD>\<EFBFBD>]<EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><EFBFBD>(<EFBFBD>]<EFBFBD>w<EFBFBD>C<EFBFBD><EFBFBD>01:00 AM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<EFBFBD><EFBFBD>)
|
|||
|
services.AddSingleton<OnTimeDeviceSubscriptionJob>();
|
|||
|
services.AddSingleton(
|
|||
|
new JobSchedule(jobType: typeof(OnTimeDeviceSubscriptionJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:OnTimeDeviceSubscriptionJob"))
|
|||
|
);
|
|||
|
#endregion
|
|||
|
|
|||
|
#region <EFBFBD><EFBFBD><EFBFBD>s<EFBFBD>Y<EFBFBD>ɭ<EFBFBD>(<EFBFBD>]<EFBFBD>w5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<EFBFBD><EFBFBD>)
|
|||
|
services.AddSingleton<OnTimeDeviceRawDataJob>();
|
|||
|
services.AddSingleton(
|
|||
|
new JobSchedule(jobType: typeof(OnTimeDeviceRawDataJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:OnTimeDeviceRawDataJob"))
|
|||
|
);
|
|||
|
#endregion
|
|||
|
|
|||
|
#region <EFBFBD>Y<EFBFBD>ɧiĵ<EFBFBD>q<EFBFBD>\<EFBFBD>]<EFBFBD><EFBFBD><EFBFBD>I<EFBFBD><EFBFBD>(<EFBFBD>]<EFBFBD>w<EFBFBD>C<EFBFBD><EFBFBD>01:00 AM <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<EFBFBD><EFBFBD>)
|
|||
|
services.AddSingleton<OntimeAlarmDeviceSubscriptionJob>();
|
|||
|
services.AddSingleton(
|
|||
|
new JobSchedule(jobType: typeof(OntimeAlarmDeviceSubscriptionJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:OntimeAlarmDeviceSubscriptionJob"))
|
|||
|
);
|
|||
|
#endregion
|
|||
|
|
|||
|
#region <EFBFBD><EFBFBD><EFBFBD>s<EFBFBD>iĵ<EFBFBD>]<EFBFBD>ƪ<EFBFBD><EFBFBD>A<EFBFBD><EFBFBD>(<EFBFBD>]<EFBFBD>w5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>@<EFBFBD><EFBFBD>)
|
|||
|
services.AddSingleton<OntimeAlarmDeviceRawDataJob>();
|
|||
|
services.AddSingleton(
|
|||
|
new JobSchedule(jobType: typeof(OntimeAlarmDeviceRawDataJob), cronExpression: configuration.GetValue<string>("BackgroundServiceCron:OntimeAlarmDeviceRawDataJob"))
|
|||
|
);
|
|||
|
#endregion
|
|||
|
}).ConfigureLogging((hostContext, logFactory) => {
|
|||
|
IConfiguration configuration = hostContext.Configuration;
|
|||
|
|
|||
|
//logFactory.AddFile("Logs/log-{Date}.txt");
|
|||
|
logFactory.AddFile(configuration.GetValue<string>("LoggerPath") + "/log-{Date}.txt");
|
|||
|
});
|
|||
|
}
|
|||
|
}
|