コード例 #1
0
        public DocumentViewModel(IDialogService dialogService, ISettingsService settings)
        {
            this.dialogService = dialogService;
            this.settings = settings;

            title = "New Document";
            Original = "";
            Document = new TextDocument();
            post = new Post();
            timer = new DispatcherTimer();
            timer.Tick += TimerTick;
            timer.Interval = delay;
        }
コード例 #2
0
        public DocumentViewModel(IDialogService dialogService, ISettingsService settings, IWindowManager windowManager, ISiteContextGenerator siteContextGenerator)
        {
            this.dialogService = dialogService;
            this.settings = settings;
            this.windowManager = windowManager;
            this.siteContextGenerator = siteContextGenerator;

            title = "New Document";
            Original = "";
            Document = new TextDocument();
            Post = new Post();
            timer = new DispatcherTimer();
            timer.Tick += TimerTick;
            timer.Interval = delay;
        }
コード例 #3
0
 public Task<bool> EditPostAsync(string postid, string username, string password, Post post, bool publish)
 {
     return Task<bool>.Factory.FromAsync(BeginEditPost(postid, username, password, post, publish, null, null), EndEditPost);
 }
コード例 #4
0
 public bool EditPost(string postid, string username, string password, Post post, bool publish)
 {
     return (bool)Invoke("EditPost", new object[] { postid, username, password, post, publish });
 }
コード例 #5
0
 public IAsyncResult BeginNewPost(string blogid, string username, string password, Post post, bool publish, AsyncCallback callback, object asyncState)
 {
     return BeginInvoke("NewPost", new object[] { blogid, username, password, post, publish }, this, callback, asyncState);
 }
コード例 #6
0
 public Task<string> NewPostAsync(string blogid, string username, string password, Post post, bool publish)
 {
     return Task<string>.Factory.FromAsync(BeginNewPost(blogid, username, password, post, publish, null, null), EndNewPost);
 }
コード例 #7
0
 public string NewPost(string blogid, string username, string password, Post post, bool publish)
 {
     return (string)Invoke("NewPost", new object[] { blogid, username, password, post, publish });
 }
コード例 #8
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);
        }
コード例 #9
0
        public void OpenFromWeb(Post post)
        {
            Post = post;
            title = post.permalink;
            Document.Text = post.description;
            Original = post.description;

            Update();
        }
コード例 #10
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);
        }