示例#1
0
        protected virtual void LoadUser(AuthenticationIdentity user, HttpActionContext actionContext)
        {
            if (HttpContext.Current != null)
            {
                BaseApiController baseApiController = actionContext.ControllerContext.Controller as BaseApiController;

                if (baseApiController != null)
                {
                    // Chave padrão do cache - nome do método + parâmetros.
                    string chave = RetornaChaveCache_LoadUser(user);
                    object cache = HttpContext.Current.Cache[chave];

                    if (cache == null)
                    {
                        #region Load user values

                        UsuarioWEB userLogged = new UsuarioWEB();

                        // Carrega usuário na session através do ticket de authenticação
                        userLogged.Usuario = new SYS_Usuario
                        {
                            ent_id = user.Entity
                            ,
                            usu_login = user.Login
                        };
                        SYS_UsuarioBO.GetSelectBy_ent_id_usu_login(userLogged.Usuario);

                        userLogged.Grupo = SYS_GrupoBO.GetEntity(new SYS_Grupo {
                            gru_id = user.Group
                        });

                        baseApiController.__userLogged = userLogged;

                        #endregion

                        HttpContext.Current.Cache.Insert(chave, userLogged, null, DateTime.Now.AddMinutes(GestaoEscolarUtilBO.MinutosCacheMedio)
                                                         , System.Web.Caching.Cache.NoSlidingExpiration);
                    }
                    else
                    {
                        baseApiController.__userLogged = cache as UsuarioWEB;
                    }
                }
            }
        }
示例#2
0
 private string RetornaChaveCache_LoadUser(AuthenticationIdentity entity)
 {
     return(string.Format("LoadUserJWK_{0}_{1}_{2}", entity.Entity, entity.Login, entity.Group));
 }