Пример #1
0
    public function Insert(ErrorLogEntity $oErrorLogEntity)
    {
        $sSql = 'INSERT INTO
					' . $this->sTableName . '
									(
									   job_queue_id
									 , box_id
									 , folio_id
									 , item_id
									 , process
									 , error
									 , created
									)
				VALUES
									(
									   ?
									 , ?
									 , ?
									 , ?
									 , ?
									 , ?
									 , ?
									)
				ON DUPLICATE KEY UPDATE
									error           = ?';
        $aBindArray = array($oErrorLogEntity->getJobQueueId(), $oErrorLogEntity->getBoxId(), $oErrorLogEntity->getFolioId(), $oErrorLogEntity->getItemId(), $oErrorLogEntity->getProcess(), $oErrorLogEntity->getError(), $oErrorLogEntity->getCreated(), $oErrorLogEntity->getError());
        $this->Execute($sSql, $aBindArray);
        return;
    }
 protected function HandleError(ImporterException $oException, EntityAbstract $oEntity)
 {
     // Create entry in error log
     $sErrorString = $this->CreateExceptionString($oException);
     $sError = $oException->getMessage();
     $oErrorLogEntity = new ErrorLogEntity();
     $oErrorLogEntity->setProcess($this->sProcess);
     $oErrorLogEntity->setError($sErrorString);
     $this->oLogger->LogException($oException);
     $iId = $oEntity->getId();
     switch (true) {
         case $oEntity instanceof JobQueueEntity:
             $this->oJobQueueDb->ClearErrorLog($iId);
             $oErrorLogEntity->setJobQueueId($iId);
             $oEntity->setStatus('error');
             $this->oJobQueueDb->InsertUpdate($oEntity);
             break;
         case $oEntity instanceof BoxEntity:
             $this->oBoxDb->ClearErrorLog($iId);
             $oErrorLogEntity->setBoxId($iId);
             $this->oBoxDb->UpdateProcessStatus($iId, $this->sProcess, 'error');
             break;
         case $oEntity instanceof FolioEntity:
             $this->oFolioDb->ClearErrorLog($iId);
             $oErrorLogEntity->setFolioId($iId);
             $this->oFolioDb->UpdateProcessStatus($iId, $this->sProcess, 'error');
             break;
         case $oEntity instanceof ItemEntity:
             $this->oItemDb->ClearErrorLog($iId);
             $oErrorLogEntity->setItemId($iId);
             $this->oItemDb->UpdateProcessStatus($iId, $this->sProcess, 'error');
             break;
     }
     $this->oErrorLogDb->Insert($oErrorLogEntity);
     // Escalate to the JobQueue but we don't want to bubble higher than the job queue
     if ($oEntity instanceof JobQueueEntity === true) {
         exit($oException->getMessage());
     }
     // Escalate it further up
     throw new ImporterException($sError);
 }