public function service() { set_time_limit(1000); $t = microtime(true); while (true) { $tmpRows = RealVoterNumberTmpManager::getInstance()->selectAdvance('*', ['synced', '=', '0', 'and', 'create_datetime', '<', "'" . date('Y-m-d H:i:s', strtotime('-16 seconds')) . "'"]); foreach ($tmpRows as $tmpRow) { $areaVoterId = $tmpRow->getAreaVoterId(); $voterId = $tmpRow->getVoterId(); $areaId = $tmpRow->getAreaId(); $observerId = $tmpRow->getObserverId(); $datetime = $tmpRow->getCreateDatetime(); $rows = RealVoterNumberManager::getInstance()->selectAdvance('*', ['moderator_id', '=', 0, 'and', 'area_id', '=', $areaId, 'and', 'area_voter_id', '=', $areaVoterId, 'and', 'NOT', "FIND_IN_SET('{$observerId}',`observers_ids`)"]); if (!empty($rows)) { $row = $rows[0]; $observersIds = $row->getObserversIds(); $observersIdsArray = explode(',', $observersIds); $observersIdsArray[] = $observerId; $row->setObserversIds(implode(',', $observersIdsArray)); RealVoterNumberManager::getInstance()->updateByPK($row); } else { RealVoterNumberManager::getInstance()->addRowForObserver($areaVoterId, $voterId, $areaId, $observerId, $datetime); } RealVoterNumberTmpManager::getInstance()->updateField($tmpRow->getId(), 'synced', 1); } sleep(1); $deltaSeconds = microtime(true) - $t; if ($deltaSeconds > 58) { break; } } }
public function service() { unset($_SESSION['can_revert']); $userId = NGS()->getSessionManager()->getUserId(); $observerDto = ObserverManager::getInstance()->selectByPK($userId); $areaId = $observerDto->getAreaId(); $observerId = NGS()->getSessionManager()->getUserId(); $ret = RealVoterNumberTmpManager::getInstance()->revertObserverLastInput($areaId, $observerId); if (!$ret) { $_SESSION['error_message'] = "You can not revert!"; } $this->redirect(''); }
public function service() { if (!isset(NGS()->args()->number) || empty(NGS()->args()->number) || NGS()->args()->number <= 0) { $_SESSION['error_message'] = "Please input positive number"; $this->redirect(''); } $number = intval(NGS()->args()->getNumber()); $userId = NGS()->getSessionManager()->getUserId(); $observerDto = ObserverManager::getInstance()->selectByPK($userId); $areaId = $observerDto->getAreaId(); $rowId = RealVoterNumberTmpManager::getInstance()->addRow($number, $userId, $areaId); $dto = RealVoterNumberTmpManager::getInstance()->selectByPK($rowId); $voterId = $dto->getVoterId(); $_SESSION['can_revert'] = 1; if ($voterId > 0) { $voter = VoterManager::getInstance()->selectByPK($voterId); $_SESSION['success_message'] = $number . ' ' . $voter->getFirstName() . ' ' . $voter->getLastName() . ' Successfully added'; } else { $_SESSION['error_message'] = "Number does not exist in list!"; $this->redirect(''); } $this->redirect(''); }