protected void btnadd_Click(object sender, EventArgs e) { try { _dtotag = new DtoTag { Link = ViewState["_link"].ToString(), WebsiteName = ViewState["_websiteName"].ToString(), UserId = UserId, TagName = txttag.Text }; var blltag = new BllTag(); blltag.AddTag(_dtotag); _bllpremalink = new BllPremalink(); GridPremalinkTags.DataSource = _bllpremalink.GetPremalinkTagsById(Convert.ToInt64(ViewState["_premalinkId"])); GridPremalinkTags.DataBind(); txttag.Text = ""; } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { _premaLinkId = Convert.ToInt32(Request.QueryString["PremaLinkID"]); _tagId = Convert.ToInt32(Request.QueryString["TagID"]); _dtopremalink = new DtoPremalink { PremalinkId = _premaLinkId, TagId = _tagId }; _bllpremalink = new BllPremalink(); _bllpremalink.DeactivateTagToWebsite(_dtopremalink); Response.Redirect("PremaLink.aspx?PremalinkID=" + _premaLinkId); } } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
protected void btnsearch_Click(object sender, EventArgs e) { var bllPremalink = new BllPremalink(); GridView1.DataSource = bllPremalink.SearchPremalink(txtsearch.Value, 1); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { try { IsWebSite(); if (!IsPostBack) { _bllWebsite = new BllWebsite(); var bllPremalink = new BllPremalink(); var lstdto = new List <DtoWebsite> { _bllWebsite.GetUserWebsite(UserId)[0] }; gridwebsite.DataSource = lstdto; gridwebsite.DataBind(); GridView1.DataSource = bllPremalink.GetWebsitePremalink(new DtoPremalink { WebsiteId = lstdto[0].WebsiteId }); GridView1.DataBind(); } } catch (Exception ex) { throw ex; } }
protected void BtnSearch_Click(object sender, EventArgs e) { try { _dtopremalink = new DtoPremalink(); _bllpremalink = new BllPremalink(); _dtopremalink.WebsiteId = Convert.ToInt64(ViewState["websiteid"]); _dtopremalink.Link = TxtSearch.Text; GridPremalink.DataSource = _bllpremalink.GetWebsitePremalink(_dtopremalink); GridPremalink.DataBind(); } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
public static void done(object values) { try { String[] a = values.ToString().Replace('[', ' ').Replace(']', ' ').Split('|')[1].Split(','); var pre = new DtoPremalink(); var bllp = new BllPremalink(); pre.Link = a[0]; pre.Image = a[1]; bllp.AddPremalinkimages(pre); } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
protected void Page_Load(object sender, EventArgs e) { try { IsUser(); if (!IsPostBack) { ViewState["_premalinkId"] = 0; ViewState["_websiteName"] = ""; ViewState["_link"] = ""; } txttag.Attributes.Add("onblur", "blurfunction('tagsdfsspan','" + txttag.ClientID + "')"); if (Request.QueryString["PremaLinkID"] != null) { if (Convert.ToInt64(Request.QueryString["PremaLinkID"]) != 0) { ViewState["_premalinkId"] = Convert.ToInt64(Request.QueryString["PremaLinkID"]); } } _bllpremalink = new BllPremalink(); GridPremalinkTags.DataSource = _bllpremalink.GetPremalinkTagsById(Convert.ToInt64(ViewState["_premalinkId"])); GridPremalinkTags.DataBind(); _dtopremalink = new DtoPremalink(); _dtopremalink = _bllpremalink.GetPremalinkById(Convert.ToInt64(ViewState["_premalinkId"])); hperlnk.Text = _dtopremalink.Title; hperlnk.NavigateUrl = "javascript:window.open('" + _dtopremalink.Link + "','_blank')"; lbldescription.Text = _dtopremalink.Description; lbldate.Text = _dtopremalink.PublishedTime.ToShortDateString(); imglnk.ImageUrl = _dtopremalink.Image; ViewState["_websiteName"] = _dtopremalink.SiteName; ViewState["_link"] = _dtopremalink.Link; } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
protected void Page_Load(object sender, EventArgs e) { try { IsWebSite(); ViewState["_premalinkId"] = 0; if (!IsPostBack) { if (Request.QueryString["ID"] != null) { _premalinkId = Convert.ToInt64(Request.QueryString["ID"]); } ViewState["_premalinkId"] = _premalinkId; _bllPremalink = new BllPremalink(); _dtoPremalink = _bllPremalink.GetPremalinkById(_premalinkId); imgPremalink.ImageUrl = _dtoPremalink.Image; lblPremalink.Text = _dtoPremalink.Title; lblDescription.Text = _dtoPremalink.Description; linkPremalink.Text = _dtoPremalink.Link; ViewState["_link"] = _dtoPremalink.Link; grdtags.DataSource = _bllPremalink.GetPremalinkTagsById(_premalinkId); grdtags.DataBind(); // grdemotion.DataSource = _bllEmotions.GetPremalinkEmotionsById(_premalinkId); // grdemotion.DataBind(); } } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
protected void Page_Load(object sender, EventArgs e) { try { IsUser(); if (!IsPostBack) { ViewState["websiteid"] = 0; _bllwebsite = new BllWebsite(); _dtowebsite = new DtoWebsite(); _dtopremalink = new DtoPremalink(); _bllpremalink = new BllPremalink(); TextBox1.Attributes.Add("onblur", "blurfunction('shortnamespan','" + TextBox1.ClientID + "')"); TextBox2.Attributes.Add("onblur", "blurfunction('websitespan','" + TextBox2.ClientID + "')"); TxtSearch.Attributes.Add("onblur", "blurfunction('searchsspan','" + TxtSearch.ClientID + "')"); if (Request.QueryString["WebsiteID"] != null & Convert.ToInt64(Request.QueryString["WebsiteID"]) != 0) { ViewState["websiteid"] = Convert.ToInt64(Request.QueryString["WebsiteID"]); _dtowebsite = _bllwebsite.GetWebsiteById(Convert.ToInt64(ViewState["websiteid"])); TextBox1.Text = _dtowebsite.WebSiteName; TextBox2.Text = _dtowebsite.WebsiteUrl; chktag.Checked = _dtowebsite.Tag; chkemotion.Checked = _dtowebsite.Emotion; chkaddable.Checked = _dtowebsite.AddTag; chkrateable.Checked = _dtowebsite.RateTag; chkemoaddable.Checked = _dtowebsite.AddEmotion; if (!string.IsNullOrEmpty(_dtowebsite.WebsiteLogo)) { imgweblogo.ImageUrl = Server.MapPath("~/Images/WebsiteLogo/") + _dtowebsite.WebsiteLogo; } if (_dtowebsite.WebSiteName != "") { Page.ClientScript.RegisterStartupScript(GetType(), "shortnamespand", "<script type='text/javascript'>document.getElementById('shortnamespan').style.opacity = 0;</script>"); } if (_dtowebsite.WebsiteUrl != "") { Page.ClientScript.RegisterStartupScript(GetType(), "websitespand", "<script type='text/javascript'>document.getElementById('websitespan').style.opacity = 0;</script>"); } txtcode.InnerText = "<div id='taghead'></div><script type ='text/javascript' language='javascript'>" + "var Websitename_shortname = '" + _dtowebsite.WebSiteName + "';</script>" + "<script src='http://www.glozzary.com/Script/NewJScript.js' type='text/javascript'></script>"; BtnDone.Visible = true; BtnRegister.Visible = false; dplstwebsitetype.DataSource = _bllwebsite.GetWebsiteType(); dplstwebsitetype.DataBind(); dplstwebsitetype.SelectedValue = _dtowebsite.WebsiteType; _dtopremalink.WebsiteId = Convert.ToInt64(ViewState["websiteid"]); _dtopremalink.Link = TxtSearch.Text; GridPremalink.DataSource = _bllpremalink.GetWebsitePremalink(_dtopremalink); GridPremalink.DataBind(); } else { BtnRegister.Visible = true; BtnDone.Visible = false; dplstwebsitetype.DataSource = _bllwebsite.GetWebsiteType(); dplstwebsitetype.DataBind(); } } else { if (TextBox1.Text != "") { Page.ClientScript.RegisterStartupScript(GetType(), "shortnamespan", "<script type='text/javascript'>document.getElementById('shortnamespan').style.opacity = 0;</script>"); } if (TextBox2.Text != "") { Page.ClientScript.RegisterStartupScript(GetType(), "websitespans", "<script type='text/javascript'>document.getElementById('websitespan').style.opacity = 0;</script>"); } if (TxtSearch.Text != "") { Page.ClientScript.RegisterStartupScript(GetType(), "searchsspans", "<script type='text/javascript'>document.getElementById('searchsspan').style.opacity = 0;</script>"); } } } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
protected void btnstart_Click(object sender, EventArgs e) { try { //System.Diagnostics.Debugger.Launch(); var bllpremalink = new BllPremalink(); var lstpremalink = new List <DtoPremalink>(); lstpremalink = bllpremalink.GetUnParsedPremalik(); var serv = new WebService(); int x = 0, y = 0, index = 0; string sr = ""; var arr = new string[11]; if (lstpremalink != null) { foreach (DtoPremalink item in lstpremalink) { arr[index] = serv.Getmetadata(item.Link); index += 1; } if (arr.Where(m => m != null).Count() > 0) { foreach (string item in arr.Where(m => m != null)) { var uri = new Uri(item); var request = (HttpWebRequest)WebRequest.Create(uri); var response = (HttpWebResponse)request.GetResponse(); var reader = new StreamReader(response.GetResponseStream()); var doc = new HtmlDocument(); doc.Load(reader); HtmlNodeCollection title = doc.DocumentNode.SelectNodes("//img"); foreach (HtmlNode item1 in title) { if (item1.HasAttributes) { foreach (HtmlAttribute attr in item1.Attributes) { if (attr.Value.ToLower().StartsWith("http://")) { sr += " <br/><img name='img" + x + "_hdn" + y + "' src= " + attr.Value + " alt='No Image' /><br/>"; sr += "<input id='hdn" + y + "' type='hidden' value='" + item + "' />"; ltrl.Text += sr; y += 1; } } } } x += 1; } ltrl.Text += "<input id='total' type='hidden' value='" + x + "' />"; Page.ClientScript.RegisterStartupScript(GetType(), "parse", "<script type='text/javascript'>Parse();</script>"); } } } catch (Exception ex) { ex.ToExceptionless().Submit(); } }
public string Getmetadata(string link) { System.Diagnostics.Debugger.Launch(); var dtometa = new DtoMeta(); var uri = new Uri(link); var request = (HttpWebRequest)WebRequest.Create(uri); var response = (HttpWebResponse)request.GetResponse(); var reader = new StreamReader(response.GetResponseStream()); var doc = new HtmlDocument(); doc.Load(reader); HtmlNode node = doc.DocumentNode; //All metachars HtmlNodeCollection All = node.SelectNodes("//meta"); string allmetachars = ""; if (All != null) { foreach (HtmlNode item in All) { allmetachars += item.OuterHtml; } } //General HtmlNodeCollection ogtitle = node.SelectNodes("//meta[@property='og:title']"); HtmlNodeCollection ogurl = node.SelectNodes("//meta[@property='og:url']"); HtmlNodeCollection ogsite_name = node.SelectNodes("//meta[@property='og:site_name']"); HtmlNodeCollection ogdescription = node.SelectNodes("//meta[@property='og:description']"); HtmlNodeCollection ogimage = node.SelectNodes("//meta[@property='og:image']"); HtmlNodeCollection ogpublished_time = node.SelectNodes("//meta[@property='og:published_time']"); HtmlNodeCollection ogkeywords = node.SelectNodes("//meta[@name='keywords']"); HtmlNodeCollection ogemotion = node.SelectNodes("//meta[@property='og:emotion']"); HtmlNodeCollection ogtype = node.SelectNodes("//meta[@property='og:type']"); //Product HtmlNodeCollection ogpriceamount = node.SelectNodes("//meta[@property='og:price:amount']"); HtmlNodeCollection ogpricecurrency = node.SelectNodes("//meta[@property='og:price:currency']"); HtmlNodeCollection ogavailability = node.SelectNodes("//meta[@property='og:availability']"); HtmlNodeCollection ograting = node.SelectNodes("//meta[@property='og:rating']"); HtmlNodeCollection oggender = node.SelectNodes("//meta[@property='og:gender']"); HtmlNodeCollection ogpricestartdate = node.SelectNodes("//meta[@property='og:price:start_date']"); HtmlNodeCollection ogpriceenddate = node.SelectNodes("//meta[@property='og:price:end_date']"); HtmlNodeCollection ogbrand = node.SelectNodes("//meta[@property='og:brand']"); //Receipe HtmlNodeCollection ogingredients = node.SelectNodes("//meta[@property='og:ingredients']"); HtmlNodeCollection ogavilabilitydestinations = node.SelectNodes("//meta[@property='og:avilability:destinations']"); HtmlNodeCollection ogcooktime = node.SelectNodes("//meta[@property='og:cooktime']"); HtmlNodeCollection ogpreptime = node.SelectNodes("//meta[@property='og:preptime']"); HtmlNodeCollection ogtotaltime = node.SelectNodes("//meta[@property='og:totaltime']"); HtmlNodeCollection ogrecipeyield = node.SelectNodes("//meta[@property='og:recipeyield']"); HtmlNodeCollection ogaggregaterating = node.SelectNodes("//meta[@property='og:aggregaterating']"); //movies HtmlNodeCollection ogduration = node.SelectNodes("//meta[@property='og:duration']"); HtmlNodeCollection oggenre = node.SelectNodes("//meta[@property='og:genre']"); HtmlNodeCollection ogactor = node.SelectNodes("//meta[@property='og:actor']"); HtmlNodeCollection ogdirector = node.SelectNodes("//meta[@property='og:director']"); HtmlNodeCollection ogcontentrating = node.SelectNodes("//meta[@property='og:contentrating']"); //Article HtmlNodeCollection ogauthor = node.SelectNodes("//meta[@property='og:author']"); HtmlNodeCollection ogsection = node.SelectNodes("//meta[@property='og:section']"); //Place HtmlNodeCollection oglocationlatitude = node.SelectNodes("//meta[@property='og:location:latitude']"); HtmlNodeCollection oglocationlongitude = node.SelectNodes("//meta[@property='og:location:longitude']"); HtmlNodeCollection ogstreet_address = node.SelectNodes("//meta[@property='og:street_address']"); HtmlNodeCollection oglocality = node.SelectNodes("//meta[@property='og:locality']"); HtmlNodeCollection ogregion = node.SelectNodes("//meta[@property='og:region']"); HtmlNodeCollection ogpostal_code = node.SelectNodes("//meta[@property='og:postal_code']"); if (ogtitle != null) { if (ogtitle[0].Attributes["content"].Value == "") { ogtitle = node.SelectNodes("//meta[@property='og:name']"); if (ogtitle != null) { if (ogtitle[0].Attributes["content"].Value == "") { ogtitle = node.SelectNodes("//title"); dtometa.Ogtitle = ogtitle[0].InnerText; } else { dtometa.Ogtitle = ogtitle[0].Attributes["content"].Value; } } } else { dtometa.Ogtitle = ogtitle[0].Attributes["content"].Value; } } if (ogurl != null) { if (ogurl[0].Attributes["content"].Value != "") { dtometa.Ogurl = ogurl[0].Attributes["content"].Value; } else { dtometa.Ogurl = link; } } if (ogsite_name != null) { if (ogsite_name[0].Attributes["content"].Value != "") { dtometa.OgsiteName = ogsite_name[0].Attributes["content"].Value; } else { dtometa.OgsiteName = uri.Host; } } if (ogdescription != null) { if (ogdescription[0].Attributes["content"].Value != "") { ogdescription = node.SelectNodes("//meta[@name='description']"); if (ogdescription != null) { dtometa.Ogdescription = ogdescription[0].Attributes["content"].Value; } } else { dtometa.Ogdescription = ogdescription[0].Attributes["content"].Value; } } if (ogimage != null) { if (ogimage[0].Attributes["content"].Value == "") { ogimage = node.SelectNodes("//link [@rel='image_src']"); if (ogimage != null) { dtometa.Ogimage = ogimage[0].Attributes["href"].Value; } } else { dtometa.Ogimage = ogimage[0].Attributes["content"].Value; } } if (ogpublished_time != null) { dtometa.OgpublishedTime = ogpublished_time[0].Attributes["content"].Value; } if (ogkeywords != null) { if (ogkeywords[0].Attributes["content"].Value == "") { ogkeywords = node.SelectNodes("//meta[@name='keywords']"); if (ogkeywords != null) { if (ogkeywords[0].Attributes["content"].Value == "") { ogkeywords = node.SelectNodes("//meta[@name='news_keywords']"); } dtometa.Ogkeywords = ogkeywords[0].Attributes["content"].Value; } } else { dtometa.Ogkeywords = ogkeywords[0].Attributes["content"].Value; } } if (ogemotion != null) { dtometa.Ogemotion = ogemotion[0].Attributes["content"].Value; } if (ogtype != null) { if (ogtype[0].Attributes["content"].Value == "") { dtometa.Ogtype = "others"; } else { dtometa.Ogtype = ogtype[0].Attributes["content"].Value; } } if (ogpriceamount != null) { dtometa.Ogpriceamount = ogpriceamount[0].Attributes["content"].Value; } if (ogpricecurrency != null) { dtometa.Ogpricecurrency = ogpricecurrency[0].Attributes["content"].Value; } if (ogavailability != null) { dtometa.Ogavailability = ogavailability[0].Attributes["content"].Value; } if (ograting != null) { dtometa.Ograting = ograting[0].Attributes["content"].Value; } if (oggender != null) { dtometa.Oggender = oggender[0].Attributes["content"].Value; } if (ogpricestartdate != null) { dtometa.Ogpricestartdate = ogpricestartdate[0].Attributes["content"].Value; } if (ogpriceenddate != null) { dtometa.Ogpriceenddate = ogpriceenddate[0].Attributes["content"].Value; } if (ogingredients != null) { dtometa.Ogingredients = ogingredients[0].Attributes["content"].Value; } if (ogavilabilitydestinations != null) { dtometa.Ogavilabilitydestinations = ogavilabilitydestinations[0].Attributes["content"].Value; } if (ogcooktime != null) { dtometa.Ogcooktime = ogcooktime[0].Attributes["content"].Value; } if (ogpreptime != null) { dtometa.Ogpreptime = ogpreptime[0].Attributes["content"].Value; } if (ogtotaltime != null) { dtometa.Ogtotaltime = ogtotaltime[0].Attributes["content"].Value; } if (ogrecipeyield != null) { dtometa.Ogrecipeyield = ogrecipeyield[0].Attributes["content"].Value; } if (ogaggregaterating != null) { dtometa.Ogaggregaterating = ogaggregaterating[0].Attributes["content"].Value; } if (ogduration != null) { dtometa.Ogduration = ogduration[0].Attributes["content"].Value; } if (oggenre != null) { dtometa.Oggenre = oggenre[0].Attributes["content"].Value; } if (ogactor != null) { dtometa.Ogactor = ogactor[0].Attributes["content"].Value; } if (ogdirector != null) { dtometa.Ogdirector = ogdirector[0].Attributes["content"].Value; } if (ogcontentrating != null) { dtometa.Ogcontentrating = ogcontentrating[0].Attributes["content"].Value; } if (ogauthor != null) { if (ogauthor[0].Attributes["content"].Value == "") { ogauthor = node.SelectNodes("//meta[@name='author']"); if (ogauthor != null) { dtometa.Ogauthor = ogauthor[0].Attributes["content"].Value; } } else { dtometa.Ogauthor = ogauthor[0].Attributes["content"].Value; } } if (ogsection != null) { if (ogsection[0].Attributes["content"].Value == "") { ogsection = node.SelectNodes("//meta[@property='article:section']"); if (ogsection != null) { dtometa.Ogsection = ogsection[0].Attributes["content"].Value; } } else { dtometa.Ogsection = ogsection[0].Attributes["content"].Value; } } if (oglocationlatitude != null) { dtometa.Oglocationlatitude = oglocationlatitude[0].Attributes["content"].Value; } if (oglocationlongitude != null) { dtometa.Oglocationlongitude = oglocationlongitude[0].Attributes["content"].Value; } if (ogstreet_address != null) { dtometa.OgstreetAddress = ogstreet_address[0].Attributes["content"].Value; } if (oglocality != null) { dtometa.Oglocality = oglocality[0].Attributes["content"].Value; } if (ogregion != null) { dtometa.Ogregion = ogregion[0].Attributes["content"].Value; } if (ogpostal_code != null) { dtometa.OgpostalCode = ogpostal_code[0].Attributes["content"].Value; } if (allmetachars != "") { dtometa.AllMetachars = allmetachars; } string[] Logo; string character = ""; if (dtometa.OgsiteName != null) { if (dtometa.OgsiteName != "") { character = dtometa.OgsiteName.Trim().Substring(0, 1); } } if (character == "") { if (dtometa.Ogurl != null) { if (dtometa.Ogurl != "") { Logo = dtometa.Ogurl.Split('.'); if (Logo.Length == 2) { character = Logo[1].Trim().Substring(0, 1); } else { character = Logo[0].Trim().Substring(0, 1); } } } } if (character == "") { character = "W"; } dtometa.WebsiteLogo = ConvertTextToImage(character.ToUpper(), "Arial", 30, Color.White, Color.Black, 50, 50); var bllpremalink = new BllPremalink(); bllpremalink.AddPremalinkMetaChar(dtometa); if (dtometa.Ogimage.Length > 0) { return(null); } return(link); }