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.
57 lines
2.0 KiB
57 lines
2.0 KiB
using Application.Domain.Entities;
|
|
using IoT.Shared.DeviceServices.FBee;
|
|
using IoT.Shared.DeviceServices.Onvif;
|
|
using IoT.Shared.DeviceServices.SerialPort;
|
|
using IoT.Shared.Infrastructure;
|
|
using IoT.UI.Shard;
|
|
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;
|
|
using System.Threading.Tasks;
|
|
using Infrastructure.Extensions;
|
|
|
|
namespace IoTNode
|
|
{
|
|
public class Startup : IoTServiceStartup
|
|
{
|
|
public Startup(IConfiguration configuration, IHostingEnvironment env) : base(configuration, env)
|
|
{
|
|
}
|
|
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddSingleton<ClientService>();
|
|
//services.AddSingleton<SerialPortService>();
|
|
services.AddSingleton<OnvifService>();
|
|
//services.AddSingleton<FBeeService>();
|
|
base.ConfigureServices(services);
|
|
}
|
|
|
|
public override void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
{
|
|
base.Configure(app, env, loggerFactory);
|
|
Task.Run(() =>
|
|
{
|
|
app.ApplicationServices.GetService<ClientService>().Start();
|
|
app.ApplicationServices.GetService<SerialPortService>()?.Start();
|
|
app.ApplicationServices.GetService<OnvifService>()?.Start();
|
|
//app.ApplicationServices.GetService<FBeeService>()?.Start();
|
|
});
|
|
}
|
|
|
|
public override void Seed(DbContext dbContext, IServiceProvider serviceProvider, IConfiguration configuration)
|
|
{
|
|
dbContext.Set<Node>().Add(new Node
|
|
{
|
|
Name = configuration["node.number"],
|
|
Number = configuration["node.number"],
|
|
});
|
|
dbContext.SaveChanges();
|
|
base.Seed(dbContext, serviceProvider, configuration);
|
|
}
|
|
}
|
|
} |