Exemplo n.º 1
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            blogInfo newBlogPost = default(blogInfo);

            newBlogPost.title       = txtTitle.Text;
            newBlogPost.description = txtPost.Text;

            categories     = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            clientProtocol = (XmlRpcClientProtocol)categories;

            clientProtocol.Url = "http://127.0.0.1/wpl/xmlrpc.php";

            string result = null;

            result = "";

            try {
                result = categories.NewPage(1, "shoban", "shoban", newBlogPost, 1);
                MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                txtPost.Text  = "";
                txtTitle.Text = "";
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void Save()
        {
            int    imgErr          = 0;
            string CnBlogsUserName = Request.Form["CnBlogsUserName"];
            string CnBlogsPassWord = Request.Form["CnBlogsPassWord"];
            string ApiAddress      = Request.Form["ApiAddress"];

            CnBlogsUserName = Decrypt(CnBlogsUserName);
            CnBlogsPassWord = Decrypt(CnBlogsPassWord);
            ApiAddress      = Decrypt(ApiAddress);
            string[]    picRes     = Request.Form["PicRes"].Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            IgetCatList categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));

            ((XmlRpcClientProtocol)categories).Url = ApiAddress;
            BlogEntity BlogInfo = default(BlogEntity);

            BlogInfo.title       = Request.Form["BlogTitle"];
            BlogInfo.description = Request.Form["BlogBody"];
            BlogInfo.dateCreated = DateTime.Now;
            BlogInfo.postid      = Request.Form["BlogId"];
            for (int i = 0; i < picRes.Length; i++)
            {
                FileData fd      = default(FileData);
                string   picPath = base.Server.MapPath(picRes[i]);
                fd.bits = File.ReadAllBytes(picPath);
                fd.name = Path.GetExtension(picPath);
                fd.type = string.Format("image/{0}", fd.name.Substring(1));
                try
                {
                    FileData obj = categories.newMediaObject(CnBlogsUserName, CnBlogsUserName, CnBlogsPassWord, fd);
                    BlogInfo.description = BlogInfo.description.Replace(picRes[i], obj.url);
                }
                catch
                {
                    imgErr++;
                }
            }
            try
            {
                if (string.IsNullOrWhiteSpace(BlogInfo.postid))
                {
                    categories.newPost(string.Empty, CnBlogsUserName, CnBlogsPassWord, BlogInfo, false);
                }
                else
                {
                    categories.editPost(BlogInfo.postid, CnBlogsUserName, CnBlogsPassWord, BlogInfo, false);
                }
            }
            catch (Exception)
            {
                Response.Write("博客发送失败");
                return;
            }
            if (imgErr < 1)
            {
                Response.Write("博客发送成功");
                return;
            }
            Response.Write(string.Format("博客虽然发送成功了,但是有{0}张图片发送失败了", imgErr));
        }
Exemplo n.º 3
0
        private void GetLast()
        {
            string CnBlogsUserName = base.Request.Form["CnBlogsUserName"];
            string CnBlogsPassWord = base.Request.Form["CnBlogsPassWord"];
            string ApiAddress      = Request.Form["ApiAddress"];

            CnBlogsUserName = Decrypt(CnBlogsUserName);
            CnBlogsPassWord = Decrypt(CnBlogsPassWord);
            ApiAddress      = Decrypt(ApiAddress);
            IgetCatList categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));

            ((XmlRpcClientProtocol)categories).Url = ApiAddress;
            try
            {
                var obj = categories.getRecentPosts(CnBlogsUserName, CnBlogsUserName, CnBlogsPassWord, 1);
                if (obj.Length < 1)
                {
                    Response.Write("没有获取到博客");
                    return;
                }
                string sRet = new JavaScriptSerializer().Serialize(obj[0]);
                Response.Write(sRet);
            }
            catch
            {
                Response.Write("获取最近一篇博客出现异常");
            }
        }
