public static Category GetCategory(int itemId, bool loadRelationships, bool loadTags, bool loadItemVersionSettings) { //cache? var c = (Category)CBO.FillObject(DataProvider.Instance().GetCategory(itemId), typeof(Category)); if (c != null) { c.CorrectDates(); if (loadRelationships) { c.LoadRelationships(); } if (loadTags && ModuleBase.AllowTagsForPortal(c.PortalId)) { c.LoadTags(); } if (loadItemVersionSettings) { c.LoadItemVersionSettings(); } } return(c); }
public static Category GetCategory(int itemId, int portalId, bool loadRelationships, bool loadTags, bool loadItemVersionSettings) { //cache? //var c = (Category)CBO.FillObject(DataProvider.Instance().GetCategory(itemId), typeof(Category)); //if (c != null) //{ // c.CorrectDates(); // if (loadRelationships) // { // c.LoadRelationships(); // } // if (loadTags && ModuleBase.AllowTagsForPortal(c.PortalId)) // { // c.LoadTags(); // } // if (loadItemVersionSettings) // { // c.LoadItemVersionSettings(); // } //} string cacheKey = Utility.CacheKeyPublishCategory + itemId.ToString(CultureInfo.InvariantCulture) + "loadRelationships" + loadRelationships + "loadTags" + loadTags + "loadItemVersionSettings" + loadItemVersionSettings; Category c; if (ModuleBase.UseCachePortal(portalId)) { object o = DataCache.GetCache(cacheKey); if (o != null) { c = (Category)o; } else { c = (Category)CBO.FillObject(DataProvider.Instance().GetCategory(itemId), typeof(Category)); if (c != null) { c.CorrectDates(); if (loadRelationships) { c.LoadRelationships(); } if (loadTags && ModuleBase.AllowTagsForPortal(c.PortalId)) { c.LoadTags(); } if (loadItemVersionSettings) { c.LoadItemVersionSettings(); } DataCache.SetCache(cacheKey, c, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId))); Utility.AddCacheKey(cacheKey, portalId); } } } else { c = (Category)CBO.FillObject(DataProvider.Instance().GetCategory(itemId), typeof(Category)); if (c != null) { c.CorrectDates(); if (loadRelationships) { c.LoadRelationships(); } if (loadTags && ModuleBase.AllowTagsForPortal(c.PortalId)) { c.LoadTags(); } if (loadItemVersionSettings) { c.LoadItemVersionSettings(); } } } return(c); }
public static Article GetArticle(int itemId, int portalId, bool loadRelationships, bool loadTags, bool loadItemVersionSettings) { string cacheKey = Utility.CacheKeyPublishArticle + itemId.ToString(CultureInfo.InvariantCulture) + "loadRelationships" + loadRelationships + "loadTags" + loadTags + "loadItemVersionSettings" + loadItemVersionSettings; Article a; if (ModuleBase.UseCachePortal(portalId)) { object o = DataCache.GetCache(cacheKey); if (o != null) { a = (Article)o; } else { a = GetArticle(itemId); if (a != null) { if (loadRelationships) { a.LoadRelationships(); } //we don't need to get the tags if the portal doesn't allow it if (loadTags && ModuleBase.AllowTagsForPortal(portalId)) { a.LoadTags(); } if (loadItemVersionSettings) { a.LoadItemVersionSettings(); } } } if (a != null) { DataCache.SetCache(cacheKey, a, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId))); Utility.AddCacheKey(cacheKey, portalId); } } else { a = GetArticle(itemId); if (a != null) { if (loadRelationships) { a.LoadRelationships(); } //we don't need to get the tags if the portal doesn't allow it if (loadTags && ModuleBase.AllowTagsForPortal(portalId)) { a.LoadTags(); } if (loadItemVersionSettings) { a.LoadItemVersionSettings(); } } } return(a); }