Exemple #1
0
 public static object wmBindDraftsList(string chapterVersionId)
 {
     try
     {
         IList <Draft> draftsList = DocoManager.GetDraftsByChapterId(chapterVersionId);
         return(draftsList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
    public static object wmLoadChapter(string Id, bool IsEdtorChanged, string ChapName)
    {
        try
        {
            IsEditorChanged = IsEdtorChanged;

            tempChapterId = ChapterId; //hold the ID of previous chapter when switching.
            ChapterId     = Id;

            XHTMLText numberedChaps = new XHTMLText();

            ChapterVersion chapter = DocoManager.GetChapterVersion(ChapterId);

            //THIS HAS BEEN REPLACED BY THE AUTO SAVE SERVICE!.
            //if (IsEditorChanged)
            //SaveDraft(tempChapterId, EditorContent, ChapName);

            if (!string.IsNullOrEmpty(contentMode) && contentMode.Equals("draft"))
            {
                IList <Draft> drafts = DocoManager.GetDraftsByChapterId(chapter.Id);

                if (drafts.Count > 0)
                {
                    Draft draft = drafts.FirstOrDefault <Draft>();
                    draft.Name     = chapter.Name;
                    draft.Sequence = chapter.Sequence + 1;
                    draft.Content  = draft.Content; //numberedChaps.AddChapNumbers(draft.Content, draft.Sequence);
                    return(draft);
                }
            }
            chapter.Sequence = chapter.Sequence + 1;
            chapter.Content  = chapter.Content;// numberedChaps.AddChapNumbers(chapter.Content, (chapter.Sequence + 1));
            return(chapter);
        }
        catch (Exception ex)
        {
            //Log - unable to load the requested chapter.
            throw ex;
        }
    }
Exemple #3
0
    /// <summary>
    /// Loads a chapter
    /// </summary>
    /// <param name="isDefault">True if called on !Postback which will load the default chapter for the document.</param>
    protected void LoadChapter(bool isDefault)
    {
        IList <ChapterVersion> chapters = DocoManager.GetAllItemsByArticleId(ArticleId);
        int lowestOrderNumber           = DocoManager.GetLowestSequenceNumber(ArticleId);

        //Load the chapter from the docoID
        if (chapters.Count > 0)
        {
            divEditor.Style.Add("display", "block");
            List <ChapterVersion> chapVersions = new List <ChapterVersion>();
            if (isDefault)
            {
                var chaps = from c in chapters
                            where c.Sequence == lowestOrderNumber
                            select c;
                chapVersions = chaps.ToList <ChapterVersion>();
            }
            else
            {
                var chaps = from c in chapters
                            where c.Id == ChapterId
                            select c;
                chapVersions = chaps.ToList <ChapterVersion>();
            }

            ChapterVersion chVersion = chapVersions.First();
            lblChapterName.Text            = chVersion.Name;
            txtBoxChapterName.Text         = chVersion.Name;
            lblChapterNameEditor.InnerHtml = chVersion.Name;
            ChapterId   = chVersion.Id;
            ChapterName = chVersion.Name;

            int chapNumb = (chVersion.Sequence + 1);

            if (!string.IsNullOrEmpty(contentMode) && contentMode.Equals("pub"))
            {
                //set the content in the editor or literal depending on the mode.
                if (chapVersions.Count <ChapterVersion>() > 0)
                {
                    DisplayContent(chVersion.Content, chapNumb, IsNumbChaps);
                }
                else
                {
                    DisplayContent("", chapNumb, IsNumbChaps);
                }

                //Bind drafts if any found for this chapter.
                //divDraftsList.InnerHtml = BindDrafts(ChapterId);
            }
            else
            {
                IList <Draft> drafts = DocoManager.GetDraftsByChapterId(ChapterId);
                if (drafts.Count > 0)
                {
                    Draft draft = drafts.FirstOrDefault <Draft>();
                    if (draft != null)
                    {
                        DisplayContent(draft.Content, chapNumb, IsNumbChaps);
                    }
                    else
                    {
                        DisplayContent("", chapNumb, IsNumbChaps);
                    }
                }
                else //load published version by default
                {
                    if (chapVersions.Count <ChapterVersion>() > 0)
                    {
                        DisplayContent(chVersion.Content, chapNumb, IsNumbChaps);
                    }
                    else
                    {
                        DisplayContent("", chapNumb, IsNumbChaps);
                    }
                }
            }
        }
        else
        {
            previewDiv.Style.Add("display", "none");
            divEditor.Style.Add("display", "none");
        }
    }