示例#1
0
        public void GetPermissaoInativo_AlunoCancelado2018_NaoPermiteLogar()
        {
            //todo pegar cpf somente com ov <= 2018 e seja cancelado
            var clientes = new AlunoEntity().GetPermissao("08942660711", (int)Aplicacoes.MEDSOFT);

            Assert.IsFalse(Convert.ToBoolean(clientes.PermiteAcesso));
        }
示例#2
0
        public void GetPermissaoInativo_AlunoSuspensoPendente_NaoPermiteLogar()
        {
            //todo pegar cpf supenso ou pendente e seja cancelado
            var clientes = new AlunoEntity().GetPermissao("53345438801", (int)Aplicacoes.MsProMobile);

            Assert.IsFalse(Convert.ToBoolean(clientes.PermiteAcesso));
        }
示例#3
0
 public AlunoResponseModel(AlunoEntity aluno)
 {
     NomeAluno = aluno.NomeAluno;
     Email     = aluno.Email;
     CPF       = aluno.CPF;
     Telefone  = aluno.Telefone;
     Id        = aluno.Id;
 }
示例#4
0
        public List <EspecialRevalida> GetEspecialRevalida(int ano, int matricula, int idAplicacao = (int)Aplicacoes.MsProMobile)
        {
            try
            {
                var lsRevalida = new List <EspecialRevalida>();
                var mednet     = new MednetEntity();
                var aluno      = new AlunoEntity();

                new Util.Log().SetLog(new LogMsPro
                {
                    Matricula = matricula,
                    IdApp     = Aplicacoes.MsProMobile,
                    Tela      = Util.Log.MsProLog_Tela.Revalida,
                    Acao      = Util.Log.MsProLog_Acao.Abriu
                });

                var rev = mednet.GetTemasVideoRevalida();

                var revAgrp = rev.GroupBy(x => x.Assunto.Id).Select(grp => new { GrpID = grp.Key, RevalidaLst = grp.ToList() }).ToList();

                //var permissao = aluno.GetIsCortesiaRevalida(matricula);

                using (MiniProfiler.Current.Step("Carregando lista revalida obtendo o máximo progresso de aula revalida por item da lista"))
                {
                    foreach (var item in revAgrp)
                    {
                        var itemRevalida = new EspecialRevalida();
                        itemRevalida.Numero = item.GrpID;
                        itemRevalida.Ativa  = 1;

                        var apostilas = item.RevalidaLst.Select(x => new Apostila
                        {
                            IdEntidade  = x.Apostila.Especialidade.Id,
                            Nome        = x.Apostila.Descricao,
                            PercentLido = GetMaximoProgressoAulaRevalida(x.IdTema, matricula),
                            Temas       = new List <AulaTema> {
                                new AulaTema {
                                    TemaID = x.IdTema
                                }
                            }
                        }
                                                                );

                        itemRevalida.Apostilas.AddRange(apostilas);

                        lsRevalida.Add(itemRevalida);
                    }
                }

                return(lsRevalida);
            }
            catch
            {
                throw;
            }
        }
示例#5
0
        //[Ignore]
        public void CanSetReportScreenshot()
        {
            var matricula = 227166;

            var post = new AlunoEntity().SetMedsoftScreenshotReport(new SegurancaDevice
            {
                Matricula         = matricula,
                ScreenshotCounter = 1
            });

            Assert.IsTrue(post);
        }
示例#6
0
        public async Task <int> Create(AlunoRequestModel request)
        {
            var aluno         = new AlunoEntity(request.NomeAluno, request.Email, request.CPF, request.Telefone);
            var alunoJaExiste = await _repository.VerificarSeJaExisteAluno(aluno.CPF);

            if (alunoJaExiste)
            {
                throw new ArgumentException("Aluno já existe.");
            }

            aluno.Validate();
            await _repository.Create(aluno);

            return(aluno.Id);
        }
示例#7
0
        public void GetPermissaoAcesso_AlunoMedsoftDesktop_RetornaTrue()
        {
            var app          = Aplicacoes.MEDSOFT_PRO_ELECTRON;
            var device       = Utilidades.TipoDevice.windows;
            var alunoDesktop = new PerfilAlunoEntityTestData().GetAcessoAplicacao(app, device);

            if (alunoDesktop == null)
            {
                Assert.Inconclusive();
            }

            var permissao = new AlunoEntity().GetPermissaoAcesso((int)app, alunoDesktop.intClientId, alunoDesktop.txtDeviceToken, (Utilidades.TipoDevice)alunoDesktop.intApplicationId);

            Assert.AreEqual(1, permissao.PermiteAcesso);
            Assert.AreEqual(0, permissao.PermiteTroca);
        }
