Exemple #1
0
 public IActionResult GetCurrentUser()
 {
     try
     {
         var sessao = SessaoSistema.GetSession(HttpContext);
         if (sessao != null)
         {
             var registro = _context.Usuario.Where(x => x.IdUsuario == sessao.IdUsuario).FirstOrDefault();
             if (registro != null)
             {
                 return(Ok(registro));
             }
             else
             {
                 return(NotFound("Usuário não encontrado!"));
             }
         }
         else
         {
             return(Unauthorized());
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
 public IActionResult Logout()
 {
     try
     {
         SessaoSistema.Logout(HttpContext);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex));
     }
 }
Exemple #3
0
        public void DefinaLabelsIPs()
        {
            if (SessaoSistema.InformacoesConexao == null)
            {
                SessaoSistema.BusqueConfiguracoesConexaoDoArquivo(DIRETORIO_LOCAL, NOME_ARQUIVO_CONFIGURACOES_BANCO);
            }

            lblIpApp.Text = GSUtilitarios.ObtenhaIPLocal();

            if (SessaoSistema.InformacoesConexao != null)
            {
                lblIpBanco.Text = SessaoSistema.InformacoesConexao.Servidor;
            }
        }
Exemple #4
0
        private void CarregueConfiguracoesConexaoBanco()
        {
            SessaoSistema.InformacoesConexao = SessaoSistema.BusqueConfiguracoesConexaoDoArquivo(DIRETORIO_LOCAL, NOME_ARQUIVO_CONFIGURACOES_BANCO);

            if (SessaoSistema.InformacoesConexao == null)
            {
                MessageBox.Show(Mensagens.NAO_HA_CONFIGURACOES_BANCO());
                return;
            }

            txtServidorConfiguracao.Text   = SessaoSistema.InformacoesConexao.Servidor;
            txtNomeBancoConfiguracoes.Text = SessaoSistema.InformacoesConexao.NomeBanco;
            txtUsuarioConfiguracao.Text    = SessaoSistema.InformacoesConexao.Usuario;
            txtSenhaConfiguracao.Text      = SessaoSistema.InformacoesConexao.Senha;
        }
Exemple #5
0
        private void btnSalvarConfiguracaoBasica_Click(object sender, EventArgs e)
        {
            var informacoesConexaoBanco = new InformacoesConexaoBanco()
            {
                Servidor  = txtServidorConfiguracao.Text.Trim(),
                NomeBanco = txtNomeBancoConfiguracoes.Text.Trim(),
                Usuario   = txtUsuarioConfiguracao.Text.Trim(),
                Senha     = txtSenhaConfiguracao.Text.Trim()
            };


            SessaoSistema.SalveConfiguracoesConexaoNoArquivo(informacoesConexaoBanco,
                                                             DIRETORIO_LOCAL,
                                                             NOME_ARQUIVO_CONFIGURACOES_BANCO);

            this.CarregueConfiguracoesConexaoBanco();
            DefinaLabelsIPs();
        }
Exemple #6
0
        //Evento Load
        private void GestaoEmpresa_Load(object sender, EventArgs e)
        {
            AjustePosicaoControlsDinamicamente();

            if (SessaoSistema.Iniciada)
            {
                CarregueChamador();
            }
            else
            {
                CarregueLogin();
            }

            txtUsuario.Select();

            CarregueConfiguracoesConexaoBanco();
            SessaoSistema.InicieVerificacaoDeConexao();

            InicieVerificacaoParaAtualizarStatusDeConexao();
        }
Exemple #7
0
        public IActionResult AuthorizationUser(string user, string password)
        {
            try
            {
                var registroUsuario = _context.Usuario.Where(x => x.Email == user).FirstOrDefault();

                if (registroUsuario == null)
                {
                    return(Unauthorized());
                }
                else
                {
                    if (registroUsuario.Senha == password)
                    {
                        SessaoSistema.NewSession(HttpContext, new SessaoSistema()
                        {
                            IdUsuario    = registroUsuario.IdUsuario,
                            Nome         = registroUsuario.Nome,
                            SobreNome    = registroUsuario.SobreNome,
                            Autenticacao = registroUsuario.Autenticacao,
                            Email        = registroUsuario.Email
                        });

                        return(Ok());
                    }
                    else
                    {
                        return(Unauthorized());
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }