issue #0001700: log Options using zend cache

This commit is contained in:
Arman KYOKCHAN 2013-09-11 13:12:19 +00:00
parent 8d02ead01f
commit efcd9b8394
5 changed files with 51 additions and 73 deletions

View File

@ -76,8 +76,7 @@ class GiantController extends Zend_Controller_Action
$liste = $giantFunction->divCommande($listeCommandes, $total); $liste = $giantFunction->divCommande($listeCommandes, $total);
$ListeRapport = new GiantRechercheController($params['pays'], $this->TestIndication); $ListeRapport = new GiantRechercheController($params['pays'], $this->TestIndication);
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId')); $giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$resultDB = $giantController->commandePays($this->getRequest()->getParam('CompanyId'),$params['pays'], $this->TestIndication); $result = $giantController->commandePays($this->getRequest()->getParam('CompanyId'),$params['pays'], $this->TestIndication);
$result = unserialize($resultDB);
$this->view->total = $total; $this->view->total = $total;
$this->view->listeCommandes = $liste; $this->view->listeCommandes = $liste;
$this->view->modification = (isset($result->MonitoringOptions))?($ListeRapport->getModification($result->MonitoringOptions->MonitoringOption[0])):null; $this->view->modification = (isset($result->MonitoringOptions))?($ListeRapport->getModification($result->MonitoringOptions->MonitoringOption[0])):null;

View File

@ -1,20 +0,0 @@
<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class Application_Model_PaysGiants extends Zend_Db_Table_Abstract
{
protected $_name = 'pays_giants';
public function getPays($pays)
{
$sql = $this->select()
->where('pays = ?', $pays);
$result = $this->getAdapter()->fetchRow($sql);
return ($result);
}
}
?>

View File

@ -10,10 +10,13 @@ require_once ('Partials.php');
Class GiantControllerLib Class GiantControllerLib
{ {
private $pathImg; private $pathImg;
protected $configVal = array();
public function __construct($companyId) public function __construct($companyId)
{ {
$this->configVal = new Zend_Config_Ini( realpath(dirname(__FILE__)).'/giant_config.ini' );
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$this->pathImg = $c->profil->path->pages.'/imgcache/'.$companyId; $this->pathImg = $c->profil->path->pages.'/imgcache/'.$companyId;
} }
@ -29,18 +32,19 @@ Class GiantControllerLib
switch ($Utilisateur->getIdClient()) { switch ($Utilisateur->getIdClient()) {
case '0': case '0':
$price = 0; $price = $this->configVal->price->test;
break; break;
case '1': case '1':
$price = 7; $price = $this->configVal->price->snd;
break; break;
default: default:
$price = 10; $price = $this->configVal->price->other;
} }
$id = $Rapport->getRapportExist($CompanyId, $Type, $Language); $id = $Rapport->getRapportExist($CompanyId, $Type, $Language);
if(empty($id)) { if(empty($id)) {
$rapport = new GiantRechercheController($Pays, $TestIndication); $rapport = new GiantRechercheController($Pays, $TestIndication);
$result = $rapport->GetRapport($CompanyId, $Type, $Language); $result = $rapport->GetRapport($CompanyId, $Type, $Language);
if (!empty($result)) {
$result = base64_encode(serialize($result)); $result = base64_encode(serialize($result));
$id = $Rapport->setReport($CompanyId, $id = $Rapport->setReport($CompanyId,
$Type, $Type,
@ -48,9 +52,10 @@ Class GiantControllerLib
$result, $result,
$Language); $Language);
} }
}
$report_id = $Rapport->getRapportExistId($CompanyId, $Language); $report_id = $Rapport->getRapportExistId($CompanyId, $Language);
if (!empty($report_id)) {
$CommandeP->login = $Utilisateur->getLogin(); $CommandeP->login = $Utilisateur->getLogin();
$CommandeP->date = date("Y-m-d"); $CommandeP->date = date("Y-m-d");
$CommandeP->typeReport = $function->getTypeReport($Type); $CommandeP->typeReport = $function->getTypeReport($Type);
@ -65,22 +70,26 @@ Class GiantControllerLib
$Commande->setCommandes($CommandeP); $Commande->setCommandes($CommandeP);
}*/ }*/
$Commande->setCommandes($CommandeP); $Commande->setCommandes($CommandeP);
}
return ($id); return ($id);
} }
public function commandePays($CompanyId,$Pays,$TestIndication) public function commandePays($CompanyId,$Pays,$TestIndication)
{ {
$Rapport = new Rapports($Pays, $TestIndication); $frontendOptions = array(
$id = $Rapport->getPaysExist($Pays)['result']; 'lifetime' => $this->configVal->cache->lifetime,
if(empty($id)) { 'automatic_serialization' => true
);
$backendOptions = array('cache_dir' => '../data/cache/giant/');
$cache = Zend_Cache::factory('Output','File',$frontendOptions,$backendOptions);
if(($result = $cache->load('Pays_'.$Pays)) === false) {
$rapport = new GiantRechercheController($Pays, $TestIndication); $rapport = new GiantRechercheController($Pays, $TestIndication);
$result = $rapport->ListeRapport($CompanyId); $result = $rapport->ListeRapport($CompanyId);
$result = serialize($result); if (!empty($result)) {
$id = $Rapport->setPaysReport($Pays,$result); $cache->save($result, 'Pays_'.$Pays);
} }
return ($id);
} }
return ($result);
}
public function startmonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode,$Pays,$TestIndication,$CompanyName) public function startmonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode,$Pays,$TestIndication,$CompanyName)
{ {
$Utilisateur = new Scores_Utilisateur(); $Utilisateur = new Scores_Utilisateur();

View File

@ -108,16 +108,6 @@ Class Rapports
$report->insert($datas); $report->insert($datas);
return ($reportSerial); return ($reportSerial);
} }
public function setPaysReport($pays, $reportSerial)
{
$report = new Application_Model_PaysGiants();
$datas = array('date' => date('Y-m-d'),
'pays' => $pays,
'result' => $reportSerial,
);
$report->insert($datas);
return ($reportSerial);
}
public function getRapportExist($companyId, $type, $Language) public function getRapportExist($companyId, $type, $Language)
{ {
$rapports = new Application_Model_RapportsGiants(); $rapports = new Application_Model_RapportsGiants();
@ -130,12 +120,6 @@ Class Rapports
$id = $rapports->getReportById($companyId, $Language); $id = $rapports->getReportById($companyId, $Language);
return ($id); return ($id);
} }
public function getPaysExist($pays)
{
$rapports = new Application_Model_PaysGiants();
$id = $rapports->getPays($pays);
return ($id);
}
public function getRetrive($date_st) public function getRetrive($date_st)
{ {
$rapports = new Application_Model_MonitoringGiants(); $rapports = new Application_Model_MonitoringGiants();

View File

@ -0,0 +1,6 @@
[price]
test = "0"
snd = "7"
other = "10"
[cache]
lifetime = "30"