示例#1
0
        public static Publication CreateBlog(BloggerEntry bloggerEntry)
        {
            var ids = bloggerEntry.Id.AbsoluteUri.Split(new string[] { "post-" }, StringSplitOptions.RemoveEmptyEntries);
            var blogContent = bloggerEntry.Content.Content;

            var blog = new Publication
                {
                    Content = blogContent,
                    Description = Substring(GetPlainText(blogContent), 300),
                    TimeStamp = bloggerEntry.Published,
                    Id = ids[1],
                    BlogId = ids[0].Replace("tag:blogger.com,1999:blog-", String.Empty).Replace(".", String.Empty),
                    Title = bloggerEntry.Title.Text,
                    //Description = StringProcessor.Substring(StringProcessor.ToPlainText(blog.Content, true), 300, "..."),
                    Url = bloggerEntry.AlternateUri.ToString()

                };

            var tags = (from c in bloggerEntry.Categories
                        select c.Term.ToLower().Trim()).ToArray();

            blog.SetTags(tags);

            return blog;
        }
 public ListEntry(BloggerEntry entry)
 {
     this.entry = entry; 
 }
        private void AddEntry_Click(object sender, System.EventArgs e)
        {
            addentry dlg = new addentry();
            if (dlg.ShowDialog() == DialogResult.OK &&
                dlg.Entry.Length > 0) 
            {
                // now add this to the feed.

                BloggerEntry entry = new BloggerEntry();

                entry.Content.Content = dlg.Entry;
                entry.Content.Type = "html"; 
                entry.Title.Text = dlg.EntryTitle;


                string userName =    this.UserName.Text;
                string passWord =    this.Password.Text;

                BloggerService service = new BloggerService("BloggerSampleApp.NET");

                if (userName != null && userName.Length > 0)
                {
                    service.Credentials = new GDataCredentials(userName, passWord);
                }

                service.Insert(new Uri(this.feedUri), entry); 

                RefreshFeed(this.feedUri);
            }
        }
示例#4
0
文件: blogger.cs 项目: dachimoto/lt
        private void AddEntry_Click(object sender, System.EventArgs e)
        {
            addentry dlg = new addentry();
            if (dlg.ShowDialog() == DialogResult.OK &&
                dlg.Entry.Length > 0)
            {
                // now add this to the feed.

                BloggerEntry entry = new BloggerEntry();

                entry.Content.Content = dlg.Entry;
                entry.Content.Type = "html";
                entry.Title.Text = dlg.EntryTitle;
                string sLables = dlg.txtLabel.Text;
                string[] arrLabels = sLables.Split(',');
                for(int i=0;i<arrLabels.Length;i++)
                {
                    AtomCategory cat = new AtomCategory();
                    cat.Scheme = new Uri("http://www.blogger.com/atom/ns#");
                    cat.Term = arrLabels[i].ToString();
                    entry.Categories.Add(cat);
                }

                string userName =    this.UserName.Text;
                string passWord =    this.Password.Text;

                BloggerService service = new BloggerService("ChessBank");

                if (userName != null && userName.Length > 0)
                {
                    service.Credentials = new GDataCredentials(userName, passWord);
                }

                service.Insert(new Uri(this.feedUri), entry);

                RefreshFeed(this.feedUri);
            }
        }