/// <summary>
        /// Proceso de sincronizacion catalogos
        /// </summary>
        private void sincroniceCatalogos()
        {
            bool local = true;
            this.addText("*****************  INICIANDO PROCESO DE SINCRONIZACIÓN DE CATÁLOGOS  *****************\n");
            string compartida = System.Configuration.ConfigurationManager.AppSettings["CarpetaCompartidaCatalogos"];
            this.addText("Obteniendo archivos de la carpeta remota para los catálogos \n");
            string[] archivosTerritorio = this.obtenerArchivos(compartida, "*.zip");
            if(archivosTerritorio.Length==0)
                this.addText("No se detectaron archivos en la carpeta remota para los catálogos \n");
            setMaxBar(archivosTerritorio.Length);
            Consultas c = new Consultas();
            foreach (string file in archivosTerritorio)
            {
                try
                {
                    FileInfo fkpi = new FileInfo(file);
                    string catalogo = fkpi.Name.Substring(0, (fkpi.Name.IndexOf("_")));
                    string date = file.Substring(file.LastIndexOf("_") + 1, (file.Length - 5 - file.LastIndexOf("_")));
                    long dateLong = -1;
                    try
                    {
                        dateLong = Convert.ToInt64(date);
                    }
                    catch{ }
                    this.addText("Insertando registro en NMT_TMP_CAT_FILES para el catálogo " + catalogo + "\n");
                    c.InsertNMT_TMP_CAT_FILES(file, catalogo, dateLong);
                }
                catch (Exception ex)
                {
                    this.addText("Error insertando registro en NMT_TMP_CAT_FILES para el catálogo en el archivo" + file + "\n" + ex.Message);
                }
                actualProces++;
                Dispatcher.Invoke(updatePbDelegate,
                System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, Convert.ToDouble(actualProces) });
            }
            this.addText("Seleccionando archivos a cargar\n");
            c.CompareNMT_TMP_CAT_FILES();
            DataTable cata = new DataTable();
            cata = c.SelectNMT_TMP_CAT_FILES().Tables[0];
            if(cata.Rows.Count==0)
                this.addText("No se detectaron archivos a cargar \n");
            foreach (DataRow g in cata.Rows)
            {
                string file = (string)g["FULL_FILENAME"];
                string catalog = (string)g["CATALOG_NAME"];
                long dateLong = (long)g["FILENAME_DATE"];
                this.cargaCurrentCatalogos(file, catalog, dateLong);
            }
            this.addText("Seleccionando archivos con bit para carga en CURRENT CAT\n");
            DataTable catCurrent = new DataTable();
            catCurrent = c.SelectNMT_CURRENT_CAT_FILES().Tables[0];
            setMaxBar(catCurrent.Rows.Count);
            if (catCurrent.Rows.Count==0)
                this.addText("No se detectaron archivos a cargar con bit en 1\n");
            foreach (DataRow g in catCurrent.Rows)
            {
                string file = (string)g["FULL_FILENAME"];
                string catalog = (string)g["CATALOG_NAME"];
                long dateLong = (long)g["FILENAME_DATE"];
                try
                {
                    this.addText("Realizando la extracción del .zip\n");
                    List<string> files = this.descomprimir(file);
                    this.addText("Homologando " + catalog + " \n");
                    try
                    {
                        string tabla = this.homologueCatalogo(catalog);
                        DataTable datosTabla = new DataTable();
                        datosTabla = c.CreateTableCatalogoTemp(tabla,local).Tables[0];
                        this.addText("Iniciando lectura de archivo\n");
                        StreamReader reader = null;
                        bool exitoLectura = true;
                        try
                        {
                            reader = new StreamReader(files[0], Encoding.Default);
                            string line = string.Empty;
                            while ((line = reader.ReadLine()) != null)
                            {
                                try
                                {
                                    string[] valores = line.Split('|');
                                    int index = 0;
                                    string columns = "";
                                    string inserts = "";
                                    foreach (DataRow gdata in datosTabla.Rows)
                                    {
                                        string column = (string)gdata["COLUMN_NAME"];
                                        string tipo = (string)gdata["TYPE_NAME"];
                                        columns += column + ",";
                                        string val = "";
                                        if (tipo.ToLower().Contains("char")) val += "{\"}";
                                        if (index < valores.Length) val += valores[index];
                                        if (tipo.ToLower().Contains("char")) val += "{\"}";
                                        inserts += val + ",";
                                        index++;
                                    }
                                    try
                                    {
                                        c.ExecuteSQLNMT_CAT_TMP_FILES(tabla, columns.Remove(columns.Length - 1, 1), inserts.Remove(inserts.Length - 1, 1), local);
                                    }
                                    catch (Exception ex2)
                                    {
                                        exitoLectura = exitoLectura && false;
                                        this.addText("Error insertando los datos en la tabla temporal\n" + ex2.Message);
                                    }
                                }
                                catch (Exception ex3)
                                {
                                    exitoLectura = exitoLectura && false;
                                    this.addText("Error mapeando columnas de tabla con columnas del archivo\n" + ex3.Message);
                                }
                            }
                            reader.Close();
                        }
                        catch (Exception ex4)
                        {
                            this.addText("Error en la lectura del archivo\n" + ex4.Message);
                            if (reader != null)
                                reader.Close();
                            exitoLectura = exitoLectura && false;
                        }
                        if (exitoLectura)
                        {
                            this.addText("Tabla temporal " + tabla + "_TMP creada y cargada\n");
                            this.addText("Truncando la tabla " + tabla + "\n");
                            try
                            {
                                //AQUI TRUNCA LA TABLA DE KPI NORMAL
                                c.Truncate_NMT_Table(tabla, local);
                                //c.Drop_NMT_Table(tabla, local);
                                this.addText("Tabla " + tabla + " truncada\n");
                                this.addText("Cargando los datos desde la tabla temporal " + tabla + "_TMP\n");
                                try
                                {
                                    c.Merge_NMT_Table(tabla + "_TMP", tabla, local);
                                    this.addText("Carga de datos desde la tabla temporal " + tabla + "_TMP exitosa\n");
                                    // ----- INI - BZG - 20120227 -----------
                                    c.SetLoadedNMT_CURRENT_CAT_FILES(catalog);
                                    // ----- FIN - BZG - 20120227 -----------
                                    this.addText("Eliminando tabla temporal " + tabla + "_TMP \n");
                                    try
                                    {
                                        c.Drop_NMT_Table(tabla + "_TMP", local);
                                    }
                                    catch (Exception ex5)
                                    {
                                        this.addText("Error eliminando la tabla temporal " + tabla + "_TMP\n"+ ex5.Message);
                                    }
                                }
                                catch (Exception ex6)
                                {
                                    this.addText("Error al intentar cargar los datos desde la tabla temporal " + tabla + "_TMP\n"+ex6.Message);
                                }
                            }
                            catch (Exception ex7)
                            {
                                this.addText("Error al intentar truncar la tabla\n" + ex7.Message);
                            }
                        }
                    }
                    catch (Exception ex8)
                    {
                        this.addText("Ocurrió un error tratando de crear la tabla temporal\n" + ex8.Message);
                    }

                }
                catch (Exception ex9)
                {
                    this.addText("Ocurrió un error en la extracción del .zip\n" + ex9.Message);
                }

                this.addText("\nEl proceso ha finalizado.\n");
                actualProces++;
                Dispatcher.Invoke(updatePbDelegate,
                System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, Convert.ToDouble(actualProces) });
            }
        }