Détail du message 81791.14

Message numéro 14 dans le sujet Problème traitement tache qui agit sur les clients.

  • 81791.14 en réponse à 81791.11 écrit par mamous

    14/11/2013 16:50


    mamous
    Rang : Expert
    J'ai toujours le problème!!
    voilà je vous file les bouts de code en espérant que cela va vous être utile:
    <?php
    
    class moduleSpec_DynamictarifgroupTask extends task_SimpleSystemTask
    {
     Framework::warn('--------------- Début DynamictarifgroupTask ----------------');	
    $i=0;
    $group = $this->getInstanceByCodereference('VPTARIFGROUP');
    $groupInit = $this->getInstanceByCodereference('ALLCLIENT');
    $errors=array();
    //Récupérer la condition du filtre
    if ($group instanceof customer_persistentdocument_tarifcustomergroup)
    {
     $queryIntersection = f_persistentdocument_DocumentFilterService::getInstance()->getQueryIntersectionFromJson($group->getQuery());
    				$newIds = $queryIntersection->findIds();
    }	
    $oldIds=$this->getAllCustomerIds();
    if($newIds)
    {
    	$initCustomers = array_diff($oldIds, $newIds);
    	$VpCustomers = array_intersect($newIds, $oldIds);
    }
    else
    {
    	$initCustomers=$oldIds;
    	$VpCustomers = NULL;
    }
    $batchPath = $this->getRemoverBatchPath();
    if($initCustomers)
    {
    	foreach (array_chunk($initCustomers, 500) as $batch)
    	{
    		$this->plannedTask->ping();
    		$result = f_util_System::execHTTPScript($batchPath, $batch);
    		// Log fatal errors...
    		if ($result != 'OK')
    		{
    			$errors[] = $result;
    		}
    	}
    }
    $batchPath = $this->getAdderBatchPath();
    if($VpCustomers)
    {
    	foreach (array_chunk($VpCustomers, 500) as $batch)
    	{
    		$this->plannedTask->ping();
    		$result = f_util_System::execHTTPScript($batchPath,$batch);
    		// Log fatal errors...
    		if ($result != 'OK')
    		{
    			$errors[] = $result;
    		}
    	}
    }
    if (count($errors))
    {
    	Framework::warn(implode("\n", $errors));
    }...
    }

    Et voilà une partie du traitement du batch
    <?php
    $userIdArray = array_slice($_POST['argv'], 1);
    $i=0;
    $group = getInstanceByCodereference('VPTARIFGROUP');
    Framework::warn('---------- IN Adder ----------- ');
    $tm = f_persistentdocument_TransactionManager::getInstance();
    foreach ($userIdArray as $userId) 
    {
    	try 
    	{
    		Framework::warn("User -----$userId ----- num $i");
    		$tm->beginTransaction();
    		$user=customer_CustomerService::getInstance()->createQuery()
    					->add(Restrictions::eq('id', $userId))->findUnique();
    		$user->setTarifgroup($group);
    		$user->save();
    		$i++;
    		$tm->commit();
    	} 
    	catch (Exception $e)
    	{
    		Framework::warn($e);
    	}
    }
    ...

    Alors?
    J'ai toujours le problème de ne pas traiter tout les clients, même j'ai supprimer les clients qui étaient en cause, il a toujours laisser une vingtaine de clients sans les traiter et sans mettre en retour une trace dans les logs...

    Développeur & Intégrateur Web

    RBS Change
    V 3.5.2
    Ecommerce Core
 
1471 membres
Aucun membre connecté