Add automatic controller propagation for dualpath machines

When a PC is assigned to control equipment that has a dualpath relationship,
the controller is now automatically propagated to the dualpath partner machine.

Changes:
- includes/db_helpers.asp: Add PropagateControllerToDualpathMachines() and
  PropagateControllerFromDualpathMachine() helper functions
- savemachine_direct.asp: Call propagation on new equipment creation
- savemachineedit.asp: Call propagation when editing equipment relationships
- api.asp: Add PropagateControllerToDualpathMachinesAPI() for PowerShell API

Also includes one-time fix script (sql/fix_dualpath_controller_relationships.sql)
that fixes 140 backwards relationships (Equipment->PC to PC->Equipment) and
propagates controllers to 30 dualpath machines that were missing them.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2025-12-10 20:04:01 -05:00
parent 30ea1bb42f
commit f8083be467
5 changed files with 407 additions and 0 deletions

View File

@@ -10,6 +10,7 @@
%>
<!--#include file="./includes/sql.asp"-->
<!--#include file="./includes/response.asp"-->
<!--#include file="./includes/db_helpers.asp"-->
<%
' Get and validate all inputs
Dim machinenumber, modelid, businessunitid, alias, machinenotes, mapleft, maptop
@@ -568,6 +569,9 @@
cmdRelPC.Execute
Set cmdRelPC = Nothing
On Error Goto 0
' Propagate controller to any dualpath machines
Call PropagateControllerToDualpathMachines(objConn, newMachineId, controllingpcVal)
End If
End If
@@ -601,6 +605,9 @@
cmdRelDual2.Execute
Set cmdRelDual2 = Nothing
On Error Goto 0
' Propagate controller from dualpath partner if exists
Call PropagateControllerFromDualpathMachine(objConn, newMachineId, dualpathidVal)
End If
End If