public void Fetch() { Posts = new ObservableCollection<Entry>(); var proxy = new MetaWeblog(this.SelectedBlog.WebAPI); proxy .GetRecentPostsAsync(SelectedBlog.BlogInfo.blogid, SelectedBlog.Username, SelectedBlog.Password, 100) .ContinueWith(UpdateBlogPosts, TaskScheduler.FromCurrentSynchronizationContext()) .ContinueWith(HandleFetchError); }
public void Publish(string postid, string postTitle, string[] categories, BlogSetting blog) { if (categories == null) categories = new string[0]; var proxy = new MetaWeblog(blog.WebAPI); var newpost = new Post(); try { var renderBody = DocumentParser.GetBodyContents(Document.Text); if (string.IsNullOrWhiteSpace(postid)) { var permalink = DisplayName.Split('.')[0] == "New Document" ? postTitle : DisplayName.Split('.')[0]; newpost = new Post { permalink = permalink, title = postTitle, dateCreated = DateTime.Now, description = blog.Language == "HTML" ? renderBody : Document.Text, categories = categories }; newpost.postid = proxy.NewPost(blog.BlogInfo.blogid, blog.Username, blog.Password, newpost, true); settings.Set(newpost.permalink, newpost); settings.Save(); } else { newpost = proxy.GetPost(postid, blog.Username, blog.Password); newpost.title = postTitle; newpost.description = blog.Language == "HTML" ? renderBody : Document.Text; newpost.categories = categories; newpost.format = blog.Language; proxy.EditPost(postid, blog.Username, blog.Password, newpost, true); //Not sure what this is doing?? settings.Set(newpost.permalink, newpost); settings.Save(); } } catch (WebException ex) { dialogService.ShowError("Error Publishing", ex.Message, ""); } catch (XmlRpcException ex) { dialogService.ShowError("Error Publishing", ex.Message, ""); } catch (XmlRpcFaultException ex) { dialogService.ShowError("Error Publishing", ex.Message, ""); } Post = newpost; Original = Document.Text; title = postTitle; NotifyOfPropertyChange(() => DisplayName); }
public void FetchBlogs() { SelectedAPIBlog = null; var proxy = new MetaWeblog(CurrentBlog.WebAPI); APIBlogs = new ObservableCollection<FetchedBlogInfo>(); proxy .GetUsersBlogsAsync("MarkPad", CurrentBlog.Username, CurrentBlog.Password) .ContinueWith(UpdateBlogList, TaskScheduler.FromCurrentSynchronizationContext()) .ContinueWith(HandleFetchError); }