Esempio n. 1
0
        /// <summary>
        /// Updates the post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="postItem">The post object.</param>
        /// <returns>True/False indicating if post was updated.</returns>
        /// <remarks>
        /// It is assumed that the Post object already has the updated
        /// details in it.
        /// </remarks>
        public bool UpdatePost(string serviceUrl, string username, string password,
                               Post postItem)
        {
            object results;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                results = proxy.editPost(postItem.postid.ToString(), username, password,
                                         postItem, true);
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return((bool)results);
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieves all posts from the blog.
        /// </summary>
        /// <param name="serviceUrl">The service URL to connect to.</param>
        /// <param name="blogId">The blog Id to login with.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>List collection of posts.</returns>
        /// <history>
        /// Sean Patterson    11/3/2010   [Created]
        /// </history>
        public List <Post> GetAllPosts(string serviceUrl, string blogId,
                                       string username, string password)
        {
            List <Post> Results = new List <Post>();

            Post[] TestPosts;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPosts = proxy.getRecentPosts(blogId, username, password, 9999999);

                if (TestPosts.Length > 0)
                {
                    Results = new List <Post>(TestPosts);
                }
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Results);
        }
Esempio n. 3
0
        /// <summary>
        /// Retrieves a blog post.
        /// </summary>
        /// <param name="serviceUrl">The service URL to connect to.</param>
        /// <param name="postId">The post Id to retrieve.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>List collection of posts.</returns>
        /// <history>
        /// Sean Patterson    11/7/2010   [Created]
        /// </history>
        public Post GetPost(string serviceUrl, int postId, string username,
                            string password)
        {
            Post results = new Post();

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                results = proxy.getPost(postId.ToString(), username, password);
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(results);
        }
Esempio n. 4
0
        /// <summary>
        /// Verifies that the destination server can be connected to by
        /// retrieving a single post.
        /// </summary>
        /// <param name="service">The service to connect to.</param>
        /// <param name="blogId">The blog Id to login with.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>String with result message.</returns>
        /// <remarks>
        /// No exception handling is performed in the method since the only
        /// thing it could do is bubble it up one step further. Calling method
        ///// must be resposible for checking for an exception.
        /// </remarks>
        /// <history>
        /// Sean Patterson    11/3/2010   [Created]
        /// </history>
        public string CheckServerStatus
            (string serviceUrl, string blogId, string username, string password)
        {
            String Results;

            Post[] TestPosts;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPosts = proxy.getRecentPosts(blogId, username, password, 1);

                if (TestPosts.Length > 0)
                {
                    Results = "Connection successful.";
                }
                else
                {
                    Results = "Connection failed. No posts found.";
                }
            }
            catch (Exception ex)
            {
                Results = "Connection failed: " + ex.ToString();
            }

            return(Results);
        }
Esempio n. 5
0
        /// <summary>
        /// Inserts a post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="blogId">The blog Id.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="postItem">The post object.</param>
        /// <returns>Post object that was created by the server.</returns>
        public Post InsertPost(string serviceUrl, string blogId, string username,
                               string password, Post postItem, StreamWriter swLog, bool batchMode)
        {
            Post   results;
            Post   tempPost;
            String postResult;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url         = serviceUrl;
            cp.NonStandard = XmlRpcNonStandard.All;
            tempPost       = new Post();

            try
            {
                tempPost.dateCreated = postItem.dateCreated;
                tempPost.userid      = username;
                tempPost.title       = postItem.title;
                tempPost.description = postItem.description;
                tempPost.categories  = postItem.categories;

                postResult = proxy.newPost(blogId, username, password, tempPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    results = proxy.getPost(postResult, username, password);
                }
                else
                {
                    throw new Exception("Post not created.");
                }
            }
            catch (Exception ex)
            {
                var messageBoxText = "An error occurred migrating blog post:" +
                                     Environment.NewLine + Environment.NewLine +
                                     ex.ToString() +
                                     Environment.NewLine + Environment.NewLine + tempPost.ToString();
                swLog.WriteLine(messageBoxText);
                if (!batchMode)
                {
                    var answer = MessageBox.Show(messageBoxText, "Error Migrating Post",
                                                 MessageBoxButton.OKCancel, MessageBoxImage.Error);
                    if (answer == MessageBoxResult.Cancel)
                    {
                        throw;
                    }
                }
                return(new Post());
            }

            return(results);
        }
        public void SetUp()
        {
            contentRepository = MockRepository.GenerateStub<IRepository<Content>>();
            contentOrderableService = MockRepository.GenerateStub<IOrderableService<Content>>();
            baseControllerService = MockRepository.GenerateStub<IBaseControllerService>();
            imageFileService = MockRepository.GenerateStub<IImageFileService>();
            userService = MockRepository.GenerateStub<IUserService>();

            metaWeblog = new MetaWeblogWcf(
                userService,
                contentRepository,
                baseControllerService,
                contentOrderableService,
                imageFileService);

            var url = "http://localhost:27198/MetaWeblogTest.svc";

            baseControllerService.Stub(s => s.SiteUrl).Return(theSiteUrl);
            userService.Stub(s => s.Authenticate(Arg<string>.Is.Anything, Arg<string>.Is.Anything)).Return(true);
            var user = new User
            {
                RoleId = Role.AdministratorId
            };
            userService.Stub(s => s.CurrentUser).Return(user);


            container = new WindsorContainer()
                .AddFacility<WcfFacility>(f => f.DefaultBinding = new XmlRpcHttpBinding())
                .Register(
                    Component.For<XmlRpcEndpointBehavior>(),
                    Component.For<IMetaWeblog>().Instance(metaWeblog)
                        .ActAs(new DefaultServiceModel()
                            .AddBaseAddresses(url)
                            .AddEndpoints(
                                WcfEndpoint.ForContract<IMetaWeblog>()
                            )

                        )
                    );

            //var targetUrl = url;
            var targetUrl = "http://ipv4.fiddler:27198/MetaWeblogTest.svc";
            var factory = new XmlRpcChannelFactory<IMetaWeblog>(new XmlRpcHttpBinding(), new EndpointAddress(targetUrl));
            client = factory.CreateChannel();

            // diagnostics
            var traceListener = new XmlWriterTraceListener("app_tracelog.svclog")
            {
                TraceOutputOptions = TraceOptions.Timestamp
            };
            Trace.Listeners.Add(traceListener);
        }
