public static AwfulPost Build(HtmlNode node, AwfulThreadPage page) { AwfulPost result = null; Logger.AddEntry("AwfulPost - Parsing postNode for html..."); int id = Factory.ParsePostID(node); try { result = new AwfulPost(); result.ID = id; result.ThreadPageID = page.ID; Factory.ParsePostThreadIndex(result, node); Factory.ParseAuthor(result, node); Factory.ParsePostDate(result, node); Factory.ParseUserID(result, node); result.ContentNode = Factory.ParseContent(node); Factory.ParseHasSeen(result, node); Factory.ParseIcon(result, node); } catch (Exception ex) { string error = string.Format("An error occured while processing the post to the database. [{0}] {1}", ex.Message, ex.StackTrace); Logger.AddEntry(error); } return result; }
public AwfulThreadPage AddOrUpdateThreadPage(AwfulThreadPage page) { AwfulThreadPage pageToUpdate = null; try { var query = this._context.ThreadPages .Where(p => p.ID == page.ID); pageToUpdate = query.SingleOrDefault(); // page is null, so add it to database if (pageToUpdate == null) { this._context.ThreadPages.InsertOnSubmit(page); } else { pageToUpdate.Update(page); } this._context.SubmitChanges(System.Data.Linq.ConflictMode.FailOnFirstConflict); } catch (Exception ex) { Event.Logger.AddEntry("An error occurred while updating the thread page table:", ex); pageToUpdate = null; } return pageToUpdate; }
private void OnPageRemove(AwfulThreadPage page) { page._Parent = null; }
private void OnPageAdd(AwfulThreadPage page) { page._Parent = this; }
public ThreadPageData GetThreadPage(int pageNumber) { if (pageNumber < -1) throw new ArgumentOutOfRangeException("Page number is out of range."); ThreadPageData page = null; int index = -1; index = Math.Min(pageNumber, this.TotalPages); index = Math.Max(-1, index); page = new AwfulThreadPage(this, index); return page; }
public static string Metrofy(AwfulThreadPage page) { return Metrofy(page.Posts); }
internal void Update(AwfulThreadPage page) { this._Parent = page._Parent; this.PageNumber = page.PageNumber; this.Posts.Clear(); this.Posts.Assign(page.Posts); this.LastUpdated = DateTime.Now; }