private ITumblrToTextParser <DataModels.TumblrSvcJson.Post> GetTumblrSvcJsonToTextParser(IBlog blog) { switch (blog.MetadataFormat) { case MetadataType.Text: return(new TumblrSvcJsonToTextParser <DataModels.TumblrSvcJson.Post>()); case MetadataType.Json: return(new TumblrSvcJsonToJsonParser <DataModels.TumblrSvcJson.Post>()); default: throw new ArgumentException("Website is not supported!", "blogType"); } }
private static IBlogService GetBlogService(IBlog blog, IFiles files) { return(new BlogService(blog, files)); }
private TumblrXmlDownloader GetTumblrXmlDownloader(IShellService shellService, CancellationToken ct, PauseToken pt, IPostQueue <TumblrCrawlerData <XDocument> > xmlQueue, ICrawlerService crawlerService, IBlog blog) { return(new TumblrXmlDownloader(shellService, ct, pt, xmlQueue, crawlerService, blog)); }
protected AbstractCrawler(IShellService shellService, CancellationToken ct, IProgress <DownloadProgress> progress, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, IPostQueue <TumblrPost> postQueue, IBlog blog) { this.shellService = shellService; this.webRequestFactory = webRequestFactory; this.cookieService = cookieService; this.postQueue = postQueue; this.blog = blog; this.ct = ct; this.progress = progress; }
private IReadOnlyList <IBlog> GetIBlogsCore(string directory) { Logger.Verbose("ManagerController:GetIBlogsCore Start"); var blogs = new List <IBlog>(); var failedToLoadBlogs = new List <string>(); string[] supportedFileTypes = Enum.GetNames(typeof(BlogTypes)).ToArray(); int[] validCollectionIds = _shellService.Settings.Collections.Select(s => s.Id).ToArray(); foreach (string filename in Directory.GetFiles(directory, "*").Where( fileName => supportedFileTypes.Any(fileName.Contains) && !fileName.Contains("_files"))) { //TODO: Refactor try { IBlog blog = null; if (filename.EndsWith(BlogTypes.tumblr.ToString())) { blog = new TumblrBlog().Load(filename); } if (filename.EndsWith(BlogTypes.tmblrpriv.ToString())) { blog = new TumblrHiddenBlog().Load(filename); } if (filename.EndsWith(BlogTypes.tlb.ToString())) { blog = new TumblrLikedByBlog().Load(filename); } if (filename.EndsWith(BlogTypes.tumblrsearch.ToString())) { blog = new TumblrSearchBlog().Load(filename); } if (filename.EndsWith(BlogTypes.tumblrtagsearch.ToString())) { blog = new TumblrTagSearchBlog().Load(filename); } if (filename.EndsWith(BlogTypes.twitter.ToString())) { blog = new TwitterBlog().Load(filename); } if (blog != null) { if (!validCollectionIds.Contains(blog.CollectionId)) { blog.CollectionId = 0; } blogs.Add(blog); } } catch (SerializationException ex) { failedToLoadBlogs.Add(ex.Data["Filename"].ToString()); } } if (failedToLoadBlogs.Any()) { string failedBlogNames = failedToLoadBlogs.Aggregate((a, b) => a + ", " + b); Logger.Verbose("ManagerController:GetIBlogsCore: {0}", failedBlogNames); _shellService.ShowError(new SerializationException(), Resources.CouldNotLoadLibrary, failedBlogNames); } Logger.Verbose("ManagerController.GetIBlogsCore End"); return(blogs); }
public TumblrLikedByCrawler(IShellService shellService, CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, ICrawlerService crawlerService, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, IDownloader downloader, IPostQueue <TumblrPost> postQueue, IBlog blog) : base(shellService, crawlerService, ct, progress, webRequestFactory, cookieService, postQueue, blog) { this.downloader = downloader; this.pt = pt; }
protected AbstractDownloader(IShellService shellService, IManagerService managerService, CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, IPostQueue <TumblrPost> postQueue, FileDownloader fileDownloader, ICrawlerService crawlerService = null, IBlog blog = null, IFiles files = null) { this.shellService = shellService; this.crawlerService = crawlerService; this.managerService = managerService; this.blog = blog; this.files = files; this.ct = ct; this.pt = pt; this.progress = progress; this.postQueue = postQueue; this.fileDownloader = fileDownloader; _saveTimer = new Timer(_ => OnSaveTimedEvent(), null, SAVE_TIMESPAN_SECS * 1000, SAVE_TIMESPAN_SECS * 1000); }
protected AbstractCrawler(IShellService shellService, CancellationToken ct, IProgress <DownloadProgress> progress, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, BlockingCollection <TumblrPost> producerConsumerCollection, IBlog blog) { this.shellService = shellService; this.webRequestFactory = webRequestFactory; this.cookieService = cookieService; this.producerConsumerCollection = producerConsumerCollection; this.blog = blog; this.ct = ct; this.progress = progress; }
public BlogRepository(IBlog context) { blogInterface = context; }
public void changeAccount(String id) { curinfo = DataMgr.getAccountById(id); if (curinfo.provider != "") { blog = BlogFactory.createBlogger(curinfo.provider); blog.authenticate(curinfo.username, curinfo.password); titlelabel.Text = curinfo.blogname; } else MessageBox.Show("切换账户出错!\r\n"); }
public BlogService(IBlog blog, IFiles files) { _blog = blog; _files = files; }
private void openbtn_Click(object sender, EventArgs e) { List<AccountInfo> infolist = DataMgr.getAllAccount(); List<DraftInfo> draftlist = DataMgr.getAllDraft(); List<RecentInfo> recentlist = DataMgr.getAllRecent(); if ((infolist == null) || (infolist.Count == 0)) MessageBox.Show("请先在博客设置中添加博客账户"); else { OpenBlogDlg openDlg = new OpenBlogDlg(infolist, draftlist, recentlist); if (openDlg.ShowDialog() == DialogResult.OK) { if (openDlg.Catagory == OpenCatagory.Blog) { //修改当前的IBlog 和 账户 blog = openDlg.Blog; curinfo = openDlg.Account; titlelabel.Text = curinfo.blogname; postinfo = openDlg.Post; titlebox.Text = postinfo.title; editor.HtmlText = postinfo.text; status = postinfo.status; } } } }
private void blogbtn_Click(object sender, EventArgs e) { /*UpdateAccoutDlg updateDlg = new UpdateAccoutDlg(); updateDlg.ShowDialog();*/ BlogConfigWizard wizard = new BlogConfigWizard(); if (wizard.ShowDialog() == DialogResult.OK) { if (wizard.Auth) { //titlelabel.Text = wizard.u //WebBrowser browser = new WebBrowser(); //browser.Navigate(wizard.Url); //browser.Url = new Uri(wizard.Url); blog = wizard.Blog; HttpWebRequest request = WebRequest.Create(wizard.Url) as HttpWebRequest; request.Method = "GET"; HttpWebResponse response = request.GetResponse() as HttpWebResponse; System.IO.Stream respStream = response.GetResponseStream(); string htmltext; // Dim reader As StreamReader = New StreamReader(respStream) using (System.IO.StreamReader reader = new System.IO.StreamReader(respStream) ) { htmltext = reader.ReadToEnd(); } //titlelabel.Text = title; //browser.DocumentText = htmltext; //string title = // browser. //browser.DocumentText = response.ToString(); // HtmlDocument doc = new HtmlDocument(); // doc.lo HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(htmltext); HtmlAgilityPack.HtmlNodeCollection nodes = doc.DocumentNode.SelectNodes("/html/head/title"); //string title = browser.DocumentTitle; titlelabel.Text = nodes[0].InnerText ; //将password account DataMgr.addAccount(wizard.AccountName, wizard.Password, wizard.Url, wizard.Provider, titlelabel.Text); } } }
public IBlog Save(IBlog model) { using (MiniProfiler.Current.Step("BlogRepository.Save")) { EnsureInjectables(); using (var dc = DataContextFactory.GetDataContext()) { Blog modelAsBlog = null; if (model.UniqueKey == 0) { modelAsBlog = new Blog(); modelAsBlog.DatePublished = DateTime.Now; } else modelAsBlog = dc.Repository<Blog>() .Where(b => b.PkID == model.UniqueKey) .SingleOrDefault(); if (modelAsBlog == null) throw new ArgumentException("Attempted to Update nonexisting Blog"); modelAsBlog.AuthorID = model.AuthorID; modelAsBlog.Entry = model.Entry; modelAsBlog.Tags = model.Tags; modelAsBlog.Title = model.Title; modelAsBlog.Slug = TitleCleaner.CleanTitle(model.Title); if (!modelAsBlog.IsPublished && model.IsPublished) { modelAsBlog.DatePublished = model.DatePublished.HasValue && model.DatePublished.Value > DateTime.Now ? model.DatePublished : DateTime.Now; modelAsBlog.IsPublished = model.IsPublished; } modelAsBlog.AuthorName = dc.Repository<User>() .SingleOrDefault(u => u.PkID == modelAsBlog.AuthorID) .FirstName; using (MiniProfiler.Current.Step("BlogRepository.Save.GenerateTags")) { // Note: This is probably slow. Good place for better algorithm if (!String.IsNullOrEmpty(modelAsBlog.Tags)) { var split = modelAsBlog.Tags.Split(' ').OrderBy(t => t[0]); modelAsBlog.Tags = ""; foreach (var tag in split) modelAsBlog.Tags += tag.ToLower() + " "; modelAsBlog.Tags = modelAsBlog.Tags.TrimEnd(); } } if (modelAsBlog.PkID == 0) dc.Insert(modelAsBlog); dc.Commit(); return modelAsBlog; } } }
protected AbstractTumblrCrawler(IShellService shellService, ICrawlerService crawlerService, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, ITumblrParser tumblrParser, IImgurParser imgurParser, IGfycatParser gfycatParser, IWebmshareParser webmshareParser, IMixtapeParser mixtapeParser, IUguuParser uguuParser, ISafeMoeParser safemoeParser, ILoliSafeParser lolisafeParser, ICatBoxParser catboxParser, IPostQueue <TumblrPost> postQueue, IBlog blog, IProgress <DownloadProgress> progress, PauseToken pt, CancellationToken ct) : base(shellService, crawlerService, progress, webRequestFactory, cookieService, postQueue, blog, pt, ct) { this.TumblrParser = tumblrParser; this.ImgurParser = imgurParser; this.GfycatParser = gfycatParser; this.WebmshareParser = webmshareParser; this.MixtapeParser = mixtapeParser; this.UguuParser = uguuParser; this.SafemoeParser = safemoeParser; this.LolisafeParser = lolisafeParser; this.CatboxParser = catboxParser; }
public TagBlogDataAdapter(IBlog blog, string tag, IDataAdapterDependencies dependencies) : this(blog.Entity, tag, dependencies) { }
public TumblrTagSearchCrawler(IShellService shellService, CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, ICrawlerService crawlerService, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, IDownloader downloader, ICrawlerDataDownloader crawlerDataDownloader, ITumblrParser tumblrParser, IImgurParser imgurParser, IGfycatParser gfycatParser, IWebmshareParser webmshareParser, IMixtapeParser mixtapeParser, IUguuParser uguuParser, ISafeMoeParser safemoeParser, ILoliSafeParser lolisafeParser, ICatBoxParser catboxParser, IPostQueue <TumblrPost> postQueue, IPostQueue <TumblrCrawlerData <Datum> > jsonQueue, IBlog blog) : base(shellService, crawlerService, ct, pt, progress, webRequestFactory, cookieService, tumblrParser, imgurParser, gfycatParser, webmshareParser, mixtapeParser, uguuParser, safemoeParser, lolisafeParser, catboxParser, postQueue, blog) { this.downloader = downloader; this.jsonQueue = jsonQueue; this.crawlerDataDownloader = crawlerDataDownloader; }
public TagBlogDataAdapter(IBlog blog, string tag, string portalName = null) : this(blog, tag, new PortalConfigurationDataAdapterDependencies(portalName)) { }
public HomeController(IUnitOfWork uow, IBlog blog, ICategoriesContent categoriesContent) { _uow = uow; _blog = blog; _categoriesContent = categoriesContent; }
public DashboardGraphController() { this._blogrepo = new BlogRepo(); }
public HomeController(IBlog service, BlogContext context) { this._blogService = service; this._context = context; }
public DashboardGraphController(IBlog blogrepo) { _blogrepo = blogrepo; }
protected AbstractCrawler(IShellService shellService, ICrawlerService crawlerService, IProgress <DownloadProgress> progress, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, IPostQueue <TumblrPost> postQueue, IBlog blog, PauseToken pt, CancellationToken ct) { ShellService = shellService; CrawlerService = crawlerService; WebRequestFactory = webRequestFactory; CookieService = cookieService; PostQueue = postQueue; Blog = blog; Progress = progress; Pt = pt; Ct = ct; }
public BlogController(IHostingEnvironment env, SafeBlockContext context, IBlog blog) { _context = context; _env = env; _blog = blog; }
public static BlogDto ToBlogDto(this IBlog <Post> dataBlog) => new Mapper(_config).Map <IBlog <Post>, BlogDto>(dataBlog);
protected AbstractDownloader(IShellService shellService, IManagerService managerService, CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, IPostQueue <AbstractPost> postQueue, FileDownloader fileDownloader, ICrawlerService crawlerService = null, IBlog blog = null, IFiles files = null) { this.shellService = shellService; this.crawlerService = crawlerService; this.managerService = managerService; this.blog = blog; this.files = files; this.ct = ct; this.pt = pt; this.progress = progress; this.postQueue = postQueue; this.fileDownloader = fileDownloader; Progress <Exception> prog = new Progress <Exception>((e) => shellService.ShowError(e, Resources.CouldNotSaveBlog, blog.Name)); _saveTimer = new Timer(_ => OnSaveTimedEvent(prog), null, SAVE_TIMESPAN_SECS * 1000, SAVE_TIMESPAN_SECS * 1000); }
private TumblrDownloader GetTumblrDownloader(CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, IShellService shellService, ICrawlerService crawlerService, IManagerService managerService, IBlog blog, IFiles files, IPostQueue <TumblrPost> postQueue) { return(new TumblrDownloader(shellService, managerService, ct, pt, progress, postQueue, GetFileDownloader(ct), crawlerService, blog, files)); }
/// <summary> /// Default internal constructor. /// </summary> /// <param name="builder">The current application builder</param> /// <param name="blog">The blog service</param> internal BlogApplicationBuilder(IApplicationBuilder builder, IBlog blog) { Builder = builder; Blog = blog; }
private TumblrJsonDownloader <T> GetTumblrJsonDownloader <T>(IShellService shellService, CancellationToken ct, PauseToken pt, IPostQueue <TumblrCrawlerData <T> > jsonQueue, ICrawlerService crawlerService, IBlog blog) { return(new TumblrJsonDownloader <T>(shellService, ct, pt, jsonQueue, crawlerService, blog)); }
public void fetchBlogThread() { //开始获取blog数据 String key="0"; //= catagorylist.FocusedItem.Name; catagorylist.Invoke( (MethodInvoker)delegate { key = catagorylist.FocusedItem.Name; } ); int idx = int.Parse(key.Trim()); blog = BlogFactory.createBlogger(infolist[idx].provider); blog.authenticate(infolist[idx].username, infolist[idx].password); posts = blog.getPost(20); //contentlist.Clear(); contentlist.Invoke( (MethodInvoker)delegate { contentlist.Clear(); } ); if (posts != null && posts.Count() != 0) { for (int i = 0; i <= posts.Count() - 1; i++) { JoeBlogs.Post p = posts.ElementAt(i); contentlist.Invoke( (MethodInvoker)delegate { contentlist.Items.Add(i + "", p.Title + " " + p.DateCreated.ToString(), 0); } ); // contentlist.Items.Add(i + "", p.title + " " + p.dateCreated.ToString(), 0); } } freeWizard1.Invoke( (MethodInvoker)delegate { freeWizard1.SelectedIndex = 0; } ); // freeWizard1.SelectedIndex = 0; }
public TumblrJsonDownloader(IShellService shellService, CancellationToken ct, PauseToken pt, BlockingCollection <TumblrCrawlerJsonData> jsonQueue, ICrawlerService crawlerService, IBlog blog) { this.shellService = shellService; this.crawlerService = crawlerService; this.blog = blog; this.ct = ct; this.pt = pt; this.jsonQueue = jsonQueue; }
private void okbtn_Click(object sender, EventArgs e) { String key = contentlist.SelectedItems[0].Name; if (catagorylist.SelectedItems[0].Index >= 2) { //设置当前的Catagory catagory = OpenCatagory.Blog; String key1 = catagorylist.SelectedItems[0].Name; int idx1 = int.Parse(key1.Trim()); //设置当前的Account curinfo = infolist[idx1]; int idx = int.Parse(key.Trim()); postinfo = new PostInfo(); postinfo.title = posts.ElementAt(idx).Title; JoeBlogs.Post p = blog.getPostById(posts.ElementAt(idx).PostID ); postinfo.text = p.Body; postinfo.postid = posts.ElementAt(idx).PostID; postinfo.status = BlogStatus.Old; } else if (catagorylist.SelectedItems[0].Index == 1) { catagory = OpenCatagory.Recently; int idx = int.Parse(key.Trim()); RecentInfo recent = recentlist[idx]; //设置account curinfo = DataMgr.getAccountById(recent.accountid); //设置当前的PostInfo postinfo = new PostInfo(); postinfo.title = recent.title; blog = BlogFactory.createBlogger(curinfo.provider); JoeBlogs.Post p = blog.getPostById(recent.postid); postinfo.text = p.Body; postinfo.postid = recent.postid; postinfo.status = BlogStatus.Old; } else { catagory = OpenCatagory.Draft; int idx = int.Parse(key.Trim()); DraftInfo draft = draftlist[idx]; postinfo = new PostInfo(); postinfo.title = draft.title; postinfo.text = draft.text; postinfo.status = BlogStatus.New; curinfo = DataMgr.getAccountById(draft.accountid); } this.DialogResult = DialogResult.OK; this.Close(); }
public QueueListItem(IBlog blog) { Blog = blog; }
protected AbstractCrawler(IShellService shellService, CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, ICrawlerService crawlerService, ISharedCookieService cookieService, IDownloader downloader, BlockingCollection <TumblrPost> producerConsumerCollection, IBlog blog) { this.shellService = shellService; this.crawlerService = crawlerService; this.cookieService = cookieService; this.downloader = downloader; this.producerConsumerCollection = producerConsumerCollection; this.blog = blog; this.ct = ct; this.pt = pt; this.progress = progress; }
public TumblrLikedByCrawler(IShellService shellService, CancellationToken ct, PauseToken pt, IProgress <DownloadProgress> progress, ICrawlerService crawlerService, IWebRequestFactory webRequestFactory, ISharedCookieService cookieService, IDownloader downloader, BlockingCollection <TumblrPost> producerConsumerCollection, IBlog blog) : base(shellService, ct, pt, progress, crawlerService, webRequestFactory, cookieService, downloader, producerConsumerCollection, blog) { }
public AdminController() { var bl = new InstanceBL(); _blog = bl.GetBlogBL(); }
private static bool CheckIfCanUpdateTumblrBlogCrawler(IBlog blog, PropertyInfo property) { return(property.PropertyType == typeof(BlogTypes) && !(blog is TumblrBlog || blog is TumblrHiddenBlog)); }
private void nextbtn_Click(object sender, EventArgs e) { if (this.SelectedIndex < this.freeWizard1.TabCount - 1) this.SelectedIndex = this.SelectedIndex + 1; else if (this.SelectedIndex == this.freeWizard1.TabCount - 1) { try { blog = BlogFactory.createBlogger(blogbox.Text); auth = blog.authenticate(usernamebox.Text, passwdbox.Text); } catch (Exception ex) { MessageBox.Show("博客连接失败 在继续之前请先处理下面的异常\r\n"+ex.Message); auth = false; } if (auth) { this.DialogResult = DialogResult.OK; this.Close(); } } }