예제 #1
0
 /**
  * Magic method (do not call directly)
  *
  * @param string $name method name
  * @param array  $args arguments
  *
  * @return mixed
  *
  * @throws Exception
  * @throws CMbException
  */
 function __call($name, $args)
 {
     $name = strtolower($name);
     $silent = strncmp($name, 'try', 3) === 0;
     $function_name = $silent ? substr($name, 3) : $name;
     $function_name = '_' . (isset(self::$aliases[$function_name]) ? self::$aliases[$function_name] : $function_name);
     if (!method_exists($this, $function_name)) {
         throw new CMbException("CSourceSFTP-call-undefined-method", $name);
     }
     if ($function_name == "_init") {
         return call_user_func_array(array($this, $function_name), $args);
     }
     if (!$this->loggable) {
         try {
             return call_user_func_array(array($this, $function_name), $args);
         } catch (CMbException $fault) {
             throw $fault;
         }
     }
     $echange_ftp = new CExchangeFTP();
     $echange_ftp->date_echange = CMbDT::dateTime();
     $echange_ftp->emetteur = CAppUI::conf("mb_id");
     $echange_ftp->destinataire = $this->hostname;
     $echange_ftp->function_name = $name;
     CApp::$chrono->stop();
     $chrono = new Chronometer();
     $chrono->start();
     $output = null;
     try {
         $output = call_user_func_array(array($this, $function_name), $args);
     } catch (CMbException $fault) {
         $echange_ftp->date_echange = CMbDT::dateTime();
         $echange_ftp->output = $fault->getMessage();
         $echange_ftp->ftp_fault = 1;
         $echange_ftp->store();
         CApp::$chrono->start();
         throw $fault;
     }
     $chrono->stop();
     CApp::$chrono->start();
     // response time
     $echange_ftp->response_time = $chrono->total;
     // Truncate input and output before storing
     $args = array_map_recursive(array("CFTP", "truncate"), $args);
     $echange_ftp->input = serialize($args);
     if ($echange_ftp->ftp_fault != 1) {
         if ($function_name == "_getlistfiles") {
             // Truncate le tableau des fichiers reçus dans le cas où c'est > 100
             $array_count = count($output);
             if ($array_count > 100) {
                 $output = array_slice($output, 0, 100);
                 $output["count"] = "{$array_count} files";
             }
         }
         $echange_ftp->output = serialize(array_map_recursive(array("CSFTP", "truncate"), $output));
     }
     $echange_ftp->store();
     return $output;
 }
예제 #2
0
 /**
  * Return a array of the first column of the query result
  * 
  * @param string $query   The SQL query
  * @param int    $maxrows Maximum number of rows to return
  * 
  * @return array the query result
  */
 function loadColumn($query, $maxrows = null)
 {
     if (!($result = $this->exec($query))) {
         return false;
     }
     $this->chronoFetch->start();
     $list = array();
     while ($row = $this->fetchRow($result)) {
         $list[] = $row[0];
         if ($maxrows && $maxrows == count($list)) {
             break;
         }
     }
     $this->chronoFetch->stop();
     $this->freeResult($result);
     return $list;
 }