示例#8
0
        public int Update(AlunoEntity aluno)
        {
            using var db = Connection;

            var query = @"UPDATE Aluno
                            SET nome = @Nome,
                                idade = @Idade,
                                data_nascimento = @DataNascimento,
                                id_unidade = @IdUnidade
                          WHERE id_aluno = @IdAluno;";

            return(db.Execute(query, new
            {
                aluno.IdAluno,
                aluno.Nome,
                aluno.Idade,
                aluno.DataNascimento,
                aluno.IdUnidade
            }));
        }
示例#9
0
        public int Insert(AlunoEntity aluno)
        {
            using var db = Connection;

            var query = @"INSERT INTO ALUNO
                            (nome, 
                             idade, 
                             data_nascimento, 
                             id_unidade) 
                            VALUES(@Nome, 
                                   @Idade, 
                                   @DataNascimento, 
                                   @IdUnidade)
                            RETURNING id_aluno;";

            return(db.ExecuteScalar <int>(query, new
            {
                aluno.Nome,
                aluno.Idade,
                aluno.DataNascimento,
                aluno.IdUnidade
            }));
        }
示例#10
0
        public AlunoMedsoft GetAcessoAluno(string register, string senha, int idAplicacao, string appVersion, string tokenDevice, int idDevice)
        {
            var response = new AlunoMedsoft();

            try
            {
                var funcionarioEntity = new FuncionarioEntity();
                var pessoaEntity      = new PessoaEntity();

                var cliente = new Cliente();
                using (MiniProfiler.Current.Step("Obtendo dados do usuario"))
                {
                    cliente = CacheClienteGetByFilters(register, idAplicacao);
                }

                if (cliente == null || cliente.ID == 0)
                {
                    SetResponse(false,
                                TipoErroAcesso.CadastroInexistente.GetDescription(),
                                _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.USUARIO_NAO_CADASTRADO),
                                TipoErroAcesso.CadastroInexistente);
                    return(response);
                }


                var aluno = new AlunoMedsoft();
                using (MiniProfiler.Current.Step("Obtendo informações do tipo de usuário"))
                {
                    var golden     = _clienteRepository.UserGolden(cliente.Register, Aplicacoes.MsProMobile);
                    var tipoPessoa = pessoaEntity.GetPersonType(cliente.Register);
                    var tipoPerfil = funcionarioEntity.GetTipoPerfilUsuario(cliente.ID);
                    var isExAluno  = false;
                    if (!_alunoRepository.IsAlunoPendentePagamento(cliente.ID))
                    {
                        isExAluno = _alunoRepository.IsExAlunoTodosProdutosCache(cliente.ID);
                    }
                    var tempoInadimplenciaTimeout = new ConfigBusiness(new ConfigEntity()).GetTempoInadimplenciaTimeoutParametro();

                    aluno = new AlunoMedsoft
                    {
                        ID         = cliente.ID,
                        Nome       = cliente.Nome.TrimEnd(),
                        NickName   = cliente.NickName,
                        Register   = cliente.Register.TrimEnd(),
                        Senha      = cliente.Senha,
                        Foto       = cliente.Foto,
                        FotoPerfil = cliente.FotoPerfil,
                        IsGolden   = golden > 0,
                        TipoPessoa = tipoPessoa,
                        TipoPerfil = tipoPerfil,
                        ExAluno    = isExAluno,
                        tokenLogin = Util.AuthJWT.GeraJwt(cliente.ID, Constants.doisDiasEmMinutos),
                        TempoInadimplenciaTimeout = tempoInadimplenciaTimeout,
                        LstOrdemVendaMsg          = cliente.LstOrdemVendaMsg
                    };

                    if (aluno.Senha == string.Empty)
                    {
                        SetResponse(false,
                                    TipoErroAcesso.SemSenhaCadastrada.GetDescription(),
                                    _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.CADASTRAR_SENHA_MEDSOFTPRO),
                                    TipoErroAcesso.SemSenhaCadastrada);
                        return(aluno);
                    }

                    if (!aluno.IsGolden && aluno.Senha != senha)
                    {
                        SetResponse(false,
                                    TipoErroAcesso.SenhaIncorreta.GetDescription(),
                                    _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.ACESSO_NEGADO_SENHA_INCORRETA),
                                    TipoErroAcesso.SenhaIncorreta);
                        return(aluno);
                    }

                    if (cliente.RetornoStatus == Cliente.StatusRetorno.SemAcesso || cliente.RetornoStatus == Cliente.StatusRetorno.Cancelado)
                    {
                        if (string.IsNullOrEmpty(cliente.MensagemRetorno))
                        {
                            SetResponse(false,
                                        TipoErroAcesso.SemProdutosContratados.GetDescription(),
                                        _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.SEM_PRODUTOS),
                                        TipoErroAcesso.SemProdutosContratados);
                        }
                        else
                        {
                            SetResponse(false, cliente.TituloMensagemRetorno, cliente.MensagemRetorno, cliente.ETipoErro);
                        }
                        return(response);
                    }
                    else if (!string.IsNullOrEmpty(cliente.MensagemRetorno))
                    {
                        SetResponse(true, cliente.TituloMensagemRetorno, cliente.MensagemRetorno, cliente.ETipoErro);
                    }
                }

                var produtosPermitidos  = new List <Produto.Produtos>();
                var produtosContradados = new List <Produto>();
                using (MiniProfiler.Current.Step("Obtendo informações de produtos contratados"))
                {
                    produtosPermitidos  = _alunoRepository.GetProdutosPermitidosLogin(idAplicacao);
                    produtosContradados = ProdutoEntity.GetProdutosContratadosPorAnoCache(cliente.ID, false, 0, true, idAplicacao);
                }
                var anoLetivoAtual             = Utilidades.GetYear();
                var anoSeguinte                = anoLetivoAtual + 1;
                var anoAnterior                = anoLetivoAtual - 1;
                var anoAnteriorAntesDataLimite = Utilidades.IsAntesDatalimiteCache(anoAnterior, idAplicacao);


                var anoDireitoVitalicio = Convert.ToInt32(ConfigurationProvider.Get("Settings:anoComDireitoVitalicio"));
                var anosPermitidos      = new List <int>();

                for (var ano = anoDireitoVitalicio; ano <= anoSeguinte; ano++)
                {
                    anosPermitidos.Add(ano);
                }

                if (anoAnteriorAntesDataLimite)
                {
                    anosPermitidos.Add(anoAnterior);
                }

                var hasPermitidos = produtosContradados
                                    .Any(p => produtosPermitidos.Contains((Produto.Produtos)p.IDProduto) && anosPermitidos.Contains(p.Ano.Value));

                if (!hasPermitidos)
                {
                    SetResponse(false,
                                TipoErroAcesso.SemProdutosContratados.GetDescription(),
                                _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.SEM_PRODUTOS),
                                TipoErroAcesso.SemProdutosContratados);
                    return(response);
                }

                bool isVersaoBloqueada = string.IsNullOrEmpty(appVersion) ? _configRepository.GetDeveBloquearAppVersaoNulaCache() : new VersaoAppPermissaoBusiness(_versaoAppRepository).IsVersaoBloqueada(appVersion, idAplicacao);

                if (isVersaoBloqueada)
                {
                    SetResponse(false,
                                TipoErroAcesso.VersaoAppDesatualizada.GetDescription(),
                                _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.APLICATIVO_DESATUALIZADO),
                                TipoErroAcesso.VersaoAppDesatualizada);
                    return(response);
                }

                var permissaoDevice = new PermissaoDevice();
                using (MiniProfiler.Current.Step("Verificando permissões de acesso de usuário"))
                {
                    permissaoDevice     = new AlunoEntity().GetPermissaoAcesso(idAplicacao, aluno.ID, tokenDevice, (Utilidades.TipoDevice)idDevice);
                    aluno.PermiteAcesso = (aluno.IsGolden || permissaoDevice.PermiteAcesso == 1);
                    aluno.PermiteTroca  = (!aluno.IsGolden && permissaoDevice.PermiteTroca == 1);
                }

                if (!aluno.PermiteAcesso && !aluno.PermiteTroca)
                {
                    SetResponse(false,
                                TipoErroAcesso.DeviceBloqueado.GetDescription(),
                                _alunoRepository.GetMensagensLogin(idAplicacao, (int)TipoMensagemMEDSOFT.DISPOSITIVO_BLOQUEADO),
                                TipoErroAcesso.DeviceBloqueado);
                    return(response);
                }

                if (!aluno.LstOrdemVendaMsg.Any(x => x.PermiteAcesso == 1))
                {
                    SetResponse(false,
                                TipoErroAcesso.BloqueadoInadimplencia.GetDescription(),
                                cliente.MensagemRetorno,
                                TipoErroAcesso.BloqueadoInadimplencia);

                    return(response);
                }

                LogLogin log = new LogLogin
                {
                    Matricula   = aluno.ID,
                    AplicacaoId = idAplicacao,
                    AcessoId    = 0
                };

                new LogEntity().InsertAcessoLogin(log);

                SetResponse(true);
                return(aluno);
            }
            catch
            {
                throw;
            }
        }
        public MaterialApostilaAluno GetUltimaApostila(int MaterialId, int matricula, int IdVersao)
        {
            var apostilaAluno = new MaterialApostilaAluno();

            var materialApostilaAlunoManager = new MaterialApostilaAlunoManager();

            using (var ctx = new DesenvContext())
            {
                var query = (from a in ctx.tblMaterialApostilaAluno
                             join b in ctx.tblMaterialApostila on a.intMaterialApostilaID equals b.intID
                             where a.bitAtiva == 1 && a.intClientID == matricula && b.intProductId == MaterialId
                             select new MaterialApostilaAluno()
                {
                    DataAtualizacao = a.dteDataCriacao,
                    Id = a.intID,
                    PdfId = b.intProductId.Value,
                    ClientId = a.intClientID.Value,
                    ApostilaId = a.intMaterialApostilaID.Value,
                    Ativa = a.bitAtiva == 1,
                    EntidadeId = b.intProductId.Value
                });


                apostilaAluno = query.OrderByDescending(x => x.Id).FirstOrDefault();



                if (apostilaAluno != null)
                {
                    apostilaAluno.DataRelease = GetDataReleaseApostila(MaterialId, matricula);

                    var anoRelease = GetAnoReleaseApostila(MaterialId);

                    apostilaAluno.Configs = ctx.tblMaterialApostilaConfig
                                            .Select(x => new MaterialApostilaConfig()
                    {
                        Descricao = x.txtDescricao,
                        Ativa     = x.bitAtiva
                    })
                                            .ToList();

                    //carrega o link do css da apostila
                    var cssName = GetNameCss(MaterialId, anoRelease);
                    apostilaAluno.LinkCss = GetApostilaCss(anoRelease, cssName);

                    //carregar o material do aluno para obter o nome da apostila que está no S3
                    var materialApostilaAluno = ctx.tblMaterialApostilaAluno
                                                .Where(x => x.intClientID == matricula && x.intMaterialApostilaID == apostilaAluno.ApostilaId && x.bitAtiva == 1)
                                                .FirstOrDefault();

                    var apostilaVersao = Utilidades.GetDetalhesApostila(materialApostilaAluno);

                    //carregar o conteudo da apostila do aluno
                    string chave = Utilidades.CriarNomeApostila(matricula, apostilaAluno.ApostilaId, apostilaVersao.Versao);
                    apostilaAluno.Conteudo = materialApostilaAlunoManager.ObterArquivo(chave);

                    //retorna se o aluno tem permissão de edição do material
                    var alunoEntity = new AlunoEntity();
                    if (alunoEntity.IsAlunoPendentePagamento(matricula))
                    {
                        apostilaAluno.Bloqueado = false;
                    }
                    else
                    {
                        apostilaAluno.Bloqueado = alunoEntity.IsExAlunoTodosProdutos(matricula);
                    }

                    var anoAtual    = Utilidades.GetYear();
                    var anoApostila = Utilidades.UnixTimeStampToDateTime(apostilaAluno.DataRelease).Year;
                    apostilaAluno.NaoInterageDuvidas = apostilaAluno.Bloqueado ? apostilaAluno.Bloqueado : anoApostila < anoAtual;
                }
            }

            return(apostilaAluno);
        }