Ejemplo n.º 1
0
        public string newPost(string blogid, string username, string password, CookComputing.MetaWeblog.Post post, bool publish)
        {
            CheckUserPassword(username, password);

            var folder = (new TextFolder(Repository, FolderHelper.SplitFullName(blogid))).AsActual();

            var values = new NameValueCollection();

            values["title"]       = post.title;
            values["description"] = post.description;
            values["body"]        = post.description;
            values["published"]   = publish.ToString();
            var content = ServiceFactory.GetService <TextContentManager>().Add(Repository, folder, values, null
                                                                               , GetCategories(folder, post.categories), username);

            var categories = GetCategories(folder, post.categories).ToArray();

            if (categories.Length > 0)
            {
                ServiceFactory.GetService <TextContentManager>().AddCategories(Repository, (TextContent)content, categories);
            }


            return(MetaWeblogHelper.CompositePostId((TextContent)content));
        }
Ejemplo n.º 2
0
        public CookComputing.MetaWeblog.Post[] getRecentPosts(string blogid, string username, string password, int numberOfPosts)
        {
            CheckUserPassword(username, password);
            var folder = new TextFolder(Repository, FolderHelper.SplitFullName(blogid));

            return(folder.CreateQuery().Take(numberOfPosts).ToArray().Select(it => new CookComputing.MetaWeblog.Post()
            {
                categories = GetCategories(folder, it),
                dateCreated = it.UtcCreationDate,
                description = it["description"] == null ? "" : it["description"].ToString(),
                postid = MetaWeblogHelper.CompositePostId(it),
                title = it["title"] == null ? "" : it["title"].ToString(),
                userid = it.UserId
            }).ToArray());
        }
Ejemplo n.º 3
0
        public CategoryInfo[] getCategories(string blogid, string username, string password)
        {
            CheckUserPassword(username, password);

            var folder     = (TextFolder)(FolderHelper.Parse <TextFolder>(Repository, blogid).AsActual());
            var categories = GetFolderCategories(folder);

            return(categories.Select(it => new CategoryInfo()
            {
                categoryid = MetaWeblogHelper.CompositePostId(it),
                description = it.GetSummary(),
                title = it.GetSummary(),
                htmlUrl = "",
                rssUrl = ""
            }).ToArray());
        }
Ejemplo n.º 4
0
        public object editPost(string postid, string username, string password, CookComputing.MetaWeblog.Post post, bool publish)
        {
            CheckUserPassword(username, password);
            string folderName;
            string userKey;
            string contentId  = MetaWeblogHelper.ParsePostId(postid, out folderName, out userKey);
            var    textFolder = new TextFolder(Repository, FolderHelper.SplitFullName(folderName));
            var    content    = textFolder.CreateQuery().WhereEquals("UUID", contentId).First();


            var values = new NameValueCollection();

            values["title"]       = post.title;
            values["description"] = post.description;
            values["body"]        = post.description;
            values["userKey"]     = userKey;
            values["published"]   = publish.ToString();

            ServiceFactory.GetService <TextContentManager>().Update(Repository, textFolder, content.UUID, values, username);


            var old_categories = GetCategories(textFolder, content);

            var removedCategories = old_categories.Where(it => !post.categories.Any(c => string.Compare(c, it, true) == 0));
            var addedCategories   = post.categories.Where(it => !old_categories.Any(c => string.Compare(c, it, true) == 0));

            var removed = GetCategories(textFolder, removedCategories).ToArray();

            if (removed.Length > 0)
            {
                ServiceFactory.GetService <TextContentManager>().RemoveCategories(Repository, (TextContent)content, removed);
            }

            var added = GetCategories(textFolder, addedCategories).ToArray();

            if (added.Length > 0)
            {
                ServiceFactory.GetService <TextContentManager>().AddCategories(Repository, (TextContent)content, added);
            }

            return(MetaWeblogHelper.CompositePostId(content));
        }