Esempio n. 7
0
        /// <summary>
        /// カテゴル初期化
        /// </summary>
        private void initCategroy(string mediaUrl, string userName, string password)
        {
            IMetaWeblog          metaWeblog     = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)metaWeblog;

            clientProtocol.Url = mediaUrl;
            Category[] cats = metaWeblog.getCategories("1", userName, password);
            cmbCategry.Items.Clear();
            foreach (Category cat in cats)
            {
                cmbCategry.Items.Add(cat.categoryName);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Inserts a test post.
        /// </summary>
        /// <param name="serviceUrl">The service URL to connect to.</param>
        /// <param name="blogId">The blog Id to login with.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>Message indicating success or failure.</returns>
        /// <history>
        /// Sean Patterson    11/3/2010   [Created]
        /// </history>
        public string InsertSamplePost(string serviceUrl, string blogId,
                                       string username, string password)
        {
            String Results;
            String postResult;
            Post   TestPost;
            Post   ReturnPost;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPost             = new Post();
                TestPost.categories  = new string[] { "Cool Category" };
                TestPost.dateCreated = DateTime.Now;
                TestPost.userid      = username;
                TestPost.title       = "Cool new XML-RPC test!";
                TestPost.description = "This is the main body of the post. " +
                                       "It has lots of cool things here to " +
                                       "test the migration I'm about to do.";

                postResult = proxy.newPost(blogId, username, password, TestPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    ReturnPost = proxy.getPost(postResult, username, password);

                    Results = "Success! Post Id = " + ReturnPost.postid
                              + Environment.NewLine +
                              "Link to post is: " + ReturnPost.link;
                }
                else
                {
                    Results = "Fail. No new post.";
                }
            }
            catch (XmlRpcFaultException fex)
            {
                Results = "XML-RPC error connecting to server: " + fex.ToString();
            }
            catch (Exception ex)
            {
                Results = "General error connecting to server: " + ex.ToString();
            }

            return(Results);
        }
Esempio n. 9
0
        /// <summary>
        /// Inserts a post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="blogId">The blog Id.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="title">The post title.</param>
        /// <param name="content">The post content.</param>
        /// <param name="authorid">The post author id.</param>
        /// <param name="dateCreated">The post creation date.</param>
        /// <param name="categories">The post categories.</param>
        /// <returns>Post object that was created by the server.</returns>
        public Post InsertPost(string serviceUrl, string blogId, string username,
                               string password, string title, string content,
                               string authorid, DateTime dateCreated,
                               List <string> categories)
        {
            Post   results;
            String postResult;
            Post   TestPost;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPost             = new Post();
                TestPost.dateCreated = dateCreated;
                TestPost.userid      = authorid;
                TestPost.title       = title;
                TestPost.description = content;
                TestPost.categories  = categories.ToArray();

                postResult = proxy.newPost(blogId, username, password, TestPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    results = proxy.getPost(postResult, username, password);
                }
                else
                {
                    throw new Exception("Post not created.");
                }
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(results);
        }
