public void Monitoreo(EventLog poLog) { try { Sesion poSesion = (Sesion)EstablecerSesion(poLog); string[] lsClaveSucursales = ConfigurationManager.AppSettings["ClaveSucursales"].Split(new Char[] { ';' }); string lsCorreoAsunto = ConfigurationManager.AppSettings["CorreoAsunto"]; string lsCorreoAlerta = ConfigurationManager.AppSettings["CorreoAlerta"]; for (int lnSucursal = 0; lnSucursal <= lsClaveSucursales.Length - 1; lnSucursal++) { string lsCorreoDestinatario = ConfigurationManager.AppSettings["CorreoDestinatario" + lsClaveSucursales[lnSucursal]]; HelperMOSGestor loMonitoreoSaldos = new HelperMOSGestor(); DataTable loClientes = loMonitoreoSaldos.BuscarSaldosClientes(poSesion, int.Parse(lsClaveSucursales[lnSucursal])); bool loInactivarClientes = loMonitoreoSaldos.InactivarClientes(poSesion, loClientes, poLog); if (loInactivarClientes) { DataSet loClientesSaldoVencido = new DataSet(); loClientesSaldoVencido.Merge(loClientes.Select("(SALDO_PADRE > 0 OR SALDO_HIJO > 0)")); if (loClientesSaldoVencido.Tables.Count > 0) { AgruparClientePersonal(loClientes, lsCorreoAsunto, poLog); ObtenerMensaje(loClientes, lsCorreoDestinatario, lsCorreoAsunto, poLog); ObtenerMensaje(loClientes, NotificarPersonal(poSesion, loClientes, lsCorreoDestinatario, int.Parse(lsClaveSucursales[lnSucursal])), lsCorreoAsunto, poLog); } else { loClientes.Clear(); ObtenerMensaje(loClientes, NotificarPersonal(poSesion, loClientes, lsCorreoDestinatario, int.Parse(lsClaveSucursales[lnSucursal])), lsCorreoAsunto, poLog); } } else { EnviarEmail("Ocurrio un problema al inactivar clientes con saldo vencido.", lsCorreoAsunto, lsCorreoAlerta, poLog); } } } catch (Exception ex) { poLog.WriteEntry("ERROR METODO MONITOREO SALDOS." + ex, EventLogEntryType.Information); } GC.Collect(); }
private string NotificarPersonal(Sesion poSesion, DataTable loClientes, string lsCorreoDestinatario, int lnSucursal) { string lsCorreoDestinatarioTemp = string.Empty; HelperMOSGestor loGestor = new HelperMOSGestor(); DataTable loResultado = loGestor.ObtenerEmailPersonal(poSesion, lnSucursal); if (loClientes.Rows.Count > 0) { string[] lsDestinatarios = lsCorreoDestinatario.Split(new Char[] { ';' }); lsCorreoDestinatario = "E_MAIL NOT IN( "; foreach (string poDestinatarios in lsDestinatarios) { lsCorreoDestinatario = lsCorreoDestinatario + "'" + poDestinatarios + "' ,"; } foreach (DataRow lsEmailPersonal in loClientes.Rows) { lsCorreoDestinatario = lsCorreoDestinatario + "'" + lsEmailPersonal["EMAIL_PERSONAL"].ToString() + "' ,"; } lsCorreoDestinatario = lsCorreoDestinatario.TrimEnd(','); foreach (DataRow lsCliente in loResultado.Select(lsCorreoDestinatario + ")")) { lsCorreoDestinatarioTemp = lsCorreoDestinatarioTemp + lsCliente["E_MAIL"].ToString() + ";"; } } else { foreach (DataRow lsCliente in loResultado.Rows) { lsCorreoDestinatario = lsCorreoDestinatario + ";" + lsCliente["E_MAIL"]; } lsCorreoDestinatarioTemp = lsCorreoDestinatario; } loClientes.Clear(); return(lsCorreoDestinatarioTemp.TrimEnd(';')); }