Example #1
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;
        }
Example #2
0
        public ExcecaoAcessoNegado(bool acessoSistema)
        {
            TradutorIdioma tradutor = new TradutorIdioma(ConfigurationSettings.AppSettings["Idioma"]);
            string mensagem = string.Empty;

            if (!acessoSistema)
                mensagem = tradutor.traduzirMensagem("AcessoNegadoAusenciaPerfil");
            else
                mensagem = tradutor.traduzirMensagem("AcessoNegadoPerfilInsuficiente");

            throw new ExcecaoAcessoNegado(mensagem);
        }
Example #3
0
        public ExcecaoInstrucaoSQLNaoInformada(string siglaIdioma)
        {
            TradutorIdioma tradutor = new TradutorIdioma(string.Empty);

            throw new Exception(tradutor.traduzirMensagem("InstrucaoSQLNaoInformada"));
        }
Example #4
0
        public ExcecaoNivelRegistroExcecaoNaoInformado(string siglaIdioma)
        {
            TradutorIdioma tradutor = new TradutorIdioma(string.Empty);

            throw new Exception(tradutor.traduzirMensagem("NivelRegistroExcecaoNaoInformado"));
        }
Example #5
0
        public ExcecaoCredenciaisConexaoInvalidas(string siglaIdioma)
        {
            TradutorIdioma tradutor = new TradutorIdioma(string.Empty);

            throw new Exception(tradutor.traduzirMensagem("CredenciaisConexaoInvalidas"));
        }
Example #6
0
        public ExcecaoCaminhoDadosNaoEncontrado(string siglaIdioma)
        {
            TradutorIdioma tradutor = new TradutorIdioma(string.Empty);

            throw new Exception(tradutor.traduzirMensagem("CaminhoDadosNaoEncontrado"));
        }
Example #7
0
        public ExcecaoAusenciaConfiguracaoConexao(string siglaIdioma)
        {
            TradutorIdioma tradutor = new TradutorIdioma(string.Empty);

            throw new Exception(tradutor.traduzirMensagem("AusenciaConfiguracaoConexao"));
        }
Example #8
0
        public ExcecaoAcaoPersistenciaInvalida(string siglaIdioma)
        {
            TradutorIdioma tradutor = new TradutorIdioma(string.Empty);

            throw new Exception(tradutor.traduzirMensagem("AcaoPersistenciaInvalida"));
        }
Example #9
0
        protected string notificarExcecao(Exception objetoExcecao, string siglaIdioma)
        {
            string mensagemRetorno = string.Empty;
            TradutorIdioma tradutorIdioma = new TradutorIdioma(siglaIdioma);

            mensagemRetorno = string.Format(tradutorIdioma.traduzirMensagem("MensagemExcecaoUsuario"), objetoExcecao.Message);

            return mensagemRetorno;
        }