Exemplo n.º 1
0
        public bool AddBlog()
        {
            var blog = new BlogSetting {
                BlogName = "New", Language = "HTML"
            };

            blog.BeginEdit();

            var blogSettings = blogSettingsCreator();

            blogSettings.InitializeBlog(blog);

            var result = windowManager.ShowDialog(blogSettings);

            if (result != true)
            {
                blog.CancelEdit();
                return(false);
            }

            blog.EndEdit();

            Blogs.Add(blog);

            return(true);
        }
Exemplo n.º 2
0
        public void AddBlog()
        {
            var blog = new BlogSetting { BlogName = "New", Language = "HTML" };

            blog.BeginEdit();

            var blogSettings = blogSettingsCreator();
            blogSettings.InitializeBlog(blog);

            var result = _windowManager.ShowDialog(blogSettings);
            if (result != true)
            {
                blog.CancelEdit();
                return;
            }

            blog.EndEdit();

            Blogs.Add(blog);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public void InitializeBlogs(List<BlogSetting> blogs)
 {
     this.Blogs = blogs;
     SelectedBlog = blogs[0];
 }
Exemplo n.º 5
0
 public void InitializeBlog(BlogSetting blog)
 {
     CurrentBlog = blog;
 }
 public void InitializeBlog(BlogSetting blog)
 {
     CurrentBlog = blog;
 }
Exemplo n.º 7
0
        public void Publish(string postTitle, string[] categories, BlogSetting blog)
        {
            if (categories == null) categories = new string[0];

            var proxy = XmlRpcProxyGen.Create<IMetaWeblog>();
            ((IXmlRpcProxy)proxy).Url = blog.WebAPI;

            var newpost = new Post();

            var permalink = this.DisplayName.Split('.')[0] == "New Document"
                                ? postTitle
                                : this.DisplayName.Split('.')[0];

            if (newpost.postid != null && !string.IsNullOrWhiteSpace(newpost.postid.ToString()))
            {
                newpost = proxy.GetPost(newpost.postid.ToString(), blog.Username, blog.Password);
            }

            try
            {
                if (string.IsNullOrWhiteSpace(newpost.permalink))
                {
                    newpost = new Post
                               {
                                   permalink = permalink,
                                   title = postTitle,
                                   dateCreated = DateTime.Now,
                                   description = blog.Language == "HTML" ? RenderBody : Document.Text,
                                   categories = categories
                               };
                    newpost.postid = proxy.AddPost(blog.BlogInfo.blogid, blog.Username, blog.Password, newpost, true);

                    settings.Set(newpost.permalink, newpost);
                    settings.Save();
                }
                else
                {
                    newpost.title = postTitle;
                    newpost.description = blog.Language == "HTML" ? RenderBody : Document.Text;
                    newpost.categories = categories;

                    proxy.UpdatePost(newpost.postid.ToString(), blog.Username, blog.Password, newpost, true);

                    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, "");
            }

            this.post = newpost;
            Original = Document.Text;
            title = postTitle;
            NotifyOfPropertyChange(() => DisplayName);
        }