예제 #3
0
            case "rpps":
                $rpps = $medecin->rpps;
                $medecin = $sibling;
                $medecin->rpps = $rpps;
        }
        $updates++;
    }
    // Sauvegarde
    $medecin->repair();
    if ($msg = $medecin->store()) {
        trigger_error("Error storing {$medecin->nom} {$medecin->prenom} ({$medecin->cp}) : {$msg}", E_USER_WARNING);
        $errors++;
    }
    $medecin->updateFormFields();
    $medecins[] = $medecin;
}
$chrono->stop();
CAppUI::stepAjax("Etape {$step} \n{$errors} erreurs d'enregistrements", $errors ? UI_MSG_OK : UI_MSG_ALERT);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("verbose", CValue::get("verbose"));
$smarty->assign("xpath_screwed", $xpath_screwed);
$smarty->assign("step", $step);
$smarty->assign("from", $from);
$smarty->assign("to", $to);
$smarty->assign("medecins", $medecins);
$smarty->assign("chrono", $chrono);
$smarty->assign("updates", $updates);
$smarty->assign("errors", $errors);
$smarty->assign("last_page", $last_page);
$smarty->display("import_medecin.tpl");
 /** Calls a SOAP function
  *
  * @param string $function_name   The name of the SOAP function to call
  * @param array  $arguments       An array of the arguments to pass to the function
  * @param array  $options         An associative array of options to pass to the client
  * @param mixed  $input_headers   An array of headers to be sent along with the SOAP request
  * @param array  &$output_headers If supplied, this array will be filled with the headers from the SOAP response
  *
  * @throws Exception|SoapFault
  *
  * @return mixed SOAP functions may return one, or multiple values
  */
 public function call($function_name, $arguments, $options = null, $input_headers = null, &$output_headers = null)
 {
     $client = $this->client;
     if (!is_array($arguments)) {
         $arguments = array($arguments);
     }
     /* @todo Lors d'un appel d'une méthode RPC le tableau $arguments contient un élement vide array( [0] => )
      * posant problème lors de l'appel d'une méthode du WSDL sans argument */
     if (isset($arguments[0]) && empty($arguments[0])) {
         $arguments = array();
     }
     if ($client->flatten && isset($arguments[0]) && !empty($arguments[0])) {
         $arguments = $arguments[0];
     }
     $output = null;
     $echange_soap = new CEchangeSOAP();
     $echange_soap->date_echange = CMbDT::dateTime();
     $echange_soap->emetteur = CAppUI::conf("mb_id");
     $echange_soap->destinataire = $client->wsdl_url;
     $echange_soap->type = $client->type_echange_soap;
     $url = parse_url($client->wsdl_url);
     $path = explode("/", $url['path']);
     $echange_soap->web_service_name = end($path);
     $echange_soap->function_name = $function_name;
     // Truncate input and output before storing
     $arguments_serialize = array_map_recursive(array('CSOAPClient', "truncate"), $arguments);
     $echange_soap->input = serialize($arguments_serialize);
     if ($client->loggable) {
         $echange_soap->store();
     }
     CApp::$chrono->stop();
     $chrono = new Chronometer();
     $chrono->start();
     try {
         $output = $client->call($function_name, $arguments, $options, $input_headers, $output_headers);
         if (!$client->loggable) {
             CApp::$chrono->start();
             return $output;
         }
     } catch (SoapFault $fault) {
         // trace
         if (CAppUI::conf("webservices trace")) {
             $client->getTrace($echange_soap);
         }
         $chrono->stop();
         $echange_soap->date_echange = CMbDT::dateTime();
         $echange_soap->output = $fault->faultstring;
         $echange_soap->soapfault = 1;
         $echange_soap->response_time = $chrono->total;
         $echange_soap->store();
         CApp::$chrono->start();
         throw $fault;
     }
     $chrono->stop();
     CApp::$chrono->start();
     $echange_soap->date_echange = CMbDT::dateTime();
     // trace
     if (CAppUI::conf("webservices trace")) {
         $client->getTrace($echange_soap);
     }
     // response time
     $echange_soap->response_time = $chrono->total;
     if ($echange_soap->soapfault != 1) {
         $echange_soap->output = serialize(array_map_recursive(array("CSOAPClient", "truncate"), $output));
     }
     $echange_soap->store();
     return $output;
 }
 function sendFile()
 {
     // On transmet aux sources le fichier
     foreach ($this->loadRefSendersSource() as $_sender_source) {
         $_sender_source->last_datetime = CMbDT::dateTime();
         $_sender_source->last_status = "triggered";
         $_sender_source->last_duration = null;
         $_sender_source->last_size = null;
         $chrono = new Chronometer();
         $chrono->start();
         $_source = $_sender_source->_ref_source;
         $source_ftp = $_source->_ref_source_ftp;
         if ($source_ftp->_id && $source_ftp->active && $_source->actif) {
             try {
                 $ftp = $source_ftp->init();
                 if ($ftp->connect()) {
                     foreach ($this->_files_list as $_i => $_file) {
                         $basename = $this->name;
                         if ($this->multipart) {
                             $destination_basename = $source_ftp->fileprefix . $basename . "/" . $this->getDateTime() . "/" . $_file["title"];
                         } else {
                             $destination_basename = $source_ftp->fileprefix . $basename;
                         }
                         $compressed = $_sender_source->_ref_source->archive;
                         $extension = "." . ($source_ftp->fileextension ? $source_ftp->fileextension : $_file["extension"]);
                         $file_name = $destination_basename . ($compressed ? ".zip" : $extension);
                         // Création de l'archive si nécessaire
                         if ($compressed && !file_exists($_file["name_zip"])) {
                             $this->_files_list[$_i]["name_zip"] = $_file["name_raw"] . ".zip";
                             $_file["name_zip"] = $this->_files_list[$_i]["name_zip"];
                             $this->_file_compressed = $this->_file . ".zip";
                             $archive = new ZipArchive();
                             $archive->open($this->_files_list[$_i]["name_zip"], ZIPARCHIVE::CREATE);
                             $archive->addFile($_file["name_raw"], $destination_basename . $extension);
                             $archive->close();
                         }
                         // Envoi du fichier
                         $file = $compressed ? $_file["name_zip"] : $_file["name_raw"];
                         $ftp->sendFile($file, $file_name);
                         $_sender_source->last_status = "uploaded";
                         // Vérification de la taille du fichier uploadé
                         $_sender_source->last_size = $ftp->getSize($file_name);
                         if ($_sender_source->last_size == filesize($file)) {
                             $_sender_source->last_status = "checked";
                         }
                         // Enregistrement
                         $source_ftp->counter++;
                         $source_ftp->store();
                     }
                     // TODO: en mode multipart, gérer la rotation
                     if (!$this->multipart) {
                         $_sender_source->last_count = $this->archiveFile($ftp, $basename, $compressed);
                     }
                     $ftp->close();
                 }
             } catch (Exception $e) {
                 $this->clearTempFiles();
                 CAppUI::stepAjax($e->getMessage(), UI_MSG_ERROR);
             }
         }
         $chrono->stop();
         $_sender_source->last_duration = $chrono->total;
         $_sender_source->store();
     }
     $this->clearTempFiles();
 }