Ejemplo n.º 1
0
        /// <summary>
        /// Add a new post to the blog.
        /// </summary>
        /// <param name="blogid">The name of the blog.</param>
        /// <param name="username">aspnet_Membership.UserId </param>
        /// <param name="password">aspnet_Membership.Password</param>
        /// <param name="post">Contents of post from WLW2011</param>
        /// <param name="publish">False if publishing a draft.</param>
        /// <returns>The post id of the new post.</returns>
        string IMetaWeblog.AddPost(string blogid, string username, 
			string password, Post post, bool publish)
        {
            if (InvalidUser(username, password))
                throw new XmlRpcFaultException(INVALID_CREDENTIALS,
                                                        INVALID_CREDENTIALS_MSG);

             return postsRep.SavePost(blogid, post, publish);
        }
Ejemplo n.º 2
0
 public bool UpdatePost(Post p, bool publish)
 {
     SeqPost sp = GetPost(Convert.ToInt32(p.postid)).SingleOrDefault<SeqPost>();
     string oldCatName = sp.SeqCategory.Name;
     sp.Title = p.title;
     sp.Description = p.description;
     sp.ExtendedText = p.mt_text_more;
     sp.Excerpt = p.mt_excerpt;
     /* Should this be set to p.CreateDate instead? */
     sp.ModifiedDate = DateTime.Now.ToUniversalTime();
     sp.Published = publish;
     sp.Permalink = Permalink.Generate(sp.Title);
     UpdateCategories(p.categories.Length > 0 ? p.categories[0] : "",sp);
     /*UpdateBooks(sp,oldcat,newcat) run in UpdateCategories due to the
        possibility of recategorization of a post. */
        UpdateTags(p.mt_keywords, sp);
     db.SaveChanges();
     return true;
 }
Ejemplo n.º 3
0
        ////TODO: Throw some kind of exception on failure.
        /// <summary>
        /// Save a post from Windows Live Writer to the database.
        /// </summary>
        /// <param name="blogid">The blog identifier string.</param>
        /// <param name="p">The post content and metadata</param>
        /// <param name="publish">Whether this is published or not. Currently 
        /// this flag is not supported by the views.</param>
        /// <returns>The post id number.</returns>
        public string SavePost(string blogid, Post p, bool publish)
        {
            SeqPost sp = new SeqPost();
            sp.BlogId = blogid;
            sp.Title = p.title;
            sp.Description = p.description;
            sp.ExtendedText = p.mt_text_more;
            sp.Excerpt = p.mt_excerpt;
            /* SQLServer can not deal with year < 1753, but dateCreated can be
               year 1 when WLW2011 post date is not set. For practical
               purposes we use 1970 as the minimum date. */
            if (p.dateCreated.Year < 1970)
               sp.CreateDate = DateTime.Now.ToUniversalTime();
            else
               sp.CreateDate = p.dateCreated;

            sp.ModifiedDate = DateTime.Now.ToUniversalTime();
            sp.Published = publish;
            sp.Permalink = Permalink.Generate(sp.Title);
            UpdateCategories(p.categories.Length>0 ? p.categories[0] : "",sp);
            UpdateTags(p.mt_keywords, sp);
            db.SeqPosts.AddObject(sp);
            db.SaveChanges();
            return sp.PostId.ToString();
        }
Ejemplo n.º 4
0
 bool IMetaWeblog.UpdatePost(string postid, string username, string password,
   Post post, bool publish)
 {
     if (InvalidUser(username, password))
         throw new XmlRpcFaultException(INVALID_CREDENTIALS,
                                                 INVALID_CREDENTIALS_MSG);
      //postid is null from parameters so seed it with postid
      post.postid = postid;
      return postsRep.UpdatePost(post, publish);
 }
Ejemplo n.º 5
0
        Post[] IMetaWeblog.GetRecentPosts(string blogid, string username,
         string password, int numberOfPosts)
        {
            if (InvalidUser(username, password))
                throw new XmlRpcFaultException(INVALID_CREDENTIALS,
                                                        INVALID_CREDENTIALS_MSG);
             List<Post> posts = new List<Post>();
             IQueryable<SeqPost> recentPosts =
            postsRep.GetPostPage(numberOfPosts,1,blogid);

             foreach (SeqPost sp in recentPosts) {
            Post p = new Post();
            p.postid = sp.PostId;
            p.title = sp.Title;
            p.dateCreated = sp.CreateDate;
            p.description = sp.Description;
            string[] category = new string[1];
            category[0] = (sp.SeqCategory == null)
                           ? "" : sp.SeqCategory.Name;
            p.categories = category;
            posts.Add(p);
             }
             return posts.ToArray();
        }
Ejemplo n.º 6
0
        Post IMetaWeblog.GetPost(string postid, string username, string password)
        {
            if (InvalidUser(username, password))
                throw new XmlRpcFaultException(INVALID_CREDENTIALS,
                                                        INVALID_CREDENTIALS_MSG);

             SeqPost sp = postsRep.GetPost(Convert.ToInt32(postid))
                                        .SingleOrDefault<SeqPost>();
             Post post = new Post();
             post.postid = sp.PostId;
             post.description = sp.Description;
             post.title = sp.Title;
             post.dateCreated = sp.CreateDate;
             post.mt_excerpt = sp.Excerpt;
             post.mt_text_more = sp.ExtendedText;
             post.mt_keywords = tagRep.GetKeywords(sp.PostId);
             post.categories = new string[] { sp.SeqCategory.Name };
             return post;
        }