Ejemplo n.º 1
0
        public virtual JsonResult GetApplicationMenu()
        {
            var appMenu  = new List <dynamic>();
            var cacheKey = string.Empty;

            try
            {
                if (UserClaims != null)
                {
                    //Creates a cacheKey using user login
                    cacheKey = "appMenu" + UserClaims.FirstOrDefault(uc => uc.ClaimType == ClaimTypes.WindowsAccountName).Value;
                    appMenu  = (List <dynamic>)HttpContext.Cache.Get(cacheKey);
                }

                if (appMenu == null || appMenu.Count <= 0)
                {
                    var menu = AppMenu.GetApplicationMenu();
                    appMenu = AppMenu.CastToDynamicMenuList(menu);

                    if (!string.IsNullOrEmpty(cacheKey))
                    {
                        HttpContext.Cache.Add(cacheKey, appMenu, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
                    }
                }
            }
            catch (Exception ex)
            {
            }

            return(Json(appMenu, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public virtual JsonResult GetMyAppsMenu()
        {
            var myAppsMenu = new List <dynamic>();
            var cacheKey   = string.Empty;

            try
            {
                var menuList = default(List <MenuModel>);

                if (UserClaims != null)
                {
                    //Creates a cacheKey using user login
                    cacheKey = "myAppsMenu" + UserClaims.FirstOrDefault(uc => uc.ClaimType == ClaimTypes.WindowsAccountName).Value;
                    menuList = (List <MenuModel>)HttpContext.Cache.Get(cacheKey);
                }

                if (menuList == null || menuList.Count <= 0)
                {
                    menuList = AppMenu.GetMyAppsMenu(AppCode, Header.LabelMenuMyApps);

                    if (!string.IsNullOrEmpty(cacheKey))
                    {
                        HttpContext.Cache.Add(cacheKey, menuList, null, DateTime.Now.AddHours(1), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
                    }
                }

                //Changes menu label for current Culture
                menuList.FirstOrDefault().Text = Header.LabelMenuMyApps;
                myAppsMenu = AppMenu.CastToDynamicMenuList(menuList);
            }
            catch (Exception ex)
            {
            }

            return(Json(myAppsMenu, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
 public virtual IdentityClaim FindUserClaim(string type)
 {
     return(UserClaims.FirstOrDefault(c => c.Type == type));
 }
Ejemplo n.º 4
0
 public virtual ApiResourceClaimDto FindClaim(string type)
 {
     return(UserClaims.FirstOrDefault(c => c.Type == type));
 }
Ejemplo n.º 5
0
 public virtual ApiScopeClaim FindClaim(string type)
 {
     return(UserClaims.FirstOrDefault(r => r.Type == type));
 }