Beispiel #1
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 #2
0
    private string ElaborateXHTML(BusiBlocks.DocoBlock.Article latestArticle, BusiBlocks.DocoBlock.ArticleBase article)
    {
        var xhtml = new BusiBlocks.XHTMLText();

        xhtml.Load(article.Body);

        string[] attachments = BusiBlocks.DocoBlock.DocoManager.GetFileAttachments(latestArticle, BusiBlocks.DocoBlock.EnabledStatus.Enabled);
        Array.Sort <string>(attachments);

        xhtml.ReplaceLinks(delegate(string oldUrl, out string newUrl)
                           { ReplaceLink(latestArticle.Name, attachments, oldUrl, out newUrl); }
                           );

        return(xhtml.Xhtml);
    }
Beispiel #3
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 #4
0
    protected void btSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            BusiBlocks.CommsBlock.Forums.Category forum = GetForum();

            var sb = new StringBuilder();

            var xhtml = new BusiBlocks.XHTMLText();
            xhtml.Load(newMessage.MessageBodyHtml);

            Exception validateError;
            if (xhtml.IsValid(forum.XHtmlMode, out validateError) == false)
            {
                throw new BusiBlocks.TextNotValidException(validateError);
            }

            BusiBlocks.Attachment.FileInfo attachment = null;
            //Create attachmentAccess.Access
            if (newMessage.AttachmentFile.HasFile)
            {
                attachment = new BusiBlocks.Attachment.FileInfo(newMessage.AttachmentFile.FileName,
                                                                newMessage.AttachmentFile.PostedFile.ContentType,
                                                                newMessage.AttachmentFile.FileBytes);
            }

            //Insert the topic
            BusiBlocks.CommsBlock.Forums.ForumsManager.CreateTopic(forum, Page.User.Identity.Name,
                                                                   newMessage.MessageSubject,
                                                                   xhtml.Xhtml,
                                                                   attachment, sb.ToString());

            Navigation.Communication_ForumView(forum.Name).Redirect(this);
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Page.Master).SetException(GetType(), ex);
        }
    }
    protected void btSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (txtTitle.Text.Length >= 100)
            {
                ((IFeedback)Page.Master).SetError(GetType(), "The announcement title must be less than 100 characters long");
                return;
            }
            Article article = DocoManager.GetArticleByName(ArticleName, true);

            //Check permissions
            if (BusiBlocks.SecurityHelper.CheckWriteAccess(Page.User.Identity.Name, article.Category.Id) == false)
            {
                throw new BusiBlocks.InvalidPermissionException("edit the article");
            }

            var       xhtml = new BusiBlocks.XHTMLText();
            Exception validateError;

            if (xhtml.IsValid(article.Category.XHtmlMode, out validateError) == false)
            {
                throw new BusiBlocks.TextNotValidException(validateError);
            }

            article.TOC           = null;
            article.Description   = txtDescription.Text;
            article.Title         = txtTitle.Text;
            article.UpdateUser    = Utilities.GetUserName(Page.User.Identity.Name);
            article.Author        = txtAuthor.Text;
            article.NumberedChaps = rblNumberedChapters.SelectedValue.ToLower().Equals("yes") ? true : false;
            article.RequiresAck   = rblAcknowledge.SelectedValue.ToLower().Equals("required") ? true : false;

            //if (!string.IsNullOrEmpty(txtEditorialComment.Text))
            //    article.Body += txtEditorialComment.Text + " - <b>(" + DateTime.Now + ")</b><br/>"; // currently using article.body as editorial comments.

            IList <Category> categories       = GetAllEditableCategories();
            Category         selectedCategory = categories[cmbCategory.SelectedIndex];
            if (!selectedCategory.Id.Equals(article.Category.Id))
            {
                Category newCategory = categories[cmbCategory.SelectedIndex];
                // Need to also physically move the document into the new category if it is an uploaded document.
                if (article.IsUpload)
                {
                    // Create the path for the new file.
                    string root            = Path.Combine(Path.Combine(Server.MapPath("~"), "Doco"), "Files");
                    string oldCategoryPath = Path.Combine(root, article.Category.Id);
                    string newCategoryPath = Path.Combine(root, newCategory.Id);
                    string oldPath         = Path.Combine(oldCategoryPath, article.FileName);
                    string newPath         = Path.Combine(newCategoryPath, article.FileName);
                    if (!Directory.Exists(newCategoryPath))
                    {
                        Directory.CreateDirectory(newCategoryPath);
                    }
                    File.Move(oldPath, newPath);
                }
                article.Category = newCategory;
            }

            DocoManager.UpdateArticle(article, false);

            ((IFeedback)Page.Master).QueueFeedback(
                BusiBlocksConstants.Blocks.Documents.LongName,
                "Document",
                Feedback.Actions.Saved,
                article.Name
                );

            Navigation.Doco_Default().Redirect(this);
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Master).SetException(GetType(), ex);
        }
    }