Ajout option filtre par nom

This commit is contained in:
Michael RICOIS 2015-06-30 09:32:45 +00:00
parent 7751aa504a
commit 7d3f435f2a
2 changed files with 36 additions and 18 deletions

2
README
View File

@ -120,7 +120,9 @@ Send Options list (in)
ftp
sftp
mail
- FilterName - Filtre par nom de prestation (true) ou par nom défini
Recv Options list (out)
-----------------------
- Log - Log read disable by default

View File

@ -23,18 +23,18 @@ require_once 'Zend/Application.php';
// --- Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
try {
$opts = new Zend_Console_Getopt(
// --- Options
array(
'help|?' => "Displays usage information.",
'file|f=s' => "Give the full file path to integrate",
'mail' => "Only send a mail when a file is write",
'debug' => "Send a mail for debug",
'help|?' => "Displays usage information.",
'file|f=s' => "Give the full file path to integrate",
'mail' => "Only send a mail when a file is write",
'debug' => "Send a mail for debug",
)
);
$opts->parse();
@ -59,6 +59,7 @@ if ( isset($opts->file) )
$optionsRunWithEndFile = false;
$optionsLog = false;
$optionsRoute = array();
$optionsFilterName = false;
$repositoryDir = 'send';
$c = new Zend_Config($application->getOptions());
@ -103,11 +104,12 @@ if ( isset($opts->file) )
$repositoryDir = $p['directory'];
}
// --- Match prestation
if ($type == $p['type'] && $fluxRepository == $repositoryDir)
{
$prestation = $p['name'];
// --- Set option
// --- Set options
if (array_key_exists('in', $p) && count($p['in']) > 0)
{
foreach ($p['in'] as $option => $value)
@ -116,6 +118,18 @@ if ( isset($opts->file) )
}
}
// --- Filters
if ($optionsFilterName === true) {
if ( strpos($filenameIn, $prestation) === false ) {
exit;
}
}
if (is_string($optionsFilterName) && strlen($optionsFilterName) > 0) {
if (strpos($filenameIn, $optionsFilterName) === false) {
exit;
}
}
break;
}
}
@ -172,6 +186,8 @@ if ( isset($opts->file) )
}
}
// ---
// --- Detail du fichier
$nbLines = 0;
if ( strtolower(substr($filenameIn, -3)) == 'csv' ) {
@ -251,7 +267,7 @@ if ( isset($opts->file) )
foreach ($optionsRoute as $tr => $value) {
switch($tr) {
case 'cp':
if (copy($fluxBasePath . '/' . $filenameIn, $value. '/' . $filenameOut)) {
if (copy($fluxBasePath . '/' . $filenameIn, $value . '/' . $filenameOut)) {
echo date('Y-m-d H:i:s')." - Copie du fichier $filenameIn dans $value\n";
}
break;
@ -279,15 +295,15 @@ if ( isset($opts->file) )
try {
$fluxM = new Application_Model_Sdv1FluxFileIn();
$fluxM->insert(array(
'client' => $client,
'name' => $prestation,
'depotType' => $type,
'depotDate' => $dateFile,
'depotFile' => $filenameOut,
'nbLines' => $nbLines,
'depotFileSize' => $size,
'dateInsert' => date('YmdHis'),
'dateExecute' => '0000-00-00 00:00:00', // @todo : dateExecute
'client' => $client,
'name' => $prestation,
'depotType' => $type,
'depotDate' => $dateFile,
'depotFile' => $filenameOut,
'nbLines' => $nbLines,
'depotFileSize' => $size,
'dateInsert' => date('YmdHis'),
'dateExecute' => '0000-00-00 00:00:00', // @todo : dateExecute
));
echo date('Y-m-d H:i:s')." - Enregistrement client:$client fichier:$filenameOut\n";
}