Forums Community

These forums are dedicated to the discussion of our DotNetNuke products, such as Ultimate DNN Blog Module - SunBlogNuke & GalleryPlus.

For the benefit of the community and to keep information here helpful to everyone who visits, please observe the following posting guidelines:

  • If you are reporting a bug and strange issue please tell us which version of DNN and SunBlogNuke and share some event logs from "Admin/Event Viewer".
  • Site Moderators have the final word on approving/removing a thread or post or comment.
  • English language posting only, please.
Home/Ultimate DNN Blog Module :: SunBlogNuke/Support Issues/How to add entries programmatically (C#)
PreviousNext
New Post
4/5/2016 6:29 AM
 

Hi,

I need to import some news articles from a proprietary Content Management System. Can you tell me how to do this using my own custom C# module?

I can use the SunBlogNuke.Entities.EntryInfo() method to create an entry and I can then use  SunBlogNuke.Business.EntryController.AddEntry() to add the entry, but I don't see the entries in my blog. Is there something else I need to do?

Thanks :)

New Post
4/5/2016 3:30 PM
 

Did you ever check out what exceptions it threw or what information in your event view log? Now I provide a sample coding below for your next try:

_Entry = new EntryInfo();
_Entry = (EntryInfo)CBO.InitializeObject(_Entry, typeof(EntryInfo));

_Entry.CreatedByUserID = UserId;
_Entry.BlogID = CurrentBlog.BlogID;
// run title against security filter
_Entry.Title = objSecurity.InputFilter(txtTitle.Text, DotNetNuke.Security.PortalSecurity.FilterFlag.NoScripting);
_Entry.Entry = txtContent.Text;
_Entry.LastModifiedByUserID = UserId;
_Entry.Approved = BlogSecurity.CanPublishPosts();
_Entry.Published = published;
_Entry.AllowComments = BlogSettings.AllowComments;
_Entry.IsPinned = false;
_Entry.DisplayHomePage = BlogSettings.PostDisplayHomePage;
_Entry.FullShowTextInEntryList = BlogSettings.PostFullShowTextInEntryList;
_Entry.DisplaySyndication = BlogSettings.PostDisplaySyndication;
_Entry.FullTextInRss = BlogSettings.PostFullTextInRss;
_Entry.Featured = false;
_Entry.Tags = txtTags.Text.Trim();
_Entry.Slug = BlogSettings.EnableAutoFriendlyUrl ? _Entry.Title : string.Empty;
_Entry.PublishedOnDate = DateTime.UtcNow;
_Entry.CategoryIds = BlogSettings.DefaultPostCategory.ToString();

_Entry.EntryID = EntryController.AddEntry(_Entry);

Ultimate DNN Blog Module - SunBlogNuke
PreviousNext
Home/Ultimate DNN Blog Module :: SunBlogNuke/Support Issues/How to add entries programmatically (C#)
Copyright © 2009-2018 Ultimate DNN Blog Module - SunBlogNuke Powered by SunBlogNuke Corp