Exemplo n.º 4
0
        private void btn匯至網站_Click(object sender, EventArgs e)
        {
            blogInfo newBlogPost = default(blogInfo);

            ICL  = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            XRCP = (XmlRpcClientProtocol)ICL;

            XRCP.Url = tb網址.Text;

            string result = null;

            result = "";

            string[] strArrFilePaths = Directory.GetFiles(tb已加值文目錄.Text);

            foreach (string strFilePath in strArrFilePaths)
            {
                newBlogPost.title       = Path.GetFileNameWithoutExtension(strFilePath);
                newBlogPost.description = File.ReadAllText(strFilePath, Encoding.Default);

                try
                {
                    result = ICL.NewPage(1, tb帳號.Text, tb密碼.Text, newBlogPost, 1);
                    MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 5
0
        private void ProcessDataWordpress(String url)
        {
            blogInfo newBlogPost = default(blogInfo);

            newBlogPost.title       = Spinner.Spin(txtTitle.Text);
            newBlogPost.description = Spinner.Spin(editor1.BodyHtml);
            categories     = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            clientProtocol = (XmlRpcClientProtocol)categories;

            string linkwordpress = "";
            string username      = "";
            string password      = "";

            string[] words = url.Split('|');

            linkwordpress = words[0];
            username      = words[1];
            password      = words[2];

            txtSite.Text = linkwordpress;
            txtUser.Text = username;
            txtPass.Text = password;

            clientProtocol.Url = "https://" + linkwordpress + "/xmlrpc.php";

            string result = null;

            result = "";
            try
            {
                result = categories.NewPage(1, username, password, newBlogPost, 1);
                //MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                //txtPost.Text = "";
                //txtTitle.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public UploadWebpages(string sitename, string username, string password, bool replaceLinks = false, bool forceUpload = false, bool useTourneyTemplate = true)
        {
            // Initialize member variables
            this.m_siteName           = sitename;
            this.m_userName           = username;
            this.m_password           = password;
            this.m_replaceLinks       = replaceLinks;
            this.m_useTourneyTemplate = useTourneyTemplate;
            this.m_forceUpload        = forceUpload;
            this.m_xmlrpcURL          = m_siteName.TrimEnd(new[] { '/', '\\' }) + "/xmlrpc.php";

            m_categories         = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            m_clientProtocol     = (XmlRpcClientProtocol)m_categories;
            m_clientProtocol.Url = this.m_xmlrpcURL;

            // read existing hash table data if any
            m_hashTableFileName = Path.Combine(Globals.m_rootDirectory, LAST_UPDATED_TIMES_PREFIX + ".log");
            if (File.Exists(m_hashTableFileName))
            {
                readHashTableFile(m_hashTableFileName);
            }
        }
Exemplo n.º 7
0
        private void btnImg_Click(object sender, EventArgs e)
        {
            var fi = new FileInfo("C:\\Program Files\\Utilities\\exiftool.exe");
            var exifTool = new ExifToolWrapper(fi);

            // Build our list of desired tags
            var tagList = new List<string>();
            tagList.AddRange(new String[]
            {
                "Title",
                "Description",
                "DateTimeOriginal"
            });

            FileInfo imageFi = new FileInfo(lblImage.Text);
            var tagValues = exifTool.GetTagsFromFile(imageFi, tagList);

            var newMediaPost = default(newMediaDescriptor);
            newMediaPost.name = "ProgramaticallyUploadedImage.jpg";
            newMediaPost.type = "image/jpeg";
            newMediaPost.overwrite = false;

            // Now we read in the picture and turn it into a byte array
            byte[] fileAsBytes;

            using (var fs = new FileStream(lblImage.Text, FileMode.Open))
            {
                fileAsBytes = new byte[fs.Length];
                fs.Read(fileAsBytes, 0, (int)fs.Length);
            }

            // And convert it to base-64 encoding
            newMediaPost.bits = Convert.ToBase64String(fileAsBytes);

            categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            clientProtocol = (XmlRpcClientProtocol)categories;
            clientProtocol.Url = "http://www.thepotters.org/test/wpl/xmlrpc.php";

            try
            {
                var result = categories.NewMedia(
                    3, "test", "DjF3iUfMDto0", newMediaPost);

                MessageBox.Show(string.Format(
                    "ID: {0}\r\nFile: {1}\r\nURL: {2}\r\nType:{3}",
                    result.id,
                    result.file,
                    result.url,
                    result.type));

                tbBody.Text = "";
                tbTitle.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 8
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            // Username:    test
            // Password:    DjF3iUfMDto0
            blogInfo newBlogPost = default(blogInfo);
            newBlogPost.title = tbTitle.Text;
            newBlogPost.description = tbBody.Text;
            newBlogPost.dateCreated = new DateTime(2009,10,11);

            categories = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            clientProtocol = (XmlRpcClientProtocol)categories;
            clientProtocol.Url = "http://www.thepotters.org/test/wpl/xmlrpc.php";
            string result = null;
            result = "";
            try
            {
                result = categories.NewPost(1, "test", "DjF3iUfMDto0", newBlogPost, 1);
                MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                tbBody.Text = "";
                tbTitle.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }