예제 #1
0
        public void Mover(EventLog poLog, string lsIndicadorEnvio, string Correocuenta, string CorreoDestinatario, string CorreoServidor, string CorreoPuerto, string CorreoCP, int lnTiempoEsperaError)
        {
            string lsUbicacionOrigen = ConfigurationManager.AppSettings["UbicacionOrigen"];

            while (true)
            {
                try
                {
                    foreach (string lsClave in ConfigurationManager.AppSettings.Keys)
                    {
                        if (lsClave == "UbicacionOrigen" || lsClave.Contains("Correo") || lsClave.Contains("Error") || lsClave.Contains("Hora"))
                        {
                            continue;
                        }

                        string[] loArchivos = Directory.GetFiles(lsUbicacionOrigen, lsClave + "*.xml", SearchOption.TopDirectoryOnly);

                        foreach (string loArchivo in loArchivos)
                        {
                            Thread.Sleep(2000);

                            if (!File.Exists(loArchivo.Replace("xml", "pdf")))
                            {
                                continue;
                            }

                            Iterador      loIteradorXML      = new Iterador(loArchivo);
                            List <string> loFechaComprobante = (List <string>)loIteradorXML.ObtenerAtributo("Comprobante", "fecha", Dapesa.Documentos.XML.Comun.Definiciones.TipoSalida.Simple);

                            #region Crear directorios
                            try
                            {
                                if (!Directory.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10))))
                                {
                                    if (!Directory.Exists(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7)))
                                    {
                                        if (!Directory.Exists(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4)))
                                        {
                                            Directory.CreateDirectory(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4));
                                            Directory.CreateDirectory(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7));
                                            Directory.CreateDirectory(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10));
                                        }
                                        else
                                        {
                                            Directory.CreateDirectory(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7));
                                            Directory.CreateDirectory(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10));
                                        }
                                    }
                                    else
                                    {
                                        Directory.CreateDirectory(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10));
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                poLog.WriteEntry("Error. Creación de Directorios: " + ex.Message, EventLogEntryType.Information);
                                loDocumentos.EnviarAviso("Error. Creadión de Directorios:" + ex.Message + " " + ex.Source, lsIndicadorEnvio, Correocuenta, CorreoDestinatario, CorreoServidor, CorreoPuerto, CorreoCP);
                                Thread.Sleep(lnTiempoEsperaError);
                                continue;
                            }

                            #endregion

                            #region Validar PDF

                            try
                            {
                                using (File.Open(loArchivo.Replace("xml", "pdf"), FileMode.Open))
                                {
                                }

                                using (File.Open(loArchivo, FileMode.Open))
                                {
                                }
                            }
                            catch
                            {
                                continue;
                            }

                            #endregion

                            #region MoverArchivos
                            try
                            {
                                if (File.Exists(loArchivo) && File.Exists(loArchivo.Replace("xml", "pdf")))
                                {
                                    if (File.Exists(loArchivo))
                                    {
                                        if (File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo))) ||
                                            File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("xml", "pdf"))))
                                        {
                                            File.Delete(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo)));
                                            File.Delete(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("xml", "pdf")));
                                        }
                                        if (File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", ""))) ||
                                            File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf"))))
                                        {
                                            File.Delete(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "")));
                                            File.Delete(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf")));
                                        }
                                        if (!File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", ""))) &&
                                            !File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf"))))
                                        {
                                            File.Move(loArchivo.Replace("xml", "pdf"), Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf")));
                                            File.Move(loArchivo, Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "")));
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                poLog.WriteEntry("Error. Mover Archivos: " + ex.Message, EventLogEntryType.Information);
                                this.loDocumentos.EnviarAviso("Error. Mover Archivos: " + ex.Message + " " + ex.Source, lsIndicadorEnvio, Correocuenta, CorreoDestinatario, CorreoServidor, CorreoPuerto, CorreoCP);
                                Thread.Sleep(lnTiempoEsperaError);
                                continue;
                            }
                            #endregion
                        }
                    }
                }
                catch (Exception ex)
                {
                    poLog.WriteEntry("Error.Metodo Mover." + ex.Message, EventLogEntryType.Information);
                    try
                    {
                        this.loDocumentos.EnviarAviso("Error. Mover Archivos: " + ex.Message + " " + ex.Source, lsIndicadorEnvio, Correocuenta, CorreoDestinatario, CorreoServidor, CorreoPuerto, CorreoCP);
                        continue;
                    }
                    catch (Exception e)
                    {
                        poLog.WriteEntry("Error. " + e.Message);
                        continue;
                    }
                }
                GC.Collect();
            }
        }
