Utilisation méthode getCompanyMatchIdentifier

This commit is contained in:
Michael RICOIS 2009-06-08 12:41:21 +00:00
parent 74eed12303
commit 69ae7c95ad
2 changed files with 5 additions and 130 deletions

View File

@ -4,71 +4,7 @@ $path = PATH_DATA.'/graydon/method';
$fileName = strtolower('CompanyMatchIdentifiers-'.$pays);
/** Recherche des identifiants et mise en cache **/
$q = Doctrine_Query::create()
->from('Matchidentifiers')
->where('country = ?', $pays);
$matchidentifiers = new Matchidentifiers();
$matchidentifiers = $q->fetchOne();
/** Recup des types d'identifiants pour le pays **/
if($matchidentifiers == FALSE){
//Récupération des intitulés identifiant
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
$firephp->log($request,'REQUETE CompanyMatchIdentifier');
try
{
$result = $graydon->getCompanyMatchIdentifiers($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
graydonRequeteLog( $tabInfo['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $tabInfo['login'];
$log->action = 'getCompanyMatchIdentifiers';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
$count = count($result->CompanyMatchIdentifiers);
if ($count>1){
$identifiers = $result->CompanyMatchIdentifiers->CompanyMatchIdentifier->CompanyIdentifier;
}elseif($count==1){
$identifiers[] = $result->CompanyMatchIdentifiers->CompanyMatchIdentifier->CompanyIdentifier;
}
//Stockage du résultat de la méthode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $pays;
$matchidentifiers->identifiers = serialize($identifiers);
$matchidentifiers->replace();
}catch( SoapFault $fault ){
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
$firephp->log($text,'texterror');
require_once 'graydon/graydon_error.php';
if(graydon_error($code, $text)!=FALSE){
if($code=='CWS0112'){
//Stockage du résultat de la méthode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $pays;
$matchidentifiers->identifiers = serialize(false);
$matchidentifiers->replace();
}
}else{
graydon_processSoapFault($graydon,$fault,$tabInfo);
}
}
}else{
$identifiers = unserialize($matchidentifiers->identifiers);
}
$identifiers = getCompanyMatchIdentifiers($pays);
if(isset($identifiers)){
$firephp->log($identifiers,'identifiers');

View File

@ -12,8 +12,8 @@ $message = '';
require_once 'dbbootstrap.php';
require_once 'graydon/graydonws.php';
require_once 'graydon/graydon_log.php';
setDbConn('graydon');
setDbConn('graydon');
$country = Doctrine_Query::create()
->from('Country')
->where('code = ?', $paysCode)
@ -348,71 +348,10 @@ if(isset($_REQUEST['pidentifier'])){
</div>
<?php
/** Recherche des identifiants et mise en cache **/
$q = Doctrine_Query::create()
->from('Matchidentifiers')
->where('country = ?', $pays);
$matchidentifiers = new Matchidentifiers();
$matchidentifiers = $q->fetchOne();
/** Recup des types d'identifiants pour le pays **/
if($matchidentifiers == FALSE){
//matchidentifiers
$request = new StdClass();
$request->Authentication_Parameters = $authentication;
$request->Country = $pays;
try
{
$result = $graydon->getCompanyMatchIdentifiers($request);
//Enregistrement de l'action dans les logs
$transactionIdentifier = $result->Service_Log->TransactionIdentifier;
$sessionID = $result->Service_Log->SessionID;
graydonRequeteLog($_SESSION['tabInfo']['login'], $page, 'getCompanyMatchIdentifiers', $transactionIdentifier, $sessionID);
//Log de la requete dans la bdd
$log = new Requetelog();
$log->login = $_SESSION['tabInfo']['login'];
$log->action = 'getCompanyMatchIdentifiers';
$log->request = serialize($request);
$log->transactionIdentifier = $transactionIdentifier;
$log->sessionID = $sessionID;
$log->mode = $mode;
$log->save();
foreach($result->CompanyMatchIdentifiers->CompanyMatchIdentifier as $item){
$count = count($item->CompanyIdentifier);
if ($count>1){
$tabIdentifiers = $item->CompanyIdentifier;
}elseif($count==1){
$tabIdentifiers[] = $item->CompanyIdentifier;
}
//Stockage du résultat de la méthode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $item->Country;
$matchidentifiers->identifiers = serialize($tabIdentifiers);
$matchidentifiers->replace();
$identifiers = $tabIdentifiers;
}
}catch( SoapFault $fault ){
$code = $fault->detail->GraydonCompanyData_Fault->FaultReturnCode;
$text = $fault->detail->GraydonCompanyData_Fault->FaultMessage;
require_once 'graydon/graydon_error.php';
$error = graydon_error($code, $text);
if($error == FALSE){
graydon_processSoapFault($graydon,$fault,$tabInfo);
}elseif($error['Code'] == 'CWS0112'){
//Stockage du résultat de la méthode en cache
$matchidentifiers = new Matchidentifiers();
$matchidentifiers->country = $pays;
$matchidentifiers->identifiers = serialize('false');
$matchidentifiers->replace();
}
}
}else{
$identifiers = unserialize($matchidentifiers->identifiers);
$firephp->log($identifiers,'test');
}
$identifiers = getCompanyMatchIdentifiers($pays);
$firephp->log($identifiers,'identifiers');
//Affichage des identifiants
//Ne pas afficher l'identifiant Internal
if(isset($identifiers) && $identifiers!='false'){