Просмотр исходного кода

remove original file after format, remove parsercompleto folder after inserts

Nermosis 3 лет назад
Родитель
Сommit
5c1a762043
1 измененных файлов: 23 добавлений и 2 удалений
  1. 23 2
      application/controllers/ParserCompleto.php

+ 23 - 2
application/controllers/ParserCompleto.php Просмотреть файл

@@ -64,6 +64,8 @@ class Parsercompleto extends CI_Controller
64 64
             emailInicioProcesoDescarga($fechaImportacionLog, $files);
65 65
 
66 66
             $this->parserfile->index($this->rutaDiariaFecha, $fechaCarpeta, $row, $idUltimaImportacion);
67
+
68
+            $this->eliminarArchivosProcesoCompleto($this->rutaDiariaFecha);
67 69
         }
68 70
 
69 71
         $this->tablasCalculadas($idUltimaImportacion);
@@ -99,9 +101,14 @@ class Parsercompleto extends CI_Controller
99 101
             $attrHref = $row['@attributes']['href'];
100 102
 
101 103
             if ($attrNext === "next") {
102
-                $enlace = $attrHref;
104
+                if (!strpos($attrHref, "licitacionesPerfilesContratanteCompleto3_20220517_133815_1")) { //"20220127_")) {
105
+                    $enlace = $attrHref;
106
+                } else {
107
+                    $enlace = "";
108
+                }
109
+                /* $enlace = $attrHref;
103 110
             } else {
104
-                $enlace = "";
111
+                $enlace = ""; */
105 112
             }
106 113
         }
107 114
 
@@ -136,6 +143,7 @@ class Parsercompleto extends CI_Controller
136 143
     {
137 144
         $openingFormat = $this->regExIniciosEsquema($xml);
138 145
         $closureFormat = $this->regExFinalesEsquema($openingFormat);
146
+        unlink($this->rutaDiariaFecha . "/" . $fileName);
139 147
         file_put_contents($this->rutaDiariaFecha . "/format/" . $fileName, $closureFormat);
140 148
     }
141 149
 
@@ -172,6 +180,19 @@ class Parsercompleto extends CI_Controller
172 180
 
173 181
         insertBucleDuplicateOnKey($licitaciones['datos'], "vista_datos_licitacion", "");
174 182
     }
183
+
184
+    private function eliminarArchivosProcesoCompleto($ruta)
185
+    {
186
+        $files = glob($ruta . "format/*");
187
+        foreach ($files as $file) { // iterate files
188
+            if (is_file($file)) {
189
+                unlink($file); // delete file
190
+            }
191
+        }
192
+
193
+        rmdir($ruta . "format");
194
+        rmdir($ruta);
195
+    }
175 196
 }
176 197
 
177 198
 /* End of file ParserCompleto.php */