feat: import xml export from buspro over sftp
This commit is contained in:
@@ -62,7 +62,11 @@ APP_BPN_CRM_ID_TEAMER=1070
|
|||||||
APP_DEFAULT_EMAIL_FROM=[email protected]
|
APP_DEFAULT_EMAIL_FROM=[email protected]
|
||||||
APP_DEFAULT_EMAIL_TO=[email protected]
|
APP_DEFAULT_EMAIL_TO=[email protected]
|
||||||
|
|
||||||
XML_EXPORT_PATH="%kernel.project_dir%/var/xmlexport"
|
SFTP_XML_EXPORT_HOST=
|
||||||
|
SFTP_XML_EXPORT_PORT=22
|
||||||
|
SFTP_XML_EXPORT_USER=
|
||||||
|
SFTP_XML_EXPORT_PASSWORD=
|
||||||
|
SFTP_XML_EXPORT_ROOT=
|
||||||
|
|
||||||
MYEP_OAUTH2_CLIENT_ID=
|
MYEP_OAUTH2_CLIENT_ID=
|
||||||
MYEP_OAUTH2_CLIENT_SECRET=
|
MYEP_OAUTH2_CLIENT_SECRET=
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
flysystem:
|
flysystem:
|
||||||
storages:
|
storages:
|
||||||
xml_export.storage:
|
xml_export.storage:
|
||||||
local:
|
sftp:
|
||||||
directory: '%env(resolve:XML_EXPORT_PATH)%'
|
host: '%env(SFTP_XML_EXPORT_HOST)%'
|
||||||
|
port: '%env(int:SFTP_XML_EXPORT_PORT)%'
|
||||||
|
username: '%env(SFTP_XML_EXPORT_USER)%'
|
||||||
|
password: '%env(SFTP_XML_EXPORT_PASSWORD)%'
|
||||||
|
root: '%env(SFTP_XML_EXPORT_ROOT)%'
|
||||||
xml_dump.storage:
|
xml_dump.storage:
|
||||||
local:
|
local:
|
||||||
directory: '%kernel.project_dir%/var/bpn'
|
directory: '%kernel.project_dir%/var/bpn'
|
||||||
# sftp:
|
|
||||||
# host: '%env(SFTP_XML_EXPORT_HOST)%'
|
|
||||||
# port: '%env(int:SFTP_XML_EXPORT_PORT)%'
|
|
||||||
# username: '%env(SFTP_XML_EXPORT_USER)%'
|
|
||||||
# password: '%env(SFTP_XML_EXPORT_PASSWORD)%'
|
|
||||||
|
|||||||
+13
@@ -97,6 +97,19 @@ host('staging')
|
|||||||
->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://myep-team.ep-reisen.net')
|
->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://myep-team.ep-reisen.net')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
host('hetzner')
|
||||||
|
->setHostname('dedi10193.your-server.de')
|
||||||
|
->setRemoteUser('myepteam')
|
||||||
|
->setForwardAgent(true)
|
||||||
|
->setSshMultiplexing(true)
|
||||||
|
->setDeployPath('/usr/home/myepteam/public_html/myep-team')
|
||||||
|
->set('bin/php', '/usr/bin/php')
|
||||||
|
->set('http_user', 'myepteam')
|
||||||
|
->set('rsync_src', __DIR__)
|
||||||
|
->set('rsync', $rsyncOptions)
|
||||||
|
->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://myep-team.ep-reisen.net')
|
||||||
|
;
|
||||||
|
|
||||||
task('deploy', [
|
task('deploy', [
|
||||||
'deploy:info',
|
'deploy:info',
|
||||||
'deploy:setup',
|
'deploy:setup',
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class BpnImportCommand extends Command
|
|||||||
try {
|
try {
|
||||||
$xmlFiles = $this
|
$xmlFiles = $this
|
||||||
->xmlExport
|
->xmlExport
|
||||||
->listContents('.')
|
->listContents('')
|
||||||
->filter(fn (StorageAttributes $attributes) => $attributes->isFile() && str_starts_with($attributes->path(), 'Ziel_'))
|
->filter(fn (StorageAttributes $attributes) => $attributes->isFile() && str_starts_with($attributes->path(), 'Ziel_'))
|
||||||
->toArray();
|
->toArray();
|
||||||
} catch (FilesystemException $e) {
|
} catch (FilesystemException $e) {
|
||||||
@@ -59,14 +59,23 @@ class BpnImportCommand extends Command
|
|||||||
$io->info('Found '.$totalCount.' XML files');
|
$io->info('Found '.$totalCount.' XML files');
|
||||||
$addedCount = 0;
|
$addedCount = 0;
|
||||||
$updatedCount = 0;
|
$updatedCount = 0;
|
||||||
|
$warnings = [];
|
||||||
|
|
||||||
|
$progressBar = $io->createProgressBar($totalCount);
|
||||||
|
$progressBar->setFormat(" %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%\n %message%");
|
||||||
|
$progressBar->setMessage('Starting');
|
||||||
|
$progressBar->start();
|
||||||
|
|
||||||
// Iterate over xml files
|
// Iterate over xml files
|
||||||
foreach ($xmlFiles as $xmlFile) {
|
foreach ($xmlFiles as $xmlFile) {
|
||||||
|
$progressBar->setMessage($xmlFile->path());
|
||||||
|
|
||||||
// Load xml file into simplexml object
|
// Load xml file into simplexml object
|
||||||
try {
|
try {
|
||||||
$xml = simplexml_load_string($this->xmlExport->read($xmlFile->path()));
|
$xml = simplexml_load_string($this->xmlExport->read($xmlFile->path()));
|
||||||
} catch (FilesystemException $e) {
|
} catch (FilesystemException $e) {
|
||||||
$io->warning('Unable to read XML file '.$xmlFile->path());
|
$warnings[] = 'Unable to read XML file '.$xmlFile->path();
|
||||||
|
$progressBar->advance();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +93,7 @@ class BpnImportCommand extends Command
|
|||||||
$pickupBusProId = (int) $pickupXml->attributes()['idbuspro'];
|
$pickupBusProId = (int) $pickupXml->attributes()['idbuspro'];
|
||||||
if ($pickupBusProId) {
|
if ($pickupBusProId) {
|
||||||
if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) {
|
if (null === $pickup = $this->pickupDataProvider->get($pickupBusProId)) {
|
||||||
$io->warning('Pickup with busProId '.$pickupBusProId.' not found');
|
$warnings[] = 'Pickup with busProId '.$pickupBusProId.' not found';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +110,7 @@ class BpnImportCommand extends Command
|
|||||||
foreach ($destinationXml->xpath('hotel') as $hotelXml) {
|
foreach ($destinationXml->xpath('hotel') as $hotelXml) {
|
||||||
$hotelBusProId = (int) $hotelXml->attributes()['idbuspro'];
|
$hotelBusProId = (int) $hotelXml->attributes()['idbuspro'];
|
||||||
if (null === $hotel = $this->hotelDataProvider->get($hotelBusProId)) {
|
if (null === $hotel = $this->hotelDataProvider->get($hotelBusProId)) {
|
||||||
$io->warning('Hotel with busProId '.$hotelBusProId.' not found');
|
$warnings[] = 'Hotel with busProId '.$hotelBusProId.' not found';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +155,16 @@ class BpnImportCommand extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$progressBar->advance();
|
||||||
|
}
|
||||||
|
|
||||||
|
$progressBar->setMessage('Done');
|
||||||
|
$progressBar->finish();
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
if ($warnings) {
|
||||||
|
$io->warning(array_unique($warnings));
|
||||||
}
|
}
|
||||||
|
|
||||||
$logMessage = 'Added '.$addedCount.' and updated '.$updatedCount.' destinations';
|
$logMessage = 'Added '.$addedCount.' and updated '.$updatedCount.' destinations';
|
||||||
|
|||||||
Reference in New Issue
Block a user