- Add AgentState read model (Models/AgentState.cs) - Add IAgentStateRepository interface with GetAllAsync, GetBySessionKeyAsync, UpdateStatusAsync - Add AgentStateRepository EF Core implementation mapping Agent entity → AgentState model - Register IAgentStateRepository in DI (Program.cs) - Exclude ControlCenter sub-project from Api compilation Build: 0 warnings, 0 errors
42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using ControlCenter.Api.Data;
|
|
using ControlCenter.Api.Hubs;
|
|
using ControlCenter.Api.Repositories;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
builder.Services.AddOpenApi();
|
|
|
|
// Register SignalR for real-time agent status updates
|
|
builder.Services.AddSignalR();
|
|
|
|
// Register Agent State Repository
|
|
builder.Services.AddScoped<IAgentStateRepository, AgentStateRepository>();
|
|
|
|
// Register DbContext with PostgreSQL
|
|
builder.Services.AddDbContext<AppDbContext>(options =>
|
|
{
|
|
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection")
|
|
?? "Host=localhost;Database=control_center;Username=postgres;Password=postgres";
|
|
|
|
options.UseNpgsql(connectionString, npgsqlOptions =>
|
|
{
|
|
npgsqlOptions.MigrationsAssembly(typeof(AppDbContext).Assembly.FullName);
|
|
});
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.MapOpenApi();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
// Map SignalR hubs
|
|
app.MapHub<AgentStatusHub>("/hubs/agent-status");
|
|
|
|
app.Run(); |