삽질하다 도저히 문제 파악이 안돼서 opcUaManager로 분리 테스트 중

This commit is contained in:
2026-02-25 08:52:03 +09:00
parent 4ea351946a
commit e88ab87771
138 changed files with 1051971 additions and 351 deletions

View File

@@ -1,27 +1,58 @@
using OpcPks.Core.Services;
using OpcPks.Core.Models;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// -----------------------------------------------------------
// 1. 공통 경로 설정
// -----------------------------------------------------------
string baseDataPath = "/home/pacer/projects/OpcPksPlatform/OpcPks.Core/Data";
// -----------------------------------------------------------
// 2. 서비스 등록 (Dependency Injection)
// -----------------------------------------------------------
builder.Services.AddControllersWithViews();
// [수정] OpcSessionManager를 먼저 등록해야 Generator에서 가져다 쓸 수 있습니다.
builder.Services.AddSingleton<OpcSessionManager>();
// [수정] 팩토리 메서드를 사용하여 OpcSessionManager를 주입(Injection)합니다.
builder.Services.AddSingleton<CertificateGenerator>(sp =>
{
var sessionManager = sp.GetRequiredService<OpcSessionManager>();
return new CertificateGenerator(baseDataPath, sessionManager);
});
var app = builder.Build();
// Configure the HTTP request pipeline.
// -----------------------------------------------------------
// 3. 실행 환경 설정
// -----------------------------------------------------------
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//app.UseHttpsRedirection();
// -----------------------------------------------------------
// 4. 미들웨어 및 라우팅 설정
// -----------------------------------------------------------
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
// 컨트롤러 루트 매핑
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
// [이미지: ASP.NET Core Dependency Injection Container flow]
// -----------------------------------------------------------
// 5. 서버 가동
// -----------------------------------------------------------
Console.WriteLine("🚀 OpcPksPlatform 서버 대기 중... (http://0.0.0.0:5000)");
Console.WriteLine("💡 사용자가 '인증서 생성' 버튼을 누를 때까지 대기합니다.");
app.Run();