Hotfix: edi/load
gitea/hedera-web/pipeline/head There was a failure building this commit
Details
gitea/hedera-web/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
a130163617
commit
81ba131375
|
@ -124,6 +124,50 @@ class Load extends Edi\Method {
|
|||
|
||||
foreach ($unhs as $unh)
|
||||
foreach ($lins = $unh->childs['LIN'] as $lin) {
|
||||
$this->processMessage($db, $unh, $lin, $mailId);
|
||||
$count++;
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
} catch (Exception $e) {
|
||||
$db->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($count == 0)
|
||||
throw new Exception('No part with EDI format was found');
|
||||
|
||||
echo " -> Mail id: $mailId\n";
|
||||
echo " -> Loaded exchanges: $count\n";
|
||||
|
||||
$folder = $this->imapConf['successFolder'];
|
||||
$db->update('mail',
|
||||
['nExchanges' => $count],
|
||||
['id' => $mailId]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
error_log($error);
|
||||
|
||||
$folder = $this->imapConf['errorFolder'];
|
||||
$db->update('mail',
|
||||
['error' => $error],
|
||||
['id' => $mailId]
|
||||
);
|
||||
}
|
||||
|
||||
// Moves the mail to another folder
|
||||
|
||||
$folder = sprintf('%s', $folder);
|
||||
|
||||
if (!imap_mail_move($imap, $msg, $folder))
|
||||
error_log('Can\'t move message to %s: %s'
|
||||
,$folder
|
||||
,imap_last_error()
|
||||
);
|
||||
}
|
||||
|
||||
function processMessage($db, $unh, $lin, $mailId) {
|
||||
$ediValues = ['mailId' => $mailId];
|
||||
|
||||
// Gets the exchange params
|
||||
|
@ -235,54 +279,18 @@ class Load extends Edi\Method {
|
|||
}
|
||||
|
||||
$db->call('ekt_refresh', [$ektFk, $mailId]);
|
||||
|
||||
try {
|
||||
if ($isNew) $db->call('ekt_load', [$ektFk]);
|
||||
} catch (Exception $e) {
|
||||
error_log("CALL ekt_load($ektFk): {$e->getMessage()}");
|
||||
}
|
||||
|
||||
$db->insert('exchange', [
|
||||
'mailFk' => $mailId,
|
||||
'typeFk' => $ediValues['bgm'],
|
||||
'ektFk' => $ektFk
|
||||
]);
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
$db->commit();
|
||||
} catch (Exception $e) {
|
||||
$db->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if ($count == 0)
|
||||
throw new Exception('No part with EDI format was found');
|
||||
|
||||
echo " -> Mail id: $mailId\n";
|
||||
echo " -> Loaded exchanges: $count\n";
|
||||
|
||||
$folder = $this->imapConf['successFolder'];
|
||||
$db->update('mail',
|
||||
['nExchanges' => $count],
|
||||
['id' => $mailId]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
$error = $e->getMessage();
|
||||
error_log($error);
|
||||
|
||||
$folder = $this->imapConf['errorFolder'];
|
||||
$db->update('mail',
|
||||
['error' => $error],
|
||||
['id' => $mailId]
|
||||
);
|
||||
}
|
||||
|
||||
// Moves the mail to another folder
|
||||
|
||||
$folder = sprintf('%s', $folder);
|
||||
|
||||
if (!imap_mail_move($imap, $msg, $folder))
|
||||
error_log('Can\'t move message to %s: %s'
|
||||
,$folder
|
||||
,imap_last_error()
|
||||
);
|
||||
}
|
||||
|
||||
function imapFindParts(&$part, &$matchTypes, $section, &$result) {
|
||||
|
|
Loading…
Reference in New Issue