//esta funcion se inicializan algunos valores ------------------------------------------------ private void init() { string[] roles = Roles.GetRolesForUser(this.User.Identity.Name); this.rol = roles[0]; //Debug.WriteLine("rol: "+rol); HiddenField_TipoRol.Value = this.rol; this.configuracion = new Configuracion(); this.email_smtp = new EmailSMTP(); this.control_db = new ControlDB(); this.enviar_correo = new EnviarCorreo(this.User.Identity.Name); this.elementos_id = 1; this.ruta_principal = Server.MapPath("~/"); this.habilitar_envio_email_aviso = bool.Parse(configuracion.HabilitarEnvioEmailAviso); this.servidor_smtp_ip = configuracion.ServidorSmtpIp; cargarDescripcion(); listarExtenciones(); }
public async Task <EmailSMTP> GetSMTPHost() { try { var emailSettings = (await _setting.GetGeneratSettingValueByKeyGroup(Constants.SMTPConstants.SMTP)).ToList(); EmailSMTP smtp = new EmailSMTP(); foreach (var item in emailSettings) { switch (item.KeyName) { case Constants.SMTPConstants.SMTP_Host: smtp.SMPTHost = item.Value; break; case Constants.SMTPConstants.SMTP_Port: smtp.SMTPPort = Convert.ToInt32(item.Value); break; case Constants.SMTPConstants.SMTP_UserName: smtp.SMTPUsername = item.Value; break; case Constants.SMTPConstants.SMTP_Password: smtp.SMTPPassword = item.Value; break; case Constants.SMTPConstants.SMTP_EnableSSL: smtp.SMTPEnableSSL = item.Value == "1" ? true : false; break; case Constants.SMTPConstants.EmailFrom: smtp.SMTPEmailFrom = item.Value; break; default: break; } } return(smtp); } catch (Exception) { throw; } }
public MainWindow() { InitializeComponent(); // Initializing coordinates with UTM coordinate system viewPort = new ViewPortArea(576158, 576954, 9716967, 9717580); viewPort.RoverX = 576246; viewPort.RoverY = 9717055; viewPort.TargetX = 576493; viewPort.TargetY = 9717345; pathDistance = viewPort.PathDistance(); lblRover.Text = "Rover: " + viewPort.RoverX.ToString() + " x " + viewPort.RoverY.ToString(); lblTarget.Text = "Target: " + viewPort.TargetX.ToString() + " x " + viewPort.TargetY.ToString(); lblDistance.Text = "Distance: " + Convert.ToInt32(pathDistance).ToString(); AddGraphics(); emailSMTP = new EmailSMTP(txtToEmail.Text, txtMessage.Text); }
private static void CheckIfItsTimeToSendEmail(object x) { try { while (true) { Thread.Sleep(3000); try { List <EmailLogEnvio> lobjEmailsPendentes = m_emailLOGRepository.All.Where(P => P.DataEnviada == null).ToList(); if (lobjEmailsPendentes.Count() > 0) { EmailSMTP lobjSMTPConfig = m_emailSMTPRepository.All.FirstOrDefault(); SmtpClient lobjSMTP = new SmtpClient(lobjSMTPConfig.EnderecoSMTP, lobjSMTPConfig.Porta); lobjSMTP.Credentials = new NetworkCredential(lobjSMTPConfig.EmailOrigem, lobjSMTPConfig.Senha); lobjSMTP.EnableSsl = false; foreach (EmailLogEnvio email in lobjEmailsPendentes) { MailMessage lobjMM = email.getAsMailMessage(); lobjMM.From = new MailAddress(lobjSMTPConfig.EmailOrigem, email.SenderName); try { lobjSMTP.Send(lobjMM); email.ErroEnvio = string.Empty; email.DataEnviada = DateTime.Now; } catch (Exception ErroEnvio) { email.ErroEnvio = ErroEnvio.Message; if (email.ErroEnvio.Length > 100) { email.ErroEnvio = email.ErroEnvio.Substring(0, 100); } throw; } m_emailLOGRepository.InsertOrUpdate(email); } m_emailLOGRepository.Save(); } } catch (Exception Error) { } /* * if (m_autoEventThreadSendEmailFaturamento.WaitOne(TIME_CHECK_IF_IS_TIME_TO_SEND_EMAIL) == true) //Aqui é o tempo que ele espera até a próxima verificação, é tipo um Thread.Sleep(5000) * { * //O StopMonitor muda o estado desse controle e se ele for chamado, aqui nesse ponto ele sai fora do Loop do While e para de monitorar. * //PackedLunchHelper.PackedLunchDailyEmailMonitor.IsSendDailyEmailMonitorRunning = false; * break; * } */ } } catch (Exception Error) { //PackedLunchHelper.PackedLunchDailyEmailMonitor.IsSendDailyEmailMonitorRunning = false; //PackedLunchHelper.PackedLunchDailyEmailMonitor.StatusMessage = "Erro:" + Error.ToString(); throw Error; } }