Ejemplo n.º 1
0
      
     
      "id": "db0dab63-70c5-466e-9ca8-60c6753465cd",
      "format": "pdf B",
      "mimetype": "application/octet-stream"
    }
  ]
}';
$type = json_decode($json_document_type, true);
require_once '../vendor/autoload.php';
use upload\model\documento;
use upload\lib\data;
use upload\lib\api;
$db = new data(array('server' => '10.102.1.3', 'user' => 'sa', 'pass' => 'i3kygbb2', 'database' => 'docflow', 'engine' => 'mssql'));
$archivador = 'THUMANO';
$thumano = new documento($db, $archivador);
$data = $thumano->getAllTipo_doc();
$user = "******";
$pass = "******";
$url = "http://www.sifinca.net/sifinca/web/app.php/admin/sifinca/mapper";
$apimapper = SetupApi($url, $user, $pass);
print_r($apimapper->get());
return 0;
$url = "http://www.sifinca.net/sifinca/web/app.php/archive/main/documenttype";
$apidocumenttype = SetupApi($url, $user, $pass);
## recorrer tipos
foreach ($data as $row) {
    ## postear en documentype
    $documenttype = $type;
    $documenttype['name'] = $row['nombre'];
    $documenttype['description'] = $row['nombre'];
Ejemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // create a log channel
     $log = new Logger('name');
     $log->pushHandler(new StreamHandler('/var/www/html/upload/files/app.log', Logger::WARNING));
     $tt1 = microtime(true);
     $output->writeln('Descargar documentos de archivadores de sifinca 1.0 y carga en sifinca 2.0 ');
     $archivador = $input->getArgument('archivador');
     if ($archivador) {
         ##   conectar a sifinca
         $output->writeln('<info>Conectando a base de datos ...</info>');
         ## conectar a base de zeus -> convertir luego a opciones
         $conn = new data(array('server' => '10.102.1.3', 'user' => 'sa', 'pass' => 'i3kygbb2', 'database' => 'docflow', 'engine' => 'mssql'));
         ### descargar documentos
         $path = $input->getOption('path');
         if ($path) {
             $path = "/var/www/html/upload/files/" . $path . "/";
         } else {
             $path = "/var/www/html/upload/files/" . $archivador . "/";
         }
         if (!file_exists($path)) {
             ##crearlo
             mkdir($path);
         }
         $tasks = $input->getOption('tasks');
         $thumano = new documento($conn, $archivador);
         if ($input->getOption('download')) {
             $urlapi1 = "www.sifinca.net/sifinca/web/app.php/archive/main/file";
             $user = "******";
             $pass = "******";
             $file = $this->SetupApi($urlapi1, $user, $pass);
             ### document
             $urlapi = "www.sifinca.net/sifinca/web/app.php/archive/main/file/indexing";
             $user = "******";
             $pass = "******";
             $document = $this->SetupApi($urlapi, $user, $pass);
             ## descargar todos
             $data = $thumano->get(array());
             $token = $this->getToken($user, $pass);
             $count = 0;
             foreach ($data as $row) {
                 $tags = array();
                 if ($tasks) {
                     $output->writeln('<info>No se encuentra implementado procesos en paralelos</info>');
                 } else {
                     ### buscar si el documento ya esta -> verficar si esta el "file" y el "documento"
                     echo "2\n";
                     echo $row['radicacion'];
                     $d = $this->getDocument($row['radicacion']);
                     print_r($d);
                     if ($d->total == 0) {
                         $flag = true;
                     } else {
                         $flag = false;
                     }
                     $filename = $path . rtrim($row['radicacion']) . ".tif";
                     if ($flag) {
                         $filepdf = $path . rtrim($row['radicacion']) . ".pdf";
                         $thumano->getFile($row['nkey'], $filename);
                         $thumano->tiff2pdf($filename, $filepdf);
                         if ($input->getOption('optimize')) {
                             $optimize = true;
                         } else {
                             $optimize = false;
                         }
                         if ($optimize) {
                             $cmd = "qpdf -linearize {$filepdf} tmp.pdf && mv tmp.pdf {$filepdf}";
                             $_out = shell_exec($cmd);
                         }
                         ### traer metadata
                         $metadoc = $thumano->getMetadata($row['id']);
                         if ($input->getOption('post')) {
                             echo "Nuevo!!!!";
                             $destinyUser = $input->getOption('destinyUser');
                             if ($destinyUser) {
                                 $user = json_encode(array("destinyUser" => $destinyUser));
                             } else {
                                 $user = json_encode(array("destinyUser" => ''));
                             }
                             $h = "x-sifinca:SessionToken SessionID=\"{$token}\", Username=\"sifinca@araujoysegovia.com\"";
                             $result = $this->postfile($filepdf, $h, $user, $urlapi1);
                             // add records to the log
                             echo json_encode($result) . "\n";
                             if (is_array($result)) {
                                 if ($result[0]['success']) {
                                     $typedoc = json_decode($this->getIdTypeDoc($row['tipo_doc'], $archivador), true);
                                     ### armar post -> document
                                     foreach ($metadoc as $tag) {
                                         $tags[] = array(array("idEmployee" => $tag['cedula']), array("nameEmployee" => $tag['nombre']), array("idContract" => $tag['codigo']), array("third" => $tag['tercero']), array("idThird" => $tag['idtercero']));
                                     }
                                     $folio = $row['folio'];
                                     if ($folio == 'VIRTUAL') {
                                         $virtual = true;
                                     } else {
                                         $virtual = false;
                                     }
                                     $doc = array("nameDocument" => $row['radicacion'], "dateDocument" => date('Y-m-d', strtotime($row['fecha'])), "tags" => $tags, "documentType" => array("id" => $typedoc['data'][0]['idTarget']), "file" => array(), "additional" => $folio, "virtual" => $virtual);
                                     ### post document
                                     $result2 = $document->post($doc);
                                     $msg = json_encode($result2);
                                     echo $msg . "\n";
                                 }
                             } else {
                                 $msg = "Success: false ->" . $filepdf;
                                 echo $msg . "\n";
                             }
                             ###
                         }
                     } else {
                         $msg = "Existe ->" . $row['radicacion'];
                         echo $msg . "\n";
                     }
                 }
                 $count++;
                 $output->writeln('<info>' . $count . ". " . $filename . '</info>');
             }
             $tt2 = microtime(true);
             $r = $tt2 - $tt1;
             $output->writeln('<info>Tiempo de  ' . $r . ' para ' . $count . ' </info>');
         } else {
             $output->writeln('<info>Debe proporcionar el archivador  </info>');
         }
     }
 }