MAJ des méthodes pour le batch graydon

This commit is contained in:
Michael RICOIS 2009-05-15 14:19:13 +00:00
parent 8f010c9f25
commit fda2c77a52

View File

@ -1,10 +1,52 @@
#!/usr/bin/php -q
<?php <?php
$version = '0.2';
$argc = $_SERVER['argc'];
$argv = $_SERVER['argv'];
//par défault, on active tout
if($argc == 1){
$checkCommandes = TRUE;
$matchidentifiers = TRUE;
$matchmethods = TRUE;
$checkCommandes = FALSE;
}else{
foreach($argv as $value){
switch($value){
case 'availability':
$availability = FALSE;
break;
case 'matchidentifiers':
$matchidentifiers = FALSE;
break;
case 'matchmethods':
$matchmethods = FALSE;
break;
case 'commandes':
$checkCommandes = FALSE;
break;
default:
print $argv[0]." version : ".$version."\n\n";
print "Lancer le script ".$argv[0]." sans paramètres permet de charger toutes les méthodes graydon et vérifier les commandes\n\n";
print "Les services disponibles sont :\n";
print "\t-Disponibilité des pays graydon (availability).\n";
print "\t-Types d'identifiant disponible par pays (matchidentifiers).\n";
print "\t-Méthodes de recherche (matchmethods).\n";
print "\t-Vérification des commandes (commandes).\n";
exit;
}
}
}
require_once '../config/prepend.php'; require_once '../config/prepend.php';
//Inclure la base de données //Inclure la base de données
require_once 'dbbootstrap.php'; require_once 'dbbootstrap.php';
//Inclure la config graydon //Inclure la config graydon
require_once 'graydon/graydonws.php'; require_once 'graydon/graydonws.php';
setDbConn('graydon');
if($availability == TRUE){
//Country Availability //Country Availability
$request = new StdClass(); $request = new StdClass();
$request->Authentication_Parameters = $authentication; $request->Authentication_Parameters = $authentication;
@ -14,24 +56,25 @@ try
//Enregistrement de l'action dans les logs //Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier; $transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID; $sessionID = $result->Service_Log->SessionID;
graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
foreach($result->CountryAvailablity->CountryAndProduct as $item){ foreach($result->CountryAvailablity->CountryAndProduct as $item){
//Enregistrement pour chaque pays de la disponibilité des services $availability = array();
$countryavailability = new Countryavailability();
$countryavailability->country = $item->Country;
$count = count($item->Products->Product); $count = count($item->Products->Product);
if ($count>1){ if ($count>1){
$availability = $item->Products->Product; $availability = $item->Products->Product;
}elseif($count==1){ }elseif($count==1){
$availability[] = $item->Products->Product; $availability[] = $item->Products->Product;
} }
//Enregistrement pour chaque pays de la disponibilité des services
$countryavailability = new Countryavailability();
$countryavailability->country = $item->Country;
$countryavailability->availability = serialize($availability); $countryavailability->availability = serialize($availability);
$countryavailability->replace(); $countryavailability->replace();
}
}catch( SoapFault $fault ){
} }
}catch( SoapFault $fault ){}
}
if($matchidentifiers == TRUE){
//matchidentifiers //matchidentifiers
$request = new StdClass(); $request = new StdClass();
$request->Authentication_Parameters = $authentication; $request->Authentication_Parameters = $authentication;
@ -41,9 +84,9 @@ try
//Enregistrement de l'action dans les logs //Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier; $transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID; $sessionID = $result->Service_Log->SessionID;
graydonRequeteLog('batch', 'batch', 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){ foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){
$tabIdentifiers = array();
$count = count($item->CompanyIdentifier); $count = count($item->CompanyIdentifier);
if ($count>1){ if ($count>1){
$tabIdentifiers = $item->CompanyIdentifier; $tabIdentifiers = $item->CompanyIdentifier;
@ -56,10 +99,10 @@ try
$matchidentifiers->identifiers = serialize($tabIdentifiers); $matchidentifiers->identifiers = serialize($tabIdentifiers);
$matchidentifiers->replace(); $matchidentifiers->replace();
} }
}catch( SoapFault $fault ){ }catch( SoapFault $fault ){}
} }
if($matchmethods == TRUE){
//matchmethods //matchmethods
$request = new StdClass(); $request = new StdClass();
$request->Authentication_Parameters = $authentication; $request->Authentication_Parameters = $authentication;
@ -68,18 +111,18 @@ try
$result = $graydon->getCompanyMatchMethods($request); $result = $graydon->getCompanyMatchMethods($request);
$transactionIdentifier = $result->Service_Log->TransactionIdentifier; $transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID; $sessionID = $result->Service_Log->SessionID;
graydonRequeteLog('batch', 'batch', 'getCompanyMatchMethods', $transactionIdentifier, $sessionID);
foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){ foreach($result->CompanyMatchMethods->CompanyMatchMethod as $item){
$methods = array();
$count = count($item->MatchMethods->MatchMethod); $count = count($item->MatchMethods->MatchMethod);
//Stockage du résultat de la méthode en cache
$matchmethods = new Matchmethods();
$matchmethods->country = $item->Country;
if ($count>1){ if ($count>1){
$methods = $item->MatchMethods->MatchMethod; $methods = $item->MatchMethods->MatchMethod;
}elseif($count==1){ }elseif($count==1){
$methods[] = $item->MatchMethods->MatchMethod; $methods[] = $item->MatchMethods->MatchMethod;
} }
//Stockage du résultat de la méthode en cache
$matchmethods = new Matchmethods();
$matchmethods->country = $item->Country;
$matchmethods->methods = serialize($methods); $matchmethods->methods = serialize($methods);
$matchmethods->replace(); $matchmethods->replace();
} }
@ -101,24 +144,22 @@ try
graydon_processSoapFault($graydon,$fault,''); graydon_processSoapFault($graydon,$fault,'');
} }
} }
}
if($checkCommandes == TRUE){
//Vérification des commandes //Vérification des commandes
$q = Doctrine_Query::create() $q = Doctrine_Query::create()
->select('*') ->select('*')
->from('Commandes'); ->from('Commandes');
$tabCommandes = $q->Execute(); $tabCommandes = $q->Execute();
//Pour chaque commande ('Completed','Assigned','InError','Initialised','Delivered','Notified','ReCompleted') //Pour chaque commande ('Completed','Assigned','InError','Initialised','Delivered','Notified','ReCompleted')
foreach($tabCommandes as $commande){ foreach($tabCommandes as $commande){
//Si servicespeed = immediate alors on ne gère pas //Si servicespeed = immediate alors on ne gère pas
if($commande->servicespeed != 'Immediate'){ if($commande->servicespeed != 'Immediate'){
switch($commande->orderstate){ switch($commande->orderstate){
case 'Delivered': //Délivré, on a été la chercher case 'Delivered': //Délivré, on a été la chercher
//On ne fait rien //On ne fait rien
break; break;
case 'Completed': //Commande prête à télécharger case 'Completed': //Commande prête à télécharger
break; break;
@ -133,10 +174,8 @@ foreach($tabCommandes as $commande){
case 'Initialised': //Commande prise en compte case 'Initialised': //Commande prise en compte
case 'Assigned': //Assigné chez graydon case 'Assigned': //Assigné chez graydon
case ''; // Pas d'état, commande pas encore vérifier case '': // Pas d'état, commande pas encore vérifier
case 'default': case 'default':
$q = Doctrine_Query::create() $q = Doctrine_Query::create()
->update('Commandes') ->update('Commandes')
->set('orderstate', $orderstate) ->set('orderstate', $orderstate)
@ -149,4 +188,5 @@ foreach($tabCommandes as $commande){
} }
} }
} }
}
?> ?>