protected void btnUpload_Click(object sender, EventArgs e) { Article article = DocoManager.GetArticleByName(ArticleName, true); article.FileName = UploadFile(article.Category.Id); DocoManager.UpdateArticle(article, false); }
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; } }
/// <summary> /// Handles the Click event of the btnSave control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void btnUploadSave_Click(object sender, EventArgs e) { if (IsValid) { // Leave if no file selected. if (!fuUpload.HasFile) { fuUpload.Focus(); return; } // Create the path for the new file. string path = string.Format( CultureInfo.InvariantCulture, Resource.NewObjectPath, _root, fuUpload.FileName); // Save to the current folder. fuUpload.SaveAs(path); string articleId = WebFiler.UrlEncoding.Decode(Request.QueryString[Resource.QSAID]); Article article = DocoManager.GetArticle(articleId); article.IsUpload = true; article.FileName = fuUpload.FileName; article.RequiresAck = chkAcknowledge.Checked; if (chkEnabled.Checked) { article.Enabled = chkEnabled.Checked; } DocoManager.UpdateArticle(article, true); Navigation.Doco_ViewCategory(article.Category.Id).Redirect(this); //Refresh(); } }
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); } }