예제 #2
0
파일: Notas.cs 프로젝트: MH3Dapesa/Dapesa
        public void Mover(EventLog poLog, string lsIndicadorEnvio, string Correocuenta, string CorreoDestinatario, string CorreoServidor, string CorreoPuerto, string CorreoCP, int lnTiempoEsperaError)
        {
            string lsUbicacionOrigen = ConfigurationManager.AppSettings["UbicacionOrigen"];  //ruta origen

            while (true)
            {
                foreach (string lsClave in ConfigurationManager.AppSettings.Keys)                                                                                           //recorre cada clave del appconfig
                {
                    if (lsClave == "UbicacionOrigen" || lsClave.Contains("cancela") || lsClave.Contains("Correo") || lsClave.Contains("Error") || lsClave.Contains("Hora")) //
                    {
                        continue;
                    }

                    // Convertir en arreglo lsClave para extraer las dos rutas donde se guardaran los archivos.
                    string[] lsClaves = ConfigurationManager.AppSettings[lsClave].Split(new Char[] { ';' });

                    string[] loArchivos = Directory.GetFiles(lsUbicacionOrigen, lsClave + "*.xml", SearchOption.TopDirectoryOnly);

                    foreach (string loArchivo in loArchivos) //encuentra los archivos xml que sean notas
                    {
                        Thread.Sleep(2000);

                        if (!File.Exists(loArchivo.Replace("xml", "pdf")))
                        {
                            continue;
                        }
                        //extrae nombre del archivo hayado descriminado la extencion
                        //string lsNombreArchivo = loArchivo.Substring(loArchivo.LastIndexOf('\\') + 1).Replace(".xml", "");

                        Iterador      loIteradorXML      = new Iterador(loArchivo);
                        List <string> loFechaComprobante = (List <string>)loIteradorXML.ObtenerAtributo("Comprobante", "fecha", Dapesa.Documentos.XML.Comun.Definiciones.TipoSalida.Simple); //obtiene la fecha del documento xml

                        #region CrearDirectorios
                        try
                        {
                            for (int i = 0; i <= lsClaves.Length - 1; i++)
                            {
                                if (!Directory.Exists(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10)))
                                {
                                    if (!Directory.Exists(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7)))
                                    {
                                        if (!Directory.Exists(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4)))
                                        {
                                            Directory.CreateDirectory(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4));                                                                                                //año
                                            Directory.CreateDirectory(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7));                                                 //mes
                                            Directory.CreateDirectory(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10)); //dia
                                        }
                                        else
                                        {
                                            Directory.CreateDirectory(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7));                                                 //mes
                                            Directory.CreateDirectory(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10)); //dia
                                        }
                                    }
                                    else
                                    {
                                        Directory.CreateDirectory(lsClaves[i].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10));//dia
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            try
                            {
                                loDocumentos.EnviarAviso(ex.Message + " " + ex.Source, lsIndicadorEnvio, Correocuenta, CorreoDestinatario, CorreoServidor, CorreoPuerto, CorreoCP);
                            }
                            catch (Exception e)
                            {
                                poLog.WriteEntry("Ocurrio un error al enviar Email: " + e.Message, EventLogEntryType.Information);
                                continue;
                            }
                            Thread.Sleep(lnTiempoEsperaError);
                            continue;
                        }

                        #endregion

                        #region Validar PDF

                        try
                        {
                            using (File.Open(loArchivo.Replace("xml", "pdf"), FileMode.Open))
                            {
                            }
                        }
                        catch
                        {
                            //poLog.WriteEntry("Validación FileOpen .pdf:" + ex.Message, EventLogEntryType.Information);
                            continue;
                        }

                        #endregion

                        #region Mueve Archivos

                        try
                        {
                            for (int i = 0; i <= lsClaves.Length - 1; i++)
                            {
                                if (File.Exists(loArchivo) && File.Exists(loArchivo.Replace("xml", "pdf")))
                                {
                                    if (File.Exists(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo))) ||
                                        File.Exists(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("xml", "pdf"))))
                                    {
                                        File.Delete(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("xml", "pdf")));
                                        File.Delete(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo)));
                                    }

                                    if (File.Exists(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", ""))) ||
                                        File.Exists(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf"))))
                                    {
                                        File.Delete(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf")));
                                        File.Delete(Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "")));
                                    }
                                    // !File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo))) &&
                                    //!File.Exists(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("xml", "pdf"))))

                                    //File.Delete(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "")));
                                    //File.Delete(Path.Combine(ConfigurationManager.AppSettings[lsClave], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf")));

                                    if (i == 0)
                                    {
                                        File.Copy(loArchivo.Replace("xml", "pdf"), Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf")));
                                        File.Copy(loArchivo, Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "")));
                                    }
                                    if (i == 1)
                                    {
                                        File.Move(loArchivo.Replace("xml", "pdf"), Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "").Replace("xml", "pdf")));
                                        File.Move(loArchivo, Path.Combine(lsClaves[i], loFechaComprobante[0].Substring(0, 4), loFechaComprobante[0].Substring(0, 7), loFechaComprobante[0].Substring(0, 10), Path.GetFileName(loArchivo).Replace("[]", "")));
                                    }

                                    //File.Delete(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10) + "\\" + lsNombreArchivo + ".xml");
                                    //File.Delete(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10) + "\\" + lsNombreArchivo + ".pdf");
                                    //File.Move(lsUbicacionOrigen.TrimEnd('\\') + "\\" + lsNombreArchivo + ".xml", ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10) + "\\" + lsNombreArchivo + ".xml");
                                    //File.Move(lsUbicacionOrigen.TrimEnd('\\') + "\\" + lsNombreArchivo + ".pdf", ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + loFechaComprobante[0].Substring(0, 4) + "\\" + loFechaComprobante[0].Substring(0, 7) + "\\" + loFechaComprobante[0].Substring(0, 10) + "\\" + lsNombreArchivo + ".pdf");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            try
                            {
                                this.loDocumentos.EnviarAviso(ex.Message + " " + ex.Source, lsIndicadorEnvio, Correocuenta, CorreoDestinatario, CorreoServidor, CorreoPuerto, CorreoCP);
                            }
                            catch (Exception e)
                            {
                                poLog.WriteEntry("Ocurrio un error al enviar Email: " + e.Message, EventLogEntryType.Information);
                                continue;
                            }
                            Thread.Sleep(lnTiempoEsperaError);
                            continue;
                        }

                        #endregion
                    }
                }

                #region Procesa los .txt

                try
                {
                    foreach (string lsClave in ConfigurationManager.AppSettings.Keys) //recorre cada clave del appconfig
                    {
                        // Convertir en arreglo lsClave para extraer las dos rutas donde se guardaran los archivos.

                        if (lsClave == "UbicacionOrigen" || lsClave.Contains("Correo") || lsClave.Contains("Error") || lsClave.Contains("Hora")) //
                        {
                            continue;
                        }



                        string[] loArchivos = Directory.GetFiles(lsUbicacionOrigen, lsClave + "*.txt", SearchOption.TopDirectoryOnly);
                        string[] lsClaves   = ConfigurationManager.AppSettings[lsClave].Split(new Char[] { ';' });

                        foreach (string loArchivo in loArchivos)
                        {
                            string lsNombreArchivo = loArchivo.Substring(loArchivo.LastIndexOf('\\') + 1).Replace(".txt", "");
                            for (int i = 0; i <= lsClaves.Length - 1; i++)
                            {
                                if (!Directory.Exists(lsClaves[i].TrimEnd('\\')))
                                {
                                    Directory.CreateDirectory(lsClaves[i].TrimEnd('\\'));
                                }
                                File.Delete(Path.Combine(lsClaves[i], Path.GetFileName(loArchivo).Replace("[]", "")));

                                if (i == 0)
                                {
                                    poLog.WriteEntry(lsClaves[i], EventLogEntryType.Information);
                                    File.Copy(loArchivo, Path.Combine(lsClaves[i], Path.GetFileName(loArchivo).Replace("[]", "")));
                                }
                                if (i == 1)
                                {
                                    poLog.WriteEntry(lsClaves[i], EventLogEntryType.Information);
                                    File.Move(loArchivo, Path.Combine(lsClaves[i], Path.GetFileName(loArchivo).Replace("[]", "")));
                                }
                                //File.Delete(ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + lsNombreArchivo + ".txt");
                                //File.Move(lsUbicacionOrigen.TrimEnd('\\') + "\\" + lsNombreArchivo + ".txt", ConfigurationManager.AppSettings[lsClave].TrimEnd('\\') + "\\" + lsNombreArchivo + ".txt");
                                //File.Move(loArchivo, Path.Combine(ConfigurationManager.AppSettings[lsClaves[i]], Path.GetFileName(loArchivo).Replace("[]", "")));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        this.loDocumentos.EnviarAviso("Procesamiento de .txt " + ex.Message + "-" + ex.Source, lsIndicadorEnvio, Correocuenta, CorreoDestinatario, CorreoServidor, CorreoPuerto, CorreoCP);
                    }
                    catch (Exception e)
                    {
                        poLog.WriteEntry("Ocurrio un error al enviar Email: " + e.Message, EventLogEntryType.Information);
                        continue;
                    }
                    Thread.Sleep(lnTiempoEsperaError);
                    continue;
                }
                #endregion

                GC.Collect();
            }
        }