private void TimerTick(object sender, EventArgs e) { timer.Stop(); Task.Factory.StartNew <string>(text => { return(DocumentParser.Parse(text.ToString())); }, Document.Text) .ContinueWith(s => { if (s.IsFaulted) { Log.Error(s.Exception); return; } this.Render = s.Result; }, TaskScheduler.FromCurrentSynchronizationContext()); }
public void Publish(string postid, string postTitle, string[] categories, BlogSetting blog) { if (categories == null) { categories = new string[0]; } var proxy = getMetaWeblog(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, format = blog.Language }; newpost.postid = proxy.NewPost(blog, newpost, true); } else { newpost = proxy.GetPost(postid, blog); newpost.title = postTitle; newpost.description = blog.Language == "HTML" ? renderBody : Document.Text; newpost.categories = categories; newpost.format = blog.Language; proxy.EditPost(postid, blog, newpost, true); } } 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); }