public ActivityController()
        {
            log.Debug("Activity Controller called");

            _activity        = new ActivityService();
            _activityProfile = new ActivityProfileService();
            _activityGroup   = new ActivityGroupService();

            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message.ToString());

                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }
        }
        public void SetImage()
        {
            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message.ToString());

                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }
        }
Пример #3
0
        public PerfilTrainingItemXPerfilItemController()
        {
            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch
            {
                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }

            _perfilTrainingItemXPerfilItem = new PerfilTrainingItemXPerfilItemService();
            _profileTraining     = new TrainingProfileService();
            _profileItemTraining = new ProfileItemService();
        }
        public ActivityProfileItemController()
        {
            log.Debug("ActivityProfileItem Controller called");

            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch
            {
                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }

            _activityProfileItem = new ActivityProfileItemService();
        }
        public EmployeeController()
        {
            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch
            {
                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }

            _employee = new EmployeeService();
            _workzone = new WorkzoneService();
        }
Пример #6
0
        public HistoricoMatrizController()
        {
            _matrizHistoricoService = new MatrizHistoricoService();

            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch
            {
                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }
        }
Пример #7
0
        public ActivityXTrainingController()
        {
            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            try
            {
                username     = AuthorizationHelper.GetSystem();
                ViewBag.User = username.Usuario.ChaveAmericas;
                if (username != null)
                {
                    var imgUser = AuthorizationHelper.GetUserImage(username.Usuario.ChaveAmericas);
                    ViewBag.UserPhoto = imgUser;
                }
            }
            catch
            {
                var imgUser = AuthorizationHelper.GetUserImage("");

                ViewBag.User      = "";
                ViewBag.UserPhoto = imgUser;
            }

            _activityXTraining = new ActivityXTrainingService();
            _activity          = new ActivityService();
            _training          = new TrainingService();
        }
        public static SistemaApi GetSystem()
        {
            SistemaApi sistema = new SistemaApi();

            //AuthorizationContext aContext = new AuthorizationContext();
            if (GetSession() == null)
            {
                return(sistema);
            }

            return(JsonConvert.DeserializeObject <SistemaApi>(GetSession()));
        }
        public static void SavePermissionSession(SistemaApi permissoes)
        {
            var jsonSystem = JsonConvert.SerializeObject(permissoes, Formatting.None,
                                                         new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                NullValueHandling     = NullValueHandling.Ignore,
                MissingMemberHandling = MissingMemberHandling.Ignore
            });

            _context.Session["nomeSession"] = jsonSystem;
            _context.Session.Timeout        = 3600;
        }
        public MatrixController()
        {
            log.Debug("Matrix Controller called");

            // HISTÓRICO
            _matrizHistoricoService = new MatrizHistoricoService();
            // SERVIÇOS REFERENTES A MATRIZ OFICIAL
            _matrizService             = new MatrizWorkzoneService();
            _matrizFuncTrainingService = new MatrizFuncTreinamentoService();
            _matrizFuncActivityService = new MatrizFuncAtividadeService();
            // SERVIÇOS REFERENTES A MATRIZ TEMPORÁRIA
            _matrizTempService             = new MatrizWorkzoneTempService();
            _matrizFuncTrainingTempService = new MatrizFuncTreinamentoTempService();
            _matrizFuncActivityTempService = new MatrizFuncAtividadeTempService();
            // FIM
            _workzoneXActivity     = new WorzoneXActivityService();
            _activityXTraining     = new ActivityXTrainingService();
            _workzoneXFunc         = new WorzoneXEmployeeService();
            _perfilAtivXperfilItem = new PerfilAtivItemXPerfilItemService();
            _workzone            = new WorkzoneService();
            _activity            = new ActivityService();
            _training            = new TrainingService();
            _trainingType        = new TrainingTypeService();
            _profileTraining     = new TrainingProfileService();
            _profileActivity     = new ActivityProfileService();
            _profileItemActivity = new ActivityProfileItemService();
            _profileItemTraining = new ProfileItemService();
            _activityGroup       = new ActivityGroupService();
            _trainingGroup       = new TrainingGroupService();
            _employee            = new EmployeeService();

            //Pega o nome do usuário para exibir na barra de navegação
            SistemaApi username = new SistemaApi();

            ViewBag.userId = "matriz";
            SetImage();
        }
        public async Task <SistemaApi> getPermissions(string usuario)
        {
            var url = ConfigurationManager.AppSettings["AutSisAPI"] + usuario + "/tipochave/0";

            SistemaApi sistemaApi = null;

            var    builder = new UriBuilder(url);
            string urlAll  = builder.ToString();


            //Ignora os valores nulos que vierem no Corpo da Resposta
            var settings = new JsonSerializerSettings
            {
                NullValueHandling     = NullValueHandling.Ignore,
                MissingMemberHandling = MissingMemberHandling.Ignore
            };

            var result = await client.GetAsync(urlAll);

            if (result.StatusCode == HttpStatusCode.OK && result.Content != null)
            {
                var returnAPI = await client.GetStringAsync(urlAll);

                sistemaApi = JsonConvert.DeserializeObject <SistemaApi>(returnAPI, settings);

                // cria a sessão
                //AuthorizationHelper.SavePermissionSession(sistemaApi);
            }
            else
            {
                Console.WriteLine("chora");
            }


            return(sistemaApi);
        }
