コード例 #1
0
        public Draft FindDraftByArticleId(string articleId)
        {
            int lowestOrderNumber = DocoManager.GetLowestSequenceNumber(articleId);

            IList <ChapterVersion> chapters = DocoManager.GetAllItemsByArticleId(articleId);

            if (chapters.Count > 0)
            {
                var chaps = from c in chapters
                            where c.Sequence == lowestOrderNumber
                            select c;

                List <ChapterVersion> ListchapVersions = chaps.ToList <ChapterVersion>();

                if (ListchapVersions.Count > 0)
                {
                    Draft draft = new Draft();
                    draft = FindItemByChapterId(ListchapVersions.First <ChapterVersion>().Id).FirstOrDefault <Draft>();
                    return(draft);
                }
            }

            return(new Draft()
            {
                Content = ""
            });
        }
コード例 #2
0
ファイル: DocoManager.cs プロジェクト: sherryswall/busiblocks
        /// <summary>
        /// Returns the count of articles in the category.
        /// </summary>
        /// <param name="categoryId"></param>
        /// <param name="pageIdentity"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public static int CountItems(string categoryId, string pageIdentity, string username)
        {
            int      itemCount = 0;
            Category cat       = DocoManager.GetCategory(categoryId);

            if (SecurityHelper.CanUserEdit(pageIdentity, categoryId))
            {
                itemCount = DocoManager.GetArticles(cat, ArticleStatus.All, false).Count;
            }
            else if (SecurityHelper.CanUserContribute(pageIdentity, categoryId))
            {
                IList <Article> allAritcles = DocoManager.GetArticles(cat, ArticleStatus.All, false);
                foreach (Article article in allAritcles)
                {
                    if (article.Owner.Equals(pageIdentity))
                    {
                        itemCount++;
                    }
                }
            }

            else if (SecurityHelper.CanUserView(pageIdentity, categoryId))
            {
                //change this in future to see only the published ones!.
                itemCount = itemCount + DocoManager.GetArticles(cat, ArticleStatus.Approved, false).Count;
            }
            return(itemCount);
        }
コード例 #3
0
        //Finds the lowest sequence/order number for the article.
        public int LowestSeqNumber(string articleId)
        {
            IList <Chapter> chapters = DocoManager.GetAllChapters(articleId);
            int             tempMin  = 999999;
            //Load the chapter from the docoID
            var chaps = from c in chapters
                        where c.DocId == articleId
                        select c;

            ICriteria criteria = CreateCriteria();

            List <string> ids = new List <string>();

            if (chaps.Count <Chapter>() > 0)
            {
                foreach (Chapter item in chaps.ToList())
                {
                    ChapterVersion minChapSeq = FindLowest(item.Id).FirstOrDefault <ChapterVersion>();
                    if (minChapSeq != null)
                    {
                        if (minChapSeq.Sequence < tempMin)
                        {
                            tempMin = minChapSeq.Sequence;
                        }
                    }
                }
                return(tempMin);
            }
            else
            {
                return(0);
            }
        }
コード例 #4
0
        public IList <ChapterVersion> FindAllItemsByArticleId(string articleId)
        {
            IList <Chapter> chapters = DocoManager.GetAllChapters(articleId);

            //Load the chapter from the docoID
            var chaps = from c in chapters
                        where c.DocId == articleId
                        select c;

            ICriteria criteria = CreateCriteria();

            List <string> ids = new List <string>();

            foreach (Chapter item in chaps.ToList())
            {
                ChapterVersion maxChapVersion = FindMaxVersion(item.Id).FirstOrDefault <ChapterVersion>();

                if (maxChapVersion != null)
                {
                    ids.Add(maxChapVersion.Id);
                }
            }

            criteria.Add(Expression.In("Id", ids));
            criteria.AddOrder(Order.Asc("Sequence"));

            return(base.Find(criteria, false));
        }
コード例 #5
0
        public int GetVersionOrder(string docId, string chapterId)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                IList <ChapterVersion> chapList = DocoManager.GetAllItemsByArticleId(docId);

                var list = from ch in chapList
                           where ch.ChapterId == chapterId
                           select ch;
                List <ChapterVersion> listChapVer = list.ToList <ChapterVersion>();

                return(GetMaxNumber(listChapVer, "version"));
            }
        }
コード例 #6
0
        public int GetNewSequenceNo(string docId)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                IList <ChapterVersion> chapList = DocoManager.GetAllItemsByArticleId(docId);

                var list = from ch in chapList
                           select ch;

                List <ChapterVersion> listChapVer = list.ToList <ChapterVersion>();

                return(GetMaxNumber(listChapVer, "sequence"));
            }
        }
コード例 #7
0
        public bool CheckChapterNameExists(string docId, string chapterName)
        {
            using (TransactionScope transaction = new TransactionScope(mConfiguration))
            {
                IList <ChapterVersion> chapList = DocoManager.GetAllItemsByArticleId(docId);

                var list = from ch in chapList
                           where ch.Name.ToLower() == chapterName.ToLower()
                           select ch;

                List <ChapterVersion> listChapVer = list.ToList <ChapterVersion>();

                if (listChapVer.Count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #8
0
ファイル: Chapter.cs プロジェクト: sherryswall/busiblocks
 public virtual void SaveSequence()
 {
     DocoManager.UpdateChapter(this);
 }
コード例 #9
0
ファイル: Chapter.cs プロジェクト: sherryswall/busiblocks
 public virtual IList <Chapter> FindAllItems()
 {
     return(DocoManager.GetAllChapters());
 }