Exemplo n.º 1
0
        public async Task <User> GetUserByUserNameAsync(string userName, bool?detalle = null)
        {
            userName.MustNotBeNull(() => new Exception("userName requerido"));

            var globalConfiguration = this.configuration;

            if (globalConfiguration == null)
            {
                return(null);
            }

            var requestUri = globalConfiguration.Configuration <string>("IdentityAPI");
            var url        = $"{requestUri}/api/Identity?username={userName}";

            if (detalle != null && detalle.Value)
            {
                url += "&includeDetails=true";
            }

            var response = await HttpRequestFactory.GetAsync(url)
                           .ConfigureAwait(false);

            var strResult = await response.Content.ReadAsStringAsync()
                            .ConfigureAwait(false);

            var result = JsonConvert.DeserializeObject <User>(strResult);

            return(result);
        }
Exemplo n.º 2
0
        public async Task <List <User> > GetUserNamesByUserNameAsync(string userName)
        {
            userName.MustNotBeNull(() => new Exception("userName requerido"));

            var urlApi = this.configuration.Configuration <string>("IdentityAPI");

            var url = $"{urlApi}/api/Identity?username={userName}&includeDetails=true&recortado=true";

            var response = await HttpRequestFactory.GetAsync(url)
                           .ConfigureAwait(false);

            var strResult = await response.Content.ReadAsStringAsync()
                            .ConfigureAwait(false);

            var result = JsonConvert.DeserializeObject <List <User> >(strResult);

            return(result);
        }
Exemplo n.º 3
0
        public async Task <User> GetUserByIdColaboradorAsync(int idColaborador)
        {
            var globalConfiguration = this.configuration;

            if (globalConfiguration == null)
            {
                return(null);
            }

            var requestUri = globalConfiguration.Configuration <string>("IdentityAPI");
            var url        = $"{requestUri}/api/Identity/GetByIdColaborador/{idColaborador}";

            var response = await HttpRequestFactory.GetAsync(url)
                           .ConfigureAwait(false);

            var strResult = await response.Content.ReadAsStringAsync()
                            .ConfigureAwait(false);

            var result = JsonConvert.DeserializeObject <User>(strResult);

            return(result);
        }
Exemplo n.º 4
0
        private async Task <List <ValidaRequisicion> > GetMatrizAprobacionAsync(
            string userNameRequeridor,
            int idRequisicion,
            string motivoIngresoDescripcion)
        {
            var urlApi   = this.configuracionGlobal.Configuration <string>("AutorizacionAPI");
            var response = await HttpRequestFactory.GetAsync(
                $"{urlApi}/api/Autorizacion/{userNameRequeridor}/{motivoIngresoDescripcion}")
                           .ConfigureAwait(false);

            var strResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var validaciones = JsonConvert.DeserializeObject <List <ValidaRequisicion> >(strResult);

            var asyncRepository = this.validacionRepository;

            if (asyncRepository == null)
            {
                return(validaciones);
            }

            var matriz = await asyncRepository.ListAsync(new ValidaRequisicionSpecification(idRequisicion))
                         .ConfigureAwait(false);

            foreach (var validaRequisicion in matriz)
            {
                var item = validaciones?.FirstOrDefault(
                    v => v != null && v.NivelValidacion == validaRequisicion.NivelValidacion);

                if (item == null)
                {
                    validaciones.Add(
                        new ValidaRequisicion
                    {
                        Id                = validaRequisicion.Id,
                        Fecha             = validaRequisicion.Fecha,
                        CreatedBy         = validaRequisicion.CreatedBy,
                        Created           = validaRequisicion.Created,
                        EditedBy          = validaRequisicion.EditedBy,
                        Edited            = validaRequisicion.Edited,
                        EstadoValidacion  = validaRequisicion.EstadoValidacion,
                        Comentario        = validaRequisicion.Comentario,
                        NivelValidacion   = validaRequisicion.NivelValidacion,
                        AprobadorUserName = validaRequisicion.AprobadorUserName
                    });
                }
                else
                {
                    item.Id = validaRequisicion.Id;

                    if (!validaRequisicion.Fecha.HasValue)
                    {
                        continue;
                    }

                    item.Fecha            = validaRequisicion.Fecha;
                    item.CreatedBy        = validaRequisicion.CreatedBy;
                    item.Created          = validaRequisicion.Created;
                    item.EditedBy         = validaRequisicion.EditedBy;
                    item.Edited           = validaRequisicion.Edited;
                    item.EstadoValidacion = validaRequisicion.EstadoValidacion;
                    item.Comentario       = validaRequisicion.Comentario;
                }
            }

            return(validaciones);
        }
Exemplo n.º 5
0
 public async Task GetAsyncWorks()
 {
     await HttpRequestFactory.GetAsync("https://google.com");
 }
        public async Task <User> GetUserODSAsync(string userNameOrigin)
        {
            try
            {
                //var identity = this.User?.Identity;
                //var userNameOrigin = identity?.Name?.Replace(@"NHELIOS\", string.Empty);

                var userName = this.configuracion?.Configuration <string>("UserSuplantado");

                if (string.IsNullOrEmpty(userName))
                {
                    var userSuplantado = await this.suplantarRepository.Single(
                        new SuplantarSpecification(userNameOrigin)).ConfigureAwait(false);

                    userName = userSuplantado?.UserProfile;
                }

                userName = userName ?? userNameOrigin;

                var urlApi = this.configuracion?.Configuration <string>("IdentityAPI");

                var response = await HttpRequestFactory.GetAsync($"{urlApi}/api" + $"/Identity?username={userName}")
                               .ConfigureAwait(false);

                var strResult = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                var user = JsonConvert.DeserializeObject <User>(strResult);

                var candidatoUser = new CandidatoUserSpecification(user.UserName);
                var candidato     = this.candidatoService.Single(candidatoUser);

                var usersEspaciales = this.configuracion.Configuration <string>("UserEspeciales").Split(';')
                                      .Select(u => u.ToUpper()).ToList();

                user.ShowNew = (int)user.NivelCompetencia >= 4 || usersEspaciales.Contains(user.UserName.ToUpper());

                user.ShowSearch = user.ShowNew || await this.IsAutorizador(user.UserName).ConfigureAwait(false) ||
                                  await this.HasEntrevistas(user.UserName).ConfigureAwait(false) ||
                                  this.IsAdminExpediente(user.UserName) ||
                                  await this.IsAdministrador(user.UserName) ||
                                  this.IsAdministradorRh(user.UserName) ||
                                  await this.IsReclutador(user.UserName).ConfigureAwait(false) ||
                                  this.IsCoordinadorRs(user.UserName) ||
                                  this.IsCompensaciones(user.UserName) ||
                                  this.IsPlaneacionEstrategica(user.UserName);

                user.ShowCatalog = await this.IsAdministradorExpediente(user.UserName) ||
                                   await this.IsAdministrador(user.UserName);

                if (candidato == null)
                {
                    return(user);
                }

                user.CandidatoUser           = candidato.CandidatoUser;
                user.ShowExpediente          = candidato.CandidatoDetalle.StatusSeleccion == EEstadoCandidato.Colaborador;
                user.CandidatoUser.Candidato = null;

                return(user);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }