protected void Page_Load(object sender, EventArgs e) { Article1.DataBind(); Article2.DataBind(); if (!IsPostBack) { Panel PanelMen = Article1.ContentPlaceholder.Controls[0].FindControl("PanelMen") as Panel; Panel PanelWomen = Article1.ContentPlaceholder.Controls[0].FindControl("PanelWomen") as Panel; Panel PanelKids = Article1.ContentPlaceholder.Controls[0].FindControl("PanelKids") as Panel; Session["CollectionsCat"] = "5"; if (Session["GeneralCategoryGenders"] == "1") { PanelMen.Visible = true; PanelWomen.Visible = false; PanelKids.Visible = false; } if (Session["GeneralCategoryGenders"] == "2") { PanelMen.Visible = false; PanelWomen.Visible = true; PanelKids.Visible = false; } if (Session["GeneralCategoryGenders"] == "3") { PanelMen.Visible = false; PanelWomen.Visible = false; PanelKids.Visible = true; } PostCategory(); } }
protected void Page_Load(object sender, EventArgs e) { Article1.DataBind(); DropDownList drpDropDownCountry = Article1.ContentPlaceholder.Controls[0].FindControl("drpDropDownCountry") as DropDownList; drpDropDownCountry.Text = "--SelectCountry--"; if (!IsPostBack) { if (Session["clients"] != null) { Panel PanelDirectToLogin = Article1.ContentPlaceholder.Controls[0].FindControl("PanelDirectToLogin") as Panel; PanelDirectToLogin.Visible = false; Panel PanelLogout = Article1.ContentPlaceholder.Controls[0].FindControl("PanelLogout") as Panel; PanelLogout.Visible = true; Panel PanelRegistrationForm = Article1.ContentPlaceholder.Controls[0].FindControl("PanelRegistrationForm") as Panel; PanelRegistrationForm.Visible = false; Panel PanelWarningForm = Article1.ContentPlaceholder.Controls[0].FindControl("PanelWarningForm") as Panel; PanelWarningForm.Visible = true; } else { Panel PanelDirectToLogin = Article1.ContentPlaceholder.Controls[0].FindControl("PanelDirectToLogin") as Panel; PanelDirectToLogin.Visible = true; Panel PanelLogout = Article1.ContentPlaceholder.Controls[0].FindControl("PanelLogout") as Panel; PanelLogout.Visible = false; Panel PanelRegistrationForm = Article1.ContentPlaceholder.Controls[0].FindControl("PanelRegistrationForm") as Panel; PanelRegistrationForm.Visible = true; Panel PanelWarningForm = Article1.ContentPlaceholder.Controls[0].FindControl("PanelWarningForm") as Panel; PanelWarningForm.Visible = false; } } }
public String Heading() { var article1 = new Article1(); var json = ""; try { using (var client = new WebClient()) { json = client.DownloadString("http://www.gaa.ie/iphone/get_news_json.php"); } json = json.Replace("@attributes", "attributes"); json = json.Remove(0, 11); json = json.TrimEnd('}'); var articless = JsonConvert.DeserializeObject <List <Article> >(json); var q = (from a in articless select a).OrderByDescending(a => a.upload_date).FirstOrDefault(); var art = q; article1.title = WebUtility.HtmlDecode(art.title); } catch (Exception ex) { var sf = new StackFrame(); var methodBase = sf.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } return(article1.title); }
protected void Page_Load(object sender, EventArgs e) { Article1.DataBind(); if (!this.IsPostBack) { ViewState["LoginErrors"] = 0; } }
public Article1 GetTaskArticle() { Article1 article = null; var json = ""; var newCode = "Uploaded: "; try { using (var client = new WebClient()) { json = client.DownloadString("http://www.gaa.ie/iphone/get_news_json.php"); } json = json.Replace("@attributes", "attributes"); json = json.Remove(0, 11); json = json.TrimEnd('}'); var articless = JsonConvert.DeserializeObject <List <Article> >(json); var topArticle = (from a in articless select a).First(); topArticle.filename = topArticle.filename.Replace("http:", ""); foreach (var sec in topArticle.sections.section_id) { if (sec == "2") { newCode = "Football"; break; } if (sec == "3") { newCode = "Hurling"; break; } newCode = "General"; } article = new Article1 { content_image_id = topArticle.content_image_id, content_text_id = topArticle.content_text_id, filename = topArticle.filename, ID = Convert.ToInt32(topArticle.newsid), thumbnail = topArticle.thumbnail, title = WebUtility.HtmlDecode(topArticle.title), upload_date = DateTime.Parse(topArticle.upload_date), url = topArticle.url, code = newCode }; } catch (Exception ex) { var sf = new StackFrame(); var methodBase = sf.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } return(article); }
private FileResult Resize(int height, int width) { var article1 = new Article1(); var json = ""; try { using (var client = new WebClient()) { json = client.DownloadString("http://www.gaa.ie/iphone/get_news_json.php"); } json = json.Replace("@attributes", "attributes"); json = json.Remove(0, 11); json = json.TrimEnd('}'); var articless = JsonConvert.DeserializeObject <List <Article> >(json); var q = (from a in articless select a).OrderByDescending(a => a.upload_date).FirstOrDefault(); var art = q; article1.title = WebUtility.HtmlDecode(art.title); article1.filename = art.filename.Replace("http:", ""); var uri = "http:" + article1.filename; var rsSettings = new ResizeSettings { Format = "jpg", MaxHeight = height, MaxWidth = width }; rsSettings.Anchor = ContentAlignment.TopCenter; rsSettings.Mode = FitMode.Crop; rsSettings.Scale = ScaleMode.Both; var c = Config.Current; var wc = new WebClient { CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore) }; var dt = wc.DownloadData(uri); using (var ms = new MemoryStream(dt)) { var mStream = new MemoryStream(); c.CurrentImageBuilder.Build(ms, mStream, rsSettings); mStream.Seek(0, SeekOrigin.Begin); return(new FileStreamResult(mStream, "image/jpeg")); } } catch (Exception ex) { var sf = new StackFrame(); var methodBase = sf.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } return(null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Article1.DataBind(); if (Session["USERS"] != null) { LinkButton lnkuser = Article1.ContentPlaceholder.Controls[0].FindControl("lnkuser") as LinkButton; lnkuser.Text = "HELLO [Admin]: " + (string)(Session["USERS"]); } if (Session["USERS"] == null) { Response.Redirect("Default.aspx?"); } } }
protected void Page_Load(object sender, EventArgs e) { Article1.DataBind(); if (!IsPostBack) { BindDataList(); if (Session["clients"] != null) { Panel PanelRegistration = Article1.ContentPlaceholder.Controls[0].FindControl("PanelRegistration") as Panel; Panel PanelLoginStatus = Article1.ContentPlaceholder.Controls[0].FindControl("PanelLoginStatus") as Panel; PanelLoginStatus.Visible = true; PanelRegistration.Visible = false; } else { Panel PanelRegistration = Article1.ContentPlaceholder.Controls[0].FindControl("PanelRegistration") as Panel; Panel PanelLoginStatus = Article1.ContentPlaceholder.Controls[0].FindControl("PanelLoginStatus") as Panel; PanelLoginStatus.Visible = false; PanelRegistration.Visible = true; } } }
private List <Article1> GetArticlesFromDb() { var articles = new List <Article1>(); try { _connection = new MySqlConnection(ConnectionString); var query = "SELECT * from GAA_Article order by Id desc Limit 50;"; using (_connection) { _connection.Open(); using (var cmd = new MySqlCommand(query, _connection)) { using (var r = cmd.ExecuteReader()) { while (r.Read()) { var article = new Article1(); article.ID = Convert.ToInt32(r.GetString("Id")); article.upload_date = DateTime.Parse(r.GetString("Upload_Date")); articles.Add(article); } } } } } catch (Exception ex) { var sf = new StackFrame(); var methodBase = sf.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } return(articles); }
public IEnumerable <Article1> GetArticles() { var tc = new TelemetryClient(); tc.TrackEvent("ArticlesPageHit"); var articles = new List <Article1>(); try { //newArticles = GetXmlArticles(); //foreach (var newArticle in newArticles.Article) //{ // Article1 article = new Article1 // { // content_image_id = newArticle.content_image_id.ToString(), // content_text_id = newArticle.content_text_id.ToString(), // filename = newArticle.filename, // ID = newArticle.id, // thumbnail = newArticle.thumbnail, // title = WebUtility.HtmlDecode(newArticle.title), // upload_date = DateTime.Parse(newArticle.upload_date), // url = newArticle.url, // code = "General" // }; // articles.Add(article); // if (article.title.StartsWith("LIVE:") || article.title.Contains("Live!")) // { // InsertUpdateToDb(article.ID.ToString()); // } //} //To change comment from here var articlesNotInDb = new List <Article1>(); var articlesInDb = new List <Article1>(); var json = ""; var newCode = ""; using (var client = new WebClient()) { json = client.DownloadString("http://www.gaa.ie/iphone/get_news_json.php"); } json = json.Replace("@attributes", "attributes"); json = json.Remove(0, 11); json = json.TrimEnd('}'); var articless = JsonConvert.DeserializeObject <List <Article> >(json); foreach (var a in articless) { if (a.newsid != "12370") { var isFootball = false; foreach (var sec in a.sections.section_id) { if (sec == "13") { newCode = "Camogie"; break; } if (sec == "1") { newCode = "General"; continue; } if (sec == "2") { newCode = "Football"; isFootball = true; continue; } if (sec == "3" && isFootball) { newCode = "General"; continue; } if (sec == "3") { newCode = "Hurling"; } } a.filename = a.filename.Replace("http:", ""); if (a.title.StartsWith("LIVE:") || a.title.Contains("Live!") || a.title.Contains("LIVE!") || a.title.EndsWith("as it happens")) { InsertUpdateToDb(a.newsid); } var article = new Article1 { content_image_id = a.content_image_id, content_text_id = a.content_text_id, filename = a.filename, ID = Convert.ToInt32(a.newsid), thumbnail = a.thumbnail, title = WebUtility.HtmlDecode(a.title), upload_date = DateTime.Parse(a.upload_date), url = a.url, code = newCode }; articles.Add(article); } } //To Here //Get Articles from DB articlesInDb = GetArticlesFromDb(); //Change date based on db foreach (var article1 in articles) { var q = (from ar in articlesInDb where ar.ID == article1.ID select ar).FirstOrDefault(); if (q != null) { article1.upload_date = q.upload_date; } else { article1.upload_date = DateTime.Now; articlesNotInDb.Add(article1); } } foreach (var article1 in articlesNotInDb) { articles.Remove(article1); } //if new save to db SaveToDb(articlesNotInDb); articles.AddRange(articlesNotInDb); } catch (Exception ex) { var sf = new StackFrame(); var methodBase = sf.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } return(articles.OrderByDescending(a => a.ID).Take(25)); }
public IEnumerable <Article1> GetArticlesWithTime(string lastLogin) { var articles = new List <Article1>(); var json = ""; var newCode = "Uploaded: "; try { using (var client = new WebClient()) { json = client.DownloadString("http://www.gaa.ie/iphone/get_news_json.php"); } json = json.Replace("@attributes", "attributes"); json = json.Remove(0, 11); json = json.TrimEnd('}'); var articless = JsonConvert.DeserializeObject <List <Article> >(json); foreach (var a in articless) { var isFootball = false; //bool isHurling = false; foreach (var sec in a.sections.section_id) { if (sec == "1") { newCode = "General"; continue; } if (sec == "2") { newCode = "Football"; isFootball = true; continue; } if (sec == "3" && isFootball) { newCode = "General"; //isHurling = true; continue; } if (sec == "3") { newCode = "Hurling"; //isHurling = true; } //if (sec == "11") //{ // newCode = "Top Daily"; // break; //} // newCode = "General"; } a.filename = a.filename.Replace("http:", ""); if (a.title.StartsWith("LIVE:") || a.title.Contains("Live!")) { InsertUpdateToDb(a.newsid); } var article = new Article1 { content_image_id = a.content_image_id, content_text_id = a.content_text_id, filename = a.filename, ID = Convert.ToInt32(a.newsid), thumbnail = a.thumbnail, title = WebUtility.HtmlDecode(a.title), upload_date = DateTime.Parse(a.upload_date), url = a.url, code = newCode, New = false }; articles.Add(article); } } catch (Exception ex) { var sf = new StackFrame(); var methodBase = sf.GetMethod(); Database.InsertErrorToDb(methodBase.Name, ex.Message, ex.ToString()); } foreach (var article1 in articles) { if (article1.upload_date > DateTime.Parse(lastLogin)) { article1.New = true; } } return(articles); }