FileSqlServerSync/Server/RemoteServer/Program.cs
zerlei 35a0710ab5 fix: websocket pipeline 测试修复了大量的问题,一大部分是对websocket和c# 不熟悉所致。
- 上传文件bug修复
- 继续测试修改bug
- 代码审查处理,添加必要注释,风格规范性等
2024-10-12 22:01:48 +08:00

51 lines
1.5 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Validations;
using RemoteServer;
using RemoteServer.Models;
var builder = WebApplication.CreateBuilder(args);
ConfigurationBuilder configurationBuilder = new();
// Add services to the container.
//添加配置文件路径
RemoteSyncServerFactory.NamePwd =
[
.. (builder.Configuration.GetSection("NamePwds").Get<Tuple<string, string>[]>() ?? [])
];
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 ?? "")
);
}
RemoteSyncServer.SqlPackageAbPath =
builder.Configuration["SqlPackageAbPath"]
?? "C:\\Users\\ZHAOLEI\\.dotnet\\tools\\sqlpackage.exe";
RemoteSyncServer.TempRootFile = builder.Configuration["TempDir"] ?? "C:/TempPack";
builder.Services.AddControllers();
builder.Services.AddDbContext<SqliteDbContext>(opions =>
{
opions.UseSqlite(builder.Configuration.GetConnectionString("DbPath"));
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<RemoteSyncServerFactory>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseWebSockets();
app.Urls.Clear();
app.Urls.Add("http://0.0.0.0:6819");
app.MapControllers();
app.Run();