2024-04-28 15:45:17 +08:00
|
|
|
#pragma warning disable SYSLIB1045
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using BITKit;
|
|
|
|
using IDIS.Services;
|
|
|
|
|
|
|
|
await BITAppForNet.InitializeAsync("IDIS");
|
|
|
|
|
2024-04-29 23:05:47 +08:00
|
|
|
var config = Path.Combine(Environment.CurrentDirectory,"appsettings.json");
|
|
|
|
if (File.Exists(config))
|
|
|
|
{
|
|
|
|
var json = File.ReadAllText(config);
|
|
|
|
DataParser.Set(json);
|
|
|
|
}
|
|
|
|
|
2024-04-28 15:45:17 +08:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
var cancellationTokenSource = new System.Threading.CancellationTokenSource();
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
2024-04-29 23:05:47 +08:00
|
|
|
builder.Services.AddTransient<IDIS_Service, IDIS_Service_MySQLBased>();
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IDIS_Statistics_MySQLBased>();
|
|
|
|
|
|
|
|
builder.Services.AddTransient<IDIS_TemplateService, IDIS_TemplateService_MySQLBased>();
|
2024-04-28 15:45:17 +08:00
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
var logger = app.Services.GetRequiredService<ILogger<Program>>();
|
|
|
|
|
|
|
|
#region 输入二级节点地址
|
|
|
|
|
|
|
|
logger.LogInformation("请输入二级节点地址,例如:88.123.99");
|
|
|
|
string? str;
|
2024-04-29 23:05:47 +08:00
|
|
|
while (true)
|
2024-04-28 15:45:17 +08:00
|
|
|
{
|
2024-04-29 23:05:47 +08:00
|
|
|
str = Console.ReadLine();
|
|
|
|
if (string.IsNullOrEmpty(str))
|
|
|
|
{
|
|
|
|
str = "88.123.99";
|
|
|
|
break;
|
|
|
|
}
|
2024-04-28 15:45:17 +08:00
|
|
|
const string pattern =@"^\d{1,3}\.\d{1,3}\.\d{1,3}$"; // 正则表达式模式
|
|
|
|
if (Regex.IsMatch(str,pattern))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
logger.LogInformation("错误的地址格式,请按照正确格式输入,例如:88.123.99");
|
|
|
|
}
|
2024-04-29 23:05:47 +08:00
|
|
|
logger.LogInformation("输入的地址符合要求。");
|
2024-04-28 15:45:17 +08:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
var idis_Service = app.Services.GetRequiredService<IDIS_Service>();
|
|
|
|
//idis_Service.PreAddress = str!;
|
|
|
|
|
2024-04-29 23:05:47 +08:00
|
|
|
app.Services.GetRequiredService<IDIS_Statistics_MySQLBased>();
|
|
|
|
|
2024-04-28 15:45:17 +08:00
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.MapGet("/", () => "Hello World!");
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
app.Run();
|