• Windows Live Plugins —— BatchPoster (发布到多个Blog)


    CSDN和CnBlogs都不错,两个都想用着,所以就写了这么一个插件。用途嘛,当然就是把文章发布到多个博客上。

    经常换Blog的或还没决定用哪一个的朋友也可以用这个,免得迁来迁去~

    特  性:在任意一个帐号编辑完文章,点击“发送”后,将启动插件,提示用户选择帐号与目录,然后将文章发布到指定的各个帐号。

    下载地址:https://sourceforge.net/projects/livewriterpost/

    总  结:

    1、几个比较常用的命名空间:

    WindowsLive.Writer.Api;
    WindowsLive.Writer.Passport;
    WindowsLive.Writer.BlogClient;
    WindowsLive.Writer.BlogClient.Clients;
    WindowsLive.Writer.Extensibility.BlogClient;

    2、使用WindowsLive.Writer.BlogClient.BlogSettings.GetBlogs函数获取帐户的列表,该函数返回一个BlogDescriptor数组。

    3、WindowsLive.Writer.BlogClient.Blog对象包含一个帐户的较完整信息(包括目录),使用构造函数创建对象即可。

    4、使用BlogSettings.ForBlogId函数获取指定帐户的设置信息。该函数返回一个BlogSettings对象。

    5、WindowsLive.Writer.Api.PublishNotificationHook是“发布”操作的接口。

    主要代码:

    public override bool OnPrePublish(System.Windows.Forms.IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish)
            {
                bool Result = false;
                if (Posting) return true;
    
                //选择帐户
                if (DialogBlogSelect.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    Posting = false;
                    return false;
                }
    
                //排除当前帐户
                for (int i = 0; i < DialogBlogSelect.SelectedBlogs.Count; i++)
                {
                    if (DialogBlogSelect.SelectedBlogs[i].ID.ToString() == publishingContext.AccountId)
                    {
                        DialogBlogSelect.SelectedBlogs.RemoveAt(i);
                        Result = true;
                        break;
                    }
                }
    
                //发送到所选择的帐户
                foreach (AccountItem blog in DialogBlogSelect.SelectedBlogs)
                {
                    string str;
                    XmlDocument document;
                    BlogSettings settings = BlogSettings.ForBlogId(blog.ID.ToString());
                    IBlogClient client = BlogClientManager.CreateClient(settings);
                    string postId = client.NewPost(settings.HostBlogId, publishingContext.PostInfo as BlogPost, NullNewCategoryContext.Instance, true, out str, out document);
                    BlogPost post = client.GetPost(settings.HostBlogId, postId);
                    string permalink = post.Permalink;
                    if (!Uri.IsWellFormedUriString(permalink, UriKind.Absolute))
                    {
                        permalink = new Uri(new Uri(settings.HomepageUrl), new Uri(post.Permalink, UriKind.Relative)).ToString();
                    }
                    ProcessStartInfo startInfo = new ProcessStartInfo(permalink);
                    startInfo.UseShellExecute = true;
                    Process.Start(startInfo);
    
                }
    
                Posting = false;
                return Result;
            }
    其中有关发布的代码参考了网上某位同学发布的一个插件,是从其dll中Reflector出来的。不过我忘了出处了,Sorry!
    赶工赶出来的,想完善的随便改去好了。
    本文即通过此插件发布。
     
  • 相关阅读:
    Python基本数据类型
    Python基础之杂货铺
    第五篇:白话tornado源码之褪去模板的外衣
    第四篇:白话tornado源码之褪去模板外衣的前戏
    第三篇:白话tornado源码之请求来了
    重构if-else方法
    linux-常用命令
    Element-UI的远程搜索输入框实现
    下载功能-vue
    上传功能-弹窗实现-vue
  • 原文地址:https://www.cnblogs.com/yedaoq/p/1687743.html
Copyright © 2020-2023  润新知