Commit cf1258bbd1101676c080ec03d18de25ca7018820
1 parent
159d6c79
Exists in
master
and in
19 other branches
[Fixed #13] Correção de erro no tratamento de transação do andamento do trâmite
Showing
1 changed file
with
23 additions
and
13 deletions
Show diff stats
rn/ProcedimentoAndamentoRN.php
| ... | ... | @@ -62,27 +62,37 @@ class ProcedimentoAndamentoRN extends InfraRN { |
| 62 | 62 | * @param string $strSituacao Tipo ENUM(S,N) |
| 63 | 63 | * @return null |
| 64 | 64 | */ |
| 65 | - protected function cadastrarControlado($strMensagem = 'Não informado', $strSituacao = 'N'){ | |
| 65 | + public function cadastrar($strMensagem = 'Não informado', $strSituacao = 'N'){ | |
| 66 | 66 | |
| 67 | 67 | if($this->isSetOpts === false) { |
| 68 | 68 | throw new InfraException('Log do cadastro de procedimento não foi configurado'); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $objInfraIBanco = $this->inicializarObjInfraIBanco(); |
| 72 | + $objInfraIBanco->abrirTransacao(); | |
| 72 | 73 | |
| 73 | - $hash = md5($this->dblIdProcedimento.$strMensagem); | |
| 74 | + try{ | |
| 75 | + $hash = md5($this->dblIdProcedimento.$strMensagem); | |
| 74 | 76 | |
| 75 | - $objProcedimentoAndamentoDTO = new ProcedimentoAndamentoDTO(); | |
| 76 | - $objProcedimentoAndamentoDTO->setStrSituacao($strSituacao); | |
| 77 | - $objProcedimentoAndamentoDTO->setDthData(date('d/m/Y H:i:s')); | |
| 78 | - $objProcedimentoAndamentoDTO->setDblIdProcedimento($this->dblIdProcedimento); | |
| 79 | - $objProcedimentoAndamentoDTO->setDblIdTramite($this->dblIdTramit); | |
| 80 | - $objProcedimentoAndamentoDTO->setStrSituacao($strSituacao); | |
| 81 | - $objProcedimentoAndamentoDTO->setStrMensagem($strMensagem); | |
| 82 | - $objProcedimentoAndamentoDTO->setStrHash($hash); | |
| 83 | - $objProcedimentoAndamentoDTO->setNumTarefa($this->numTarefa); | |
| 77 | + $objProcedimentoAndamentoDTO = new ProcedimentoAndamentoDTO(); | |
| 78 | + $objProcedimentoAndamentoDTO->setStrSituacao($strSituacao); | |
| 79 | + $objProcedimentoAndamentoDTO->setDthData(date('d/m/Y H:i:s')); | |
| 80 | + $objProcedimentoAndamentoDTO->setDblIdProcedimento($this->dblIdProcedimento); | |
| 81 | + $objProcedimentoAndamentoDTO->setDblIdTramite($this->dblIdTramit); | |
| 82 | + $objProcedimentoAndamentoDTO->setStrSituacao($strSituacao); | |
| 83 | + $objProcedimentoAndamentoDTO->setStrMensagem($strMensagem); | |
| 84 | + $objProcedimentoAndamentoDTO->setStrHash($hash); | |
| 85 | + $objProcedimentoAndamentoDTO->setNumTarefa($this->numTarefa); | |
| 84 | 86 | |
| 85 | - $objProcedimentoAndamentoBD = new ProcedimentoAndamentoBD($objInfraIBanco); | |
| 86 | - $objProcedimentoAndamentoBD->cadastrar($objProcedimentoAndamentoDTO); | |
| 87 | + $objProcedimentoAndamentoBD = new ProcedimentoAndamentoBD($objInfraIBanco); | |
| 88 | + $objProcedimentoAndamentoBD->cadastrar($objProcedimentoAndamentoDTO); | |
| 89 | + | |
| 90 | + $objInfraIBanco->confirmarTransacao(); | |
| 91 | + | |
| 92 | + } catch (Exception $e) { | |
| 93 | + $objInfraIBanco->cancelarTransacao(); | |
| 94 | + throw $e; | |
| 95 | + | |
| 96 | + } | |
| 87 | 97 | } |
| 88 | 98 | } | ... | ... |