public OrderedDictionary GetEmoticonHashTable() { const string key = "GetEmoticonHashTable"; var emoticons = _cacheService.Get <OrderedDictionary>(key); if (emoticons == null) { emoticons = new OrderedDictionary(); var root = SiteConfig.Instance.GetSiteConfig(); var emoticonNodes = root?.SelectNodes("/App/emoticons/emoticon"); if (emoticonNodes != null) { foreach (XmlNode emoticonNode in emoticonNodes) { //<emoticon symbol="O:)" image="angel-emoticon.png" /> if (emoticonNode.Attributes != null) { var emoticonSymbolAttr = emoticonNode.Attributes["symbol"]; var emoticonImageAttr = emoticonNode.Attributes["image"]; if (emoticonSymbolAttr != null && emoticonImageAttr != null) { emoticons.Add(emoticonSymbolAttr.InnerText, emoticonImageAttr.InnerText); } } } _cacheService.Set(key, emoticons, CacheTimes.OneDay); } } return(emoticons); }
public ShoppingCartProduct Get(Guid Id) { string cachekey = string.Concat(CacheKeys.ShoppingCartProduct.StartsWith, "Get-", Id); var cart = _cacheService.Get <ShoppingCartProduct>(cachekey); if (cart == null) { var Cmd = _context.CreateCommand(); Cmd.CommandText = "SELECT * FROM [ShoppingCartProduct] WHERE [Id] = @Id"; Cmd.AddParameters("Id", Id); DataRow data = Cmd.FindFirst(); if (data == null) { return(null); } cart = DataRowToShoppingCartProduct(data); Cmd.Close(); _cacheService.Set(cachekey, cart, CacheTimes.OneHour); } return(cart); }
public Employees Get(Guid id) { string cachekey = string.Concat(CacheKeys.Employees.StartsWith, "Get-", id); var cat = _cacheService.Get <Employees>(cachekey); if (cat == null) { var allcat = GetAll(); if (allcat == null) { return(null); } foreach (Employees it in allcat) { if (it.Id == id) { cat = it; break; } } _cacheService.Set(cachekey, cat, CacheTimes.OneDay); } return(cat); }
public List <MembershipRole> GetAllMembershipRole() { string cachekey = string.Concat(CacheKeys.Role.MembershipRole, "GetAllMembershipRole"); var cachedSettings = _cacheService.Get <List <MembershipRole> >(cachekey); if (cachedSettings == null) { var Cmd = _context.CreateCommand(); Cmd.CommandText = "SELECT * FROM [MembershipRole]"; DataTable data = Cmd.FindAll(); Cmd.Close(); if (data == null) { return(null); } cachedSettings = new List <MembershipRole>(); foreach (DataRow it in data.Rows) { cachedSettings.Add(DataRowToMembershipRole(it)); } _cacheService.Set(cachekey, cachedSettings, CacheTimes.OneDay); } return(cachedSettings); }
public Post Get(Guid Id) { string cachekey = string.Concat(CacheKeys.Post.StartsWith, "Get-", Id); var cat = _cacheService.Get <Post>(cachekey); if (cat == null) { var Cmd = _context.CreateCommand(); Cmd.CommandText = "SELECT * FROM [Post] WHERE Id = @Id"; Cmd.AddParameters("Id", Id); DataRow data = Cmd.FindFirst(); if (data == null) { return(null); } cat = DataRowToPost(data); _cacheService.Set(cachekey, cat, CacheTimes.OneDay); } return(cat); }
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 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); }