Пример #1
0
 /// <summary>
 /// Delete the content.
 /// </summary>
 /// <param name="content"></param>
 public void DeleteContent(AlternateContent content)
 {
     ITransaction tx = base.NHSession.BeginTransaction();
     try
     {
         base.NHSession.Delete(content);
         tx.Commit();
         OnContentDeleted(new IndexEventArgs(AlternateContentToSearchContent(content)));
     }
     catch (Exception ex)
     {
         tx.Rollback();
         throw new Exception("Unable to delete content: " + ex.Message, ex);
     }
 }
Пример #2
0
 /// <summary>
 /// Save the content.
 /// </summary>
 /// <param name="content"></param>
 public void SaveContent(AlternateContent content)
 {
     ITransaction tx = base.NHSession.BeginTransaction();
     try
     {
         if (content.Id == -1)
         {
             content.UpdateTimestamp = DateTime.Now;
             base.NHSession.Save(content);
             OnContentCreated(new IndexEventArgs(AlternateContentToSearchContent(content)));
         }
         else
         {
             base.NHSession.Update(content);
             OnContentUpdated(new IndexEventArgs(AlternateContentToSearchContent(content)));
         }
         tx.Commit();
     }
     catch (Exception ex)
     {
         tx.Rollback();
         throw new Exception("Unable to save content: " + ex.Message, ex);
     }
 }
Пример #3
0
        private SearchContent AlternateContentToSearchContent(AlternateContent shc)
        {
            SearchContent sc = new SearchContent();
            sc.Title = shc.Section.Title;
            sc.Summary = Text.TruncateText(shc.Content, 200); // trunctate the summary to 200 chars
            sc.Contents = shc.Content;
            sc.Author = shc.ModifiedBy.FullName;
            sc.ModuleType = shc.Section.ModuleType.Name;
            sc.Path = this.SectionUrl;
            sc.Category = String.Empty;
            sc.Site = shc.Section.Node.Site.Name;
            sc.DateCreated = shc.UpdateTimestamp;
            sc.DateModified = shc.UpdateTimestamp;
            sc.SectionId = shc.Section.Id;

            return sc;
        }
Пример #4
0
 private void SaveStaticHtml()
 {
     User currentUser = (User)Context.User.Identity;
     AlternateContent content = this._module.GetContent();
     if (content == null)
     {
         // New
         content = new AlternateContent();
         content.Section = this._module.Section;
         content.CreatedBy = currentUser;
         content.ModifiedBy = currentUser;
     }
     else
     {
         // Exisiting
         content.ModifiedBy = currentUser;
     }
     content.Content = this.fckEditor.Value;
     this._module.SaveContent(content);
 }