2024-06-24 09:27:12 +00:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-09-22 05:27:52 +00:00
|
|
|
using Microsoft.OpenApi.Validations;
|
2024-09-05 09:48:08 +00:00
|
|
|
using RemoteServer;
|
2024-06-24 09:27:12 +00:00
|
|
|
using RemoteServer.Models;
|
|
|
|
|
2024-06-21 04:32:55 +00:00
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
2024-09-05 09:48:08 +00:00
|
|
|
ConfigurationBuilder configurationBuilder = new();
|
|
|
|
|
2024-06-21 04:32:55 +00:00
|
|
|
// Add services to the container.
|
|
|
|
|
2024-09-05 09:48:08 +00:00
|
|
|
//添加配置文件路径
|
2024-10-11 01:04:58 +00:00
|
|
|
foreach (var x in builder.Configuration.GetSection("NamePwds").GetChildren())
|
|
|
|
{
|
|
|
|
var it = x.GetChildren();
|
|
|
|
RemoteSyncServerFactory.NamePwd.Add(
|
|
|
|
new Tuple<string, string>(it.ElementAt(0).Value ?? "", it.ElementAt(1).Value ?? "")
|
|
|
|
);
|
|
|
|
}
|
2024-09-27 07:02:55 +00:00
|
|
|
RemoteSyncServer.SqlPackageAbPath =
|
|
|
|
builder.Configuration["SqlPackageAbPath"]
|
|
|
|
?? "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
|
2024-09-07 06:46:08 +00:00
|
|
|
RemoteSyncServer.TempRootFile = builder.Configuration["TempDir"] ?? "C:/TempPack";
|
2024-06-21 04:32:55 +00:00
|
|
|
builder.Services.AddControllers();
|
2024-09-05 09:48:08 +00:00
|
|
|
builder.Services.AddDbContext<SqliteDbContext>(opions =>
|
|
|
|
{
|
2024-06-24 09:27:12 +00:00
|
|
|
opions.UseSqlite(builder.Configuration.GetConnectionString("DbPath"));
|
|
|
|
});
|
2024-06-21 04:32:55 +00:00
|
|
|
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen();
|
2024-09-07 06:46:08 +00:00
|
|
|
builder.Services.AddSingleton<RemoteSyncServerFactory>();
|
2024-06-21 04:32:55 +00:00
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
}
|
2024-09-05 01:59:57 +00:00
|
|
|
app.UseWebSockets();
|
2024-10-17 07:24:30 +00:00
|
|
|
|
2024-11-01 08:20:34 +00:00
|
|
|
app.Urls.Clear();
|
|
|
|
app.Urls.Add("http://0.0.0.0:6819");
|
2024-06-21 04:32:55 +00:00
|
|
|
app.MapControllers();
|
2024-09-27 07:02:55 +00:00
|
|
|
app.Run();
|