Esempio n. 10
0
        /// <summary>
        /// Inserts a post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="blogId">The blog Id.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="postItem">The post object.</param>
        /// <returns>Post object that was created by the server.</returns>
        public Post InsertPost(string serviceUrl, string blogId, string username,
                               string password, Post postItem)
        {
            Post   results;
            Post   tempPost;
            String postResult;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url         = serviceUrl;
            cp.NonStandard = XmlRpcNonStandard.All;

            try
            {
                tempPost             = new Post();
                tempPost.dateCreated = postItem.dateCreated;
                tempPost.userid      = username;
                tempPost.title       = postItem.title;
                tempPost.description = postItem.description;
                tempPost.categories  = postItem.categories;

                postResult = proxy.newPost(blogId, username, password, tempPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    results = proxy.getPost(postResult, username, password);
                }
                else
                {
                    throw new Exception("Post not created.");
                }
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(results);
        }
Esempio n. 11
0
        /// <summary>
        /// 媒体连接测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnTest_Click(object sender, EventArgs ex)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                string mediaType   = cmbMediaType.Text;
                string mediaUrl    = txtMediaURL.Text;
                string appKey      = txtAppKey.Text;
                string appPassword = txtAppPassword.Text;
                string user        = txtUserName.Text;
                string password    = txtPassword.Text;
                string content     = txtOther.Text;
                string pic         = txtTestImage.Text;
                if (File.Exists(pic))
                {
                    switch (mediaType)
                    {
                    case "TENCENT":
                        FormQWeiboLogin LoginDlg = new FormQWeiboLogin(appKey, appPassword, user, password);
                        LoginDlg.ShowDialog();
                        if (LoginDlg.Comfirm)
                        {
                            OauthKey oauthKey = new OauthKey();
                            oauthKey.customKey    = LoginDlg.AppKey;
                            oauthKey.customSecret = LoginDlg.AppSecret;
                            oauthKey.tokenKey     = LoginDlg.AccessKey;
                            oauthKey.tokenSecret  = LoginDlg.AccessSecret;

                            ///发送带图片微博
                            t            twit = new t(oauthKey, "json");
                            UTF8Encoding utf8 = new UTF8Encoding();

                            string ret = twit.add_pic(utf8.GetString(utf8.GetBytes(content)),
                                                      utf8.GetString(utf8.GetBytes("127.0.0.1")),
                                                      utf8.GetString(utf8.GetBytes("")),
                                                      utf8.GetString(utf8.GetBytes("")),
                                                      utf8.GetString(utf8.GetBytes(pic))
                                                      );

                            string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0057I", db.Language);
                            MessageBox.Show(msg);
                        }
                        break;

                    case "WORDPRESS":
                        IMetaWeblog          metaWeblog     = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
                        XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)metaWeblog;
                        clientProtocol.Url = mediaUrl;
                        string picURL   = null;
                        string filename = pic;
                        if (File.Exists(filename))
                        {
                            FileData fileData = default(FileData);
                            fileData.name = Path.GetFileName(filename);
                            fileData.type = Path.GetExtension(filename);
                            try
                            {
                                FileInfo fi = new FileInfo(filename);
                                using (BinaryReader br = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read)))
                                {
                                    fileData.bits = br.ReadBytes((int)fi.Length);
                                }
                                UrlData urlData = metaWeblog.newMediaObject("6", user, password, fileData);
                                picURL = urlData.url;
                            }
                            catch (Exception exc)
                            {
                                NCLogger.GetInstance().WriteExceptionLog(exc);
                            }
                        }

                        Post newBlogPost = default(Post);
                        newBlogPost.title         = content;
                        newBlogPost.description   = "";
                        newBlogPost.categories    = new string[1];
                        newBlogPost.categories[0] = cmbCategry.Text;
                        newBlogPost.dateCreated   = System.DateTime.Now;
                        if (picURL != null)
                        {
                            newBlogPost.description += "<br><img src='" + picURL + "'/>";
                        }

                        try
                        {
                            string result = metaWeblog.newPost("6", user,
                                                               password, newBlogPost, true);
                        }
                        catch (Exception ex2)
                        {
                            NCLogger.GetInstance().WriteExceptionLog(ex2);
                        }

                        break;

                    case "FACEBOOK":
                        var fbLoginDlg = new FormFacebookLogin(appKey, user, password);
                        fbLoginDlg.ShowDialog();
                        if (fbLoginDlg.FacebookOAuthResult != null && fbLoginDlg.FacebookOAuthResult.IsSuccess)
                        {
                            string _accessToken = fbLoginDlg.FacebookOAuthResult.AccessToken;
                            var    fb           = new FacebookClient(_accessToken);

                            // make sure to add event handler for PostCompleted.
                            fb.PostCompleted += (o, e) =>
                            {
                                // incase you support cancellation, make sure to check
                                // e.Cancelled property first even before checking (e.Error!=null).
                                if (e.Cancelled)
                                {
                                    // for this example, we can ignore as we don't allow this
                                    // example to be cancelled.

                                    // you can check e.Error for reasons behind the cancellation.
                                    var cancellationError = e.Error;
                                }
                                else if (e.Error != null)
                                {
                                    // error occurred
                                    this.BeginInvoke(new MethodInvoker(
                                                         () =>
                                    {
                                        MessageBox.Show(e.Error.Message);
                                    }));
                                }
                                else
                                {
                                    // the request was completed successfully

                                    // make sure to be on the right thread when working with ui.
                                    this.BeginInvoke(new MethodInvoker(
                                                         () =>
                                    {
                                        //MessageBox.Show("Picture uploaded successfully");

                                        Application.DoEvents();
                                    }));
                                }
                            };

                            dynamic parameters = new ExpandoObject();
                            parameters.message = content;
                            parameters.source  = new FacebookMediaObject
                            {
                                ContentType = "image/jpeg",
                                FileName    = Path.GetFileName(pic)
                            }.SetValue(File.ReadAllBytes(pic));

                            fb.PostAsync("me/photos", parameters);
                        }

                        break;

                    case "TWITTER":
                        TwitterService   service = new TwitterService(appKey, appPassword);
                        FormTwitterLogin form    = new FormTwitterLogin(db, service);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            SendTweetWithMediaOptions sendOptions = new SendTweetWithMediaOptions();
                            sendOptions.Images = new Dictionary <string, Stream>();
                            sendOptions.Images.Add(Path.GetFileName(pic),
                                                   new FileStream(pic, FileMode.Open, FileAccess.Read));
                            if (content.Length > 70)
                            {
                                content = content.Substring(0, 70);
                            }
                            sendOptions.Status = content;

                            if (service.SendTweetWithMedia(sendOptions) != null)
                            {
                                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0057I", db.Language);
                                MessageBox.Show(msg);
                            }
                        }
                        break;

                    case "LINKEDIN":
                        OAuth1 _OAuthLinkedin = new OAuth1(db);
                        _OAuthLinkedin.Settings_Provider              = "Linkedin";
                        _OAuthLinkedin.Settings_ConsumerKey           = appKey;
                        _OAuthLinkedin.Settings_ConsumerSecret        = appPassword;
                        _OAuthLinkedin.Settings_AccessToken_page      = "https://api.linkedin.com/uas/oauth/accessToken";
                        _OAuthLinkedin.Settings_Authorize_page        = "https://api.linkedin.com/uas/oauth/authorize";
                        _OAuthLinkedin.Settings_RequestToken_page     = "https://api.linkedin.com/uas/oauth/requestToken";
                        _OAuthLinkedin.Settings_Redirect_URL          = "http://www.chojo.co.jp/";
                        _OAuthLinkedin.Settings_User_agent            = "CJW";
                        _OAuthLinkedin.Settings_OAuth_Realm_page      = "https://api.linkedin.com/";
                        _OAuthLinkedin.Settings_GetProfile_API_page   = "https://api.linkedin.com/v1/people/~/";
                        _OAuthLinkedin.Settings_StatusUpdate_API_page = "https://api.linkedin.com/v1/people/~/current-status";
                        _OAuthLinkedin.getRequestToken();
                        _OAuthLinkedin.authorizeToken();
                        String accessToken = _OAuthLinkedin.getAccessToken();
                        try
                        {
                            string ret = _OAuthLinkedin.APIWebRequest("POST", _OAuthLinkedin.Settings_StatusUpdate_API_page, pic);
                            string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
                            xml += "<current-status>" + txtOther.Text + "<img src =" + ret + "/>" + "</current-status>";
                            _OAuthLinkedin.APIWebRequest("PUT", _OAuthLinkedin.Settings_StatusUpdate_API_page, xml);
                        }
                        catch (Exception exp)
                        {
                            MessageBox.Show(exp.Message);
                        }

                        break;

                    case "MSN":
                    case "GOOGLE":
                    case "YAHOO":
                        PROVIDER_TYPE provider_type = (PROVIDER_TYPE)Enum.Parse(typeof(PROVIDER_TYPE), mediaType);
                        setConfigure(user, password, mediaType);
                        FormAuthSocialLogin loginForm = new FormAuthSocialLogin(db, provider_type, socialAuthManager);
                        if (loginForm.ShowDialog() == DialogResult.OK)
                        {
                            string msgs     = HttpUtility.UrlEncode(content);
                            string endpoint = mediaUrl + msgs;

                            string body = String.Empty;
                            //byte[] reqbytes = new ASCIIEncoding().GetBytes(body);
                            byte[] reqbytes = File.ReadAllBytes(pic);
                            Dictionary <string, string> headers = new Dictionary <string, string>();
                            //headers.Add("contentType", "application/x-www-form-urlencoded");
                            headers.Add("contentType", "image/jpeg");
                            headers.Add("FileName", Path.GetFileName(pic));
                            var response = socialAuthManager.ExecuteFeed(
                                endpoint,
                                TRANSPORT_METHOD.POST,
                                provider_type,
                                reqbytes,
                                headers
                                );
                        }
                        break;
                    }
                }
                else
                {
                    string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0058I", db.Language);
                    MessageBox.Show(msg);
                }
            }
            else
            {
                string msg = NCMessage.GetInstance(db.Language).GetMessageById("CM0050I", db.Language);
                MessageBox.Show(msg);
            }
        }
 public void SetUp()
 {
     var factory = new XmlRpcChannelFactory<IMetaWeblog>(new XmlRpcHttpBinding(), new EndpointAddress(url));
     client = factory.CreateChannel();
 }
        /// <summary>
        /// Post
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bntPost_Click(object sender, EventArgs args)
        {
            if (lstCategory.SelectedItems.Count < 1)
            {
                MessageBox.Show("Please select a category!");
                return;
            }
            pgbPost.Value   = 0;
            pgbPost.Maximum = ds_media.Tables[0].Rows.Count;
            for (int idx = 0; idx < ds_media.Tables[0].Rows.Count; idx++)
            {
                String mediaPublishId = ds_media.Tables[0].Rows[idx]["发布编号"].ToString();
                setMediaPublishStatus(mediaPublishId, "发行中");
                IMetaWeblog          metaWeblog     = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
                XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)metaWeblog;
                clientProtocol.Url = ds_media.Tables[0].Rows[idx]["MediaURL"].ToString();
                string userName = ds_media.Tables[0].Rows[idx]["MediaUser"].ToString();
                string password = ds_media.Tables[0].Rows[idx]["MediaPassword"].ToString();
                string picURL   = null;
                string filename = ds_media.Tables[0].Rows[idx]["本地图片"].ToString();
                if (File.Exists(filename))
                {
                    FileData fileData = default(FileData);
                    fileData.name = Path.GetFileName(filename);
                    fileData.type = Path.GetExtension(filename);
                    try
                    {
                        FileInfo fi = new FileInfo(filename);
                        using (BinaryReader br = new BinaryReader(new FileStream(filename, FileMode.Open, FileAccess.Read)))
                        {
                            fileData.bits = br.ReadBytes((int)fi.Length);
                        }
                        UrlData urlData = metaWeblog.newMediaObject("1", userName, password, fileData);
                        picURL = urlData.url;
                    }
                    catch (Exception ex)
                    {
                        NCLogger.GetInstance().WriteExceptionLog(ex);
                    }
                }

                Post newBlogPost = default(Post);
                newBlogPost.title = ds_media.Tables[0].Rows[idx]["名称"].ToString()
                                    + ds_media.Tables[0].Rows[idx]["发行期号"].ToString()
                                    + "[" + ds_media.Tables[0].Rows[idx]["发行日期"].ToString() + "]";
                newBlogPost.description = ds_media.Tables[0].Rows[idx]["文本内容"].ToString();
                if (picURL != null)
                {
                    newBlogPost.description += "<br><img src='" + picURL + "'/>";
                }
                string[] cats = new string[lstCategory.SelectedItems.Count];
                lstCategory.SelectedItems.CopyTo(cats, 0);
                newBlogPost.categories  = cats;
                newBlogPost.dateCreated = System.DateTime.Now;

                try
                {
                    string result = metaWeblog.newPost("1", userName,
                                                       password, newBlogPost, true);
                    //MessageBox.Show("Post Successful!Post ID:" + result);
                    setMediaPublishStatus(mediaPublishId, "发行完");
                }
                catch (Exception ex)
                {
                    setMediaPublishStatus(mediaPublishId, "未发行");
                    NCLogger.GetInstance().WriteExceptionLog(ex);
                }
            }
        }