9e97c1acd2
Central now resolves site Akka remoting addresses from the Sites DB table (NodeAAddress/NodeBAddress) instead of relying on runtime RegisterSite messages. Eliminates the race condition where sites starting before central had their registration dead-lettered. Addresses are cached in CentralCommunicationActor with 60s periodic refresh and on-demand refresh when sites are added/edited/deleted via UI or CLI.
72 lines
2.0 KiB
C#
72 lines
2.0 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using ScadaLink.Commons.Entities.Sites;
|
|
|
|
namespace ScadaLink.ConfigurationDatabase.Configurations;
|
|
|
|
public class SiteConfiguration : IEntityTypeConfiguration<Site>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Site> builder)
|
|
{
|
|
builder.HasKey(s => s.Id);
|
|
|
|
builder.Property(s => s.Name)
|
|
.IsRequired()
|
|
.HasMaxLength(200);
|
|
|
|
builder.Property(s => s.SiteIdentifier)
|
|
.IsRequired()
|
|
.HasMaxLength(100);
|
|
|
|
builder.Property(s => s.Description)
|
|
.HasMaxLength(2000);
|
|
|
|
builder.Property(s => s.NodeAAddress).HasMaxLength(500);
|
|
builder.Property(s => s.NodeBAddress).HasMaxLength(500);
|
|
|
|
builder.HasIndex(s => s.Name).IsUnique();
|
|
builder.HasIndex(s => s.SiteIdentifier).IsUnique();
|
|
}
|
|
}
|
|
|
|
public class DataConnectionConfiguration : IEntityTypeConfiguration<DataConnection>
|
|
{
|
|
public void Configure(EntityTypeBuilder<DataConnection> builder)
|
|
{
|
|
builder.HasKey(d => d.Id);
|
|
|
|
builder.Property(d => d.Name)
|
|
.IsRequired()
|
|
.HasMaxLength(200);
|
|
|
|
builder.Property(d => d.Protocol)
|
|
.IsRequired()
|
|
.HasMaxLength(50);
|
|
|
|
builder.Property(d => d.Configuration)
|
|
.HasMaxLength(4000);
|
|
|
|
builder.HasIndex(d => d.Name).IsUnique();
|
|
}
|
|
}
|
|
|
|
public class SiteDataConnectionAssignmentConfiguration : IEntityTypeConfiguration<SiteDataConnectionAssignment>
|
|
{
|
|
public void Configure(EntityTypeBuilder<SiteDataConnectionAssignment> builder)
|
|
{
|
|
builder.HasKey(a => a.Id);
|
|
|
|
builder.HasOne<Site>()
|
|
.WithMany()
|
|
.HasForeignKey(a => a.SiteId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasOne<DataConnection>()
|
|
.WithMany()
|
|
.HasForeignKey(a => a.DataConnectionId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
builder.HasIndex(a => new { a.SiteId, a.DataConnectionId }).IsUnique();
|
|
}
|
|
}
|