Pārlūkot izejas kodu

Utilizar link diario descargando archivos hasta fecha: 20220127_

Nermosis 3 gadus atpakaļ
vecāks
revīzija
d00db3aa5c
1 mainītis faili ar 29 papildinājumiem un 28 dzēšanām
  1. 29 28
      application/controllers/Parser.php

+ 29 - 28
application/controllers/Parser.php Parādīt failu

@@ -24,51 +24,51 @@ class Parser extends CI_Controller
24 24
 
25 25
     public function index()
26 26
     {
27
-        /*$existCronRun = $this->Parser_model->existCronRun();
27
+        $existCronRun = $this->Parser_model->existCronRun();
28 28
 
29 29
         if ($existCronRun['num_rows'] > 0) {
30
-        if ($existCronRun['datos']->cron_ejecucion == 0) {
30
+            if ($existCronRun['datos']->cron_ejecucion == 0) {
31 31
 
32
-        $this->Parser_model->inicioParser();
32
+                $this->Parser_model->inicioParser();
33 33
 
34
-        $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
34
+                $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
35 35
 
36
-        foreach ($resultSetPerfiles['datos'] as $row) {
37
-        $fechaCarpeta = date("Y-m-d_H-i-s");
38
-        $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
36
+                foreach ($resultSetPerfiles['datos'] as $row) {
37
+                    $fechaCarpeta = date("Y-m-d_H-i-s");
38
+                    $rutaPerfil = $this->rutaDiaria . "/" . $row->prefijos_tablas;
39 39
 
40
-        $this->newFolder($rutaPerfil);
40
+                    $this->newFolder($rutaPerfil);
41 41
 
42
-        if ($this->newFolder($rutaPerfil . "/" . $fechaCarpeta)) {
43
-        $this->rutaDiariaFecha = $rutaPerfil . "/" . $fechaCarpeta . "/";
42
+                    if ($this->newFolder($rutaPerfil . "/" . $fechaCarpeta)) {
43
+                        $this->rutaDiariaFecha = $rutaPerfil . "/" . $fechaCarpeta . "/";
44 44
 
45
-        $this->downloadProcess($row->url_descarga);
45
+                        $this->downloadProcess($row->url_descarga);
46
+                    }
47
+                }
46 48
 
47
-        $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row);
48
-        }
49
-        }
49
+                $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row);
50 50
 
51
+            } else {
52
+                echo "EXISTE UN CRON EN MARCHA.";
53
+            }
51 54
         } else {
52
-        echo "EXISTE UN CRON EN MARCHA.";
53
-        }
54
-        } else {
55
-        echo "No existe parametro que iniciar.";
55
+            echo "No existe parametro que iniciar.";
56 56
         }
57 57
 
58 58
         $this->Parser_model->stopParser();
59
-         */
60
-        $resultSetPerfiles = $this->Parser_model->getUrlArchivos();
61
-        foreach ($resultSetPerfiles['datos'] as $row) {
62
-            $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-10_09-02-17", date("Y-m-n"), $row);
63
-        }
59
+
60
+        /*$resultSetPerfiles = $this->Parser_model->getUrlArchivos();
61
+    foreach ($resultSetPerfiles['datos'] as $row) {
62
+    $this->parserfile->index($this->rutaDiaria . "PER_PCSP_EX/2022-02-10_09-02-17", date("Y-m-n"), $row);
63
+    }*/
64 64
     }
65 65
 
66 66
     private function downloadProcess($urlXML)
67 67
     {
68
-        $fileName = basename($urlXML);
69
-        //$downladedZip = $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
68
+        /*$fileName = basename($urlXML);
69
+        $downladedZip = $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
70 70
 
71
-        /* if ($downladedZip) {
71
+        if ($downladedZip) {
72 72
         $zip = new ZipArchive;
73 73
         if ($zip->open($this->rutaDiariaFecha . $fileName)) {
74 74
         $zip->extractTo($this->rutaDiariaFecha);
@@ -82,7 +82,8 @@ class Parser extends CI_Controller
82 82
 
83 83
         }
84 84
 
85
-        } */
85
+        }*/
86
+        $fileName = basename($urlXML);
86 87
         $this->downloadFile($fileName, $urlXML, $this->rutaDiariaFecha);
87 88
         $archivoAtom = $this->getFile($this->rutaDiariaFecha . $fileName, $fileName);
88 89
         $nuevoAtomAttrNext = $this->readNextAttribute($archivoAtom);
@@ -143,7 +144,7 @@ class Parser extends CI_Controller
143 144
                 } else {
144 145
                     $enlace = "";
145 146
                 }
146
-
147
+                //$enlace = $attrHref;
147 148
             }
148 149
         }
149 150