Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 private void OnPageRemove(AwfulThreadPage page)
 {
     page._Parent = null;
 }
Ejemplo n.º 4
0
 private void OnPageAdd(AwfulThreadPage page)
 {
     page._Parent = this;
 }
Ejemplo n.º 5
0
        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);
 }
Ejemplo n.º 7
0
 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;
 }