function Synchronise($p_oMaster, $p_oNonMaster, $p_nSystemId = 0) { $this->m_nError = $this->m_nDBO_OK; $p_oMaster->SetSynchronising(true); $p_oNonMaster->SetSynchronising(true); $sOrder = "CONFIGID"; $this->SetOrder($sOrder); $this->Select($p_oMaster); $oNonMaster = new CRowtblconfig(); $oNonMaster->SetOrder($sOrder); $oNonMaster->Select($p_oNonMaster); while (!($this->GetEof() && $oNonMaster->GetEof())) { $nCompare = 0; if ($this->GetEof()) { $nCompare = 1; } else { if ($oNonMaster->GetEof()) { $nCompare = -1; } else { if ($this->m_nConfigId > $oNonMaster->GetConfigId()) { $nCompare = 1; } else { if ($this->m_nConfigId < $oNonMaster->GetConfigId()) { $nCompare = -1; } } } } if ($nCompare == 0) { $nUpdate = 0; if ($nUpdate != 0) { if ($p_nSystemId == -1) { $nUpdate = 1; } else { if ($oNonMaster->GetConfigId() <= $p_nSystemId) { $nUpdate = 1; } } } if ($nUpdate == 1) { if (!$this->Update($p_oNonMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } else { if (!$oNonMaster->Update($p_oMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } $oNonMaster->MoveNext(); $this->MoveNext(); } else { if ($nCompare > 0) { if ($p_nSystemId == -1) { if (!$oNonMaster->Delete($p_oNonMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } else { if ($oNonMaster->GetConfigId() <= $p_nSystemId) { if (!$oNonMaster->Delete($p_oNonMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } else { if (!$oNonMaster->Insert($p_oMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } } $oNonMaster->MoveNext(); } else { if ($p_nSystemId == -1) { if (!$this->Insert($p_oNonMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } else { if ($this->m_nConfigId <= $p_nSystemId) { if (!$this->Insert($p_oNonMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } else { if (!$this->Delete($p_oMaster)) { $this->m_nError = $this->m_nDBO_SYNC_FAILURE; $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return false; } } } $this->MoveNext(); } } } $p_oMaster->SetSynchronising(false); $p_oNonMaster->SetSynchronising(false); return true; }
$sXML .= $oCompleted->GetOutXML(); } else { $bError = true; $sXML .= $oCompleted->GetOutXML(); $sMessage .= $sXML; $sXML = ""; } } $oCompleted->MoveNext(); } } } if ($nCommandGroup == $nConfEdit) { $oConfig = new CRowtblconfig(); $oConfig->SetParam("ZONES"); $oConfig->Select($oSession); $sZones = $oConfig->GetValue(); $oConfig->Clear(); $oConfig->SetParam("TIMEOUT"); $oConfig->Select($oSession); $nTimeout = $oConfig->GetValue() / 1000; $_SESSION["timeout"] = $nTimeout; $_SESSION["zones"] = $sZones; } $sHeader = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"; if ($sFormat == "xslt") { $sHeader .= "<?xml-stylesheet type=\"text/xsl\" href=\"heating_" . $sTrans . ".xsl\" ?>"; } $sHeader .= "<" . $sRootTag . " current=\"" . $nCommandGroup . "\" home=\"" . $nHome . "\" polledit=\"" . $nPollEdit . "\" alertedit=\"" . $nAlertEdit . "\" conditionedit=\"" . $nCondEdit . "\" commandedit=\"" . $nCmdEdit . "\">"; if (!$bError) { $sHeader .= $sZones;