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 = "COMPLETEDID"; $this->SetOrder($sOrder); $this->Select($p_oMaster); $oNonMaster = new CRowtblcompleted(); $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_nCompletedId > $oNonMaster->GetCompletedId()) { $nCompare = 1; } else { if ($this->m_nCompletedId < $oNonMaster->GetCompletedId()) { $nCompare = -1; } } } } if ($nCompare == 0) { $nUpdate = 0; if ($nUpdate != 0) { if ($p_nSystemId == -1) { $nUpdate = 1; } else { if ($oNonMaster->GetCompletedId() <= $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->GetCompletedId() <= $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_nCompletedId <= $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; }
} else { $sXML = substr($sXML, 0, $nIndex) . " mode=\"" . $sMode . "\" val=\"{$nIndex}-{$nIndexEnd}\"" . substr($sXML, $nIndex); } $sMessage .= $sXML; $sXML = ""; } else { if ($oCompleted->GetSuccess() == 5) { $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; }