コード例 #1
0
        public string registrarExcecao(Usuario usuarioRemetente, long hashEntidadeRemetente, Exception objetoExcecao, short tipoExcecao, int nivelRegistro, string siglaIdioma)
        {
            string retornoRegistro = string.Empty;

            if (nivelRegistro > 0)
            {
                if ((NivelRegistroExcecao.Notificacao & nivelRegistro) == NivelRegistroExcecao.Notificacao)
                    retornoRegistro = notificarExcecao(objetoExcecao, siglaIdioma);

                if ((NivelRegistroExcecao.Gravacao & nivelRegistro) == NivelRegistroExcecao.Gravacao)
                    gravarExcecao(usuarioRemetente, hashEntidadeRemetente, objetoExcecao, tipoExcecao, siglaIdioma);

                if ((NivelRegistroExcecao.Armazenamento & nivelRegistro) == NivelRegistroExcecao.Armazenamento)
                    armazenarExcecao(usuarioRemetente, hashEntidadeRemetente, objetoExcecao);

                //if ((NivelRegistroExcecao.EnvioPorEmail & nivelRegistro) == NivelRegistroExcecao.EnvioPorEmail)
                    //enviarExcecao(usuarioRemetente, hashEntidadeRemetente, objetoExcecao);

                //if ((NivelRegistroExcecao.AcionamentoSuporteTecnico & nivelRegistro) == NivelRegistroExcecao.AcionamentoSuporteTecnico)
                    //acionarSuporteTecnico(usuarioRemetente, hashEntidadeRemetente, objetoExcecao);
            }
            else
                throw new ExcecaoNivelRegistroExcecaoNaoInformado(siglaIdioma);

            return retornoRegistro;
        }
コード例 #2
0
        protected void armazenarExcecao(Usuario usuarioRemetente, long hashEntidadeRemetente, Exception objetoExcecao)
        {
            Excecao novaExcecao = new Excecao();
            RegistroSistema registroExcecao = new RegistroSistema();
            Serializador serializador = new Serializador();

            novaExcecao.Mensagem = objetoExcecao.Message;
            novaExcecao.Rastreamento = objetoExcecao.StackTrace;

            registroExcecao.IdUsuario = usuarioRemetente.Id;
            registroExcecao.HashEntidade = hashEntidadeRemetente;
            registroExcecao.DataAcao = DateTime.Now;
            registroExcecao.Acao = AcaoRegistroSistema.RegistroExcecao;
            registroExcecao.Descricao = serializador.serializarBinario(novaExcecao);

            registroExcecao.incluir(registroExcecao);
        }
コード例 #3
0
        protected void gravarExcecao(Usuario usuarioRemetente, long hashEntidadeRemetente, Exception objetoExcecao, short tipoExcecao, string siglaIdioma)
        {
            string tituloAplicacao = string.Empty;
            string mensagemRegistro = string.Empty;
            string origemErro = string.Empty;
            EventLog registroEventoSistema = new EventLog();
            EventLogEntryType tipoEntradaRegistro = EventLogEntryType.Information;
            TradutorIdioma tradutorIdioma = new TradutorIdioma(siglaIdioma);

            mensagemRegistro = string.Format(tradutorIdioma.traduzirMensagem("MensagemExcecaoSistema"),
                                                                                 objetoExcecao.Message,
                                                                              usuarioRemetente.Apelido,
                                                                                 hashEntidadeRemetente,
                                                                              objetoExcecao.StackTrace);

            tituloAplicacao = tradutorIdioma.traduzirTexto("SGE_TituloAplicacao");

            origemErro = string.Concat("SGE.v2 : ", objetoExcecao.Message.Substring(0, objetoExcecao.Message.Length >= 203 ?
                                                                                       203 :
                                                                                       objetoExcecao.Message.Length));

            if (!EventLog.SourceExists(origemErro))
                EventLog.CreateEventSource(origemErro, tituloAplicacao);

            registroEventoSistema.Source = origemErro;
            registroEventoSistema.Log = tituloAplicacao;

            switch (tipoExcecao)
            {
                case TipoExcecao.Informacao:
                    tipoEntradaRegistro = EventLogEntryType.Information;
                    break;
                case TipoExcecao.Alerta:
                    tipoEntradaRegistro = EventLogEntryType.Warning;
                    break;
                case TipoExcecao.Erro:
                    tipoEntradaRegistro = EventLogEntryType.Error;
                    break;
            }

            registroEventoSistema.WriteEntry(mensagemRegistro, tipoEntradaRegistro);
            registroEventoSistema.Dispose();

            tradutorIdioma = null;
        }
コード例 #4
0
ファイル: Teste.cs プロジェクト: angelacheredia/ROPSQL
        private static void Ingressar(string usuario, string senha)
        {
            ControladorAcesso controleAcesso = new ControladorAcesso();
            Usuario usuarioIngressar = new Usuario();
            Usuario usuarioRegistrado = null;

            usuarioIngressar.Apelido = usuario;
            usuarioIngressar.Senha = senha;

            usuarioRegistrado = controleAcesso.validarAcesso(usuarioIngressar);

            if (usuarioRegistrado != null)
            {
                controleAcesso.listarFuncionalidades(usuarioRegistrado.PerfilAcesso);
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.Write("Funcionalidades listadas.");
            }
            else
                throw new ExcecaoAcessoNegado(false);
        }
コード例 #5
0
        public Usuario validarAcesso(Usuario usuarioValidar)
        {
            Usuario usuarioConsulta = new Usuario();
            Criptografador cripto = new Criptografador();

            usuarioValidar.Senha = cripto.criptografarTexto(usuarioValidar.Senha);

            usuarioConsulta = (Usuario)usuarioConsulta.consultar(usuarioValidar, false);

            return usuarioConsulta;
        }