- CSharp - LiveInternet - BlogHosting - IBlogHosting - SettingsCollection - NotSupportedException - BlogPost - gOkPfeKlhZJ - IiyeydCabZvnd - cVcdYlaDiKEbuQNQT
None
Please wait, it may take some time...
Copy Source | Copy HTMLnamespace MultiPostExtension.Blogs { #region using using System; using System.IO; using System.Web; using System.Net; using System.Text; using BlogEngine.Core; using BlogEngine.Core.Web.Controls; using System.Threading; using BlogsAPI; #endregion /// <summary> /// Design a post to somewhere /// </summary> public class LiveInternet : BlogHosting, IBlogHosting { /// <summary> /// NameOf /// </summary> public String Name { get { return "LiveInternet"; } } /// <summary> /// Defs /// </summary> /// <returns></returns> public SettingsCollection Defaults() { SettingsCollection sc = new SettingsCollection(); sc.Add("true"); sc.Add(" "); sc.Add(this.Name); sc.Add("flashr"); sc.Add(""); sc.Add("noneed"); sc.Add("1"); sc.Add(PostType.Public.ToString()); return sc; } /// <summary> /// Constructor with params /// </summary> /// <param name="sets"></param> public LiveInternet(SettingsCollection settings) { this.Hostname = "liveinternet.ru"; this.blogSettings = settings; } /// <summary> /// Making it published /// </summary> /// <param name="post">Object of Post</param> public Boolean PublishItem(IPublishable post) { Boolean bRet = false; if (this.AttemptsCount++ < this.blogSettings.Attempts) { if (this.MakePost(post)) { bRet = true; } } else { throw new NotSupportedException("Too many fails for " + post.Title); } return bRet; } /// <summary> /// Hidden actions /// </summary> /// <param name="post">Published content</param> /// <returns></returns> private Boolean MakePost(IPublishable post) { BlogPost blogPost = new BlogPost(){ Subject = post.Title, Body = post.Content, type = post.IsPublished?PostType.Public:PostType.Private }; //adding tags blogPost.Attributes.Add(new PostAttribute(PostParams.Tags.ToString(),GetTags(post.Categories))); BlogsAPI.Sites.Liveinternet liru = new BlogsAPI.Sites.Liveinternet(); return liru.MakePost(new UserAccaunt( this.blogSettings.Login, this.blogSettings.Password ), blogPost ).Success; } } }