private string PostContent(string username, string password, ref Post post, bool publish, PostType postType) { ValidateUser(username, password, Blog.AllowServiceAccess); var entry = new Entry(postType) { PostType = postType, IsActive = publish, Author = Blog.Author, Email = Blog.Email }; post.CopyValuesTo(entry); entry.AllowComments = true; entry.DisplayOnHomePage = true; DateTime dateTimeInPost = post.dateCreated != null ? post.dateCreated.Value : DateTime.UtcNow; // Store in the blog's timezone dateTimeInPost = Blog.TimeZone.FromUtc(dateTimeInPost); entry.DateCreated = entry.DateModified = Blog.TimeZone.Now; if (publish) { entry.DateSyndicated = dateTimeInPost; } entry.IncludeInMainSyndication = true; entry.IsAggregated = true; entry.SyndicateDescriptionOnly = false; int postId; try { //TODO: Review whether keywords should be true. postId = EntryPublisher.Publish(entry); if (Blog.TrackbacksEnabled) { NotificationServices.Run(entry, Blog, Url); } if (post.enclosure != null) { Components.Enclosure enclosure = post.enclosure.Value.CopyValuesToEnclosure(); enclosure.EntryId = postId; Repository.Create(enclosure); } AddCommunityCredits(entry); } catch (Exception e) { throw new XmlRpcFaultException(0, e.Message + " " + e.StackTrace); } if (postId < 0) { throw new XmlRpcFaultException(0, Resources.XmlRpcFault_AddPostFailed); } return(postId.ToString(CultureInfo.InvariantCulture)); }
public bool editPost(string postid, string username, string password, Post post, bool publish) { ValidateUser(username, password, Blog.AllowServiceAccess); Entry entry = GetBlogPost(postid); if (entry != null) { entry.Author = Blog.Author; entry.Email = Blog.Email; entry.Categories.Clear(); post.CopyValuesTo(entry); entry.IncludeInMainSyndication = true; entry.PostType = PostType.BlogPost; //User trying to change future dating. if (publish && post.dateCreated != null && Blog.TimeZone.IsInFuture(post.dateCreated.Value, TimeZoneInfo.Utc)) { entry.DateSyndicated = post.dateCreated.Value; } entry.IsActive = publish; entry.DateModified = Blog.TimeZone.Now; EntryPublisher.Publish(entry); if (entry.Enclosure == null) { if (post.enclosure != null) { Components.Enclosure enclosure = post.enclosure.Value.CopyValuesToEnclosure(); enclosure.EntryId = entry.Id; Repository.Create(enclosure); } } else // if(entry.Enclosure != null) { if (post.enclosure != null) { Components.Enclosure enclosure = entry.Enclosure; post.enclosure.Value.CopyValuesTo(enclosure); Repository.Update(enclosure); } else { Repository.DeleteEnclosure(entry.Enclosure.Id); } } } return(true); }
private string PostContent(string username, string password, ref Post post, bool publish, PostType postType) { ValidateUser(username, password, Blog.AllowServiceAccess); var entry = new Entry(postType) {PostType = postType, IsActive = publish, Author = Blog.Author, Email = Blog.Email}; post.CopyValuesTo(entry); entry.AllowComments = true; entry.DisplayOnHomePage = true; DateTime dateTimeInPost = post.dateCreated != null ? post.dateCreated.Value : DateTime.UtcNow; // Store in the blog's timezone dateTimeInPost = Blog.TimeZone.FromUtc(dateTimeInPost); entry.DateCreated = entry.DateModified = Blog.TimeZone.Now; if(publish) { entry.DateSyndicated = dateTimeInPost; } entry.IncludeInMainSyndication = true; entry.IsAggregated = true; entry.SyndicateDescriptionOnly = false; int postId; try { //TODO: Review whether keywords should be true. postId = EntryPublisher.Publish(entry); if(Blog.TrackbacksEnabled) { NotificationServices.Run(entry, Blog, Url); } if(post.enclosure != null) { Components.Enclosure enclosure = post.enclosure.Value.CopyValuesToEnclosure(); enclosure.EntryId = postId; Repository.Create(enclosure); } AddCommunityCredits(entry); } catch(Exception e) { throw new XmlRpcFaultException(0, e.Message + " " + e.StackTrace); } if(postId < 0) { throw new XmlRpcFaultException(0, Resources.XmlRpcFault_AddPostFailed); } return postId.ToString(CultureInfo.InvariantCulture); }
public bool editPost(string postid, string username, string password, Post post, bool publish) { ValidateUser(username, password, Blog.AllowServiceAccess); Entry entry = GetBlogPost(postid); if(entry != null) { entry.Author = Blog.Author; entry.Email = Blog.Email; entry.Categories.Clear(); post.CopyValuesTo(entry); entry.IncludeInMainSyndication = true; entry.PostType = PostType.BlogPost; //User trying to change future dating. if(publish && post.dateCreated != null && Blog.TimeZone.IsInFuture(post.dateCreated.Value, TimeZoneInfo.Utc)) { entry.DateSyndicated = post.dateCreated.Value; } entry.IsActive = publish; entry.DateModified = Blog.TimeZone.Now; EntryPublisher.Publish(entry); if(entry.Enclosure == null) { if(post.enclosure != null) { Components.Enclosure enclosure = post.enclosure.Value.CopyValuesToEnclosure(); enclosure.EntryId = entry.Id; Repository.Create(enclosure); } } else // if(entry.Enclosure != null) { if(post.enclosure != null) { Components.Enclosure enclosure = entry.Enclosure; post.enclosure.Value.CopyValuesTo(enclosure); Repository.Update(enclosure); } else { Repository.DeleteEnclosure(entry.Enclosure.Id); } } } return true; }