fix(template-engine): DiffService covers native alarm sources — Deployments diff view no longer blind to native-alarm edits

Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
Joseph Doherty
2026-07-09 16:42:00 -04:00
parent 0302694f9a
commit d833219920
3 changed files with 133 additions and 3 deletions
@@ -4,7 +4,8 @@ namespace ZB.MOM.WW.ScadaBridge.TemplateEngine.Flattening;
/// <summary>
/// Compares two FlattenedConfigurations (deployed vs current) and produces a ConfigurationDiff
/// showing Added, Removed, and Changed entries for attributes, alarms, and scripts.
/// showing Added, Removed, and Changed entries for attributes, alarms, scripts,
/// and native alarm sources.
/// </summary>
public class DiffService
{
@@ -42,6 +43,12 @@ public class DiffService
s => s.CanonicalName,
ScriptsEqual);
var nativeAlarmSourceChanges = ComputeEntityDiff(
oldConfig?.NativeAlarmSources ?? [],
newConfig.NativeAlarmSources,
n => n.CanonicalName,
NativeAlarmSourcesEqual);
// Surface standalone connection endpoint/protocol/
// failover drift. Per-attribute binding changes already show up under
// AttributeChanges, but a connection's own ConfigurationJson /
@@ -57,6 +64,7 @@ public class DiffService
AttributeChanges = attributeChanges,
AlarmChanges = alarmChanges,
ScriptChanges = scriptChanges,
NativeAlarmSourceChanges = nativeAlarmSourceChanges,
ConnectionChanges = connectionChanges
};
}
@@ -138,6 +146,13 @@ public class DiffService
a.TriggerConfiguration == b.TriggerConfiguration &&
a.OnTriggerScriptCanonicalName == b.OnTriggerScriptCanonicalName;
private static bool NativeAlarmSourcesEqual(ResolvedNativeAlarmSource a, ResolvedNativeAlarmSource b) =>
a.CanonicalName == b.CanonicalName &&
a.ConnectionName == b.ConnectionName &&
a.SourceReference == b.SourceReference &&
a.ConditionFilter == b.ConditionFilter &&
a.IsLocked == b.IsLocked;
private static bool ScriptsEqual(ResolvedScript a, ResolvedScript b) =>
a.CanonicalName == b.CanonicalName &&
a.Code == b.Code &&