コード例 #1
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;
        }
    }