You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.7 KiB
66 lines
2.7 KiB
using Hangfire;
|
|
using Hangfire.LiteDB;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Email;
|
|
using Infrastructure.Web;
|
|
using IoT.Shared.Services;
|
|
using IoTNode.DeviceServices.FBee;
|
|
using IoTNode.DeviceServices.Onvif;
|
|
using IoTNode.DeviceServices.SerialPortManager;
|
|
using IoTNode.Services;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace IoTNode
|
|
{
|
|
public class Startup : BaseStartup
|
|
{
|
|
public Startup(IConfiguration configuration, IWebHostEnvironment env) : base(configuration, env)
|
|
{
|
|
}
|
|
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddHangfire(o => o.UseLiteDbStorage("job.db"));
|
|
services.AddTransient<SceneTiggerService>();
|
|
services.AddTransient<ISceneTiggerService, CachedSceneTiggerService>();
|
|
services.AddTransient<IDbConfig, DbConfig>();
|
|
services.AddTransient<IRoleService, RoleService>();
|
|
services.AddTransient<DataService>();
|
|
services.AddTransient<IoTNodeJob>();
|
|
services.AddSingleton<IoTNodeClient>();
|
|
services.AddSingleton<IOnvifDeviceManagement, OnvifDeviceManagement>();
|
|
services.AddSingleton<OnvifService>();
|
|
services.AddSingleton<FBeeService>();
|
|
services.AddSingleton<SerialPortService>();
|
|
services.AddHostedService(o => o.GetService<IoTNodeClient>());
|
|
services.AddHostedService(o => o.GetService<OnvifService>());
|
|
services.AddHostedService(o => o.GetService<FBeeService>());
|
|
services.AddHostedService(o => o.GetService<SerialPortService>());
|
|
services.AddTransient<IEmailSender, EmptyEmailSender>();
|
|
base.ConfigureServices(services);
|
|
}
|
|
|
|
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
|
{
|
|
base.Configure(app, env, loggerFactory);
|
|
app.UseHangfireDashboard(pathMatch: "/job");
|
|
|
|
app.UseHangfireServer();
|
|
|
|
//Task.Run(() =>
|
|
//{
|
|
// using var scope = app.ApplicationServices.CreateScope();
|
|
// var timerRepo = scope.ServiceProvider.GetService<IRepository<SceneTimer>>();
|
|
// var timers = timerRepo.ReadOnlyTable().Where(o => o.Scene.NodeId != null).ToList();
|
|
// foreach (var timer in timers)
|
|
// {
|
|
// RecurringJob.AddOrUpdate<IoTNodeJob>(timer.Id.ToString(), o => o.TimerHanle(timer.Id), timer.Cron, TimeZoneInfo.Local);
|
|
// }
|
|
//});
|
|
}
|
|
}
|
|
} |