Пример #12
0
        private TipoResultadoAutorizacao CheckUserAuthorization()
        {
            log.Debug("CheckUserAuthorization called");


            SistemaApi usuarioPermissions = null;


            bool local = FormsAuthentication.LoginUrl == "/Account/Login" ? true : false;


            // Verifica se o usuário do SGP esta autenticado OU se você está rodando o sistema local
            log.Debug("User.Identity.IsAuthenticated: " + User.Identity.IsAuthenticated.ToString());

            if (User.Identity.IsAuthenticated || local)
            {
                string user = null;
                try
                {
                    user = AuthorizationHelper.GetSystem().Usuario.ChaveAmericas;

                    log.Debug("User chave americas: " + user.ToString());
                }
                catch
                {
                    user = null;
                }

                // Verifica se o usuário logado no sgp não é o mesmo que esta na sessão
                if (user == null || (!User.Identity.Name.ToUpper().Equals(user.ToUpper()) && !local))
                {
                    log.Debug("User chave americas é igual ao da sessão ou é nulo");


                    // Verifica se existe usuário do SGP logado
                    if (!String.IsNullOrEmpty(User.Identity.Name))
                    {
                        log.Debug("Usuário do SGP está logado");

                        string username = User.Identity.Name.ToString();
                        usuarioPermissions = Task.Run(async() => await _autsisService.getPermissions(username)).Result;
                    }

                    else if (user != null)
                    {
                        if (!String.IsNullOrEmpty(user))
                        {
                            usuarioPermissions = Task.Run(async() => await _autsisService.getPermissions(user)).Result;
                        }
                    }

                    else if (user == null && local)
                    {
                        return(TipoResultadoAutorizacao.NAO_AUTENTICADO);
                    }

                    else if (user != null && local)
                    {
                        return(TipoResultadoAutorizacao.AUTORIZADO);
                    }


                    if (usuarioPermissions != null) //Verifica se o usuário existe
                    {
                        AuthorizationHelper.SavePermissionSession(usuarioPermissions);

                        return(TipoResultadoAutorizacao.AUTORIZADO);
                    }

                    return(TipoResultadoAutorizacao.USUARIO_NAO_CADASTRADO);
                }

                return(TipoResultadoAutorizacao.AUTORIZADO);
            }

            return(TipoResultadoAutorizacao.NAO_AUTENTICADO);
        }
 public void SetMenu(SistemaApi permissions)
 {
 }