private void CreateDownloadedPost() { var item = ListViewPosts.SelectedItem as Post; if (item == null) { return; } string postId = item.PostID.ToString(); WeblogInfo weblogInfo = Model.ActiveWeblogInfo; var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl, weblogInfo.Username, weblogInfo.Password); Post post = null; try { post = wrapper.GetPost(postId); } catch (Exception ex) { MessageBox.Show("Unable to download post.\r\n\r\n" + ex.Message); return; } Model.Addin.CreateDownloadedPostOnDisk(post, weblogInfo.Name); Close(); }
private async Task CreateDownloadedPost() { var item = ListViewPosts.SelectedItem as Post; if (item == null) { return; } StatusBar.ShowStatusProgress("Downloading Weblog post '" + item.Title + "'"); string postId = item.PostId.ToString(); WeblogInfo weblogInfo = Model.ActiveWeblogInfo; Post post = null; if (weblogInfo.Type == WeblogTypes.MetaWeblogApi) { var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl, weblogInfo.Username, mmApp.DecryptString(weblogInfo.Password), weblogInfo.BlogId); try { post = await Task.Run(() => wrapper.GetPost(postId)); } catch (Exception ex) { StatusBar.ShowStatus(); MessageBox.Show("Unable to download post.\r\n\r\n" + ex.Message); return; } } else { var wrapper = new WordPressWrapper(weblogInfo.ApiUrl, weblogInfo.Username, mmApp.DecryptString(weblogInfo.Password)); try { post = wrapper.GetPost(postId); } catch (Exception ex) { StatusBar.ShowStatus(); MessageBox.Show("Unable to download post.\r\n\r\n" + ex.Message); return; } } Model.Addin.CreateDownloadedPostOnDisk(post, weblogInfo.Name); Close(); StatusBar.ShowStatus(); }
public void GetRecentPost() { WeblogInfo weblogInfo = WeblogAddinConfiguration.Current.Weblogs[ConstWeblogName]; var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl, weblogInfo.Username, weblogInfo.Password); var posts = wrapper.GetRecentPosts(2).ToList(); Assert.IsTrue(posts.Count == 2); var postId = posts[0].PostID; var post = wrapper.GetPost(postId.ToString()); Assert.IsNotNull(post); Console.WriteLine(post.Title); // markdown Console.WriteLine(post.CustomFields?[0].Value); }
private async Task CreateDownloadedPost() { var item = ListViewPosts.SelectedItem as Post; if (item == null) { return; } WeblogInfo weblogInfo = Model.ActiveWeblogInfo; StatusBar.ShowStatusProgress("Downloading Weblog post '" + item.Title + "'"); string postId = item.PostId?.ToString(); Post post = null; if (weblogInfo.Type == WeblogTypes.MetaWeblogApi) { var wrapper = new MetaWeblogWrapper(weblogInfo.ApiUrl, weblogInfo.Username, mmApp.DecryptString(weblogInfo.Password), weblogInfo.BlogId); try { post = await Task.Run(() => wrapper.GetPost(postId)); } catch (Exception ex) { StatusBar.ShowStatusError("Unable to download post.\r\n\r\n" + ex.Message); return; } Model.Addin.CreateDownloadedPostOnDisk(post, weblogInfo.Name); } else if (weblogInfo.Type == WeblogTypes.Wordpress) { var wrapper = new WordPressWrapper(weblogInfo.ApiUrl, weblogInfo.Username, mmApp.DecryptString(weblogInfo.Password)); try { post = wrapper.GetPost(postId); } catch (Exception ex) { StatusBar.ShowStatus(); StatusBar.ShowStatusError("Unable to download post.\r\n\r\n" + ex.Message); return; } Model.Addin.CreateDownloadedPostOnDisk(post, weblogInfo.Name); } else if (weblogInfo.Type == WeblogTypes.LocalJekyll) { var pub = new LocalJekyllPublisher(null, weblogInfo, null); post = pub.GetPost(postId); if (post == null) { StatusBar.ShowStatusError("Unable to import post from Jekyll."); return; } string outputFile = pub.CreateDownloadedPostOnDisk(post, weblogInfo.Name); mmApp.Model.Window.OpenTab(outputFile); mmApp.Model.Window.ShowFolderBrowser(folder: Path.GetDirectoryName(outputFile)); } Close(); StatusBar.ShowStatusSuccess("Post has been imported into Markdown Monster Web log Posts."); }