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);
$ListeRapport = new GiantRechercheController($params['pays'], $this->TestIndication);
$giantController = new GiantControllerLib($this->getRequest()->getParam('CompanyId'));
$resultDB = $giantController->commandePays($this->getRequest()->getParam('CompanyId'),$params['pays'], $this->TestIndication);
$result = unserialize($resultDB);
$result = $giantController->commandePays($this->getRequest()->getParam('CompanyId'),$params['pays'], $this->TestIndication);
$this->view->total = $total;
$this->view->listeCommandes = $liste;
$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
{
private $pathImg;
private $pathImg;
protected $configVal = array();
public function __construct($companyId)
{
$this->configVal = new Zend_Config_Ini( realpath(dirname(__FILE__)).'/giant_config.ini' );
$c = Zend_Registry::get('config');
$this->pathImg = $c->profil->path->pages.'/imgcache/'.$companyId;
}
@ -29,58 +32,64 @@ Class GiantControllerLib
switch ($Utilisateur->getIdClient()) {
case '0':
$price = 0;
$price = $this->configVal->price->test;
break;
case '1':
$price = 7;
$price = $this->configVal->price->snd;
break;
default:
$price = 10;
$price = $this->configVal->price->other;
}
$id = $Rapport->getRapportExist($CompanyId, $Type, $Language);
if(empty($id)) {
$rapport = new GiantRechercheController($Pays, $TestIndication);
$result = $rapport->GetRapport($CompanyId, $Type, $Language);
$result = base64_encode(serialize($result));
$id = $Rapport->setReport($CompanyId,
$Type,
$Pays,
$result,
$Language);
if (!empty($result)) {
$result = base64_encode(serialize($result));
$id = $Rapport->setReport($CompanyId,
$Type,
$Pays,
$result,
$Language);
}
}
$report_id = $Rapport->getRapportExistId($CompanyId, $Language);
$CommandeP->login = $Utilisateur->getLogin();
$CommandeP->date = date("Y-m-d");
$CommandeP->typeReport = $function->getTypeReport($Type);
$CommandeP->price = $price;
$CommandeP->pays = strtolower($Pays);
$CommandeP->rapportId = $report_id[0]['id'];
//$CommandeP->lang = $Utilisateur->getLang();
/*echo'<pre>';
print_r($report_id);
echo'</pre>';
if(!$Commande->getCommandeExistToday($CommandeP->login, $CommandeP->date, $CommandeP->typeReport, $CommandeP->pays)) {
$Commande->setCommandes($CommandeP);
}*/
$Commande->setCommandes($CommandeP);
if (!empty($report_id)) {
$CommandeP->login = $Utilisateur->getLogin();
$CommandeP->date = date("Y-m-d");
$CommandeP->typeReport = $function->getTypeReport($Type);
$CommandeP->price = $price;
$CommandeP->pays = strtolower($Pays);
$CommandeP->rapportId = $report_id[0]['id'];
//$CommandeP->lang = $Utilisateur->getLang();
/*echo'<pre>';
print_r($report_id);
echo'</pre>';
if(!$Commande->getCommandeExistToday($CommandeP->login, $CommandeP->date, $CommandeP->typeReport, $CommandeP->pays)) {
$Commande->setCommandes($CommandeP);
}*/
$Commande->setCommandes($CommandeP);
}
return ($id);
}
public function commandePays($CompanyId,$Pays,$TestIndication)
{
$Rapport = new Rapports($Pays, $TestIndication);
$id = $Rapport->getPaysExist($Pays)['result'];
if(empty($id)) {
$frontendOptions = array(
'lifetime' => $this->configVal->cache->lifetime,
'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);
$result = $rapport->ListeRapport($CompanyId);
$result = serialize($result);
$id = $Rapport->setPaysReport($Pays,$result);
if (!empty($result)) {
$cache->save($result, 'Pays_'.$Pays);
}
}
return ($id);
return ($result);
}
public function startmonitoring($CompanyId, $CategorieName, $EventType, $PreferredStartDate, $PreferredEndDate, $Version, $LanguageCode,$Pays,$TestIndication,$CompanyName)
{
$Utilisateur = new Scores_Utilisateur();
@ -148,7 +157,7 @@ Class GiantControllerLib
$result = $rapport->GetRetriveMonitoring($CompanyId, $StartFrom,$InternalOrderId,$EventType);
return ($result);
}
public function retrivDB($date_st)
{
$Rapport = new Rapports();

View File

@ -108,16 +108,6 @@ Class Rapports
$report->insert($datas);
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)
{
$rapports = new Application_Model_RapportsGiants();
@ -130,12 +120,6 @@ Class Rapports
$id = $rapports->getReportById($companyId, $Language);
return ($id);
}
public function getPaysExist($pays)
{
$rapports = new Application_Model_PaysGiants();
$id = $rapports->getPays($pays);
return ($id);
}
public function getRetrive($date_st)
{
$rapports = new Application_Model_MonitoringGiants();

View File

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