Beispiel #1
0
    public static string wmAddChapter(string chapterName)
    {
        try
        {
            Chapter newChapter = BusiBlocks.DocoBlock.DocoManager.CreateChapter(ViewArticle2.ArticleId, chapterName);
            if (!string.IsNullOrEmpty(newChapter.Id))
            {
                ChapterVersion chapterVersion = new ChapterVersion();
                chapterVersion.ChapterId = newChapter.Id;
                chapterVersion.Name      = chapterName;
                chapterVersion.Content   = "";
                chapterVersion.Version   = "1.0"; // every version starts from 1.0 unless specified - custom version feature to be available later on.
                chapterVersion           = BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.New);

                //ChapterId = chapterVersion.Id;
                ChapterName = chapterVersion.Name;

                return(chapterVersion.Id);
            }
            else
            {
                return("");
            }
        }
        catch (Exception ex)
        {
            //Log - unable to save chapter name.
            throw ex;
        }
    }
Beispiel #2
0
    protected Draft SaveDraft(string ChaptId, string Content)
    {
        try
        {
            //if (IsNameChanged)
            // {
            ChapterVersion cv = DocoManager.GetAllChapterVersion().Where(x => x.Id.Equals(ChaptId)).First <ChapterVersion>();

            if (txtBoxChapterName.Text != cv.Name)
            {
                cv.Name = txtBoxChapterName.Text;
                DocoManager.UpdateChapterVersion(cv);
            }
            //IsNameChanged = false;
            //}
            Draft draft = new Draft();
            draft.VersionId = ChaptId;
            draft.Content   = Content;
            draft.SaveDate  = DateTime.Now;
            draft           = BusiBlocks.DocoBlock.DocoManager.UpsertDraft(draft);
            //divDraftsList.InnerHtml = BindDrafts(ChaptId);

            //Reconstruct Menu;
            CreateSubChapterMenu(Content);
            return(draft);
        }
        catch (Exception ex)
        {
            //Log - unable to save current draft.
            throw ex;
        }
    }
Beispiel #3
0
    protected static void SaveDraft(string ChaptId, string Content, string chapName)
    {
        try
        {
            // if (IsNameChanged)
            // {
            ChapterVersion cv = DocoManager.GetAllChapterVersion().Where(x => x.Id.Equals(ChaptId)).First <ChapterVersion>();

            if (chapName != cv.Name)
            {
                cv.Name = chapName;
                DocoManager.UpdateChapterVersion(cv);
            }
            //   IsNameChanged = false;
            //  }
            Draft draft = new Draft();
            draft.VersionId = ChaptId;
            draft.Content   = Content;
            draft.SaveDate  = DateTime.Now;
            draft           = BusiBlocks.DocoBlock.DocoManager.UpsertDraft(draft);
            //divDraftsList.InnerHtml = BindDrafts(ChaptId);
        }
        catch (Exception ex)
        {
            //Log - unable to save current draft.
            throw ex;
        }
    }
Beispiel #4
0
    /// <summary>
    /// Saves content for the ediotr. Creates a new version entry in the DB
    /// </summary>
    protected void SaveContent(string ChapID, string sender)
    {
        try
        {
            ChapterVersion chapterVersion = new ChapterVersion();

            IList <ChapterVersion> allChapters = DocoManager.GetAllItemsByArticleId(ArticleId);
            chapterVersion = allChapters.First(x => x.Id.Equals(ChapID));

            string temp = chapterVersion.Content;
            //  chapterVersion.Content = UltimateEditor1.EditorHtml;

            BusiBlocks.XHTMLText htmlText = new BusiBlocks.XHTMLText();
            //chapterVersion.Content = htmlText.FormatXHTML(txtEditor.Content);
            chapterVersion.Content = txtEditor.Content;

            //check if the user has changed the Chapter Name.
            if (txtBoxChapterName.Visible && !string.IsNullOrEmpty(txtBoxChapterName.Text) && txtBoxChapterName.Text != chapterVersion.Name)
            {
                chapterVersion.Name = txtBoxChapterName.Text;
            }

            //if this is the first chapter and no content has been uploaded then
            if (string.IsNullOrEmpty(temp)) // if the content is empty or is being added for the first time it will update the only existing single record.
            {
                BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVersion);
            }
            else
            //Check if the chapter name has changed at all - if yes then pass in VersionUpdateType.Chapter
            //Update chapter ID if using the button to save content, if not then do no update since the wmLoadChapter does it.
            {
                if (sender == "button")
                {
                    ChapterId = BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.Content).Id;
                }
                else
                {
                    BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.Content);
                }
            }
            //perform draft operations.
            //DeleteDraft(chapterVersion.Id);
        }
        catch (Exception ex)
        {
            //Log - unable to save current content for the selected chapter.
            throw ex;
        }

        lblLastDraft.Text = "<i>Chapter content saved on: " + DateTime.Now.ToShortDateString() + " - " + DateTime.Now.ToShortTimeString() + "</i>";
    }
