예제 #1
0
        public void Salvar(TUsuarioVO tusuariovo, Int32 usuarioLogado)
        {
            try
            {
                TLogVO log = new TLogVO();
                log.Tabela    = "TUsuario";
                log.IDUsuario = usuarioLogado;
                log.Data      = DateTime.Now;

                if (tusuariovo.IDUsuario > 0)
                {
                    log.Tipo = "Alterar - " + tusuariovo.Login + "-" + tusuariovo.Senha;
                    TUsuarioBLL.Alterar(tusuariovo);
                }
                else
                {
                    log.Tipo = "Inserir - " + tusuariovo.Login;
                    TUsuarioBLL.Inserir(tusuariovo);
                }

                TLogBLL.Inserir(log);
            }
            catch (CABTECException)
            {
                throw new CABTECException("Erro ao Salvar Usuário.");
            }
            catch (Exception)
            {
                throw new CABTECException("Erro ao Salvar Usuário.");
            }
        }
예제 #2
0
        public void ValidarMudarSenha(TUsuarioVO usuarioLogado, string novaSenha, string confirmaSenha)
        {
            try
            {
                if (!novaSenha.Equals(confirmaSenha))
                {
                    throw new CABTECException("A Nova Senha informada não confere!");
                }

                if (usuarioLogado == null)
                {
                    throw new CABTECException("O Usuário não foi informado!");
                }

                usuarioLogado.Senha = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", novaSenha);

                TUsuarioBLL.Alterar(usuarioLogado);
            }
            catch (CABTECException)
            {
                throw new CABTECException("Erro ao Alterar Senha.");
            }
            catch (Exception)
            {
                throw new CABTECException("Erro ao Alterar Senha.");
            }
        }
예제 #3
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.");
            }
        }
예제 #4
0
        public void AlterarSenha(TUsuarioVO usuarioLogado, string senhaAtual, string senhaNova, string senhaConfirma)
        {
            try
            {
                if (usuarioLogado == null)
                {
                    throw new CABTECException("Usuário inválido!");
                }

                if (!usuarioLogado.Senha.Equals(Criptografia.EncryptSymmetric("DESCryptoServiceProvider", senhaAtual)))
                {
                    throw new CABTECException("Senha Atual inválida!");
                }

                if (!senhaNova.Equals(senhaConfirma))
                {
                    throw new CABTECException("A Nova Senha informada não confere!");
                }

                usuarioLogado.Senha = Criptografia.EncryptSymmetric("DESCryptoServiceProvider", senhaNova);

                TUsuarioBLL.Alterar(usuarioLogado);

                TLogVO log = new TLogVO();
                log.Tabela    = "TUsuario";
                log.IDUsuario = usuarioLogado.IDUsuario;
                log.Data      = DateTime.Now;
                log.Tipo      = "Alterar - " + usuarioLogado.Login + " - " + senhaAtual + " - " + senhaNova;
                TLogBLL.Inserir(log);
            }
            catch (CABTECException)
            {
                throw new CABTECException("Erro ao Alterar Senha.");
            }
            catch (Exception)
            {
                throw new CABTECException("Erro ao Alterar Senha.");
            }
        }