コード例 #1
0
        public async Task <IActionResult> FinalizarReliquidacion(ReliquidacionViatico reliquidacionViatico)
        {
            Response response = new Response();

            try
            {
                var solicitud = new SolicitudViatico
                {
                    IdSolicitudViatico = reliquidacionViatico.IdSolicitudViatico
                };
                response = await apiServicio.ObtenerElementoAsync(solicitud,
                                                                  new Uri(WebApp.BaseAddress),
                                                                  "api/ReliquidacionViaticos/ActualizarEstadoReliquidacion");

                if (response.IsSuccess)
                {
                    return(RedirectToAction("Informe", new { IdSolicitudViatico = reliquidacionViatico.IdSolicitudViatico, IdItinerarioViatico = reliquidacionViatico.IdItinerarioViatico }));
                }

                ViewData["Error"] = response.Message;
                return(RedirectToAction("Informe", new { IdSolicitudViatico = reliquidacionViatico.IdSolicitudViatico, IdItinerarioViatico = reliquidacionViatico.IdItinerarioViatico }));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        public async Task <IActionResult> Detalle(int id, int IdActividad)
        {
            try
            {
                var usuario = new DocumentoFAOViewModel
                {
                    IdEmpleado = id,
                    IdFormularioAnalisisOcupacional = IdActividad
                };
                var response = await apiServicio.ObtenerElementoAsync(usuario, new Uri(WebApp.BaseAddress)
                                                                      , "api/Empleados/ObtenerEncabezadoEmpleadosFaoValidarConValidacionRH");

                if (response.IsSuccess)
                {
                    var empleado = JsonConvert.DeserializeObject <DocumentoFAOViewModel>(response.Resultado.ToString());
                    return(View(empleado));
                }
                ViewData["Error"] = response.Message;
                return(View());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #3
0
        public async Task <IActionResult> DetalleJefe(int id, int IdActividad)
        {
            try
            {
                var usuario = new DocumentoFAOViewModel
                {
                    IdEmpleado = id,
                    IdFormularioAnalisisOcupacional = IdActividad
                };
                var response = await apiServicio.ObtenerElementoAsync(usuario, new Uri(WebApp.BaseAddress)
                                                                      , "api/Empleados/InformeFinalFAO");

                if (response.IsSuccess)
                {
                    var empleado = JsonConvert.DeserializeObject <DocumentoFAOViewModel>(response.Resultado.ToString());
                    ViewData["IdManualPuesto"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList((empleado.ListasManualPuesto), "IdManualPuesto", "Nombre");
                    return(View(empleado));
                }
                ViewData["Error"] = response.Message;
                return(View());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #4
0
        public async Task <IActionResult> Index(string mensaje)
        {
            InicializarMensaje(mensaje);

            var modelo = new RequerimientoRolPorDependenciaViewModel();

            modelo.RolesNivelJerarquicoSuperior = new RequerimientoRolPorGrupoOcupacionalViewModel();
            modelo.RolesNivelOperativo          = new RequerimientoRolPorGrupoOcupacionalViewModel();
            modelo.RolesNivelJerarquicoSuperior.ListaRolesRequeridos = new List <RequerimientoRolViewModel>();
            modelo.RolesNivelOperativo.ListaRolesRequeridos          = new List <RequerimientoRolViewModel>();

            modelo.IdDependencia = 0;


            try
            {
                var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();

                if (claim.IsAuthenticated == true)
                {
                    var token         = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value;
                    var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;


                    modelo.NombreUsuario = NombreUsuario;


                    // Obtención de datos para generar pantalla
                    var respuesta = await apiServicio.ObtenerElementoAsync <RequerimientoRolPorDependenciaViewModel>(modelo, new Uri(WebApp.BaseAddress), "api/SituacionPropuesta/ObtenerRequerimientoRolPorDependencia");

                    if (respuesta.IsSuccess)
                    {
                        respuesta.Resultado = JsonConvert.DeserializeObject <RequerimientoRolPorDependenciaViewModel>(respuesta.Resultado.ToString());

                        return(View(respuesta.Resultado));
                    }
                    else
                    {
                        return(RedirectToAction("AutorizacionError", "SituacionPropuesta", new { mensaje = respuesta.Message }));
                    }
                }

                return(RedirectToAction("Login", "Login"));
            }
            catch (Exception ex)
            {
                if (String.IsNullOrEmpty(mensaje) == true)
                {
                    mensaje = Mensaje.Excepcion;
                }

                InicializarMensaje(mensaje);

                return(View(modelo));
            }
        }
コード例 #5
0
        public async Task <IActionResult> Edit(int id)
        {
            try
            {
                var modelo = new AccionPersonalViewModel {
                    IdAccionPersonal = id
                };

                var respuesta = await apiServicio.ObtenerElementoAsync <AccionPersonalViewModel>(
                    modelo,
                    new Uri(WebApp.BaseAddress),
                    "api/AccionesPersonal/ObtenerAccionPersonalViewModel");

                if (respuesta.IsSuccess)
                {
                    modelo = JsonConvert.DeserializeObject <AccionPersonalViewModel>(respuesta.Resultado.ToString());

                    await InicializarCombos();


                    var situacionActualViewModel = new SituacionActualEmpleadoViewModel {
                        IdEmpleado = modelo.DatosBasicosEmpleadoViewModel.IdEmpleado
                    };

                    var situacionActualEmpleadoViewModelResponse = await apiServicio.ObtenerElementoAsync <SituacionActualEmpleadoViewModel>(situacionActualViewModel, new Uri(WebApp.BaseAddress),
                                                                                                                                             "api/Empleados/ObtenerSituacionActualEmpleadoViewModel");

                    if (respuesta.IsSuccess)
                    {
                        situacionActualViewModel = JsonConvert.DeserializeObject <SituacionActualEmpleadoViewModel>(situacionActualEmpleadoViewModelResponse.Resultado.ToString());
                    }

                    modelo.SituacionActualEmpleadoViewModel = situacionActualViewModel;


                    var listaIOMP = await apiServicio.Listar <IndicesOcupacionalesModalidadPartidaViewModel>(
                        new Uri(WebApp.BaseAddress),
                        "api/IndicesOcupacionalesModalidadPartida/ListarIndicesOcupacionalesModalidadPartidaViewModel");

                    modelo.ListaIndicesOcupacionalesModalidadPartida = listaIOMP;


                    return(View(modelo));
                }

                return(BadRequest());
            }
            catch (Exception)
            {
                return(BadRequest());

                throw;
            }
        }
コード例 #6
0
ファイル: BodegaController.cs プロジェクト: nvalle88/WebAppRM
 public async Task <IActionResult> Create()
 {
     try
     {
         var claimTransfer = claimsTransfer.ObtenerClaimsTransferHttpContext();
         ViewData["Sucursal"] = new SelectList(new List <Sucursal> {
             new Sucursal {
                 IdSucursal = (int)claimTransfer.IdSucursal, Nombre = claimTransfer.NombreSucursal
             }
         }, "IdSucursal", "Nombre");
         ViewData["Empleado"] = new SelectList((await apiServicio.ObtenerElementoAsync <List <DatosBasicosEmpleadoViewModel> >(new EmpleadosPorSucursalViewModel {
             IdSucursal = claimTransfer.IdSucursal, EmpleadosActivos = true
         }, new Uri(WebApp.BaseAddressTH), "api/Empleados/ListarEmpleadosPorSucursal")).Select(c => new ListaEmpleadoViewModel {
             IdEmpleado = c.IdEmpleado, NombreApellido = $"{c.Nombres} {c.Apellidos}"
         }), "IdEmpleado", "NombreApellido");
         ViewData["Dependencia"] = new MultiSelectList(await apiServicio.ObtenerElementoAsync <List <Dependencia> >(new Sucursal {
             IdSucursal = claimTransfer.IdSucursal
         }, new Uri(WebApp.BaseAddressTH), "api/Dependencias/ListarDependenciaporSucursal"), "IdDependencia", "Nombre");
         return(View());
     }
     catch (Exception)
     {
         return(this.Redireccionar($"{Mensaje.Error}|{Mensaje.ErrorCargarDatos}"));
     }
 }
コード例 #7
0
        public async Task <IActionResult> Create()
        {
            try
            {
                var claim         = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();
                var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;

                var usuario = new DocumentoFAOViewModel
                {
                    NombreUsuario = NombreUsuario
                };
                var response = await apiServicio.ObtenerElementoAsync(usuario, new Uri(WebApp.BaseAddress)
                                                                      , "api/Empleados/ObtenerEncabezadoEmpleadosFao");

                if (response.IsSuccess)
                {
                    var empleado = JsonConvert.DeserializeObject <DocumentoFAOViewModel>(response.Resultado.ToString());
                    return(View(empleado));
                }
                //ViewData["Error"] = response.Message;
                return(RedirectToAction("ValidacionFao"));
                //return View();
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #8
0
        public async Task <FileResult> Download(string id)
        {
            var response = await apiServicio.SeleccionarAsync <Response>(id, new Uri(WebApp.BaseAddress),
                                                                         "api/MaterialesInduccion");

            var materialinduccion = JsonConvert.DeserializeObject <MaterialInduccion>(response.Resultado.ToString());
            var d = new MaterialInduccion
            {
                IdMaterialInduccion = Convert.ToInt32(id),
                Url = materialinduccion.Url
            };

            var ext = Path.GetExtension(materialinduccion.Url);

            if (ext != "")
            {
                var responseGetFile = await apiServicio.ObtenerElementoAsync(d,
                                                                             new Uri(WebApp.BaseAddress),
                                                                             "api/MaterialesInduccion/GetFile");

                var m = JsonConvert.DeserializeObject <DocumentoInstitucionalTransfer>(responseGetFile.Resultado.ToString());

                //var fileName = $"{ responseGetFile.Message}.pdf";


                var    fileName = string.Format("{0}{1}", $"{ responseGetFile.Message}", ext);
                string mime     = MimeKit.MimeTypes.GetMimeType(fileName);
                return(File(m.Fichero, mime, fileName));
            }
            else
            {
                return(File("", ""));
            }
        }
コード例 #9
0
        public async Task <IActionResult> Create(PieFirma PieFirma)
        {
            if (!ModelState.IsValid)
            {
                InicializarMensaje(null);
                return(View(PieFirma));
            }
            Response response = new Response();

            try
            {
                response = await apiServicio.ObtenerElementoAsync(PieFirma.IndiceOcupacional,
                                                                  new Uri(WebApp.BaseAddress),
                                                                  "api/IndicesOcupacionales/ObtenerIndiceOcupacional");

                response = await apiServicio.InsertarAsync(PieFirma,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/PiesFirma/InsertarPieFirma");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado un pie de firma",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Pie de Firma:", PieFirma.IdPieFirma),
                    });

                    return(RedirectToAction("Index"));
                }

                ViewData["Error"] = response.Message;
                ViewData["IdTipoAccionPersonal"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <TipoAccionPersonal>(new Uri(WebApp.BaseAddress), "api/TiposAccionesPersonales/ListarTiposAccionesPersonales"), "IdTipoAccionPersonal", "Nombre");
                //ViewData["IdIndiceOcupacional"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar<IndiceOcupacional>(new Uri(WebApp.BaseAddress), "api/IndicesOcupacionales/ListarIndicesOcupaciones"), "IdIndiceOcupacional", "Nombre");
                ViewData["IdCiudad"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <Ciudad>(new Uri(WebApp.BaseAddress), "api/Ciudad/ListarCiudad"), "IdCiudad", "Nombre");

                return(View(PieFirma));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando un pie de firma",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
コード例 #10
0
        /// <summary>
        /// Método que válida si el usuario actual tiene permiso para realizar la acción solicitada en el contexto
        /// El usuario debe tener los permisos en la base de datos
        /// </summary>
        /// <param name="context"></param>
        /// <param name="requirement"></param>
        /// <returns>Si la acción solicitada es o no satisfactoria</returns>
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, RolesRequirement requirement)
        {
            try
            {
                /// <summary>
                /// Se obtiene el contexto de datos
                /// </summary>
                /// <returns></returns>
                var recurso     = context.Resource as Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext;
                var httpContext = recurso.HttpContext;

                /// <summary>
                /// Se obtiene el path solicitado
                /// </summary>
                /// <returns></returns>
                var request = httpContext.Request;

                /// <summary>
                /// Se obtiene información del usuario autenticado
                /// </summary>
                /// <returns></returns>
                var claim         = context.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();
                var token         = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value;
                var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;

                var permiso = new PermisoUsuario
                {
                    Contexto = request.Path,
                    Token    = token,
                    Usuario  = NombreUsuario,
                };

                /// <summary>
                /// Se valida que la información del usuario actual tenga permiso para acceder al path solicitado...
                /// </summary>
                /// <returns></returns>
                var respuesta = apiServicio.ObtenerElementoAsync <entidades.Utils.Response>(permiso, new Uri(WebApp.BaseAddressSeguridad), "api/Adscpassws/TienePermiso");

                //respuesta.Result.IsSuccess = true;
                if (respuesta.Result.IsSuccess)
                {
                    context.Succeed(requirement);
                }
                else
                {
                    context.Fail();
                }
            }
            catch (Exception)
            {
                context.Fail();
                return(Task.CompletedTask);
            }
            return(Task.FromResult(0));
        }
コード例 #11
0
        public async Task <IActionResult> CodigoArticulo_SelectResult(int idArticulo)
        {
            try
            {
                var response = await apiServicio.ObtenerElementoAsync <Response>(idArticulo, new Uri(WebApp.BaseAddressRM), "api/MaestroArticuloSucursal/ObtenerGrupoArticulo");

                if (response.IsSuccess)
                {
                    return(Json(response.Resultado));
                }
            }
            catch (Exception)
            { }
            return(StatusCode(500));
        }
コード例 #12
0
        public async Task <FileResult> Download(string id)
        {
            var d = new DocumentoInformacionInstitucional
            {
                IdDocumentoInformacionInstitucional = Convert.ToInt32(id),
            };

            var response = await apiServicio.ObtenerElementoAsync(d,
                                                                  new Uri(WebApp.BaseAddress),
                                                                  "api/DocumentosInformacionInstitucional/GetFile");

            var m        = JsonConvert.DeserializeObject <DocumentoInstitucionalTransfer>(response.Resultado.ToString());
            var fileName = $"{ response.Message}.pdf";

            return(File(m.Fichero, "application/pdf", fileName));
        }
コード例 #13
0
        public async Task <FileResult> Download(string id, int IdSolicitudViatico, int IdItinerarioViatico)
        {
            var id2 = new ViewModelFacturaViatico
            {
                IdFacturaViatico = Convert.ToInt32(id),
            };
            var response = await apiServicio.ObtenerElementoAsync(id2,
                                                                  new Uri(WebApp.BaseAddress),
                                                                  "api/FacturaViatico/GetFile");


            var m        = JsonConvert.DeserializeObject <ViewModelFacturaViatico>(response.Resultado.ToString());
            var fileName = $"{ response.Message}.pdf";

            return(File(m.Fichero, "application/pdf", fileName));
        }
コード例 #14
0
        public async Task <FileResult> DescargarFichaOdontologica(string id)
        {
            var id2 = new FichaOdontologicaViewModel
            {
                IdPersona = Convert.ToInt32(id),
            };

            var response = await apiServicio.ObtenerElementoAsync(id2,
                                                                  new Uri(WebApp.BaseAddress),
                                                                  "api/ExamenesComplementarios/ObtenerFichaOdontologica");


            var m        = JsonConvert.DeserializeObject <FichaOdontologicaViewModel>(response.Resultado.ToString());
            var fileName = $"{id2.IdPersona}.pdf";

            return(File(m.Fichero, "application/pdf", fileName));
        }
コード例 #15
0
        public async Task <IActionResult> Index(string mensaje)
        {
            InicializarMensaje(mensaje);

            var modelo = new LavadoActivoEmpleadoViewModel();

            modelo.ListaLavadoActivoItemViewModel = new List <LavadoActivoItemViewModel>();

            try
            {
                var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();

                if (claim.IsAuthenticated == true)
                {
                    var token         = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value;
                    var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;

                    modelo.NombreUsuario = NombreUsuario;

                    // Obtención de datos para generar pantalla
                    var respuesta = await apiServicio.ObtenerElementoAsync <LavadoActivoEmpleadoViewModel>(modelo, new Uri(WebApp.BaseAddress), "api/LavadoActivoEmpleados/CrearLavadoActivoEmpleado");

                    if (respuesta.IsSuccess)
                    {
                        modelo = JsonConvert.DeserializeObject <LavadoActivoEmpleadoViewModel>(respuesta.Resultado.ToString());


                        return(View(modelo));
                    }
                    else
                    {
                        InicializarMensaje(respuesta.Message);
                        return(View(modelo));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
コード例 #16
0
ファイル: LoginController.cs プロジェクト: nvalle88/WebAppRM
        private async Task <Adscpassw> GetAdscPassws(Adscpassw adscpassw)
        {
            try
            {
                if (!adscpassw.Equals(null))
                {
                    var respuesta = await apiServicio.ObtenerElementoAsync <entidades.Utils.Response>(adscpassw, new Uri(WebApp.BaseAddressSeguridad), "api/Adscpassws/SeleccionarMiembroLogueado");

                    if (respuesta.IsSuccess)
                    {
                        var obje = JsonConvert.DeserializeObject <Adscpassw>(respuesta.Resultado.ToString());
                        return(obje);
                    }
                }
                return(null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #17
0
        public async Task <IActionResult> Login(Login login)
        {
            Response response = new Response();

            try
            {
                response = await apiServicio.ObtenerElementoAsync(login, new Uri(WebApp.BaseAddress),
                                                                  "api/Logins/ObtenerUsuario");

                if (response.IsSuccess)
                {
                    return(RedirectToAction("Index", "Personas"));
                }

                return(RedirectToAction("Login"));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #18
0
        public async Task <IActionResult> ListarMaterialesInduccion()
        {
            var lista      = new List <MaterialInduccion>();
            var imagenes   = new List <MaterialInduccion>();
            var documentos = new List <MaterialInduccion>();
            var videos     = new List <MaterialInduccion>();

            try
            {
                var claim = HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();

                if (claim.IsAuthenticated == true)
                {
                    var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;


                    var empleadoJson = ObtenerEmpleadoLogueado(NombreUsuario);

                    var induccionEmpleado = new Induccion
                    {
                        IdEmpleado = empleadoJson.Result.IdEmpleado
                    };

                    Response response = await apiServicio.ObtenerElementoAsync(induccionEmpleado, new Uri(WebApp.BaseAddress)
                                                                               , "api/MaterialesInduccion/ListarMaterialesInduccion");


                    if (response.IsSuccess)
                    {
                        return(RedirectToAction("Certificado"));
                    }

                    else if (String.IsNullOrEmpty(response.Message) == true)
                    {
                        lista = JsonConvert.DeserializeObject <List <MaterialInduccion> >(response.Resultado.ToString());

                        foreach (var item in lista)
                        {
                            var ext = Path.GetExtension(item.Url);
                            if (ext == ".jpeg" || ext == ".bmp" || ext == ".jpe" || ext == ".jpg" || ext == ".gif")
                            {
                                imagenes.Add(item);
                            }
                            else if (ext == ".pdf" || ext == ".xlsx" || ext == ".xls" || ext == ".docx" || ext == ".doc" || ext == ".pptx" || ext == ".ppt" || ext == "ppsx" || ext == "pps")
                            {
                                documentos.Add(item);
                            }
                            else
                            {
                                item.Url = item.Url.Replace("watch?v=", "embed/");
                                videos.Add(item);
                            }
                        }

                        var ViewModelInduccion = new ViewModelInduccion
                        {
                            Imagenes = imagenes,
                            Archivos = documentos,
                            Videos   = videos
                        };

                        return(View(ViewModelInduccion));
                    }

                    else
                    {
                        return(RedirectToAction("Error", response.Message));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Login"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
コード例 #19
0
        public async Task <IActionResult> Index(int IdPlanGestionCambio, int IdActividadesGestionCambio)
        {
            try
            {
                if (IdPlanGestionCambio != 0 && IdActividadesGestionCambio == 0)
                {
                    var actividadesGestionCambio = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio = Convert.ToInt32(IdPlanGestionCambio),
                    };

                    var viewModelActividadesGestionCambio = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio           = Convert.ToInt32(IdPlanGestionCambio),
                        ListaActividadesGestionCambio = await apiServicio.Listar <ActividadesGestionCambioIndex>(actividadesGestionCambio, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ListarActividadesGestionCambioconIdPlan")
                    };

                    return(View(viewModelActividadesGestionCambio));
                }

                if (IdPlanGestionCambio == 0 && IdActividadesGestionCambio != 0)
                {
                    var actividadesGestionCambio = new ActividadesGestionCambio
                    {
                        IdActividadesGestionCambio = Convert.ToInt32(IdActividadesGestionCambio),
                    };


                    var respuesta = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress),
                                                                                                      "/api/ActividadesGestionCambio/ActividadesGestionCambioconIdActividad");

                    var actividades = JsonConvert.DeserializeObject <ActividadesGestionCambio>(respuesta.Resultado.ToString());

                    var actividadesGestionCambioViewModel = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio = Convert.ToInt32(actividades.IdPlanGestionCambio),
                    };


                    var viewModelActividadesGestionCambio = new ActividadesGestionCambioViewModel
                    {
                        IdPlanGestionCambio           = Convert.ToInt32(actividades.IdPlanGestionCambio),
                        ListaActividadesGestionCambio = await apiServicio.Listar <ActividadesGestionCambioIndex>(actividadesGestionCambioViewModel, new Uri(WebApp.BaseAddress), "/api/ActividadesGestionCambio/ListarActividadesGestionCambioconIdPlan")
                    };


                    return(View(viewModelActividadesGestionCambio));
                }


                ViewData["Mensaje"] = "Ir a la página de Plan Gestión Cambio";
                return(View("NoExisteElemento"));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Listando una actividad de gestión de cambio",
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.NetActivity),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
コード例 #20
0
        public async Task <IActionResult> Create(AvanceGestionCambio AvanceGestionCambio)
        {
            Response response = new Response();

            try
            {
                var actividadesGestionCambio = new ActividadesGestionCambio
                {
                    IdActividadesGestionCambio = AvanceGestionCambio.IdActividadesGestionCambio,
                };

                var respuestaActividades = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress),
                                                                                                             "/api/ActividadesGestionCambio/ActividadesGestionCambioconIdActividad");

                var actividades = JsonConvert.DeserializeObject <ActividadesGestionCambio>(respuestaActividades.Resultado.ToString());

                var respuestaSuma = await apiServicio.ObtenerElementoAsync <ActividadesGestionCambio>(actividadesGestionCambio, new Uri(WebApp.BaseAddress),
                                                                                                      "/api/AvancesGestionCambio/AvanceGestionCambioSumaIndicadorReal");

                var suma = JsonConvert.DeserializeObject <AvanceGestionCambioModel>(respuestaSuma.Resultado.ToString());

                if ((suma.Suma + AvanceGestionCambio.Indicadorreal) <= actividades.Indicador)
                {
                    response = await apiServicio.InsertarAsync(AvanceGestionCambio,
                                                               new Uri(WebApp.BaseAddress),
                                                               "/api/AvancesGestionCambio/InsertarAvanceGestionCambio");

                    if (response.IsSuccess)
                    {
                        var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                            ExceptionTrace       = null,
                            Message              = "Se ha creado un avance gestión de cambio",
                            UserName             = "******",
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                            EntityID             = string.Format("{0} {1}", "Avance gestión de cambio:", AvanceGestionCambio.IdAvanceGestionCambio),
                        });

                        return(RedirectToAction("Index", new { IdActividadesGestionCambio = AvanceGestionCambio.IdActividadesGestionCambio }));
                    }
                    else
                    {
                        ViewData["Error"] = response.Message;
                        return(View(AvanceGestionCambio));
                    }
                }
                else
                {
                    string mensaje = "No se puede crear el avance de control cambio ya que el indicador de la actividad es " + actividades.Indicador + " y la suma del indicador real es de " + suma.Suma + "  y al aumentarle " + AvanceGestionCambio.Indicadorreal + " sobrepasaría en " + ((suma.Suma + AvanceGestionCambio.Indicadorreal) - actividades.Indicador);
                    ViewData["Error"] = mensaje;
                    return(View(AvanceGestionCambio));
                }
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando un avance gestión de cambio",
                    ExceptionTrace       = ex,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
コード例 #21
0
ファイル: Filtro.cs プロジェクト: nvalle88/WebAppRM
        public void OnActionExecuting(ActionExecutingContext context)
        {
            try
            {
                /// <summary>
                /// Se obtiene el contexto de datos
                /// </summary>
                /// <returns></returns>
                /// con
                var httpContext = context.HttpContext;

                /// <summary>
                /// Se obtiene el path solicitado
                /// </summary>
                /// <returns></returns>
                var request = httpContext.Request;

                /// <summary>
                /// Se obtiene información del usuario autenticado
                /// </summary>
                /// <returns></returns>
                var claim         = context.HttpContext.User.Identities.Where(x => x.NameClaimType == ClaimTypes.Name).FirstOrDefault();
                var token         = claim.Claims.Where(c => c.Type == ClaimTypes.SerialNumber).FirstOrDefault().Value;
                var NombreUsuario = claim.Claims.Where(c => c.Type == ClaimTypes.Name).FirstOrDefault().Value;

                var permiso = new PermisoUsuario
                {
                    Contexto = request.Path,
                    Token    = token,
                    Usuario  = NombreUsuario
                };

                /// <summary>
                /// Se valida que la información del usuario actual tenga permiso para acceder al path solicitado...
                /// </summary>
                /// <returns></returns>
                var respuestaToken = apiServicio.ObtenerElementoAsync <Response>(permiso, new Uri(WebApp.BaseAddressSeguridad), "api/Adscpassws/ExisteToken");

                if (!respuestaToken.Result.IsSuccess)
                {
                    context.HttpContext.Authentication.SignOutAsync("Cookies");

                    foreach (var cookie in context.HttpContext.Request.Cookies.Keys)
                    {
                        context.HttpContext.Response.Cookies.Delete(cookie);
                    }

                    var result = new ViewResult {
                        ViewName = "SeccionCerrada"
                    };
                    context.Result = result;
                }
                else
                {
                    var respuesta = apiServicio.ObtenerElementoAsync <Response>(permiso, new Uri(WebApp.BaseAddressSeguridad), "api/Adscpassws/TienePermiso");
                    if (!respuesta.Result.IsSuccess)
                    {
                        var result = new ViewResult {
                            ViewName = "AccesoDenegado"
                        };
                        context.Result = result;
                    }
                    else
                    {
                        var claimTransfer = claimsTransfer.ObtenerClaimsTransferHttpContext();
                        if (claimTransfer == null || claimTransfer.IdSucursal == 0 || String.IsNullOrEmpty(claimTransfer.NombreSucursal))
                        {
                            var result = new ViewResult {
                                ViewName = "AccesoDenegadoEmpleadosClaims"
                            };
                            context.Result = result;
                        }
                    }
                }
            }
            catch (Exception)
            {
                var result = new RedirectResult(WebApp.BaseAddressWebAppLogin);
                context.Result = result;
            }
        }
コード例 #22
0
        public async Task <IActionResult> Create(int id)
        {
            try
            {
                var datosBasicosEmpleado = new DatosBasicosEmpleadoSinRequiredViewModel {
                    IdEmpleado = id
                };

                var respuesta = await apiServicio.ObtenerElementoAsync <DatosBasicosEmpleadoSinRequiredViewModel>(
                    datosBasicosEmpleado,
                    new Uri(WebApp.BaseAddress),
                    "api/Empleados/ObtenerDatosBasicosEmpleado");

                if (respuesta.IsSuccess)
                {
                    datosBasicosEmpleado = JsonConvert.DeserializeObject <DatosBasicosEmpleadoSinRequiredViewModel>(respuesta.Resultado.ToString());


                    var situacionActualViewModel = new SituacionActualEmpleadoViewModel {
                        IdEmpleado = datosBasicosEmpleado.IdEmpleado
                    };

                    var situacionActualEmpleadoViewModelResponse = await apiServicio.ObtenerElementoAsync <SituacionActualEmpleadoViewModel>(situacionActualViewModel, new Uri(WebApp.BaseAddress),
                                                                                                                                             "api/Empleados/ObtenerSituacionActualEmpleadoViewModel");

                    if (respuesta.IsSuccess)
                    {
                        situacionActualViewModel = JsonConvert.DeserializeObject <SituacionActualEmpleadoViewModel>(situacionActualEmpleadoViewModelResponse.Resultado.ToString());
                    }


                    var listaIOMP = await apiServicio.Listar <IndicesOcupacionalesModalidadPartidaViewModel>(
                        new Uri(WebApp.BaseAddress),
                        "api/IndicesOcupacionalesModalidadPartida/ListarIndicesOcupacionalesModalidadPartidaViewModel");

                    var model = new AccionPersonalViewModel
                    {
                        DatosBasicosEmpleadoViewModel = datosBasicosEmpleado,
                        Numero         = "0",
                        Fecha          = DateTime.Now,
                        FechaRige      = DateTime.Now,
                        FechaRigeHasta = DateTime.Now,
                        SituacionActualEmpleadoViewModel          = situacionActualViewModel,
                        GeneraMovimientoPersonal                  = false,
                        ListaIndicesOcupacionalesModalidadPartida = listaIOMP
                    };


                    await InicializarCombos();


                    return(View(model));
                }

                return(BadRequest());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }