|
|
@ -6,17 +6,18 @@ using HybirdFrameworkCore.Autofac;
|
|
|
|
using HybirdFrameworkCore.Configuration;
|
|
|
|
using HybirdFrameworkCore.Configuration;
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
using HybirdFrameworkCore.Redis;
|
|
|
|
using HybirdFrameworkCore.Redis;
|
|
|
|
|
|
|
|
using log4net;
|
|
|
|
using Mapster;
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
|
using Service.Cloud.Client;
|
|
|
|
using Service.Cloud.Client;
|
|
|
|
using Service.Execute;
|
|
|
|
using Service.Execute;
|
|
|
|
using Service.Execute.StaticTools;
|
|
|
|
|
|
|
|
using Service.Plc.Client;
|
|
|
|
using Service.Plc.Client;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar;
|
|
|
|
using SqlSugar.IOC;
|
|
|
|
using SqlSugar.IOC;
|
|
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
var log = LogManager.GetLogger(typeof(Program));
|
|
|
|
|
|
|
|
|
|
|
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
|
|
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
|
|
|
builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
|
|
|
|
builder.Host.ConfigureContainer<ContainerBuilder>(cb =>
|
|
|
@ -63,17 +64,12 @@ builder.Services.AddCors(options =>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//redis
|
|
|
|
//redis
|
|
|
|
var section = builder.Configuration.GetSection("Redis");
|
|
|
|
var redisConnectionString = AppSettingsHelper.GetContent("Redis", "Connection");
|
|
|
|
//连接字符串
|
|
|
|
var instanceName = AppSettingsHelper.GetContent("Redis", "InstanceName");//默认数据库
|
|
|
|
var redisConnectionString = section.GetSection("Connection").Value;
|
|
|
|
var defaultDb = int.Parse(AppSettingsHelper.GetContent("Redis", "DefaultDB") ?? "0");
|
|
|
|
//实例名称
|
|
|
|
|
|
|
|
var instanceName = section.GetSection("InstanceName").Value;
|
|
|
|
|
|
|
|
//默认数据库
|
|
|
|
|
|
|
|
var _defaultDB = int.Parse(section.GetSection("DefaultDB").Value ?? "0");
|
|
|
|
|
|
|
|
if (redisConnectionString != null && instanceName != null)
|
|
|
|
if (redisConnectionString != null && instanceName != null)
|
|
|
|
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, _defaultDB));
|
|
|
|
builder.Services.AddSingleton(new RedisHelper(redisConnectionString, instanceName, defaultDb));
|
|
|
|
|
|
|
|
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -122,12 +118,6 @@ builder.Services.AddAuthentication(options =>
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
//Json 序列化
|
|
|
|
|
|
|
|
builder.Services.AddControllers().AddJsonOptions(configure =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
configure.JsonSerializerOptions.Converters.Add(new DatetimeJsonConverter());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,12 +126,9 @@ var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseStaticFiles();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseAuthorization();
|
|
|
|
app.UseCors("myCors");
|
|
|
|
app.UseCors("myCors");
|
|
|
@ -150,6 +137,7 @@ app.MapControllers();
|
|
|
|
var list = AppSettingsHelper.GetContent("Kestrel", "Endpoints", "http", "Url");
|
|
|
|
var list = AppSettingsHelper.GetContent("Kestrel", "Endpoints", "http", "Url");
|
|
|
|
foreach (var s in list.Split(";"))
|
|
|
|
foreach (var s in list.Split(";"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
log.Info($"use url={s}");
|
|
|
|
app.Urls.Add(s);
|
|
|
|
app.Urls.Add(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -157,10 +145,28 @@ foreach (var s in list.Split(";"))
|
|
|
|
AppInfo.Container = app.Services.GetAutofacRoot();
|
|
|
|
AppInfo.Container = app.Services.GetAutofacRoot();
|
|
|
|
|
|
|
|
|
|
|
|
//云平台
|
|
|
|
//云平台
|
|
|
|
|
|
|
|
if (AppSettingsHelper.GetBool("cloud", "enable"))
|
|
|
|
|
|
|
|
{
|
|
|
|
CloudClientMgr.Init();
|
|
|
|
CloudClientMgr.Init();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//PLC
|
|
|
|
//PLC
|
|
|
|
|
|
|
|
if (AppSettingsHelper.GetBool("plc", "enable"))
|
|
|
|
|
|
|
|
{
|
|
|
|
PlcMgr.Init();
|
|
|
|
PlcMgr.Init();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//启动换电流程
|
|
|
|
//启动换电流程
|
|
|
|
//StationSoftMgr.SwappingStateMachineStart();
|
|
|
|
if (AppSettingsHelper.GetBool("swap", "enable"))
|
|
|
|
//StationSoftMgr.StartTasks();
|
|
|
|
{
|
|
|
|
|
|
|
|
StationSoftMgr.SwappingStateMachineStart();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Task
|
|
|
|
|
|
|
|
if (AppSettingsHelper.GetBool("task", "enable"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
StationSoftMgr.StartTasks();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.Run();
|
|
|
|
app.Run();
|