Beispiel #5
0
    protected void SaveContent(string ChapID, int sequence)
    {
        try
        {
            ChapterVersion       chapterVersion = new ChapterVersion();
            BusiBlocks.XHTMLText xhtml          = new BusiBlocks.XHTMLText();

            IList <ChapterVersion> allChapters = DocoManager.GetAllItemsByArticleId(ArticleId);

            chapterVersion = allChapters.First(x => x.Id.Equals(ChapID));

            Draft draft = DocoManager.GetDraftByChapterId(chapterVersion.Id);

            string temp = chapterVersion.Content;

            if (draft != null)
            {
                chapterVersion.Content = draft.Content;
            }

            //add anchor tags for subchapters.

            chapterVersion.Sequence = sequence;
            chapterVersion.Content  = xhtml.AddAnchorTags(chapterVersion.Content);

            //if this is the first time chapter content is added and no content has been uploaded then
            if (string.IsNullOrEmpty(temp)) // if the content is empty or is being added for the first time it will update the only existing single record.
            {
                BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVersion);
            }
            else
            //Update chapter ID if using the button to save content, if not then do no update since the wmLoadChapter does it.
            {
                BusiBlocks.DocoBlock.DocoManager.CreateChapterVersion(ArticleId, chapterVersion, VersionUpdateType.Content);
            }

            Article a = DocoManager.GetArticle(ArticleId);
            a.UpdateDate = DateTime.Now;
            DocoManager.UpdateArticle(a, false);
        }
        catch (Exception ex)
        {
            //Log - unable to save current content for the selected chapter.
            throw ex;
        }
    }
Beispiel #6
0
    protected void rlTemplate_ItemReorder(object sender, AjaxControlToolkit.ReorderListItemReorderEventArgs e)
    {
        ChapterVersion chapterVers = new ChapterVersion();

        IList <ChapterVersion> allChapters = DocoManager.GetAllItemsByArticleId(ArticleId);

        HiddenField lblIdSender = (HiddenField)e.Item.FindControl("hdnId");

        //item moving down  -- all items below it will move up starting from the new index
        if (e.NewIndex > e.OldIndex)
        {
            for (int i = e.NewIndex; i > e.OldIndex; i--)
            {
                HiddenField lblId = (HiddenField)ReorderList1.Items[i].FindControl("hdnId");
                chapterVers = allChapters.First(x => x.Id.Equals(lblId.Value));

                chapterVers.Sequence = i - 1;
                BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVers);
            }
        }
        else if (e.NewIndex < e.OldIndex)
        {
            for (int i = e.NewIndex; i < e.OldIndex; i++)
            {
                HiddenField lblId = (HiddenField)ReorderList1.Items[i].FindControl("hdnId");
                chapterVers = allChapters.First(x => x.Id.Equals(lblId.Value));

                chapterVers.Sequence = i + 1;
                BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVers);
            }
        }

        //update the item itself
        chapterVers = allChapters.First(x => x.Id.Equals(lblIdSender.Value));

        chapterVers.Sequence = e.NewIndex;
        BusiBlocks.DocoBlock.DocoManager.UpdateChapterVersion(chapterVers);

        BindSequence();
    }
Beispiel #7
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;
        }
    }
Beispiel #8
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");
        }
    }