fix(native-alarms): a 4-column CSV import keeps stored MES overrides on the CLI path too (ScadaBridge#104)

The bulk SetInstanceNativeAlarmSourceOverridesCommand handler always wrote the
entry's IsMesReportableOverride, so a CLI import of a legacy 4-column CSV (no
MesReportable column) reset every imported source's MES override to inherit. The
Central UI avoided it only by looking up the stored flag client-side.

NativeAlarmSourceOverrideEntry gains an additive trailing KeepStoredMesReportable
flag: when set, the server leaves an existing row's MES override untouched (a new
row inherits) and ignores IsMesReportableOverride; unset keeps the old meaning
(null = clear to inherit), so older senders are unaffected. The CLI and the Central
UI now build their entries through one rule (ToOverrideEntry on each row type):
no MesReportable column => KeepStoredMesReportable. CLI README and
Component-CentralUI updated.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 15:41:33 -05:00
parent a81dac76ed
commit 063fb21815
11 changed files with 197 additions and 16 deletions
@@ -68,4 +68,35 @@ public class ImportNativeAlarmSourceOverridesTests
Assert.Null(entries[1].SourceReferenceOverride);
Assert.Null(entries[1].ConditionFilterOverride);
}
// ── MES flag (ScadaBridge#104) ───────────────────────────────────────────
/// <summary>A legacy 4-column file leaves the MES flag unspecified, so the server keeps it.</summary>
[Fact]
public void FourColumnCsv_EntryKeepsStoredMesFlag()
{
var parsed = NativeAlarmSourceOverrideCsvParser.Parse("SourceName,Connection,SourceReference,Filter\nPressure,ConnA,,");
var entry = Assert.Single(parsed.Rows).ToOverrideEntry();
Assert.True(entry.KeepStoredMesReportable);
Assert.Null(entry.IsMesReportableOverride);
Assert.Equal("ConnA", entry.ConnectionNameOverride);
}
/// <summary>A file with the MesReportable column is authoritative, blank included (= inherit).</summary>
[Fact]
public void FiveColumnCsv_EntrySpecifiesMesFlag()
{
var parsed = NativeAlarmSourceOverrideCsvParser.Parse(
"SourceName,Connection,SourceReference,Filter,MesReportable\nPressure,,,,false\nTemp,,,,");
var pressure = parsed.Rows[0].ToOverrideEntry();
var temp = parsed.Rows[1].ToOverrideEntry();
Assert.False(pressure.KeepStoredMesReportable);
Assert.False(pressure.IsMesReportableOverride);
Assert.False(temp.KeepStoredMesReportable);
Assert.Null(temp.IsMesReportableOverride);
}
}