public Extracted.Entities.RootObject init(string HTML) { string callURL = createURL(HTML); string entityJSON = getEntities(callURL); Extracted.Entities.RootObject extEnt = Deserialize <Extracted.Entities.RootObject>(entityJSON); return(extEnt); }
protected void Page_Load(object sender, EventArgs e) { ContentManager contentManager = new ContentManager(); ContentData cData = new ContentData(); long id = 0; try { long.TryParse(Request["id"].ToString(), out id); } catch { id = 0; } cData = contentManager.GetItem(id, true); ExtractEntities contentEnt = new ExtractEntities(); Extracted.Entities.RootObject entResults = contentEnt.init(cData.Html); List <Extracted.Entities.Entity> top2People = getRelevantContent(2, "Person", entResults); List <Extracted.Entities.Entity> top2Org = getRelevantContent(2, "Organization", entResults); QueryParams parm = new QueryParams(); // Populate related content based on most relevant entity IEnumerable <QueryResult> results = populateRelatedContent(id, parm, top2People[0].text, cData.Id, 5); morethreeList.DataSource = results; morethreeList.DataBind(); morethreeList.Visible = true; if (results.Count() > 0) { morethree.Text = "<h4>More on " + top2People[0].text + "</h4>"; morethree.Visible = true; } // Populate related content based on most relevant entity IEnumerable <QueryResult> results2 = populateRelatedContent(id, parm, top2People[1].text, cData.Id, 3); morefourList.DataSource = results2; morefourList.DataBind(); morefourList.Visible = true; if (results2.Count() > 0) { morefour.Text = "<h4>More on " + top2People[1].text + "</h4>"; morefour.Visible = true; } // Populate related content based on second most relevant entity IEnumerable <QueryResult> results3 = populateRelatedContent(id, parm, top2Org[0].text, cData.Id, 3); moreoneList.DataSource = results3; moreoneList.DataBind(); moreoneList.Visible = true; if (results3.Count() > 0) { moreone.Text = "<h4>More on " + top2Org[0].text + "</h4>"; moreone.Visible = true; } // Populate related content based on second most relevant entity IEnumerable <QueryResult> results4 = populateRelatedContent(id, parm, top2Org[1].text, cData.Id, 3); moretwoList.DataSource = results4; moretwoList.DataBind(); moretwoList.Visible = true; if (results4.Count() > 0) { moretwo.Text = "<h4>More on " + top2Org[1].text + "</h4>"; moretwo.Visible = true; } List <Related> people = getRelatedContent(top2People); peopleList.DataSource = people; peopleList.DataBind(); List <Related> organizations = getRelatedContent(top2Org); orgList.DataSource = organizations; orgList.DataBind(); string bannerhtml = createBannerHTML(cData); bannerImage.Text = bannerhtml; phoneHeading.Text = cData.Title; string merchandiseSearch = top2People[0].text + " " + top2People[1].text + " " + top2Org[0].text + " " + top2Org[1].text; try { List <ContentType <Attraction> > relatedMerchandise = populateMerchandise(merchandiseSearch, 4); if (relatedMerchandise.Count > 0) { merchandiseList.DataSource = relatedMerchandise; merchandiseList.DataBind(); merchandiseHeader.Visible = true; merchandiseHeader.Text = "<h3 style=\"margin-top: 1em;\">RELATED MERCHANDISE</h3>"; } } catch { } }
public List <Extracted.Entities.Entity> getRelevantContent(int amount, string entType, Extracted.Entities.RootObject results) { List <Extracted.Entities.Entity> qResult = new List <Extracted.Entities.Entity>(); qResult = results.entities.Where(x => x.type == entType).ToList(); return(qResult); }