using System; using System.Collections.Generic; using System.Linq; using System.Web; using EnVisage.Code; using EnVisage.Code.Cache; namespace EnVisage.App_Start { public static class SecurityProvider { public static Dictionary GeneralAccess { get { object d = System.Web.HttpContext.Current.Application["SecurityItems"]; return (d == null ? null : (Dictionary)d); } set { System.Web.HttpContext.Current.Application["SecurityItems"] = value; } } public static Dictionary ProjectAccess { get { object d = System.Web.HttpContext.Current.Application["SecurityItems"]; return (d == null ? null : (Dictionary)d); } set { System.Web.HttpContext.Current.Application["SecurityItems"] = value; } } static SecurityProvider() { EnVisageEntities context = new EnVisageEntities(); ProjectAccessCache projAccessCache = new ProjectAccessCache(); SecurityAreasCache securityAreasCache = new SecurityAreasCache(); var projects = (from pr in projAccessCache.Value select pr).ToList(); var _ProjectAccess = new Dictionary(); foreach (var access in projects) { _ProjectAccess.Add(access.ProjectId, access.PrincipalId); } ProjectAccess = _ProjectAccess; var securityItems = (from pr in securityAreasCache.Value select pr).ToList(); var _GeneralAccess = new Dictionary(); foreach (var access in securityItems) { _GeneralAccess.Add(access.PrincipalId, (Areas)Enum.Parse(typeof(Areas), access.SecurityObject)); } GeneralAccess = _GeneralAccess; } } }