示例#1
0
        public void EnvioSenha(string login)
        {
            try
            {
                if (string.IsNullOrEmpty(login))
                {
                    throw new CABTECException("Informe o Login.");
                }

                TUsuarioVO usuario = new TUsuarioVO();

                usuario.Login = login;

                List <TUsuarioVO> usuarioLogin = TUsuarioBLL.Listar(usuario).ToList();

                if (usuarioLogin.Count != 1)
                {
                    throw new CABTECException("Login inválido!");
                }

                string path = HttpContext.Current.Server.MapPath("Template\\EmailEsqueceuSenha.htm");

                Random number = new Random();

                int novaSenha = number.Next(10000000, 99999999);

                string password = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", novaSenha.ToString());

                usuarioLogin[0].Senha = password;

                TUsuarioBLL.Alterar(usuarioLogin[0]);

                string html;

                using (var arquivoHtml = new StreamReader(path))
                {
                    html = arquivoHtml.ReadToEnd();
                    html = html.Replace("[LOGO]", WebConfigurationManager.AppSettings["DiretorioIMAGEM"] + @"LogoCliente.png");
                    html = html.Replace("[RODAPE]", WebConfigurationManager.AppSettings["DiretorioIMAGEM"] + @"sinafemail.png");
                    html = html.Replace("[SENHA]", novaSenha.ToString());
                }

                var de = WebConfigurationManager.AppSettings["EmailPADRAO"];

                List <string> emails = new List <string>();
                emails.Add(usuarioLogin[0].Email);

                EnviarEmail.Enviar(de, emails, "SINAF - Nova Senha", html, new List <string>());
            }
            catch (CABTECException)
            {
                throw new CABTECException("Erro ao Enviar Senha.");
            }
            catch (Exception)
            {
                throw new CABTECException("Erro ao Enviar Senha.");
            }
        }
示例#2
0
 public List <TUsuarioVO> Listar(TUsuarioVO filtro)
 {
     try
     {
         if (filtro.IDUsuario > 0)
         {
             List <TUsuarioVO> listaRetorno = new List <TUsuarioVO>();
             listaRetorno.Add(TUsuarioBLL.Obter(filtro.IDUsuario));
             return(listaRetorno);
         }
         else
         {
             return(TUsuarioBLL.Listar(filtro).ToList());
         }
     }
     catch (CABTECException)
     {
         throw new CABTECException("Erro ao Listar Usuário.");
     }
     catch (Exception)
     {
         throw new CABTECException("Erro ao Listar Usuário.");
     }
 }