public MembershipUser Get(Guid Id, bool nocache = false) { string cachekey = string.Concat(CacheKeys.Member.StartsWith, "Get-", Id); var data = _cacheService.Get <MembershipUser>(cachekey); if (data == null || nocache) { var Cmd = _context.CreateCommand(); Cmd.CommandText = "SELECT * FROM [MembershipUser] WHERE Id = @Id"; Cmd.AddParameters("Id", Id); data = Cmd.FindFirst <MembershipUser>(); if (data == null) { return(null); } if (!nocache) { _cacheService.Set(cachekey, data, CacheTimes.OneDay); } } return(data); }
public Menu Get(Guid id) { string cachekey = string.Concat(CacheKeys.Menu.StartsWith, "Get-", id); var cat = _cacheService.Get <Menu>(cachekey); if (cat == null) { var allcat = GetAll(); if (allcat == null) { return(null); } foreach (Menu it in allcat) { if (it.Id == id) { cat = it; break; } } _cacheService.Set(cachekey, cat, CacheTimes.OneDay); } return(cat); }
public string GetSetting(string key) { string cachekey = string.Concat(CacheKeys.Settings.StartsWith, "getSetting-", key); var cachedSettings = _cacheService.Get <string>(cachekey); if (cachedSettings == null) { cachedSettings = this.GetSettingNoCache(key); _cacheService.Set(cachekey, cachedSettings, CacheTimes.OneDay); } return(cachedSettings); }
public XmlNode GetSiteConfig() { const string cacheKey = "forumsiteconfig"; var siteRootNode = _cacheService.Get <XmlNode>(cacheKey); if (siteRootNode == null) { var xDoc = GetXmlDoc(ConfigLocation); if (xDoc != null) { siteRootNode = xDoc.DocumentElement; _cacheService.Set(cacheKey, siteRootNode, CacheTimes.TwelveHours); } } return(siteRootNode); }
public int GetCount() { string cachekey = string.Concat(CacheKeys.Contact.StartsWith, "GetCount"); var count = _cacheService.Get <int?>(cachekey); if (count == null) { var Cmd = _context.CreateCommand(); Cmd.CommandText = "SELECT COUNT(*) FROM [dbo].[Contact]"; count = (int)Cmd.command.ExecuteScalar(); Cmd.Close(); _cacheService.Set(cachekey, count, CacheTimes.OneDay); } return((int)count); }
public Topic Get(Guid Id) { string cachekey = string.Concat(CacheKeys.Topic.StartsWith, "Get-", Id); var topic = _cacheService.Get <Topic>(cachekey); if (topic == null) { using (var Cmd = _context.CreateCommand()) { Cmd.CommandText = "SELECT * FROM [Topic] WHERE Id = @Id"; Cmd.AddParameters("Id", Id); topic = Cmd.FindFirst <Topic>(); if (topic == null) { return(null); } _cacheService.Set(cachekey, topic, CacheTimes.OneDay); } } return(topic); }
public List <Permission> GetPermissions(List <MembershipRole> roles) { if (roles == null || roles.Count == 0) { return(new List <Permission>()); } roles.Sort(); string InRoles = "("; for (int i = 0; i < roles.Count; i++) { if (i == 0) { InRoles += roles[i].Id.ToString(); } else { InRoles += "," + roles[i].Id.ToString(); } } InRoles += ")"; string cachekey = string.Concat(CacheKeys.Permission.StartsWith, "GetPermissions-", InRoles); var cachedSettings = _cacheService.Get <List <Permission> >(cachekey); if (cachedSettings == null) { using (var Cmd = _context.CreateCommand()) { Cmd.CommandText = "SELECT P.* FROM [dbo].[Permission] AS P INNER JOIN [dbo].[PermissionsInRoles] AS K ON P.[Id] = K.[PermissionId] WHERE K.[RoleId] IN " + InRoles; cachedSettings = Cmd.FindAll <Permission>(); } _cacheService.Set(cachekey, cachedSettings, CacheTimes.OneDay); } return(cachedSettings); }
public Language Get(Guid id) { string cachekey = string.Concat(CacheKeys.Localization.StartsWith, "Get-", id); var cat = _cacheService.Get <Language>(cachekey); if (cat == null) { var allcat = GetAll(); if (allcat == null) { return(null); } foreach (Language it in allcat) { if (it.Id == id) { cat = it; break; } } _cacheService.Set(cachekey, cat, CacheTimes.OneDay); } return(cat); }