示例#1
0
        public static List <ItemVersionSetting> GetItemVersionSettings(int itemVersionId, string controlName, int portalId)
        {
            string cacheKey = Utility.CacheKeyPublishItemVersionSettings + controlName.ToString(CultureInfo.InvariantCulture) + itemVersionId.ToString(CultureInfo.InvariantCulture);
            List <ItemVersionSetting> ivs;

            if (ModuleBase.UseCachePortal(portalId))
            {
                var o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    ivs = (List <ItemVersionSetting>)o;
                }
                else
                {
                    ivs = GetItemVersionSettings(itemVersionId, controlName);
                }
                if (ivs != null)
                {
                    DataCache.SetCache(cacheKey, ivs, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                ivs = GetItemVersionSettings(itemVersionId, controlName);
            }
            return(ivs);
        }
示例#2
0
        public static int CommentsWaitingForApprovalCount(int portalId, int authorUserId)
        {
            //cache this
            int    commentCount;
            string cacheKey = Utility.CacheKeyPublishAuthorCommentCount + authorUserId.ToString(CultureInfo.InvariantCulture) + "_" + portalId;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    commentCount = (int)o;
                }
                else
                {
                    commentCount = DataProvider.Instance().CommentsWaitingForApprovalCount(portalId, authorUserId);
                }

                DataCache.SetCache(cacheKey, commentCount, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                Utility.AddCacheKey(cacheKey, portalId);
            }
            else
            {
                commentCount = DataProvider.Instance().CommentsWaitingForApprovalCount(portalId, authorUserId);
            }

            return(commentCount);
        }
示例#3
0
        public static Category GetCategory(int itemId, int portalId)
        {
            string   cacheKey = Utility.CacheKeyPublishCategory + itemId.ToString(CultureInfo.InvariantCulture);
            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();
                        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();
                }
            }
            return(c);
        }
示例#4
0
        public static Tag GetTag(int tagId, int portalId)
        {
            string    cacheKey = Utility.CacheKeyPublishTagById + tagId.ToString(CultureInfo.InvariantCulture) + portalId.ToString(CultureInfo.InvariantCulture);
            DataTable dt;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    dt = (DataTable)o;
                }
                else
                {
                    dt = DataProvider.Instance().GetTag(tagId);
                }
                if (dt != null)
                {
                    DataCache.SetCache(cacheKey, dt, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                dt = DataProvider.Instance().GetTag(tagId);
            }
            return(new Tag(dt));
        }
示例#5
0
        /// <summary>
        /// Returns a dataset of the top level categories available for a specific portal
        /// </summary>
        /// <param name="portalId">The Portal ID that we want to return data for.</param>
        /// <returns>A <see cref="DataSet" /> with the categories available.</returns>

        public static DataSet GetTopLevelCategories(int portalId)
        {
            string  cacheKey = Utility.CacheKeyPublishTopLevelCategories + portalId.ToString(CultureInfo.InvariantCulture);
            DataSet ds;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    ds = (DataSet)o;
                }
                else
                {
                    ds = DataProvider.Instance().GetTopLevelCategories(portalId);
                }
                if (ds != null)
                {
                    DataCache.SetCache(cacheKey, ds, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                ds = DataProvider.Instance().GetTopLevelCategories(portalId);
            }

            return(ds);
        }
示例#6
0
        public static DataTable GetAllChildCategories(int parentItemId, int portalId)
        {
            //return DataProvider.Instance().GetAllChildCategories(parentItemId, portalId);

            string    cacheKey = Utility.CacheKeyPublishAllChildCategories + parentItemId.ToString(CultureInfo.InvariantCulture);
            DataTable dt;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    dt = (DataTable)o;
                }
                else
                {
                    dt = DataProvider.Instance().GetAllChildCategories(parentItemId, portalId);
                }
                if (dt != null)
                {
                    DataCache.SetCache(cacheKey, dt, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                dt = DataProvider.Instance().GetAllChildCategories(parentItemId, portalId);
            }

            return(dt);
        }
