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); } }