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.
71 lines
2.8 KiB
71 lines
2.8 KiB
using Application.Domain.Entities;
|
|
using Hangfire;
|
|
using Hangfire.LiteDB;
|
|
using Infrastructure.Data;
|
|
using Infrastructure.Email;
|
|
using Infrastructure.Extensions;
|
|
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.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using System.Linq;
|
|
|
|
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);
|
|
using var scope = app.ApplicationServices.CreateScope();
|
|
var services = scope.ServiceProvider;
|
|
var context = services.GetService<DbContext>();
|
|
var node = context.Set<Node>().FirstOrDefault();
|
|
node.Version = Helper.Instance.GetVersion();
|
|
context.SaveChanges();
|
|
|
|
var options = new DashboardOptions
|
|
{
|
|
Authorization = new[] { new CustomDashboardAuthorizationFilter() }
|
|
};
|
|
|
|
app.UseHangfireDashboard("/job", options);
|
|
|
|
app.UseHangfireServer();
|
|
}
|
|
}
|
|
} |