示例#7
0
        public static List <ItemVersionSetting> GetItemVersionSettingsByModuleId(int moduleId, int portalId)
        {
            string cacheKey = Utility.CacheKeyPublishItemVersionSettingsByModuleId + moduleId;
            List <ItemVersionSetting> settings;

            if (ModuleBase.UseCachePortal(portalId))
            {
                var o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    settings = (List <ItemVersionSetting>)o;
                }
                else
                {
                    settings = CBO.FillCollection <ItemVersionSetting>(DataProvider.Instance().GetItemVersionSettingsByModuleId(moduleId));
                }
                if (settings != null)
                {
                    DataCache.SetCache(cacheKey, settings, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                settings = CBO.FillCollection <ItemVersionSetting>(DataProvider.Instance().GetItemVersionSettingsByModuleId(moduleId));
            }
            return(settings);

            //List<ItemVersionSetting> settings = CBO.FillCollection<ItemVersionSetting>(DataProvider.Instance().GetItemVersionSettingsByModuleId(moduleId));
            //return settings;
        }
示例#8
0
        public static ArrayList GetItemTags(int itemVersionId, int portalId)
        {
            string    cacheKey = Utility.CacheKeyPublishArticleTags + itemVersionId.ToString(CultureInfo.InvariantCulture) + "_" + portalId.ToString(CultureInfo.InvariantCulture);
            ArrayList al;

            if (ModuleBase.UseCachePortal(portalId))
            {
                var o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    al = (ArrayList)o;
                }
                else
                {
                    al = CBO.FillCollection(DataProvider.Instance().GetItemTags(itemVersionId), typeof(ItemTag));
                }
                if (al != null)
                {
                    DataCache.SetCache(cacheKey, al, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                al = CBO.FillCollection(DataProvider.Instance().GetItemTags(itemVersionId), typeof(ItemTag));
            }
            return(al);
            //return CBO.FillCollection(DataProvider.Instance().GetItemTags(_itemVersionId), typeof(ItemTag));
        }
示例#9
0
        public static ArrayList GetItemRelationships(int childItemId, int childItemVersionId, int relationshipTypeId, bool isActive, int portalId)
        {
            string cacheKey = Utility.CacheKeyPublishItemRelationships + childItemId.ToString(CultureInfo.InvariantCulture) + "_" +
                              childItemVersionId.ToString(CultureInfo.InvariantCulture) + "_" +
                              relationshipTypeId.ToString(CultureInfo.InvariantCulture);
            ArrayList al;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    al = (ArrayList)o;
                }
                else
                {
                    al =
                        CBO.FillCollection(
                            DataProvider.Instance().GetItemRelationships(childItemId, childItemVersionId, relationshipTypeId, isActive),
                            typeof(ItemRelationship));
                    DataCache.SetCache(cacheKey, al, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                al = CBO.FillCollection(
                    DataProvider.Instance().GetItemRelationships(childItemId, childItemVersionId, relationshipTypeId, isActive),
                    typeof(ItemRelationship));
            }

            return(al);
        }
示例#10
0
        /// <summary>
        /// Gets all tags that match a portion of a particular string for a portal
        /// </summary>
        /// <param name="partialTag">The string to start matching from. </param>
        /// <param name="portalId">The Portal Id.</param>
        public static DataTable GetTagsByString(string partialTag, int portalId)
        {
            //parse through the table and create each tag?

            //return DataProvider.Instance().GetTagsByString(partialTag, _portalId);
            string    cacheKey = Utility.CacheKeyPublishGetTagsByString + partialTag.ToString(CultureInfo.InvariantCulture) + "_" + portalId.ToString(CultureInfo.InvariantCulture);
            DataTable dt;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    dt = (DataTable)o;
                }
                else
                {
                    dt = DataProvider.Instance().GetTagsByString(partialTag, portalId);
                }
                if (dt != null)
                {
                    DataCache.SetCache(cacheKey, dt, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                dt = DataProvider.Instance().GetTagsByString(partialTag, portalId);
            }
            return(dt);
        }
示例#11
0
        public static Article GetArticleVersion(int articleVersionId, int portalId)
        {
            string  cacheKey = Utility.CacheKeyPublishArticleVersion + articleVersionId.ToString(CultureInfo.InvariantCulture);
            Article a;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    a = (Article)o;
                }
                else
                {
                    a = (Article)CBO.FillObject(DataProvider.Instance().GetArticleVersion(articleVersionId, portalId), typeof(Article));
                    if (a != null)
                    {
                        a.CorrectDates();
                    }
                    DataCache.SetCache(cacheKey, a, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                a = (Article)CBO.FillObject(DataProvider.Instance().GetArticleVersion(articleVersionId, portalId), typeof(Article));
                if (a != null)
                {
                    a.CorrectDates();
                }
            }
            return(a);
        }
示例#12
0
        public static DataTable GetItemsFromTagsPaging(int portalId, ArrayList tagList, int maxItems, int pageId, string sortOrder)
        {
            //return DataProvider.Instance().GetItemsFromTagsPaging(_portalId, tagList, maxItems, pageId);

            var sb = new StringBuilder(50);

            //if (tagList != null) tags = tagList.ToString().Replace(" ", string.Empty);

            if (tagList != null)
            {
                foreach (int tag in tagList)
                {
                    sb.Append(tag.ToString());
                    sb.Append("_");
                }
            }


            string    cacheKey = Utility.CacheKeyPublishItemsFromTagsPage + sb + "_" + pageId + "_" + portalId.ToString(CultureInfo.InvariantCulture);
            DataTable dt;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    dt = (DataTable)o;
                }
                else
                {
                    dt = DataProvider.Instance().GetItemsFromTagsPaging(portalId, tagList, maxItems, pageId, sortOrder);
                }
                if (dt != null)
                {
                    DataCache.SetCache(cacheKey, dt, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                dt = DataProvider.Instance().GetItemsFromTagsPaging(portalId, tagList, maxItems, pageId, sortOrder);
            }
            return(dt);
        }
示例#13
0
        public static DataTable GetPopularTags(int portalId, ArrayList tagList, bool selectTop)
        {
            //TODO: change tagList to a <List> of strings
            //string tags = string.Empty;
            var sb = new StringBuilder(50);

            //if (tagList != null) tags = tagList.ToString().Replace(" ", string.Empty);

            if (tagList != null)
            {
                foreach (int tag in tagList)
                {
                    sb.Append(tag.ToString());
                    sb.Append("_");
                }
            }

            string    cacheKey = Utility.CacheKeyPublishPopularTags + sb + selectTop.ToString(CultureInfo.InvariantCulture) + "_" + portalId.ToString(CultureInfo.InvariantCulture);
            DataTable dt;

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                if (o != null)
                {
                    dt = (DataTable)o;
                }
                else
                {
                    dt = DataProvider.Instance().GetPopularTags(portalId, tagList, selectTop);
                }
                if (dt != null)
                {
                    DataCache.SetCache(cacheKey, dt, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                dt = DataProvider.Instance().GetPopularTags(portalId, tagList, selectTop);
            }
            return(dt);
        }
示例#14
0
        public static ItemVersionSetting GetItemVersionSetting(int itemVersionId, string controlName, string propertyName, int portalId)
        {
            // IDataReader dr = DataProvider.Instance().GetItemVersionSetting(_itemVersionId, _controlName, _propertyName);

            // return (ItemVersionSetting)CBO.FillObject(dr, typeof(ItemVersionSetting));
            string cacheKey = Utility.CacheKeyPublishItemVersionSetting + controlName.ToString(CultureInfo.InvariantCulture) +
                              propertyName.ToString(CultureInfo.InvariantCulture) + itemVersionId.ToString(CultureInfo.InvariantCulture);
            ItemVersionSetting ivs;

            if (ModuleBase.UseCachePortal(portalId))
            {
                var o = DataCache.GetCache(cacheKey);
                if (o != null && o.ToString() != "-1")
                {
                    ivs = (ItemVersionSetting)o;
                }
                else
                {
                    ivs = GetItemVersionSetting(itemVersionId, controlName, propertyName);
                    if (ivs == null)
                    {
                        // for settings we don't have a value for in the DB we should set the cache to -1 so we don't always make requests to the DB
                        DataCache.SetCache(cacheKey, "-1", DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                        Utility.AddCacheKey(cacheKey, portalId);
                    }
                }

                if (ivs != null)
                {
                    DataCache.SetCache(cacheKey, ivs, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                ivs = GetItemVersionSetting(itemVersionId, controlName, propertyName);
            }

            return(ivs);
        }
示例#15
0
        public static int GetParentCategory(int childItemId, int portalId)
        {
            int    parentId;
            string cacheKey = Utility.CacheKeyPublishItemParentCategoryId + childItemId.ToString(CultureInfo.InvariantCulture); // +"PageId";

            if (ModuleBase.UseCachePortal(portalId))
            {
                object o = DataCache.GetCache(cacheKey);
                parentId = o != null?Convert.ToInt32(o.ToString()) : DataProvider.Instance().GetParentCategory(childItemId, portalId);

                if (parentId != -1)
                {
                    DataCache.SetCache(cacheKey, parentId, DateTime.Now.AddMinutes(ModuleBase.CacheTimePortal(portalId)));
                    Utility.AddCacheKey(cacheKey, portalId);
                }
            }
            else
            {
                parentId = DataProvider.Instance().GetParentCategory(childItemId, portalId);
            }
            return(parentId);
        }
示例#16
0
        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);
        }
示例#17
0
        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);
        }